OSDN Git Service

* inclhack.def (hpux_htonl): Allow trailing whitespace in select.
[pf3gnuchains/gcc-fork.git] / fixincludes / inclhack.def
index 79295e6..ef4f167 100644 (file)
@@ -607,7 +607,7 @@ fix = {
 fix = {
     hackname  = alpha_assert;
     files     = "assert.h";
-    select    = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
+    select    = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
     c_fix     = format;
     c_fix_arg = "%1(EX)";
     test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
@@ -794,27 +794,6 @@ fix = {
 
 
 /*
- *  Change external names of wcstok/wcsftime via asm instead of macros on
- *  Tru64 UNIX V4.0.
- */
-fix = {
-    hackname = alpha_wchar;
-    files    = wchar.h;
-
-    mach     = "alpha*-dec-osf4*";
-    select   = "#define wcstok wcstok_r";
-    sed      = "s@#define wcstok wcstok_r@"
-                "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
-                          "wchar_t **)) __asm__(\"wcstok_r\");@";
-    sed      = "s@#define wcsftime __wcsftime_isoc@"
-                "extern size_t   wcsftime __((wchar_t *, size_t, const wchar_t *"
-                          ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
-    test_text = "#define wcstok wcstok_r\n"
-               "#define wcsftime __wcsftime_isoc";
-};
-
-
-/*
  *  For C++, avoid any typedef or macro definition of bool,
  *  and use the built in type instead.
  *  HP/UX 10.20 also has it in curses_colr/curses.h.
@@ -1598,6 +1577,28 @@ fix = {
 };
 
 
+/* Some versions of glibc have a version of bits/string2.h that
+   produces "value computed is not used" warnings from strncpy; fix
+   this definition by using __builtin_strncpy instead as in newer
+   versions.  */
+fix = {
+    hackname  = glibc_strncpy;
+    files     = bits/string2.h;
+    bypass    = "__builtin_strncpy";
+    c_fix     = format;
+    c_fix_arg = "#  define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
+    c_fix_arg = "#  define strncpy([^\n]*\\\\\n)*[^\n]*";
+    test_text = <<-EOT
+       #  define strncpy(dest, src, n) \
+         (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \\
+                         ? (strlen (src) + 1 >= ((size_t) (n))                       \\
+                            ? (char *) memcpy (dest, src, n)                         \\
+                            : strncpy (dest, src, n))                                \\
+                         : strncpy (dest, src, n)))
+       EOT;
+
+};
+
 /* glibc's tgmath.h relies on an expression that is not an integer
    constant expression being treated as it was by GCC 4.4 and
    earlier.  */
@@ -1984,7 +1985,7 @@ fix = {
 fix = {
     hackname = hpux_htonl;
     files    = netinet/in.h;
-    select   = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
+    select   = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
                "(/\\*\n"
                " \\* Macros for number representation conversion\\.\n"
                " \\*/\n"
@@ -3248,45 +3249,23 @@ fix = {
 
 
 /*
-<<<<<<< .mine
- *  On OpenServer and on UnixWare 7, <math.h> uses the native compiler
- *  __builtin_generic. We fix that usage to use the GCC equivalent.
- * It also has a plethora of inline functions that conflict with libstdc++.
+ *  Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
+ *  for C99.  This is wrong for C++, which needs many C99 features, but
+ *  only supports __restrict.
  */
 fix = {
-    hackname = sco_math;
-    files    = math.h, '*/math.h';
-    select   = "inline double abs";
-    bypass   = "__GNUG__";
-    sed      = "/#define.*__fp_class(a) \\\\/i\\\n"
-              "#ifndef __GNUC__\n";
-    sed      =
-"/.*__builtin_generic/a\\\n"
-"#else\\\n"
-"#define __fp_class(a) \\\\\\\n"
-"\\  __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
-"\\   __fpclassifyl(a), \\\\\\\n"
-"\\    __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
-"\\      __fpclassifyf(a),__fpclassify(a)))\\\n"
-"#endif\n";
-
-    sed      = "/extern \"C++\"/N;"
-              "/inline double abs/i\\\n"
-               "#ifndef __GNUC__\n";
-    sed      = "/inline long double trunc/N;"
-              "/inline long double trunc.*}.*extern \"C++\"/a\\\n"
-              "#endif /* ! __GNUC__ */\n";
-
-    test_text =
-    "#define __fp_class(a) \\\\\n"
-    " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
-
+    hackname  = solaris___restrict;
+    files     = sys/feature_tests.h;
+    select    = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
+    mach      = "*-*-solaris2*";
+    c_fix     = format;
+    c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
+               "#else\n%0\n#endif";
+    test_text = "#define       _RESTRICT_KYWD  restrict";
 };
 
 
 /*
-=======
->>>>>>> .r157397
  * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
  * themselves, which are Sun Studio compiler intrinsics.  Remove _Imaginary_I
  * and imaginary definitions which are not supported by GCC.
@@ -3311,6 +3290,43 @@ fix = {
 
 
 /*
+ * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus.  Wrap in
+ * extern "C" instead so libstdc++ can use it.
+ */
+fix = {
+    hackname  = solaris_complex_cxx;
+    mach      = "*-*-solaris2.*";
+    files     = complex.h;
+    sed              = "/#if[ \t]*!defined(__cplusplus)/c"
+               "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
+    sed              = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c"
+               "#ifdef\t__cplusplus\\\n}\\\n#endif";
+    test_text = "#if !defined(__cplusplus)\n"
+               "#endif /* !defined(__cplusplus) */";
+};
+
+
+/*
+ * Solaris 8 PTHREAD_COND_INITIALIZER lacks the __pthread_cond_magic field.
+ * COND_MAGIC is only defined in <synch.h> and pollutes the namespace, so
+ * use the value literally instead.
+ */
+fix = {
+    hackname = solaris_cond_init;
+    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    files = pthread.h;
+    mach = '*-*-solaris2.8';
+    c_fix = format;
+    c_fix_arg = "%1, 0x4356%2";
+    c_fix_arg = "^(#define[ \t]+PTHREAD_COND_INITIALIZER[ \t]+"
+                "\\{.*0)(\\},[ \t]*0\\}.*)$";
+    test_text =
+    '#pragma ident     "@(#)pthread.h  1.29    01/07/07 SMI"'"\n"
+    '#define   PTHREAD_COND_INITIALIZER        {{{0}, 0}, 0}   /* = DEFAULTCV */';
+};
+
+
+/*
  * Sun Solaris 10 defines several C99 math macros in terms of
  * builtins specific to the Studio compiler, in particular not
  * compatible with the GNU compiler.
@@ -3378,7 +3394,7 @@ fix = {
 
 fix = {
     hackname = solaris_math_8;
-    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
     bypass = "__GNUC__";
     files = iso/math_c99.h;
     c_fix = format;
@@ -3388,10 +3404,11 @@ fix = {
                 "\t\t\t     ? __builtin_signbitl(x) \\\n"
                 "\t\t\t     : __builtin_signbit(x))";
     c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
-    test_text =
-    '#ident    "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
-    "#undef    signbit\n"
-    "#define   signbit(x)      __builtin_signbit(x)";
+    test_text = <<- _EOText_
+       #ident  "@(#)math_c99.h 1.9     04/11/01 SMI"
+       #undef  signbit
+       #define signbit(x)      __builtin_signbit(x)
+       _EOText_;
 };
 
 fix = {