OSDN Git Service

fixincludes:
[pf3gnuchains/gcc-fork.git] / fixincludes / inclhack.def
index a759b40..9257ffa 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,6 +3249,23 @@ fix = {
 
 
 /*
+ *  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  = 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";
+};
+
+
+/*
  * 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.
@@ -3272,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.
@@ -3339,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;
@@ -3352,7 +3407,7 @@ fix = {
     test_text = <<- _EOText_
        #ident  "@(#)math_c99.h 1.9     04/11/01 SMI"
        #undef  signbit
-       #define signbit(x)      __builtin_signbit(x);
+       #define signbit(x)      __builtin_signbit(x)
        _EOText_;
 };
 
@@ -3639,6 +3694,34 @@ fix = {
 
 
 /*
+ * On Solaris 8 and 9, __va_list needs to become a typedef for
+ * __builtin_va_list to make -Wmissing-format-attribute work.
+ */
+fix = {
+    hackname = solaris_sys_va_list;
+    files    = sys/va_list.h;
+    mach     = '*-*-solaris2.[89]';
+    select   = "#if.*__STDC__.*\n"
+              "typedef void \\*__va_list;\n"
+              "#else\n"
+              "typedef char \\*__va_list;\n"
+              "#endif";
+
+    c_fix    = format;
+    c_fix_arg = "#ifdef __GNUC__\n"
+               "typedef __builtin_va_list __va_list;\n"
+               "#else\n"
+               "%0\n"
+               "#endif";
+    test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
+               "typedef void *__va_list;\n"
+               "#else\n"
+               "typedef char *__va_list;\n"
+               "#endif";
+};
+
+
+/*
  *  a missing semi-colon at the end of the statsswtch structure definition.
  */
 fix = {