OSDN Git Service

Apply https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00777/aarch64-int-iterators-backp...
[pf3gnuchains/gcc-fork.git] / fixincludes / inclhack.def
index e1d413c..2e9fee5 100644 (file)
@@ -356,6 +356,76 @@ fix = {
 
 
 /*
+ * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
+ * which only is provided by AIX xlc C99.
+ */
+fix = {
+    hackname  = aix_complex;
+    mach      = "*-*-aix*";
+    files     = complex.h;
+    select    = "#define[ \t]_Complex_I[ \t]__I";
+    c_fix     = format;
+    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
+    test_text = "#define _Complex_I    __I\n";
+};
+
+/*
+ *  malloc.h on AIX6 uses XLC++ specific builtin syntax
+ */
+fix = {
+    hackname  = aix_malloc;
+    mach      = "*-*-aix*";
+    files     = "malloc.h";
+    select    = "#ifdef __cplusplus";
+    c_fix     = format;
+    c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
+    test_text = "#ifdef __cplusplus";
+};
+
+/*
+ * net/if_arp.h defines a variable fc_softc instead of adding a
+ * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
+ */
+fix = {
+    hackname  = aix_net_if_arp;
+    mach      = "*-*-aix*";
+    files     = "net/if_arp.h";
+    select    = "^struct  fc_softc \\{";
+    c_fix     = format;
+    c_fix_arg = "typedef struct _fc_softc {";
+    test_text = "struct  fc_softc {\n  int a;\n};";
+};
+
+/*
+ *  pthread.h on AIX defines PTHREAD_ONCE_INIT without enough braces.
+ */
+fix = {
+    hackname  = aix_once_init_1;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
+               "\\{ \\\\\n";
+    c_fix     = format;
+    c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
+               "{{ \\\n";
+    test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
+               "{ \\\\\n";
+};
+
+fix = {
+    hackname  = aix_once_init_2;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "[ \t]0 \\\\\n"
+               "\\}\n";
+    c_fix     = format;
+    c_fix_arg = "      0 \\\n"
+               "}}\n";
+    test_text = "      0 \\\\\n"
+               "}\n";
+};
+
+/*
  *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
  *  which violates a requirement of ISO C.
  */
@@ -371,6 +441,106 @@ fix = {
 
 
 /*
+ *  AIX stdint.h fixes.
+ */
+fix = {
+    hackname  = aix_stdint_1;
+    mach      = "*-*-aix*";
+    files     = stdint-aix.h, stdint.h;
+    select    = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
+               "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
+    c_fix     = format;
+    c_fix_arg = "#define UINT8_MAX     (255)\n"
+               "#define UINT16_MAX     (65535)";
+    test_text = "#define UINT8_MAX     (255U)\n"
+               "#define UINT16_MAX     (65535U)";
+};
+
+
+fix = {
+    hackname  = aix_stdint_2;
+    mach      = "*-*-aix*";
+    files     = stdint-aix.h, stdint.h;
+    select    = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
+               "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
+               "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
+               "#else\n"
+               "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
+               "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
+               "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
+    c_fix     = format;
+    c_fix_arg = "#define INTPTR_MIN    (-INTPTR_MAX-1)\n"
+               "#define INTPTR_MAX     9223372036854775807L\n"
+               "#define UINTPTR_MAX    18446744073709551615UL\n"
+               "#else\n"
+               "#define INTPTR_MIN     (-INTPTR_MAX-1)\n"
+               "#define INTPTR_MAX     2147483647L\n"
+               "#define UINTPTR_MAX    4294967295UL";
+    test_text = "#define INTPTR_MIN    INT64_MIN\n"
+               "#define INTPTR_MAX     INT64_MAX\n"
+               "#define UINTPTR_MAX    UINT64_MAX\n"
+               "#else\n"
+               "#define INTPTR_MIN     INT32_MIN\n"
+               "#define INTPTR_MAX     INT32_MAX\n"
+               "#define UINTPTR_MAX    UINT32_MAX";
+};
+
+
+fix = {
+    hackname  = aix_stdint_3;
+    mach      = "*-*-aix*";
+    files     = stdint-aix.h, stdint.h;
+    select    = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
+               "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
+               "#else\n"
+               "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
+               "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
+    c_fix     = format;
+    c_fix_arg = "#define PTRDIFF_MIN   (-9223372036854775807L - 1)\n"
+               "#define PTRDIFF_MAX    9223372036854775807L\n"
+               "#else\n"
+               "#define PTRDIFF_MIN    (-2147483647L - 1)\n"
+               "#define PTRDIFF_MAX    2147483647L";
+    test_text = "#define PTRDIFF_MIN   INT64_MIN\n"
+               "#define PTRDIFF_MAX    INT64_MAX\n"
+               "#else\n"
+               "#define PTRDIFF_MIN     INT32_MIN\n"
+               "#define PTRDIFF_MAX    INT32_MAX";
+};
+
+
+fix = {
+    hackname  = aix_stdint_4;
+    mach      = "*-*-aix*";
+    files     = stdint-aix.h, stdint.h;
+    select    = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
+               "#else\n"
+               "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
+    c_fix     = format;
+    c_fix_arg = "#define SIZE_MAX      18446744073709551615UL\n"
+               "#else\n"
+               "#define SIZE_MAX       4294967295UL";
+    test_text = "#define SIZE_MAX      UINT64_MAX\n"
+               "#else\n"
+               "#define SIZE_MAX        UINT32_MAX";
+};
+
+
+fix = {
+    hackname  = aix_stdint_5;
+    mach      = "*-*-aix*";
+    files     = stdint-aix.h, stdint.h;
+    select    = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
+               "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
+    c_fix     = format;
+    c_fix_arg = "#define UINT8_C(c)    c\n"
+               "#define UINT16_C(c)    c";
+    test_text = "#define UINT8_C(c)    __CONCAT__(c,U)\n"
+               "#define UINT16_C(c)    __CONCAT__(c,U)";
+};
+
+
+/*
  *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
  *  in an otherwise harmless (and #ifed out) macro definition
  */
@@ -492,7 +662,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 '
@@ -679,27 +849,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.
@@ -892,6 +1041,21 @@ fix = {
     test_text = '#define  vfscanf      __svfscanf';
 };
 
+/*
+ * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
+ * that it conforms to ISO/IEC 14882:2011.  It currently does
+ * not support the [[noreturn]] procedure attribute.
+ * When it does, this hack should be removed.
+ * SEE:  gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
+ */
+fix = {
+    hackname  = cdef_cplusplus;
+    files     = sys/cdefs.h;
+    select    = '\[\[noreturn\]\]';
+    c_fix     = format;
+    c_fix_arg = '__attribute__((__noreturn__))';
+    test_text = "#define _Noreturn     [[noreturn]]";
+};
 
 /*
  *  Fix various macros used to define ioctl numbers.
@@ -1023,6 +1187,193 @@ fix = {
 
 
 /*
+ * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
+ * unsigned constants.
+ */
+fix = {
+    hackname  = darwin_stdint_1;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
+    select    = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
+               "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
+    test_text = "#define UINT8_C(v)   (v ## U)\n"
+               "#define UINT16_C(v)  (v ## U)";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
+ * with wrong types.
+ */
+fix = {
+    hackname  = darwin_stdint_2;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define INTPTR_MAX 9223372036854775807L\n"
+               "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
+               "#else\n"
+               "#define INTPTR_MAX 2147483647L\n"
+               "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
+               "#endif";
+    select    = "#if __WORDSIZE == 64\n"
+               "#define INTPTR_MIN[ \t]+INT64_MIN\n"
+               "#define INTPTR_MAX[ \t]+INT64_MAX\n"
+               "#else\n"
+               "#define INTPTR_MIN[ \t]+INT32_MIN\n"
+               "#define INTPTR_MAX[ \t]+INT32_MAX\n"
+               "#endif";
+    test_text = "#if __WORDSIZE == 64\n"
+               "#define INTPTR_MIN        INT64_MIN\n"
+               "#define INTPTR_MAX        INT64_MAX\n"
+               "#else\n"
+               "#define INTPTR_MIN        INT32_MIN\n"
+               "#define INTPTR_MAX        INT32_MAX\n"
+               "#endif";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
+ */
+fix = {
+    hackname  = darwin_stdint_3;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define UINTPTR_MAX 18446744073709551615UL\n"
+               "#else\n"
+               "#define UINTPTR_MAX 4294967295UL\n"
+               "#endif";
+    select    = "#if __WORDSIZE == 64\n"
+               "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
+               "#else\n"
+               "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
+               "#endif";
+    test_text = "#if __WORDSIZE == 64\n"
+               "#define UINTPTR_MAX       UINT64_MAX\n"
+               "#else\n"
+               "#define UINTPTR_MAX       UINT32_MAX\n"
+               "#endif";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
+ */
+fix = {
+    hackname  = darwin_stdint_4;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define SIZE_MAX 18446744073709551615UL\n"
+               "#else\n"
+               "#define SIZE_MAX 4294967295UL\n"
+               "#endif";
+    select    = "#if __WORDSIZE == 64\n"
+               "#define SIZE_MAX[ \t]+UINT64_MAX\n"
+               "#else\n"
+               "#define SIZE_MAX[ \t]+UINT32_MAX\n"
+               "#endif";
+    test_text = "#if __WORDSIZE == 64\n"
+               "#define SIZE_MAX          UINT64_MAX\n"
+               "#else\n"
+               "#define SIZE_MAX          UINT32_MAX\n"
+               "#endif";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
+ * with a wrong type.
+ */
+fix = {
+    hackname  = darwin_stdint_5;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define INTMAX_MIN   (-9223372036854775807L - 1)\n"
+               "#define INTMAX_MAX   9223372036854775807L\n"
+               "#define UINTMAX_MAX  18446744073709551615UL\n"
+               "#else\n"
+               "#define INTMAX_MIN   (-9223372036854775807LL - 1)\n"
+               "#define INTMAX_MAX   9223372036854775807LL\n"
+               "#define UINTMAX_MAX  18446744073709551615ULL\n"
+               "#endif";
+    select    = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
+               "#define INTMAX_MAX[ \t]+INT64_MAX\n"
+               "\n"
+               "#define UINTMAX_MAX[ \t]+UINT64_MAX";
+    test_text = "#define INTMAX_MIN        INT64_MIN\n"
+               "#define INTMAX_MAX        INT64_MAX\n"
+               "\n"
+               "#define UINTMAX_MAX       UINT64_MAX";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines {U,}INTMAX_C
+ * with a wrong type.
+ */
+fix = {
+    hackname  = darwin_stdint_6;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
+               "#define PTRDIFF_MAX 9223372036854775807L\n"
+               "#else\n"
+               "#define PTRDIFF_MIN (-2147483647 - 1)\n"
+               "#define PTRDIFF_MAX 2147483647\n"
+               "#endif";
+    select    = "#if __WORDSIZE == 64\n"
+               "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
+               "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
+               "#else\n"
+               "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
+               "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
+               "#endif";
+    test_text = "#if __WORDSIZE == 64\n"
+               "#define PTRDIFF_MIN       INT64_MIN\n"
+               "#define PTRDIFF_MAX       INT64_MAX\n"
+               "#else\n"
+               "#define PTRDIFF_MIN       INT32_MIN\n"
+               "#define PTRDIFF_MAX       INT32_MAX\n"
+               "#endif";
+};
+
+
+/*
+ * Darwin headers have a stdint.h that defines {U,}INTMAX_C
+ * with a wrong type.
+ */
+fix = {
+    hackname  = darwin_stdint_7;
+    mach      = "*-*-darwin*";
+    files     = stdint-darwin.h, stdint.h;
+    c_fix     = format;
+    c_fix_arg = "#if __WORDSIZE == 64\n"
+               "#define INTMAX_C(v)  (v ## L)\n"
+               "#define UINTMAX_C(v) (v ## UL)\n"
+               "#else\n"
+               "#define INTMAX_C(v)  (v ## LL)\n"
+               "#define UINTMAX_C(v) (v ## ULL)\n"
+               "#endif";
+    select    = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
+               "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
+    test_text = "#define INTMAX_C(v)  (v ## LL)\n"
+               "#define UINTMAX_C(v) (v ## ULL)";
+};
+
+
+/*
  *  Fix <c_asm.h> on Digital UNIX V4.0:
  *  It contains a prototype for a DEC C internal asm() function,
  *  clashing with gcc's asm keyword.  So protect this with __DECC.
@@ -1149,10 +1500,19 @@ fix = {
     hackname  = glibc_c99_inline_2;
     files     = sys/stat.h, '*/sys/stat.h';
     select    = "extern __inline__ int";
-    sed     = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
+    sed     = "s/extern int \\(stat\\)/"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
+              "__inline__ int \\1/";
+    sed     = "s/extern int \\([lf]stat\\)/"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
+              "__inline__ int \\1/";
+    sed     = "s/extern int \\(mknod\\)/"
               "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
               "__inline__ int \\1/";
-    sed     = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
+    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
+              "__inline__ int __REDIRECT\\1 (\\2/";
+    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
               "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
               "__inline__ int __REDIRECT\\1 (\\2/";
     sed     = "s/^extern __inline__ int/"
@@ -1207,25 +1567,33 @@ fix = {
     hackname = glibc_mutex_init;
     files    = pthread.h;
     select   = '\{ *\{ *0, *\} *\}';
-    sed      = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
+    sed      = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
                "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
     sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
-               "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
+               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
+    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
+               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
+    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
+               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
     sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
-               "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
-    sed      = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
+               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
+    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
+               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
+    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
+               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
+    sed      = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
                "N;s/^[ \t]*#[ \t]*"
-               "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
-               "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
-               "#  \\1\\n"
-               "  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
-               "# else\\n"
-               "#  \\1\\n"
-               "  { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
+               "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
+               "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
+               "#  \\1\\\n"
+               "  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
+               "# else\\\n"
+               "#  \\1\\\n"
+               "  { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
                "# endif/";
     sed      = "s/{ \\(0, 0, 0, 0, 0, 0, "
                "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
-    sed      = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
+    sed      = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
                "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
 
     test_text = <<- _EOText_
@@ -1265,6 +1633,42 @@ fix = {
 };
 
 
+/* glibc versions before 2.5 have a version of stdint.h that defines
+   UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
+   versions with stdint.h based on those glibc versions.  */
+fix = {
+    hackname  = glibc_stdint;
+    files     = stdint.h;
+    select    = "GNU C Library";
+    c_fix     = format;
+    c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
+    c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
+    test_text = "/* This file is part of the GNU C Library.  */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U";
+};
+
+
+/* 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.  */
@@ -1272,7 +1676,7 @@ fix = {
     hackname  = glibc_tgmath;
     files     = tgmath.h;
     select    = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
-    bypass    = "__floating_type \\\\\n.*__builtin_classify_type";
+    bypass    = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
     c_fix     = format;
     c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
     test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
@@ -1515,7 +1919,7 @@ fix = {
  */
 fix = {
     hackname  = hpux11_abs;
-    mach      = "ia64-hp-hpux11*";
+    mach      = "*-hp-hpux11*";
     files     = stdlib.h;
     select    = "ifndef _MATH_INCLUDED";
     c_fix     = format;
@@ -1595,35 +1999,6 @@ fix = {
                 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
 };
 
-
-/*
- * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
- * of UINT32_C has undefined behavior according to ISO/ANSI:
- * the arguments to __CONCAT__ are not macro expanded before the
- * concatination happens so the trailing ')' in the first argument
- * is concatinated with the 'l' in the second argument creating an
- * invalid pp token.  The behavior of invalid pp tokens is undefined.
- * GCC does not handle these invalid tokens the way the HP compiler does.
- * This problem will potentially occur anytime macros are used in the
- * arguments to __CONCAT__.  A general solution to this problem would be to
- * insert another layer of macro between __CONCAT__ and its use
- * in UINT32_C.  An example of this solution can be found in the C standard.
- * A more specific solution, the one used here, is to change the UINT32_C
- * macro to not used macros in the arguments to __CONCAT__.
- */
-fix = {
-    hackname = hpux11_uint32_c;
-    files    = inttypes.h;
-    select   = "^#define UINT32_C\\(__c\\)[ \t]*"
-                         "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
-    c_fix    = format;
-    c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
-    test_text =
-    "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
-    "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
-};
-
-
 /*
  *  Fix hpux 11.00 broken vsnprintf declaration
  */
@@ -1680,7 +2055,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"
@@ -1707,6 +2082,8 @@ fix = {
  */
 fix = {
     hackname  = hpux_long_double;
+    mach      = "*-*-hpux10*";
+    mach      = "*-*-hpux11.[012]*";
     files     = stdlib.h;
     select    = "extern[ \t]long_double[ \t]strtold";
     bypass    = "long_double_t";
@@ -1722,6 +2099,20 @@ fix = {
                "extern long_double strtold(const char *, char **);\n";
 };
 
+ /*
+  * We cannot use the above rule on 11.31 because it removes the strtold
+  * definition.  ia64 is OK with no hack, PA needs some help.
+  */
+fix = {
+    hackname  = hpux_long_double_2;
+    mach      = "hppa*-*-hpux11.3*";
+    files     = stdlib.h;
+    select    = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
+    c_fix     = format;
+    c_fix_arg = "#  if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
+
+    test_text = "#  if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
+};
 
 /*
  *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
@@ -1835,6 +2226,91 @@ fix = {
                "}\n";
 };
 
+fix = {
+    hackname  = hpux_c99_intptr;
+    mach      = "*-hp-hpux11.3*";
+    files     = stdint-hpux11.h, stdint.h;
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
+    test_text = "#define PTRDIFF_MAX   INT32_MAX\n"
+               "#define PTRDIFF_MIN    INT32_MIN\n"
+               "#define INTPTR_MAX     INT32_MAX\n"
+               "#define INTPTR_MIN     INT32_MIN\n"
+               "#define UINTPTR_MAX    UINT32_MAX\n"
+               "#define SIZE_MAX       UINT32_MAX\n";
+};
+
+/*
+ * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
+ */
+
+fix = {
+    hackname  = hpux_c99_inttypes;
+    mach      = "*-hp-hpux11.[23]*";
+    files     = inttypes.h;
+    files     = stdint-hpux11.h, stdint.h;
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
+    test_text = "#define UINT8_C(__c)     __CONCAT_U__(__c)\n"
+                "#define UINT16_C(__c)    __CONCAT_U__(__c)\n"
+               "#define INT32_C(__c)     __CONCAT__(__c,l)\n"
+               "#define UINT32_C(__c)     __CONCAT__(__c,ul)\n";
+};
+
+fix = {
+    hackname  = hpux_c99_inttypes2;
+    mach      = "*-hp-hpux11.2*";
+    files     = stdint-hpux11.h, stdint.h;
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
+    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
+    test_text = "#  define     INT8_C(__c)     ((signed char)(__c))\n"
+                "#  define      UINT8_C(__c)    ((unsigned char)(__c))\n"
+               "#  define      INT16_C(__c)    ((short)(__c))\n"
+               "#  define      UINT16_C(__c)   ((unsigned short)(__c))\n";
+};
+
+fix = {
+    hackname  = hpux_stdint_least_fast;
+    mach      = "*-hp-hpux11.2*";
+    files     = stdint-hpux11.h, stdint.h;
+    select    =
+        "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
+    c_fix     = format;
+    c-fix-arg = "#  define     UINT_%164_MAX   __UINT64_MAX__";
+    test-text = "#  define       UINT_FAST64_MAX        ULLONG_MAX\n"
+               "#  define       UINT_LEAST64_MAX        ULLONG_MAX\n";
+       _EOFix_;
+};
+
+fix = {
+    hackname  = hpux_inttype_int8_t;
+    mach      = "*-hp-hpux1[01].*";
+    files     = sys/_inttypes.h;
+    select    = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
+    c_fix     = format;
+    c_fix_arg = "typedef signed char int%18_t;";
+    test_text = "typedef char int_least8_t;\n"
+                "typedef char int8_t;\n";
+};
+
+fix = {
+    hackname  = hpux_imaginary_i;
+    mach      = "ia64-hp-hpux11.*";
+    files     = complex.h;
+    select    = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
+    c_fix     = format;
+    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
+    test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
+};
+
 /*
  *  Fix glibc definition of HUGE_VAL in terms of hex floating point constant
  */
@@ -2042,6 +2518,29 @@ fix = {
 
 
 /*
+ * IRIX 6.5 complex.h defines _Complex_I and _Imaginary_I in terms of __I__,
+ * which is a MIPSpro compiler builtin.  Remove _Imaginary_I and imaginary
+ * definitions which are not supported by GCC. 
+ */
+fix = {
+    hackname  = irix_complex;
+    mach      = "mips-sgi-irix6.5";
+    files     = complex.h;
+    select    = "#define[ \t]_Complex_I[ \t]\\(\\(float[ \t]_Complex\\)[ \t]\\(__I__\\)\\)";
+    sed              = "s/#define[ \t]_Complex_I[ \t]((float[ \t]_Complex)[ \t](__I__))/"
+               "#define _Complex_I (__extension__ 1.0iF)/";
+    sed              = "/#define[ \t]imaginary[ \t]_Imaginary/d";
+    sed              = "/#define[ \t]_Imaginary_I/d";
+    sed       = "s/#define[ \t]I[ \t]_Imaginary_I/#define I _Complex_I/";
+    test_text = "#define _Complex_I ((float _Complex) (__I__))\n"
+               "#define imaginary _Imaginary\n"
+               "// #define _Imaginary_I ((float _Imaginary) 1)\n"
+               "#define _Imaginary_I __I__\n"
+               "#define I _Imaginary_I";
+};
+
+
+/*
  *  Non-traditional "const" declaration in Irix's limits.h.
  */
 fix = {
@@ -2055,6 +2554,24 @@ fix = {
 
 
 /*
+ *  IRIX 6.5 PTHREAD_*_INITIALIZER need an additional level of braces in
+ *  <pthread.h>.
+ */
+fix = {
+    hackname    = irix_pthread_init;
+    files       = pthread.h;
+    select      = "^(#define[ \t]+PTHREAD_.*_INITIALIZER[ \t]+)(\\{ 0 \\})";
+
+    mach       = "mips-sgi-irix6.5";
+    c_fix       = format;
+    c_fix_arg   = "%1{ %2 }";
+    test_text   = "#define PTHREAD_MUTEX_INITIALIZER   { 0 }\n"
+                 "#define PTHREAD_COND_INITIALIZER     { 0 }\n"
+                 "#define PTHREAD_RWLOCK_INITIALIZER   { 0 }";
+};
+
+
+/*
  *  IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
  *  Various socket function prototypes use different types instead,
  *  depending on the API in use (BSD, XPG4/5), but the socklen_t
@@ -2083,7 +2600,7 @@ fix = {
  *  otherwise.
  */
 fix = {
-    hackname  = irix_stdint_c99;
+    hackname  = irix_stdint_c99_mode;
     files     = stdint.h;
     select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
 
@@ -2097,6 +2614,87 @@ fix = {
 
 
 /*
+ *  IRIX 6.5 <stdint.h> has some *_MIN/MAX constants whose types don't
+ *  match the corresponding types, as required by ISO C99.
+ */
+fix = {
+    hackname  = irix_stdint_c99_types;
+    files     = stdint-irix65.h, stdint.h;
+    mach      = "mips-sgi-irix6.5";
+    sed       = "s@^#define INT64_MIN.*(-0x7fffffffffffffff - 1)$@"
+                "#define INT64_MIN               (-0x7fffffffffffffffLL - 1)@";
+    sed       = "s@^#define INT64_MAX.*0x7fffffffffffffff$@"
+                "#define INT64_MAX               0x7fffffffffffffffLL@";
+    sed       = "s@^#define UINT32_MAX.*0xffffffff$@"
+                "#define UINT32_MAX              0xffffffffU@";
+    sed       = "s@^#define UINT64_MAX.*0xffffffffffffffff$@"
+                "#define UINT64_MAX              0xffffffffffffffffULL@";
+    sed       = "s@^#define INTPTR_MIN.*INT32_MIN$@"
+                "#define INTPTR_MIN              (-0x7fffffffL - 1)@";
+    sed       = "s@^#define INTPTR_MAX.*INT32_MAX$@"
+                "#define INTPTR_MAX              0x7fffffffL@";
+    sed       = "s@^#define UINTPTR_MAX.*UINT32_MAX$@"
+                "#define UINTPTR_MAX             0xffffffffUL@";
+    sed       = "s@^#define INTPTR_MIN.*INT64_MIN@"
+                "#define INTPTR_MIN              (-0x7fffffffffffffffL - 1)@";
+    sed       = "s@^#define INTPTR_MAX.*INT64_MAX$@"
+                "#define INTPTR_MAX              0x7fffffffffffffffL@";
+    sed       = "s@^#define UINTPTR_MAX.*UINT64_MAX$@"
+                "#define UINTPTR_MAX             0xffffffffffffffffUL@";
+    sed       = "s@^#define PTRDIFF_MIN.*INT64_MIN$@"
+                "#define PTRDIFF_MIN             (-0x7fffffffffffffffL - 1)@";
+    sed       = "s@^#define PTRDIFF_MAX.*INT64_MAX$@"
+                "#define PTRDIFF_MAX             0x7fffffffffffffffL@";
+    sed       = "s@^#define SIZE_MAX.*UINT64_MAX$@"
+                "#define SIZE_MAX                0xffffffffffffffffUL@";
+    test_text = "#define INT64_MIN               (-0x7fffffffffffffff - 1)\n"
+                "#define INT64_MAX               0x7fffffffffffffff\n"
+                "#define UINT32_MAX              0xffffffff\n"
+                "#define UINT64_MAX              0xffffffffffffffff\n"
+                "#define INTPTR_MIN              INT32_MIN\n"
+                "#define INTPTR_MAX              INT32_MAX\n"
+                "#define UINTPTR_MAX             UINT32_MAX\n"
+                "#define INTPTR_MIN              INT64_MIN\n"
+                "#define INTPTR_MAX              INT64_MAX\n"
+                "#define UINTPTR_MAX             UINT64_MAX\n"
+                "#define PTRDIFF_MIN             INT64_MIN\n"
+                "#define PTRDIFF_MAX             INT64_MAX\n"
+                "#define SIZE_MAX                UINT64_MAX";
+};
+
+
+/*
+ *  IRIX 6.5 <stdint.h> uses casts in some macros which cannot thus be used
+ *  in preprocessor tests, although ISO C99 requires this.
+ */
+fix = {
+    hackname  = irix_stdint_c99_macros;
+    files     = stdint-irix65.h, stdint.h;
+    mach      = "mips-sgi-irix6.5";
+    sed       = "s@^#define INT8_C(x).*int.*_t.*$@#define INT8_C(x)               (x)@";
+    sed       = "s@^#define INT16_C(x).*int.*_t.*$@#define INT16_C(x)              (x)@";
+    sed       = "s@^#define INT32_C(x).*int.*_t.*$@#define INT32_C(x)              (x)@";
+    sed       = "s@^#define INT64_C(x).*int.*_t.*$@#define INT64_C(x)              (x ## LL)@";
+    sed       = "s@^#define UINT8_C(x).*int.*_t.*$@#define UINT8_C(x)              (x)@";
+    sed       = "s@^#define UINT16_C(x).*int.*_t.*$@#define UINT16_C(x)             (x)@";
+    sed       = "s@^#define UINT32_C(x).*int.*_t.*$@#define UINT32_C(x)             (x ## U)@";
+    sed       = "s@^#define UINT64_C(x).*int.*_t.*$@#define UINT64_C(x)             (x ## ULL)@";
+    sed       = "s@^#define INTMAX_C(x).*int.*_t.*$@#define INTMAX_C(x)             (x ## LL)@";
+    sed       = "s@^#define UINTMAX_C(x).*int.*_t.*$@#define UINTMAX_C(x)            (x ## ULL)@";
+    test_text = "#define INT8_C(x)               (int_least8_t)(x)\n"
+                "#define INT16_C(x)              (int_least16_t)(x)\n"
+                "#define INT32_C(x)              (int_least32_t)(x)\n"
+                "#define INT64_C(x)              (int_least64_t)(x)\n"
+                "#define UINT8_C(x)              (uint_least8_t)(x)\n"
+                "#define UINT16_C(x)             (uint_least16_t)(x)\n"
+                "#define UINT32_C(x)             (uint_least32_t)(x)\n"
+                "#define UINT64_C(x)             (uint_least64_t)(x)\n"
+                "#define INTMAX_C(x)             (intmax_t)(x)\n"
+                "#define UINTMAX_C(x)            (uintmax_t)(x)";
+};
+
+
+/*
  *  IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
  *  some functions that take a va_list as
  *  taking char *.  However, GCC uses void * for va_list, so
@@ -2133,42 +2731,6 @@ fix = {
                "const struct tm *);";
 };
 
-/*
- * Fixing ISC fmod declaration
- */
-fix = {
-    hackname  = isc_fmod;
-    files     = math.h;
-    select    = 'fmod\(double\)';
-    c_fix     = format;
-    c_fix_arg = "fmod(double, double)";
-    test_text = "extern double fmod(double);";
-};
-
-
-/*
- *  On Interactive Unix 2.2, certain traditional Unix definitions
- *  (notably getc and putc in stdio.h) are omitted if __STDC__ is
- *  defined, not just if _POSIX_SOURCE is defined.  This makes it
- *  impossible to compile any nontrivial program except with -posix.
- */
-fix = {
-    hackname = isc_omits_with_stdc;
-
-    files     = "stdio.h";
-    files     = "math.h";
-    files     = "ctype.h";
-    files     = "sys/limits.h";
-    files     = "sys/fcntl.h";
-    files     = "sys/dirent.h";
-
-    select    = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
-    c_fix     = format;
-    c_fix_arg = '!defined(_POSIX_SOURCE)';
-    test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
-                "\nint foo;\n#endif";
-};
-
 
 /*
  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
@@ -2362,20 +2924,6 @@ fix = {
 
 
 /*
- * Fixing nested comments in ISC <sys/limits.h>
- */
-fix = {
-    hackname = nested_sys_limits;
-    files  = sys/limits.h;
-    select = CHILD_MAX;
-    sed    = "/CHILD_MAX/s,/\\* Max, Max,";
-    sed    = "/OPEN_MAX/s,/\\* Max, Max,";
-    test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
-                "#define OPEN_MAX  20 /* Max, Max, ... */\n";
-};
-
-
-/*
  *  Some versions of NetBSD don't expect the C99 inline semantics.
  */
 fix = {
@@ -2435,7 +2983,7 @@ fix = {
    versions.  */
 fix = {
     hackname  = newlib_stdint_1;
-    files     = stdint.h;
+    files     = stdint-newlib.h, stdint.h;
     select    = "@todo - Add support for wint_t types";
     sed       = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
     sed       = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
@@ -2471,7 +3019,7 @@ fix = {
 
 fix = {
     hackname  = newlib_stdint_2;
-    files     = stdint.h;
+    files     = stdint-newlib.h, stdint.h;
     select    = "@todo - Add support for wint_t types";
     c_fix     = format;
     c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
@@ -2789,38 +3337,133 @@ fix = {
 
 
 /*
- *  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";
-
-    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__ */";
+    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.
+ */
+fix = {
+    hackname  = solaris_complex;
+    mach      = "*-*-solaris2.*";
+    files     = complex.h;
+    select    = "#define[ \t]_Complex_I[ \t]_Complex_I";
+    sed              = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
+               "#define\t_Complex_I\t(__extension__ 1.0iF)/";
+    sed              = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
+    sed              = "/#define[ \t]imaginary[ \t]_Imaginary/d";
+    sed       = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
+    test_text = "#define       _Complex_I      _Complex_I\n"
+               "#define        complex         _Complex\n"
+               "#define        _Imaginary_I    _Imaginary_I\n"
+               "#define        imaginary       _Imaginary\n"
+               "#undef I\n"
+               "#define        I               _Imaginary_I";
+};
+
+
+/*
+ * 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\\\n"
+               "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
+    sed              = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
+               "#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 */';
+};
+
+
+/*
+ *  g++ rejects functions declared with both C and C++ linkage.
+ */
+fix = {
+    hackname  = solaris_cxx_linkage;
+    mach      = '*-*-solaris2*';
+    files     = "iso/stdlib_iso.h";
+    select    = "(#if __cplusplus >= 199711L)\n"
+               "(extern \"C\\+\\+\" \\{\n)"
+               "(.*(bsearch|qsort).*)";
+    c_fix     = format;
+    c_fix_arg = "%1 && !__GNUG__\n%2%3";
 
     test_text =
-    "#define __fp_class(a) \\\\\n"
-    " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
+    "#if __cplusplus >= 199711L\n"
+    "extern \"C++\" {\n"
+    "  void *bsearch(const void *, const void *, size_t, size_t,";
+};
+
+
+/*
+ *  Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
+ *  _STRICT_STDC, but uses it.
+ */
+fix = {
+    hackname  = solaris_getc_strict_stdc;
+    mach      = "*-*-solaris2*";
+    files     = "iso/stdio_iso.h";
+    select    = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
+    c_fix     = format;
+    c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
+
+    test_text =
+    "#if       !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
+};
+
+
+/*
+ *  Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
+ */
+fix = {
+    hackname  = solaris_longjmp_noreturn;
+    mach      = "*-*-solaris2*";
+    files     = "iso/setjmp_iso.h";
+    bypass    = "__NORETURN";
+    select    = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
+    c_fix     = format;
+    c_fix_arg = "%1 __attribute__ ((__noreturn__));";
 
+    test_text = "extern void longjmp(jmp_buf, int);";
 };
 
 
@@ -2892,7 +3535,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;
@@ -2902,10 +3545,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 = {
@@ -2996,6 +3640,24 @@ fix = {
 
 
 /*
+ *  The pow overloads with int were removed in C++ 2011.
+ */
+fix = {
+    hackname  = solaris_pow_int_overload;
+    mach      = '*-*-solaris2*';
+    files     = "iso/math_iso.h";
+    select    = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
+               " *\\{[^{}]*\n[^{}]*\\}";
+    c_fix     = format;
+    c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif";
+
+    test_text =
+    "  inline long double pow(long double __X, int __Y) { return\n"
+    "          __powl(__X, (long double) (__Y)); }";
+};
+
+
+/*
  * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
  *  fields of the pthread_rwlock_t structure, which are of type
  *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
@@ -3075,7 +3737,142 @@ fix = {
 
 
 /*
- * Solaris 2.8 has what appears to be some gross workaround for 
+ * Sun Solaris 2 has a version of sys/int_const.h that defines
+ * UINT8_C and UINT16_C to unsigned constants.
+ */
+fix = {
+    hackname  = solaris_int_const;
+    files     = sys/int_const.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
+                "%1\n"
+                "#define\tUINT16_C(c)\t(c)";
+    select    = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
+                "(/\*.*\*/)\n"
+                "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
+    test_text =
+    "#define   UINT8_C(c)      __CONCAT__(c,u)\n"
+    "/* CSTYLED */\n"
+    "#define   UINT16_C(c)     __CONCAT__(c,u)";
+};
+
+
+/*
+ * Sun Solaris 2 has a version of sys/int_limits.h that defines
+ * UINT8_MAX and UINT16_MAX to unsigned constants.
+ */
+fix = {
+    hackname  = solaris_int_limits_1;
+    files     = sys/int_limits.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
+                "#define\tUINT16_MAX\t(65535)";
+    select    = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
+                "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
+    test_text =
+    "#define   UINT8_MAX       (255U)\n"
+    "#define   UINT16_MAX      (65535U)";
+};
+
+
+/*
+ * Sun Solaris 2 has a version of sys/int_limits.h that defines
+ * INT_FAST16 limits to wrong values for sys/int_types.h.
+ */
+fix = {
+    hackname  = solaris_int_limits_2;
+    files     = sys/int_limits.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
+    select    = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
+    test_text =
+    "#define   INT_FAST16_MAX INT16_MAX\n"
+    "#define   UINT_FAST16_MAX UINT16_MAX\n"
+    "#define   INT_FAST16_MIN  INT16_MIN";
+};
+
+
+/*
+ * Sun Solaris 2 has a version of sys/int_limits.h that defines
+ * SIZE_MAX as unsigned long.
+ */
+fix = {
+    hackname  = solaris_int_limits_3;
+    files     = sys/int_limits.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
+    select    = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
+    test_text =
+    "#define   SIZE_MAX        4294967295UL";
+};
+
+
+/*
+ * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
+ * of Standard C99 64-bit types in 32-bit mode.
+ */
+fix = {
+    hackname  = solaris_int_types;
+    select    = "__STDC__ - 0 == 0";
+    bypass    = "_LONGLONG_TYPE";
+    files     = sys/int_types.h;
+    c_fix     = format;
+    c_fix_arg =
+    "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
+    test_text =
+    "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
+    "typedef   long long               int64_t;\n"
+    "#endif\n\n"
+    "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
+    "typedef int64_t                   intmax_t;\n"
+    "#endif";
+};
+
+
+/*
+ * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
+ * posix_spawn declarations, which doesn't work with C++.
+ */
+fix = {
+    hackname  = solaris_posix_spawn_restrict;
+    files     = spawn.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
+    select    = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
+    test_text =
+    "char *const argv[_RESTRICT_KYWD],\n"
+    "char *const envp[_RESTRICT_KYWD]);";
+};
+
+
+/*
+ * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
+ * std::__flsbuf, but <iso/stdio_iso.h> uses them.
+ */
+fix = {
+    hackname  = solaris_std___filbuf;
+    files     = stdio.h;
+    mach      = '*-*-solaris2*';
+    bypass    = "using std::__filbuf";
+    select    = "(using std::perror;\n)(#endif)";
+    c_fix     = format;
+    c_fix_arg = "%1#ifndef _LP64\n"
+               "using std::__filbuf;\n"
+               "using std::__flsbuf;\n"
+               "#endif\n%2";
+
+    test_text = "using std::perror;\n"
+               "#endif";
+};
+
+
+/*
+ * Sun Solaris 8 has what appears to be some gross workaround for
  * some old version of their c++ compiler.  G++ doesn't want it
  * either, but doesn't want to be tied to SunPRO version numbers.
  */
@@ -3094,6 +3891,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 = {
@@ -3740,6 +4565,65 @@ fix = {
 
 
 /*
+ *  Define __CAN_USE_EXTERN_PREFIX on vms.
+ */
+fix = {
+    hackname  = vms_define_can_use_extern_prefix;
+    files     = "rtldef/decc$types.h";
+    select    = "#[ \t]*else\n"
+               "#[ \t]*if defined\\(__DECCXX\\)\n"
+               "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
+    mach      = "*-*-*vms*";
+    c_fix     = format;
+
+    c_fix_arg = "%0"
+               "#    elif defined (__GNUC__)\n"
+               "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
+
+    test_text = "# else\n"
+               "#    if defined(__DECCXX)\n"
+               "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
+               "#    endif\n"
+               "# endif\n";
+};
+
+/*
+ * On VMS, use pragma extern_model instead of VAX-C keywords.
+ */
+fix = {
+    hackname  = vms_use_pragma_extern_model;
+    select    = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
+               "# pragma extern_model __save\n";
+    mach      = "*-*-*vms*";
+    c_fix     = format;
+
+    c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
+               "# pragma extern_model __save\n";
+
+    test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
+               "# pragma extern_model __save\n"
+               "# pragma extern_model strict_refdef\n"
+               "   extern struct x zz$yy;\n"
+               "# pragma extern_model __restore\n"
+               "#endif\n";
+};
+
+/*
+ * On VMS, disable the use of dec-c string builtins
+ */
+fix = {
+    hackname  = vms_disable_decc_string_builtins;
+    select    = "#if !defined\\(__VAX\\)\n";
+    mach      = "*-*-*vms*";
+    files     = "rtldef/string.h";
+    c_fix     = format;
+
+    c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
+
+    test_text = "#if !defined(__VAX)\n";
+};
+
+/*
  *  AIX and Interix headers define NULL to be cast to a void pointer,
  *  which is illegal in ANSI C++.
  */
@@ -3758,6 +4642,7 @@ fix = {
     files     = sys/types.h;
     /* avoid changing C++ friendly NULL */
     bypass    = __cplusplus;
+    bypass    = __null;
     select    = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
     c_fix     = format;
     c_fix_arg = "#define NULL 0";
@@ -3912,7 +4797,7 @@ fix = {
 
     sed      = "/Widget\told, new;/i\\\n"
                    "#ifdef __cplusplus\\\n"
-                   "\tWidget\told, c_new;\\\n"
+                   "\\\tWidget\told, c_new;\\\n"
                    "#else\n";
 
     sed      = "/Widget\told, new;/a\\\n"
@@ -3921,7 +4806,7 @@ fix = {
     sed      = "s/Widget new,/Widget c_new,/g";
     test_text =
     "struct wedge {\n"
-    "   Widget\told, new; /* fixinc check FAILS ON BSD */\n"
+    "   Widget\told, new;\n"
     "};\nextern Wedged( Widget new, Widget old );";
 };