diff fixincludes/inclhack.def @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
line wrap: on
line diff
--- a/fixincludes/inclhack.def	Sun Aug 21 07:07:55 2011 +0900
+++ b/fixincludes/inclhack.def	Fri Oct 27 22:46:09 2017 +0900
@@ -11,7 +11,7 @@
           pattern='^/\*$' \
           trailer='^/\*EOF\*[/]' \
           input=inclhack.def \
-          key='hackname[ 	]*=[ 	]*(.*);'
+          key=$'hackname[ \t]*=[ \t]*(.*);'
 
    Set up a debug test so we can make the templates emit special
    code while debugging these fixes:  */
@@ -64,6 +64,43 @@
 	_EOArg_;
 };
 
+/* On AIX when _LARGE_FILES is defined fcntl.h defines open to
+ * open64 and creat to creat64.  This fixes fcntl.h to
+ * undef those defines and use __asm__ to alias the symbols if
+ * building with g++ and -D_LARGE_FILES
+ */
+fix = {
+    hackname  = AAB_aix_fcntl;
+    files     = fcntl.h;
+    select    = "define open[ \t]open64";
+    mach      = "*-*-aix*";
+    test-text = ''; /* no way to test */
+
+    c_fix     = wrap;
+
+    c_fix_arg = "";
+
+    c_fix_arg = <<- _EOArg_
+
+	#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
+	#define __need__aix_fcntl_h_fix
+	#ifdef __need__aix_fcntl_h_fix
+	#undef open
+	#undef creat
+	#undef openat
+	/* Alias the symbols using asm */
+	extern "C" {
+	extern int open(const char *, int, ...) __asm__("open64");
+	extern int creat(const char *, mode_t) __asm__("creat64");
+	#if (_XOPEN_SOURCE >= 700)
+	extern int openat(int, const char *, int, ...) __asm__("open64at");
+	#endif
+	}
+	#endif
+	#endif
+
+	_EOArg_;
+};
 
 /*
  *  On Mac OS 10.3.9, the 'long double' functions are available in
@@ -157,25 +194,6 @@
 	_EndOfHeader_;
 };
 
-
-/*
- *  ... and for the previous fix to be useful, you have to not use ""
- *  includes.
- */
-fix = {
-  hackname  = AAB_darwin7_9_long_double_funcs_2;
-  mach      = "*-*-darwin7.9*";
-  files     = math.h;
-  select    = '#include[ \t]+\"';
-  c_fix     = format;
-  c_fix_arg = "%1<%2.h>";
-  
-  c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
-  
-  test_text = '#include "architecture/ppc/math.h"';
-};
-
-
 /*
  *  This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
  */
@@ -217,7 +235,6 @@
 	_EndOfHeader_;
 };
 
-
 /*
  *  This fixes __FD_ZERO bug for glibc-1.x
  */
@@ -255,7 +272,6 @@
 	_EndOfHeader_;
 };
 
-
 /*
  *  This fixes __FD_ZERO bug for glibc-2.0.x
  */
@@ -297,7 +313,6 @@
 	_EndOfHeader_;
 };
 
-
 /*
  * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
  * the same interface as <stdarg.h>.  No idea why they couldn't have just
@@ -316,7 +331,6 @@
 	_EndOfHeader_;
 };
 
-
 /*
  *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
  *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
@@ -354,6 +368,103 @@
 	_EndOfHeader_;
 };
 
+/*
+ * Fix assert.h on VxWorks:
+ */
+fix = {
+    hackname    = AAB_vxworks_assert;
+    files       = assert.h;
+    mach        = "*-*-vxworks*";
+        
+    replace     = <<- _EndOfHeader_
+	#ifndef _ASSERT_H
+	#define _ASSERT_H
+
+	#ifdef assert
+	#undef assert
+	#endif
+
+	#if defined(__STDC__) || defined(__cplusplus)
+	extern void __assert (const char*);
+	#else
+	extern void __assert ();
+	#endif
+
+	#ifdef NDEBUG
+	#define assert(ign) ((void)0)
+	#else
+
+	#define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
+	#define ASSERT_STRINGIFY_HELPER(str) #str
+
+	#define assert(test) ((void) \
+	        ((test) ? ((void)0) : \
+	        __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
+	        __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
+
+	#endif
+
+	#endif
+	_EndOfHeader_;
+};
+
+/*
+ * Add needed include to regs.h (NOT the gcc header) on VxWorks
+ */
+
+fix = {
+    hackname    = AAB_vxworks_regs_vxtypes;
+    files       = regs.h;
+    mach        = "*-*-vxworks*";
+
+    replace     = <<- _EndOfHeader_
+	#ifndef _REGS_H
+	#define _REGS_H
+	#include <types/vxTypesOld.h>
+	#include_next <arch/../regs.h>
+	#endif
+	_EndOfHeader_;
+};
+
+/*
+ *  This hack makes makes unistd.h more POSIX-compliant on VxWorks
+ */
+fix = {
+    hackname    = AAB_vxworks_unistd;
+    files       = unistd.h;
+    mach        = "*-*-vxworks*";
+        
+    replace     = <<- _EndOfHeader_
+	#ifndef _UNISTD_H
+	#define _UNISTD_H
+	#include_next <unistd.h>
+	#include <ioLib.h>
+	#ifndef STDIN_FILENO
+	#define STDIN_FILENO 0
+	#endif
+	#ifndef STDOUT_FILENO
+	#define STDOUT_FILENO 1
+	#endif
+	#ifndef STDERR_FILENO
+	#define STDERR_FILENO 2
+	#endif
+	#endif /* _UNISTD_H */
+	_EndOfHeader_;
+};
+
+/*
+ * assert.h on AIX 7 redefines static_assert as _Static_assert without
+ * protecting C++.
+ */
+fix = {
+    hackname  = aix_assert;
+    mach      = "*-*-aix*";
+    files     = assert.h;
+    select    = "#define[ \t]static_assert[ \t]_Static_assert";
+    c_fix     = format;
+    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
+    test_text = "#define static_assert _Static_assert";
+};
 
 /*
  * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
@@ -369,6 +480,179 @@
     test_text = "#define _Complex_I	__I\n";
 };
 
+/*
+ *  On AIX some headers are not properly guarded by 'extern "C"'.
+ */
+fix = {
+  hackname  = aix_externc;
+  mach      = "*-*-aix*";
+  files     = ctype.h;
+  files     = fcntl.h;
+  files     = langinfo.h;
+  files     = ldfcn.h;
+  files     = sys/localedef.h;
+  files     = sys/times.h;
+  bypass    = "extern \"C\"";
+  c_fix     = wrap;
+  c_fix_arg = "#ifdef __cplusplus\n"
+              "extern \"C\" {\n"
+              "#endif\n";
+  c_fix_arg = "#ifdef __cplusplus\n"
+              "}\n"
+              "#endif\n";
+  test_text = "extern int __n_pthreads;\n";
+};
+
+/*
+ *  On AIX sys/socket.h assumes C++.
+ */
+fix = {
+  hackname  = aix_externcpp1;
+  mach      = "*-*-aix*";
+  files     = "sys/socket.h";
+  select    = "#ifdef __cplusplus";
+  c_fix     = format;
+  c_fix_arg = "#ifdef __cplusplus\n"
+              "extern \"C++\" {";
+  test_text = "#ifdef __cplusplus";
+
+};
+
+fix = {
+  hackname  = aix_externcpp2;
+  mach      = "*-*-aix*";
+  files     = "sys/socket.h";
+  select    = "#else  /\\* __cplusplus \\*/";
+  c_fix     = format;
+  c_fix_arg = "} /* extern \"C++\" */\n"
+              "#else  /* __cplusplus */";
+  test_text = "#else  /* __cplusplus */";
+
+};
+
+/*
+ *  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};";
+};
+
+/*
+ *  Fix AIX definition of NULL for G++.
+ */
+fix = {
+    hackname  = aix_null;
+    mach      = "*-*-aix*";
+    files     = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
+    time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
+    bypass    = __null;
+    select    = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
+    c_fix     = format;
+    c_fix_arg = <<- _EOFix_
+	#ifndef NULL
+	#ifdef __cplusplus
+	#ifdef __GNUG__
+	#define NULL __null
+	#else /* ! __GNUG__  */
+	#define NULL 0L
+	#endif /* __GNUG__  */
+	#else /* ! __cplusplus  */
+	#define NULL ((void *)0)
+	#endif /* __cplusplus  */
+	#endif /* !NULL  */
+	_EOFix_;
+    test_text = "# define\tNULL \t(0L)  /* typed NULL */";
+};
+
+/*
+ *  pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
+ *  PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER 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";
+};
+
+fix = {
+    hackname  = aix_mutex_initializer_1;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
+		"\\{ \\\\\n";
+    c_fix     = format;
+    c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
+		"{{ \\\n";
+    test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
+		"{ \\\\\n";
+};
+
+fix = {
+    hackname  = aix_cond_initializer_1;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
+		"\\{ \\\\\n";
+    c_fix     = format;
+    c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
+		"{{ \\\n";
+    test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
+		"{ \\\\\n";
+};
+
+fix = {
+    hackname  = aix_rwlock_initializer_1;
+    mach      = "*-*-aix*";
+    files     = "pthread.h";
+    select    = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
+		"\\{ \\\\\n";
+    c_fix     = format;
+    c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
+		"{{ \\\n";
+    test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
+		"{ \\\\\n";
+};
 
 /*
  *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
@@ -377,14 +661,13 @@
 fix = {
     hackname  = aix_pthread;
     files     = "pthread.h";
-    select    = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
+    select    = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
     c_fix     = format;
     c_fix_arg = "%1 %2";
     test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
                 "{...init stuff...}";
 };
 
-
 /*
  *  AIX stdint.h fixes.
  */
@@ -401,7 +684,9 @@
 		"#define UINT16_MAX	(65535U)";
 };
 
-
+/*
+ * aix_stdint_2
+ */
 fix = {
     hackname  = aix_stdint_2;
     mach      = "*-*-aix*";
@@ -430,7 +715,9 @@
 		"#define UINTPTR_MAX	UINT32_MAX";
 };
 
-
+/*
+ * aix_stdint_3
+ */
 fix = {
     hackname  = aix_stdint_3;
     mach      = "*-*-aix*";
@@ -453,7 +740,9 @@
 		"#define PTRDIFF_MAX	INT32_MAX";
 };
 
-
+/*
+ * aix_stdint_4
+ */
 fix = {
     hackname  = aix_stdint_4;
     mach      = "*-*-aix*";
@@ -470,7 +759,9 @@
 		"#define SIZE_MAX        UINT32_MAX";
 };
 
-
+/*
+ * aix_stdint_5
+ */
 fix = {
     hackname  = aix_stdint_5;
     mach      = "*-*-aix*";
@@ -484,6 +775,81 @@
 		"#define UINT16_C(c)	__CONCAT__(c,U)";
 };
 
+/*
+ * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
+   produces wrong code with G++.
+ */
+fix = {
+    hackname  = aix_stdio_inline;
+    mach      = "*-*-aix*";
+    files     = stdio.h;
+    select    = "#ifdef __cplusplus\\\n"
+                "}\\\n\\\n"
+                "#ifdef ferror\\\n";
+    c_fix     = format;
+    c_fix_arg = "#ifdef __cplusplus\n"
+                "}\n"
+                "#endif\n\n"
+                "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
+                "#ifdef ferror\n";
+    test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
+};
+
+/*
+ * stdlib.h on AIX uses #define on malloc and friends.
+ */
+fix = {
+    hackname  = aix_stdlib_malloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+malloc[ \t]+__linux_malloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
+    test_text = "#define malloc __linux_malloc";
+};
+
+fix = {
+    hackname  = aix_stdlib_realloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+realloc[ \t]+__linux_realloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
+    test_text = "#define realloc __linux_realloc";
+};
+
+fix = {
+    hackname  = aix_stdlib_calloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+calloc[ \t]+__linux_calloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
+    test_text = "#define calloc __linux_calloc";
+};
+
+fix = {
+    hackname  = aix_stdlib_valloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+valloc[ \t]+__linux_valloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
+    test_text = "#define valloc __linux_valloc";
+};
+
+/*
+ * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
+ */
+fix = {
+    hackname  = aix_strtof_const;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
+    c_fix     = format;
+    c_fix_arg = "%1(const char *, char **);";
+    test_text = "extern float    strtof(char *, char **);";
+};
 
 /*
  *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
@@ -491,6 +857,7 @@
  */
 fix = {
     hackname  = aix_sysmachine;
+    mach      = "*-*-aix*";
     files     = sys/machine.h;
     select    = "\\\\ +\n";
     c_fix     = format;
@@ -499,20 +866,20 @@
     " bar \\ \n baz \\ \n bat";
 };
 
-
 /*
  *  sys/wait.h on AIX 5.2 defines macros that have both signed and
  *  unsigned types in conditional expressions.
  */
 fix = {
     hackname  = aix_syswait_2;
+    mach      = "*-*-aix*";
     files     = sys/wait.h;
     select    = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
     c_fix     = format;
     c_fix_arg = "? (int)%1";
-    test_text = "#define WSTOPSIG(__x)    (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
-};
-
+    test_text = "#define WSTOPSIG(__x)    "
+        "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
+};
 
 /*
  *  sys/signal.h on some versions of AIX uses volatile in the typedef of
@@ -522,6 +889,7 @@
  */
 fix = {
     hackname  = aix_volatile;
+    mach      = "*-*-aix*";
     files     = sys/signal.h;
     select    = "typedef volatile int sig_atomic_t";
     c_fix     = format;
@@ -529,7 +897,6 @@
     test_text = "typedef volatile int sig_atomic_t;";
 };
 
-
 /*
  *  Fix __assert declaration in assert.h on Alpha OSF/1.
  */
@@ -542,64 +909,6 @@
     test_text = 'extern void __assert(char *, char *, int);';
 };
 
-
-/*
- *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
- */
-fix = {
-    hackname  = alpha___extern_prefix;
-    select    = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
-                "(#[ \t]*pragma[ \t]*extern_prefix.*)";
-
-    mach      = "alpha*-dec-osf*";
-    c_fix     = format;
-    c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
-
-    test_text = "#ifdef  __DECC\n"
-		"#pragma extern_prefix \"_P\"\n"
-		"#   if defined(__DECC)\n"
-		"#     pragma extern_prefix \"_E\"\n"
-		"# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
-		"#  pragma extern_prefix \"\"";
-};
-
-
-/*
- *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
- */
-fix = {
-    hackname  = alpha___extern_prefix_standards;
-    files     = standards.h;
-    select    = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
-
-    mach      = "alpha*-dec-osf*";
-    c_fix     = format;
-    c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
-
-    test_text = "#if (_ISO_C_SOURCE>=19990L) "
-                "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
-};
-
-
-/*
- *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
- *  <sys/stat.h>.  The tests for __DECC are special in various ways, so
- *  alpha__extern_prefix cannot be used.
- */
-fix = {
-    hackname  = alpha___extern_prefix_sys_stat;
-    files     = sys/stat.h;
-    files     = sys/mount.h;
-    select    = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
-
-    mach      = "alpha*-dec-osf5*";
-    c_fix     = format;
-    c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
-
-    test_text = "#   if defined(__DECC)";
-};
-
-
 /*
  *  Fix assert macro in assert.h on Alpha OSF/1.
  *  The superfluous int cast breaks C++.
@@ -614,38 +923,6 @@
                 ': __assert(#EX, __FILE__, __LINE__))';
 };
 
-
-/*
- *  Fix #defines under Alpha OSF/1:
- *  The following files contain '#pragma extern_prefix "_FOO"' followed by
- *  a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
- *  statements is to reduce namespace pollution.  While these macros work
- *  properly in most cases, they don't allow you to take a pointer to the
- *  "something" being modified.  To get around this limitation, change these
- *  statements to be of the form '#define something _FOOsomething'.
- *
- *  sed ain't egrep, lesson 2463:  sed can use self-referential
- *  regular expressions.  In the substitute expression below,
- *  "\\1" and "\\2" refer to subexpressions found earlier in the
- *  same match.  So, we continue to use sed.  "extern_prefix" will
- *  be a rare match anyway...
- */
-fix = {
-    hackname = alpha_bad_lval;
-
-    select   = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
-    mach      = "alpha*-dec-osf*";
-
-    sed      =
-        "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
-               "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
-
-    test_text = '#pragma extern_prefix "_FOO"'"\n"
-                "#define something(x,y,z) _FOOsomething(x,y,z)\n"
-                "#define mumble _FOOmumble";
-};
-
-
 /*
  *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
  */
@@ -659,7 +936,6 @@
     test_text = 'extern int getopt(int, char *[], char *);';
 };
 
-
 /*
  *  Fix missing semicolon on Alpha OSF/4 in <net/if.h>
  */
@@ -672,7 +948,6 @@
     test_text = '     struct  sockaddr vmif_paddr     /* protocol address */';
 };
 
-
 /*
  * Remove erroneous parentheses in sym.h on Alpha OSF/1.
  */
@@ -685,100 +960,6 @@
     test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
 };
 
-
-/*
- *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
- */
-fix = {
-    hackname  = alpha_pthread;
-    files     = pthread.h;
-    select    = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
-                "|def _PTHREAD_ENV_DECC)(.*))\n"
-		"(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
-
-    mach      = "alpha*-dec-osf*";
-    c_fix     = format;
-    c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
-                "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
-
-    test_text = "#  if defined (_PTHREAD_ENV_DECC) "
-                      "|| defined (_PTHREAD_ENV_EPCC)\n"
-		"#   define _PTHREAD_USE_PTDNAM_\n"
-		"#  endif\n"
-		"#  ifdef _PTHREAD_ENV_DECC\n"
-		"#   define _PTHREAD_USE_PTDNAM_\n"
-		"#  endif";
-};
-
-
-/*
- *  Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
- */
-fix = {
-    hackname  = alpha_pthread_gcc;
-    files     = pthread.h;
-    select    = "#else\n# error <pthread.h>: unrecognized compiler.";
-
-    mach      = "alpha*-dec-osf*";
-    c_fix     = format;
-    c_fix_arg = "#elif defined (__GNUC__)\n"
-		"# define _PTHREAD_ENV_GCC\n"
-    		"%0";
-
-    test_text = "# define _PTHREAD_ENV_INTELC\n"
-		"#else\n"
-		"# error <pthread.h>: unrecognized compiler.\n"
-		"#endif";
-};
-
-
-/*
- * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
- * incorrectly, specifying less fields in the initializers than are
- * defined in the corresponding structure types.  Use of these macros
- * in user code results in spurious warnings.
- */
-fix = {
-    hackname  = alpha_pthread_init;
-    files     = pthread.h;
-    select    = ' \* @\(#\).RCSfile: pthread\.h,v \$'
-                ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
-                ' .Date: 2000/08/15 15:30:13 \$';
-    mach      = "alpha*-dec-osf*";
-    sed       = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
-                "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
-                "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
-                "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
-                "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
-                "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
-    test_text = <<- _EOText_
-	/*
-	 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
-	 */
-	#ifndef _PTHREAD_NOMETER_STATIC
-	# define PTHREAD_MUTEX_INITIALIZER \
-	    {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
-	# define PTHREAD_COND_INITIALIZER \
-	    {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
-	# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
-	    {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
-	# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
-	    {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
-	#else
-	# define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
-	# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
-	    {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
-	# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
-	    {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
-	#endif
-
-	#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
-	#define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
-	        {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
-	_EOText_;
-};
-
-
 /*
  *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
  *  And OpenBSD.
@@ -792,7 +973,6 @@
     test_text = "extern char* sbrk(ptrdiff_t increment);";
 };
 
-
 /*
  *  For C++, avoid any typedef or macro definition of bool,
  *  and use the built in type instead.
@@ -815,7 +995,9 @@
     test_text = "# define bool\t char \n";
 };
 
-
+/*
+ * avoid_bool_type
+ */
 fix = {
     hackname = avoid_bool_type;
     files    = curses.h;
@@ -832,7 +1014,6 @@
     test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
 };
 
-
 /*
  *  For C++, avoid any typedef definition of wchar_t,
  *  and use the built in type instead.
@@ -856,7 +1037,6 @@
     test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
 };
 
-
 /*
  *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
  */
@@ -870,7 +1050,6 @@
     test_text = 'typedef struct term;';
 };
 
-
 /*
  *  Fix one other error in this file:
  *  a mismatched quote not inside a C comment.
@@ -885,7 +1064,6 @@
     test_text = "/* doesn't have matched single quotes */";
 };
 
-
 /*
  *  check for broken assert.h that needs stdio.h
  */
@@ -899,7 +1077,6 @@
     test_text = "extern FILE* stderr;";
 };
 
-
 /*
  *  check for broken assert.h that needs stdlib.h
  */
@@ -915,14 +1092,9 @@
     test_text = "extern void exit ( int );";
 };
 
-
 /*
  *  Remove `extern double cabs' declarations from math.h.
  *  This conflicts with C99.  Discovered on AIX.
- *  IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
- *  declares cabs() to take a struct __cabs_s argument.
- *  SunOS4 has its cabs() declaration followed by a comment which
- *  terminates on the following line.
  *  Darwin hides its broken cabs in architecture-specific subdirs.
  */
 fix = {
@@ -938,13 +1110,8 @@
                 "#else\n"
                 "extern     double   cabs();\n"
                 "#endif\n"
-                "extern double cabs ( _Complex z );\n"
-                "extern double cabs(); /* This is a comment\n"
-                "                         and it ends here. */\n"
-                "extern double	cabs(struct __cabs_s);\n"
-                "extern long double cabsl( struct __cabsl_s );";
-};
-
+                "extern double cabs ( _Complex z );";
+};
 
 /*
  * Fixup Darwin's broken check for __builtin_nanf.
@@ -959,14 +1126,13 @@
      */
     files     = "architecture/ppc/math.h";
     files     = "architecture/*/math.h";
-    select    = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
+    select    = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
     bypass    = "powl";
     c_fix     = format; 
     c_fix_arg = "#if 1";
     test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
 };
 
-
 /*
  *  Various systems derived from BSD4.4 contain a macro definition
  *  for vfscanf that interacts badly with requirements of builtin-attrs.def.
@@ -986,7 +1152,6 @@
     test_text = '#define  vfscanf	__svfscanf';
 };
 
-
 /*
  *  Fix various macros used to define ioctl numbers.
  *  The traditional syntax was:
@@ -1018,6 +1183,9 @@
     test_text = "#define _CTRL(c) ('c'&037)";
 };
 
+/*
+ *  Fix various macros used to define ioctl numbers.
+ */
 fix = {
     hackname  = ctrl_quotes_use;
     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
@@ -1026,7 +1194,6 @@
     test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
 };
 
-
 /*
  *  sys/mman.h on HP/UX is not C++ ready,
  *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
@@ -1054,6 +1221,48 @@
     test_text = "extern void* malloc( size_t );";
 };
 
+/*
+ *  macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
+ *  unconditionally.
+ */
+fix = {
+    hackname  = darwin_availabilityinternal;
+    mach      = "*-*-darwin*";
+    files     = AvailabilityInternal.h;
+    select    = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
+    c_fix     = format;
+    c_fix_arg = <<- _EOFix_
+	#if defined(__has_attribute)
+	  #if __has_attribute(availability)
+	%0
+	  #else
+	    #define %1
+	  #endif
+	#else
+	    #define %1
+	#endif
+	_EOFix_;
+
+    test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
+		"#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
+};
+
+/*
+ *  For the AAB_darwin7_9_long_double_funcs fix to be useful,
+ *  you have to not use "" includes.
+ */
+fix = {
+    hackname  = darwin_9_long_double_funcs_2;
+    mach      = "*-*-darwin7.9*";
+    files     = math.h;
+    select    = '#include[ \t]+\"';
+    c_fix     = format;
+    c_fix_arg = "%1<%2.h>";
+  
+    c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
+  
+    test_text = '#include "architecture/ppc/math.h"';
+};
 
 /*
  *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
@@ -1080,12 +1289,10 @@
   test_text = "extern void swap_fat_header();\n";
 };
 
-
 /*
  * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
  * bad __GNUC__ tests.
  */
-
 fix = {
   hackname  = darwin_gcc4_breakage;
   mach      = "*-*-darwin*";
@@ -1097,6 +1304,76 @@
   	      "(__GNUC_MINOR__ >= 1)\n";
 };
 
+/*
+ *  Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
+ */
+fix = {
+    hackname  = darwin_longjmp_noreturn;
+    mach      = "*-*-darwin*";
+    files     = "i386/setjmp.h";
+    bypass    = "__dead2";
+    select    = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
+    c_fix     = format;
+    c_fix_arg = "%1 __attribute__ ((__noreturn__));";
+
+    test_text = "void siglongjmp(sigjmp_buf, int);";
+};
+
+/*
+ *  Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
+ */
+fix = {
+  hackname  = darwin_os_trace_1;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = "^(_os_trace_verify_printf.*) (__attribute__.*)";
+  c_fix     = format;
+  c_fix_arg = "%1";
+  test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
+};
+
+/*
+ *  Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
+ *  extension without guard.
+ */
+fix = {
+  hackname  = darwin_os_trace_2;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = "typedef.*\\^os_trace_payload_t.*";
+  c_fix     = format;
+  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+  test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
+};
+
+/*
+ *  In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
+ *  os_trace_payload_t typedef, too.
+ */
+fix = {
+  hackname  = darwin_os_trace_3;
+  mach      = "*-*-darwin*";
+  files     = os/trace.h;
+  select    = <<- _EOSelect_
+	__(API|OSX)_.*
+	OS_EXPORT.*
+	.*
+	_os_trace.*os_trace_payload_t payload);
+	_EOSelect_;
+  c_fix     = format;
+  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+  test_text = <<- _EOText_
+	__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
+	OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
+	void
+	_os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
+
+	__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
+	OS_EXPORT OS_NOTHROW
+	void
+	_os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
+	_EOText_;
+};
 
 /*
  *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
@@ -1115,7 +1392,6 @@
 	      "unsigned long *address);\n";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
  * unsigned constants.
@@ -1132,7 +1408,6 @@
 		"#define UINT16_C(v)  (v ## U)";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
  * with wrong types.
@@ -1165,7 +1440,6 @@
 		"#endif";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
  */
@@ -1191,7 +1465,6 @@
 		"#endif";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
  */
@@ -1217,7 +1490,6 @@
 		"#endif";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
  * with a wrong type.
@@ -1246,7 +1518,6 @@
 		"#define UINTMAX_MAX       UINT64_MAX";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  * with a wrong type.
@@ -1279,7 +1550,6 @@
 		"#endif";
 };
 
-
 /*
  * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  * with a wrong type.
@@ -1302,7 +1572,6 @@
 		"#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,
@@ -1320,7 +1589,6 @@
     "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
 };
 
-
 /*
  * Fix typo in <wchar.h> on DJGPP 2.03.
  */
@@ -1336,7 +1604,6 @@
                 "extern __DJ_wint_t x;\n";
 };
 
-
 /*
  * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
  */
@@ -1351,6 +1618,59 @@
     test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
 };
 
+/*
+ *  Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
+ *  that fails when compiling for SSE-less 32-bit x86.
+ */
+fix = {
+    hackname  = feraiseexcept_nosse_divbyzero;
+    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
+    files     = bits/fenv.h, '*/bits/fenv.h';
+    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
+		": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
+    bypass    = "\"fdivp .*; fwait\"";
+    
+    c_fix     = format;
+    c_fix_arg = <<- _EOText_
+	# ifdef __SSE_MATH__
+	%0
+	# else
+	%1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
+	%1			: "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
+	# endif
+	_EOText_;
+
+    test_text = <<- _EOText_
+	  __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
+	_EOText_;
+};
+
+/*
+ *  Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
+ *  that fails when compiling for SSE-less 32-bit x86.
+ */
+fix = {
+    hackname  = feraiseexcept_nosse_invalid;
+    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
+    files     = bits/fenv.h, '*/bits/fenv.h';
+    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
+		": \"x\" \\(__f\\)\\);$";
+    bypass    = "\"fdiv .*; fwait\"";
+    
+    c_fix     = format;
+    c_fix_arg = <<- _EOText_
+	# ifdef __SSE_MATH__
+	%0
+	# else
+	%1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
+	%1			: "=t" (__f) : "0" (__f));
+	# endif
+	_EOText_;
+
+    test_text = <<- _EOText_
+	  __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
+	_EOText_;
+};
 
 /*
  *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
@@ -1368,7 +1688,6 @@
     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
 };
 
-
 /*
  *  Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
  *  neither the existence of GCC 4 nor its exact feature set yet break
@@ -1384,7 +1703,6 @@
     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
 };
 
-
 /*
  *  Some versions of glibc don't expect the C99 inline semantics.
  */
@@ -1402,7 +1720,6 @@
 	EOT;
 };
 
-
 /*
  *  Similar, but a version that didn't have __NO_INLINE__
  */
@@ -1420,7 +1737,6 @@
 	EOT;
 };
 
-
 /*
  * The glibc_c99_inline_1 fix should have fixed everything.  Unfortunately
  * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
@@ -1456,7 +1772,9 @@
 	EOT;
 };
 
-
+/*
+ * glibc_c99_inline_3
+ */
 fix = {
     hackname  = glibc_c99_inline_3;
     files     = bits/string2.h, '*/bits/string2.h';
@@ -1474,10 +1792,13 @@
 	EOT;
 };
 
-
+/*
+ * glibc_c99_inline_4
+ */
 fix = {
     hackname  = glibc_c99_inline_4;
-    files     = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
+    files     = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
+    pthread.h, '*/pthread.h';
     bypass    = "__extern_inline|__gnu_inline__";
     select    = "(^| )extern __inline";
     c_fix     = format;
@@ -1488,7 +1809,6 @@
 	EOT;
 };
 
-
 /*  glibc-2.3.5 defines pthread mutex initializers incorrectly,
  *  so we replace them with versions that correspond to the
  *  definition.
@@ -1562,7 +1882,6 @@
 	_EOText_;
 };
 
-
 /* 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.  */
@@ -1573,9 +1892,10 @@
     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";
-};
-
+    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
@@ -1583,7 +1903,7 @@
    versions.  */
 fix = {
     hackname  = glibc_strncpy;
-    files     = bits/string2.h;
+    files     = bits/string2.h, '*/bits/string2.h';
     bypass    = "__builtin_strncpy";
     c_fix     = format;
     c_fix_arg = "#  define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
@@ -1608,7 +1928,9 @@
     select    = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
     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))";
+    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))";
 };
 
@@ -1640,7 +1962,6 @@
                 "typedef ushort_t wchar_t; /* ushort_t */";
 };
 
-
 /*
  *  Fix HP & Sony's use of "../machine/xxx.h"
  *  to refer to:  <machine/xxx.h>
@@ -1660,7 +1981,6 @@
     test_text = ' # include "../machine/mumble.h"';
 };
 
-
 /*
  *  Check for (...) in C++ code in HP/UX sys/file.h.
  */
@@ -1676,7 +1996,6 @@
     test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
 };
 
-
 /*
  *  Un-Hide a series of five FP defines from post-1999 compliance GCC:
  *  FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
@@ -1710,7 +2029,6 @@
             "#  define FP_NAN        4\n";
 };
 
-
 /*
  * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
  * math.h to prevent clash with define in c_std/bits/std_cmath.h.
@@ -1758,7 +2076,6 @@
             "   }\n";
 };
 
-
 /*
  *  Fix hpux 10.X missing ctype declarations 1
  */
@@ -1780,7 +2097,6 @@
     test_text = "#  define _toupper(__c)         __toupper(__c)\n";
 };
 
-
 /*
  *  Fix hpux 10.X missing ctype declarations 2
  */
@@ -1821,7 +2137,6 @@
 		"     extern unsigned int *__SB_masks;\n";
 };
 
-
 /*
  *  Fix hpux 10.X missing stdio declarations
  */
@@ -1843,13 +2158,30 @@
     test_text = "#  define _iob __iob\n";
 };
 
+/*
+ *  The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
+ *  As a result, we need to include sys/stdsyms.h in alloca.h.
+ */
+fix = {
+    hackname  = hppa_hpux11_alloca;
+    mach      = "hppa*-*-hpux11*";
+    files     = alloca.h;
+    select    = "#ifndef _STDDEF_INCLUDED";
+    c_fix     = format;
+    c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
+		"#  include <sys/stdsyms.h>\n"
+		"#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
+		"%0";
+
+    test_text = "#ifndef _STDDEF_INCLUDED";
+};
 
 /*
  *  Make sure hpux defines abs in header.
  */
 fix = {
     hackname  = hpux11_abs;
-    mach      = "ia64-hp-hpux11*";
+    mach      = "*-hp-hpux11*";
     files     = stdlib.h;
     select    = "ifndef _MATH_INCLUDED";
     c_fix     = format;
@@ -1857,6 +2189,46 @@
     test_text = "#ifndef _MATH_INCLUDED";
 };
 
+/*
+ *  Fix hpux11 __LWP_RWLOCK_VALID define
+ */
+fix = {
+    hackname  = hpux11_lwp_rwlock_valid;
+    mach      = "*-hp-hpux11*";
+    files     = sys/pthread.h;
+    select    = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
+    c_fix     = format;
+    c_fix_arg = "#define __LWP_RWLOCK_VALID              -29551";
+    test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
+};
+
+/*
+ * hpux sendfile()
+ */
+fix = {
+    hackname  = hpux11_extern_sendfile;
+    mach      = "*-hp-hpux11.[12]*";
+    files     = sys/socket.h;
+    select    = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
+    c_fix     = format;
+    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
+    test_text = "   extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
+        "                               const struct iovec *, int));\n";
+};
+
+/*
+ * hpux sendpath()
+ */
+fix = {
+    hackname  = hpux11_extern_sendpath;
+    mach      = "*-hp-hpux11.[12]*";
+    files     = sys/socket.h;
+    select    = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
+    c_fix     = format;
+    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
+    test_text = "   extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
+        "                               const struct iovec *, int));\n";
+};
 
 /*
  *  Keep HP-UX 11 from stomping on C++ math namespace
@@ -1864,9 +2236,9 @@
  */
 fix = {
     hackname  = hpux11_fabsf;
+    mach      = "*-hp-hpux11*";
     files     = math.h;
     select    = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
-    bypass    = "__cplusplus";
 
     c_fix     = format;
     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
@@ -1877,22 +2249,38 @@
     "#endif";
 };
 
-
-/*
- *  Fix C99 constant in __POINTER_SET define.
+/*
+ *  The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
+ *  in pthread.h need to be constant expressions to be standard complient.
+ *  As a result, we need to remove the void * casts in the initializers
+ *  (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
+ *  to use the long type.
+ */
+fix = {
+    hackname  = hpux11_pthread_pointer;
+    mach      = "*-hp-hpux11.[0-3]*";
+    files     = sys/pthread.h;
+    select    = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
+
+    c_fix     = format;
+    c_fix_arg = "long\t%2%3";
+    test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
+};
+
+/*
+ *  Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
  */
 fix = {
     hackname  = hpux11_pthread_const;
     mach      = "*-hp-hpux11.[0-3]*";
     files     = sys/pthread.h;
-    select    = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
+    select    = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
 
     c_fix     = format;
-    c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
+    c_fix_arg = "%11";
     test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
 };
 
-
 /*
  * Prevent HP-UX 11 from defining __size_t and preventing size_t from
  * being defined by having it define _hpux_size_t instead.
@@ -1910,7 +2298,6 @@
     "       extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
 };
 
-
 /*
  *  Fix hpux 11.00 broken snprintf declaration
  *  (third argument is char *, needs to be const char * to prevent
@@ -1944,6 +2331,19 @@
                                      ' __va__list);';
 };
 
+/*
+ *  Fix missing const in hpux vsscanf declaration
+ */
+fix = {
+    hackname = hpux_vsscanf;
+    mach    = "*-*-hpux*";
+    files   = stdio.h;
+    select  = '(extern int vsscanf\()char';
+    c_fix   = format;
+    c_fix_arg = "%1const char";
+
+    test_text = 'extern int vsscanf(char *, const char *, __va_list);';
+};
 
 /*
  *  get rid of bogus inline definitions in HP-UX 8.0
@@ -1962,6 +2362,75 @@
                 "inline double sqr(double v) { return v**0.5; }";
 };
 
+/*
+ * hpux intptr
+ */
+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";
+};
+
+/*
+ * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
+ */
+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 hpux broken ctype macros
@@ -1978,6 +2447,25 @@
 		"# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
 };
 
+/*
+ * hpux errno()
+ */
+fix = {
+    hackname  = hpux_extern_errno;
+    mach      = "*-hp-hpux10.*";
+    mach      = "*-hp-hpux11.[0-2]*";
+    files     = errno.h;
+    select    = "^[ \t]*extern int errno;$";
+    c_fix     = format;
+    c_fix_arg = "#ifdef __cplusplus\n"
+        "extern \"C\" {\n"
+        "#endif\n"
+        "%0\n"
+        "#ifdef __cplusplus\n"
+        "}\n"
+        "#endif";
+    test_text = "   extern int errno;\n";
+};
 
 /*
  *  Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
@@ -2006,6 +2494,32 @@
                 "#endif  /* ! _XOPEN_SOURCE_EXTENDED */";
 };
 
+/*
+ * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
+ */
+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";
+};
+
+/*
+ * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
+ */
+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";
+};
 
 /*
  * HP-UX long_double
@@ -2029,90 +2543,24 @@
 		"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.
-  */
+/*
+ * 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\\)";
+    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
- */
-fix = {
-    hackname = hpux_systime;
-    files    = sys/time.h;
-    select   = "^extern struct sigevent;";
-
-    c_fix     = format;
-    c_fix_arg = "struct sigevent;";
-
-    test_text = 'extern struct sigevent;';
-};
-
-
-/*
- *  Wrap spu_info in ifdef _KERNEL.  GCC cannot handle an array of unknown
- *  type and mpinfou is only defined when _KERNEL is set.
- */
-fix = {
-    hackname = hpux_spu_info;
-    mach     = "*-hp-hpux*";
-    /*
-     *  It is tempting to omit the first "files" entry.  Do not.
-     *  The testing machinery will take the first "files" entry as the name
-     *  of a test file to play with.  It would be a nuisance to have a directory
-     *  with the name "*".
-     */
-    files    = "ia64/sys/getppdp.h";
-    files    = "*/sys/getppdp.h";
-    select   = "^.*extern.*spu_info.*";
-
-    c_fix     = format;
-    c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
-
-    test_text = "extern union mpinfou spu_info[];";
-};
-
-fix = {
-    hackname  = hpux11_extern_sendfile;
-    mach      = "*-hp-hpux11.[12]*";
-    files     = sys/socket.h;
-    select    = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
-    c_fix     = format;
-    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
-    test_text = "   extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
-};
-
-fix = {
-    hackname  = hpux11_extern_sendpath;
-    mach      = "*-hp-hpux11.[12]*";
-    files     = sys/socket.h;
-    select    = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
-    c_fix     = format;
-    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
-    test_text = "   extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
-};
-
-fix = {
-    hackname  = hpux_extern_errno;
-    mach      = "*-hp-hpux10.*";
-    mach      = "*-hp-hpux11.[0-2]*";
-    files     = errno.h;
-    select    = "^[ \t]*extern int errno;$";
-    c_fix     = format;
-    c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
-    test_text = "   extern int errno;\n";
-};
-
+    test_text = "#  if !defined(__ia64) || "
+        "!defined(_PROTOTYPES) || "
+        "defined(_LONG_DOUBLE_STRUCT)\n";
+};
 
 /*
  *  Add missing braces to pthread initializer defines.
@@ -2156,57 +2604,32 @@
 		"}\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";
+/*
+ *  Wrap spu_info in ifdef _KERNEL.  GCC cannot handle an array of unknown
+ *  type and mpinfou is only defined when _KERNEL is set.
+ */
+fix = {
+    hackname = hpux_spu_info;
+    mach     = "*-hp-hpux*";
+    /*
+     *  It is tempting to omit the first "files" entry.  Do not.
+     *  The testing machinery will take the first "files" entry as the name
+     *  of a test file to play with.  It would be a nuisance to have a directory
+     *  with the name "*".
+     */
+    files    = "ia64/sys/getppdp.h";
+    files    = "*/sys/getppdp.h";
+    select   = "^.*extern.*spu_info.*";
+
+    c_fix     = format;
+    c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
+
+    test_text = "extern union mpinfou spu_info[];";
 };
 
 /*
  * 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*";
@@ -2217,28 +2640,35 @@
     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.*";
+};
+
+/*
+ *  Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
+ */
+fix = {
+    hackname = hpux_longjmp;
+    mach     = "*-hp-hpux*";
+    files    = setjmp.h;
+    select   = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
+
     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_arg = "%0 __attribute__ ((__noreturn__))";
+
+    test_text = 'extern void	longjmp __((jmp_buf, int));';
+};
+
+/*
+ *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
+ */
+fix = {
+    hackname = hpux_systime;
+    files    = sys/time.h;
+    select   = "^extern struct sigevent;";
+
     c_fix     = format;
-    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
-    test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
+    c_fix_arg = "struct sigevent;";
+
+    test_text = 'extern struct sigevent;';
 };
 
 /*
@@ -2246,7 +2676,7 @@
  */
 fix = {
     hackname  = huge_val_hex;
-    files     = bits/huge_val.h;
+    files     = bits/huge_val.h, '*/bits/huge_val.h';
     select    = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
     bypass    = "__builtin_huge_val";
 
@@ -2256,13 +2686,12 @@
     test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
 };
 
-
 /*
  *  Fix glibc definition of HUGE_VALF in terms of hex floating point constant
  */
 fix = {
     hackname  = huge_valf_hex;
-    files     = bits/huge_val.h;
+    files     = bits/huge_val.h, '*/bits/huge_val.h';
     select    = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
     bypass    = "__builtin_huge_valf";
 
@@ -2272,13 +2701,12 @@
     test_text = "#  define HUGE_VALF (__extension__ 0x1.0p255f)";
 };
 
-
 /*
  *  Fix glibc definition of HUGE_VALL in terms of hex floating point constant
  */
 fix = {
     hackname  = huge_vall_hex;
-    files     = bits/huge_val.h;
+    files     = bits/huge_val.h, '*/bits/huge_val.h';
     select    = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
     bypass    = "__builtin_huge_vall";
 
@@ -2288,7 +2716,6 @@
     test_text = "#  define HUGE_VALL (__extension__ 0x1.0p32767L)";
 };
 
-
 /*
  *  Fix return type of abort and free
  */
@@ -2306,7 +2733,6 @@
                 "extern int exit(void*);";
 };
 
-
 /*
  *  Fix various macros used to define ioctl numbers.
  *  The traditional syntax was:
@@ -2337,6 +2763,9 @@
     "#define XX_IO(x)        ('x'<<8|256)";
 };
 
+/*
+ *  Fix the usage of the ioctl macro numbers.
+ */
 fix = {
     hackname  = io_quotes_use;
     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
@@ -2348,7 +2777,6 @@
                 "BSD43__IOWR(T, 1) /* Some are multi-line */";
 };
 
-
 /*
  *  Check for missing ';' in struct
  */
@@ -2365,111 +2793,6 @@
     "}; /* mumbled struct */\n";
 };
 
-
-/*
- *  IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
- *  __restrict as restrict iff __c99.  This is wrong for C++, which
- *  needs many C99 features, but only supports __restrict.
- */
-fix = {
-    hackname  = irix___restrict;
-    files     = internal/sgimacros.h;
-    select    = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
-
-    mach      = "mips-sgi-irix6.5";
-    c_fix     = format;
-    c_fix_arg = "%1"
-		"#  ifndef __cplusplus\n%2\n#  endif";
-
-    test_text = "#ifdef __c99\n#  define __restrict restrict";
-};
-
-/*
- * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
- * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit 
- * functions.
- *
- * This was probably introduced around IRIX 6.5.18
- */
-fix = {
-    hackname  = irix___generic1;
-    files     = internal/math_core.h;
-    mach      = "mips-sgi-irix6.5";
-    select    = "#define ([a-z]+)\\(x\\) *__generic.*";
-
-    c_fix     = format;
-    c_fix_arg = "extern int %1(double);\n"
-		"extern int %1f(float);\n"
-		"extern int %1l(long double);\n"
-		"#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
-		"               : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
-		"               : _%1l(x))\n";
-
-    test_text = 
-      "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
-};
-
-
-/* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
-   compiler's __generic intrinsic to define isgreater, isgreaterequal,
-   isless, islessequal, islessgreater and isunordered functions.  */
-fix = {
-    hackname  = irix___generic2;
-    files     = internal/math_core.h;
-    mach      = "mips-sgi-irix6.5";
-    select    = "#define ([a-z]+)\\(x,y\\) *__generic.*";
-
-    c_fix     = format;
-    c_fix_arg = "#define %1(x,y) \\\n"
-		"  ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
-		"   : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
-		"   : _%1l(x,y))\n";
-
-    test_text = 
-      "#define isless(x,y)         __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
-};
-
-
-/*
- *  IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
- *  that causes the assembly preprocessor to complain about an
- *  unterminated character constant.
- */
-fix = {
-    hackname  = irix_asm_apostrophe;
-    files     = sys/asm.h;
-
-    select    = "^[ \t]*#.*[Ww]e're";
-    c_fix     = format;
-    c_fix_arg = "%1 are";
-    c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
-    test_text = "\t# and we're on vacation";
-};
-
-
-/*
- * 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.
  */
@@ -2482,157 +2805,13 @@
     test_text   = "extern const char limit; /* test limits */";
 };
 
-
-/*
- *  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
- *  definition doesn't reflect this (SGI Bug Id 864477, fixed in
- *  IRIX 6.5.19).
- */
-fix = {
-    hackname  = irix_socklen_t;
-    files     = sys/socket.h;
-    select    = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
-
-    mach      = "mips-sgi-irix6.5";
-    c_fix     = format;
-    c_fix_arg = "%1"
-    		"#if _NO_XOPEN4 && _NO_XOPEN5\n"
-    		"typedef int socklen_t;\n"
-		"#else\n"
-    		"%2\n"
-    		"#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
-
-    test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
-};
-
-/*
- *  IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
- *  otherwise.
- */
-fix = {
-    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)";
-
-    mach      = "mips-sgi-irix6.5";
-    c_fix  = format;
-    c_fix_arg = "#if 0\n"
-	        "%2";
-    test_text =
-    "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
-};
-
-
-/*
- *  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
+/*
+ *  IRIX 5.x's stdio.h declares some functions that take a va_list as
  *  taking char *.  However, GCC uses void * for va_list, so
  *  calling vfprintf with a va_list fails in C++.  */
 fix = {
     hackname  = irix_stdio_va_list;
     files     = stdio.h;
-    files     = internal/stdio_core.h;
 
     select = '/\* va_list \*/ char \*';
     c_fix  = format;
@@ -2641,27 +2820,6 @@
     "extern int printf( const char *, /* va_list */ char * );";
 };
 
-
-/*
- *  IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
- *  wcsftime by default.  ISO C99 requires the XPG5 variant instead.
- */
-fix = {
-    hackname  = irix_wcsftime;
-    files     = internal/wchar_core.h;
-    select    = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
-
-    mach      = "mips-sgi-irix6.5";
-    c_fix     = format;
-    c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
-
-    test_text = "#if _NO_XOPEN5\n"
-		"extern size_t wcsftime(wchar_t *, "
-		"__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, "
-		"const struct tm *);";
-};
-
-
 /*
  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
  * use / * * / to concatenate tokens.
@@ -2686,8 +2844,8 @@
     test_text = "#define __CONCAT__(a,b) a/**/b";
 };
 
-
-/* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
+/*
+ * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
  * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
  * constant on recent versions of g++.
  */
@@ -2703,7 +2861,6 @@
 	"\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
 };
 
-
 /* 
  *  Remove header file warning from sys/time.h.  Autoconf's
  *  AC_HEADER_TIME recommends to include both sys/time.h and time.h
@@ -2718,7 +2875,6 @@
     test_text = "#warning Using <time.h> instead of <sys/time.h>";
 };
 
-
 /* 
  *  Add missing declaration for putenv.
  */
@@ -2735,7 +2891,6 @@
     test_text = "extern char *getenv	_AP((const char *));";
 };
 
-
 /*
  * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
  *
@@ -2754,7 +2909,6 @@
     test_text = " # define _BSD_VA_LIST_\tchar**";
 };
 
-
 /*
  *  Fix non-ansi machine name defines
  */
@@ -2768,7 +2922,6 @@
     "\n/* no uniform test, so be careful  :-) */";
 };
 
-
 /*
  *  Some math.h files define struct exception (it's in the System V
  *  Interface Definition), which conflicts with the class exception defined
@@ -2781,13 +2934,16 @@
     files     = math.h;
     select    = "struct exception";
     /*
-     * This should be bypassed on __cplusplus, but some supposedly C++ C++
+     * This should be bypassed on __cplusplus, but some supposedly C++
      * aware headers, such as Solaris 8 and 9, don't wrap their struct
      * exception either.  So currently we bypass only for glibc, based on a
      * comment in the fixed glibc header.  Ick.
      */
     bypass    = 'We have a problem when using C\+\+|for C\+\+, '
 		'_[a-z0-9A-Z_]+_exception; for C, exception';
+    /* The Solaris 10 headers already get this right.  */
+    mach   = '*-*-solaris2.1[0-9]*';
+    not_machine = true;
     c_fix     = wrap;
 
     c_fix_arg = "#ifdef __cplusplus\n"
@@ -2801,7 +2957,6 @@
     test_text = "typedef struct exception t_math_exception;";
 };
 
-
 /*
  *  This looks pretty broken to me.  ``dbl_max_def'' will contain
  *  "define DBL_MAX " at the start, when what we really want is just
@@ -2839,7 +2994,6 @@
     "#define HUGE_VAL DBL_MAX";
 };
 
-
 /*
  *  nested comment
  */
@@ -2852,7 +3006,6 @@
     test_text = "/*#include <rpc/auth_des.h> /* skip this */";
 };
 
-
 /*
  *  Some versions of NetBSD don't expect the C99 inline semantics.
  */
@@ -2872,7 +3025,9 @@
     test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
 };
 
-
+/*
+ * netbsd_c99_inline_2
+ */
 fix = {
     hackname  = netbsd_c99_inline_2;
     mach      = "*-*-netbsd*";
@@ -2891,7 +3046,6 @@
     test_text = "#define _SIGINLINE extern __inline";
 };
 
-
 /*
  * NetBSD has a semicolon after the ending '}' for some extern "C".
  */
@@ -2907,10 +3061,11 @@
     test_text = "#define __END_DECLS };";
 };
 
-
-/* newlib's stdint.h has several failures to conform to C99.  The fix
-   for these removed a comment that can be matched to identify unfixed
-   versions.  */
+/*
+ * newlib's stdint.h has several failures to conform to C99.  The fix
+ *  for these removed a comment that can be matched to identify unfixed
+ *  versions.
+ */
 fix = {
     hackname  = newlib_stdint_1;
     files     = stdint-newlib.h, stdint.h;
@@ -2918,12 +3073,18 @@
     sed       = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
     sed       = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
     sed       = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
-    sed       = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
-    sed       = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
-    sed       = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
-    sed       = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
-    sed       = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
-    sed       = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
+    sed       = "s@#define INT_LEAST32_MIN.*@"
+                  "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
+    sed       = "s@#define INT_LEAST32_MAX.*@"
+                  "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
+    sed       = "s@#define UINT_LEAST32_MAX.*@"
+                  "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
+    sed       = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
+                  '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
+    sed       = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
+                  '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
+    sed       = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
+                  '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
     sed       = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
     sed       = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
     sed       = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
@@ -2946,7 +3107,9 @@
                 "#define UINT16_C(x) x##U";
 };
 
-
+/*
+ * newlib_stdint_2
+ */
 fix = {
     hackname  = newlib_stdint_2;
     files     = stdint-newlib.h, stdint.h;
@@ -2965,7 +3128,6 @@
                 "/** Macros for minimum-width integer constant expressions */";
 };
 
-
 /*
  *  NeXT 3.2 adds const prefix to some math functions.
  *  These conflict with the built-in functions.
@@ -2982,7 +3144,6 @@
     test_text = "extern\tdouble\t__const__\tmumble();";
 };
 
-
 /*
  *  NeXT 3.2 uses the word "template" as a parameter for some
  *  functions. GCC reports an invalid use of a reserved key word
@@ -2999,7 +3160,6 @@
     test_text = "extern mumble( char * template); /* fix */";
 };
 
-
 /*
  *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
  *  function prototypes. That conflicts with the  built-in functions.
@@ -3016,7 +3176,6 @@
     test_text = "extern\tvolatile\tvoid\tabort();";
 };
 
-
 /*
  *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
  *  Note that version 3 of the NeXT system has wait.h in a different directory,
@@ -3033,7 +3192,6 @@
     test_text = "extern pid_d wait(union wait*);";
 };
 
-
 /*
  *  a missing semi-colon at the end of the nodeent structure definition.
  */
@@ -3166,7 +3324,6 @@
     test_text = "#include <reg_types.h>";
 };
 
-
 /*
  * On broken glibc-2.3.3 systems an array of incomplete structures is
  * passed to __sigsetjmp.  Fix that to take a pointer instead.
@@ -3177,8 +3334,10 @@
     select    = "struct __jmp_buf_tag";
     c_fix     = format;
     c_fix_arg = "%1 *%2%3";
-    c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
-    test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
+    c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
+        "(__env)\\[1\\](.*)$";
+    test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
+        "int __savemask);";
 };
 
 /*
@@ -3195,7 +3354,6 @@
     test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
 };
 
-
 /*
  *  Fix casts as lvalues in glibc's <rpc/xdr.h>.
  */
@@ -3209,7 +3367,9 @@
                 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
 };
 
-
+/*
+ * rpc_xdr_lvalue_cast_b
+ */
 fix = {
     hackname  = rpc_xdr_lvalue_cast_b;
     files     = rpc/xdr.h;
@@ -3220,7 +3380,6 @@
                 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
 };
 
-
 /*
  *  function class(double x) conflicts with C++ keyword on rs/6000
  */
@@ -3236,7 +3395,6 @@
     test_text = "extern int class();";
 };
 
-
 /*
  *  Wrong fchmod prototype on RS/6000.
  */
@@ -3249,7 +3407,6 @@
     test_text = "extern int fchmod(char *, mode_t);";
 };
 
-
 /*
  *  parameters conflict with C++ new on rs/6000
  */
@@ -3265,7 +3422,6 @@
     test_text = 'extern int rename(const char *old, const char *new);';
 };
 
-
 /*
  *  Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
  *  for C99.  This is wrong for C++, which needs many C99 features, but
@@ -3282,7 +3438,6 @@
     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
@@ -3306,7 +3461,6 @@
 		"#define	I		_Imaginary_I";
 };
 
-
 /*
  * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus.  Wrap in
  * extern "C" instead so libstdc++ can use it.
@@ -3315,34 +3469,156 @@
     hackname  = solaris_complex_cxx;
     mach      = "*-*-solaris2.*";
     files     = complex.h;
-    sed	      = "/#if[ \t]*!defined(__cplusplus)/c"
+    sed	      = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
     		"#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
-    sed	      = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c"
+    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\\}.*)$";
+/*
+ *  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 =
+    "#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 =
-    '#pragma ident	"@(#)pthread.h	1.29	01/07/07 SMI"'"\n"
-    '#define	PTHREAD_COND_INITIALIZER	{{{0}, 0}, 0}	/* = DEFAULTCV */';
-};
-
+    "#if	!defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
+};
+
+/*
+ *  Solaris <iso/stdio_iso.h> should deprecate gets before C11.
+ */
+fix = {
+    hackname  = solaris_gets_c11;
+    mach      = "*-*-solaris2*";
+    files     = "iso/stdio_iso.h";
+    select    = "(extern char[ \t]*\\*gets\\(char \\*\\));";
+
+    c_fix     = format;
+    c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
+    		"%1 __attribute__((__deprecated__));\n"
+		"#endif";
+
+    test_text = "extern char	*gets(char *);";
+};
+
+/*
+ *  Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
+ */
+fix = {
+    hackname  = solaris_gets_cxx14;
+    mach      = "*-*-solaris2*";
+    files     = "iso/stdio_iso.h";
+    select    = <<- _EOSelect_
+(#if __STDC_VERSION__ < 201112L)
+(extern char	\*gets\(char \*\) __ATTR_DEPRECATED;)
+_EOSelect_;
+    c_fix     = format;
+    c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
+
+    test_text = <<- _EOText_
+#if __STDC_VERSION__ < 201112L
+extern char	*gets(char *) __ATTR_DEPRECATED;
+_EOText_;
+};
+
+/*
+ * 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 10 defines several C99 math macros in terms of
@@ -3367,6 +3643,35 @@
     "#define	HUGE_VALL	__builtin_huge_vall";
 };
 
+/*
+ * On Solaris 11, if you do isinf(NaN) you'll get a floating point
+ * exception.  Provide an alternative using GCC's builtin.
+ */
+fix = {
+    hackname  = solaris_math_10;
+    select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    files     = iso/math_c99.h;
+    c_fix     = format;
+    c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
+    c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
+                "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
+                    "[ \t]*\\\\\n"
+                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
+                    "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
+                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
+                    "\\(-INFINITY\\);[ \t]*\\}\\)";
+    test_text =
+    '#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"'"\n"
+    "#undef	isinf\n"
+    "#define	isinf(x)	__extension__( \\\\\n"
+    "			{ __typeof(x) __x_i = (x); \\\\\n"
+    "			__x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
+    "			__x_i == (__typeof(__x_i)) (-INFINITY); })";
+};
+
+/*
+ * Solaris math INFINITY
+ */
 fix = {
     hackname = solaris_math_2;
     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
@@ -3381,6 +3686,9 @@
     "#define	INFINITY	__builtin_infinity";
 };
 
+/*
+ * Solaris math NAN
+ */
 fix = {
     hackname = solaris_math_3;
     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
@@ -3395,6 +3703,9 @@
     "#define	NAN	__builtin_nan";
 };
 
+/*
+ * Solaris math fpclassify
+ */
 fix = {
     hackname = solaris_math_4;
     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
@@ -3402,7 +3713,8 @@
     files = iso/math_c99.h;
     c_fix = format;
     c_fix_arg = "#define\tfpclassify(x) \\\n"
-                "  __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
+                "  __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
+                    "FP_SUBNORMAL, FP_ZERO, (x))";
     c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
     test_text =
     '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
@@ -3410,6 +3722,9 @@
     "#define	fpclassify(x)	__builtin_fpclassify(x)";
 };
 
+/*
+ * Solaris math signbit
+ */
 fix = {
     hackname = solaris_math_8;
     select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
@@ -3429,6 +3744,9 @@
 	_EOText_;
 };
 
+/*
+ * Solaris math comparison macros
+ */
 fix = {
     hackname = solaris_math_9;
     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
@@ -3436,7 +3754,8 @@
     files = iso/math_c99.h;
     c_fix = format;
     c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
-    c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
+    c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
+                    "__builtin_[a-z]+\\(y\\)\\)";
     test_text =
     '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
     "#undef	isgreater\n"
@@ -3454,67 +3773,124 @@
 };
 
 /*
- * On Solaris 11, if you do isinf(NaN) you'll get a floating point
- * exception.  Provide an alternative using GCC's builtin.
- */
-
-fix = {
-    hackname  = solaris_math_10;
-    select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
-    files     = iso/math_c99.h;
-    c_fix     = format;
-    c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
-    c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
-                "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
-                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
-                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
-    test_text =
-    '#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"'"\n"
-    "#undef	isinf\n"
-    "#define	isinf(x)	__extension__( \\\\\n"
-    "			{ __typeof(x) __x_i = (x); \\\\\n"
-    "			__x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
-    "			__x_i == (__typeof(__x_i)) (-INFINITY); })";
-};
-
-/*
- * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
- * "0" for the last field of the pthread_mutex_t structure, which is
- * of type upad64_t, which itself is typedef'd to int64_t, but with
- * __STDC__ defined (e.g. by -ansi) it is a union. So change the
- * initializer to "{0}" instead
- */
-fix = {
-    hackname = solaris_mutex_init_2;
+ * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
+ * warnings.
+ */
+fix = {
+    hackname = solaris_math_11;
+    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
+    files = iso/math_c99.h;
+    c_fix = format;
+    c_fix_arg = << _EOArg_
+#undef	signbit
+#define	signbit(x)	(sizeof(x) == sizeof(float) \
+			   ? __builtin_signbitf(x) \
+			   : sizeof(x) == sizeof(long double) \
+			     ? __builtin_signbitl(x) \
+			     : __builtin_signbit(x))
+_EOArg_;
+    c_fix_arg = << _EOArg_
+^#undef[ 	]+signbit
+#if defined\(__sparc\)
+#define[ 	]+signbit\(x\)[ 	]+__extension__\( \\
+[ 	]+\{[ 	]*__typeof\(x\)[ 	]*__x_s[ 	]*=[ 	]*\(x\);[ 	]*\\
+[ 	]+\(int\)[ 	]*\(\*\(unsigned[ 	]*\*\)[ 	]*\&__x_s[ 	]*>>[ 	]*31\);[ 	]*\}\)
+#elif defined\(__i386\) \|\| defined\(__amd64\)
+#define[ 	]+signbit\(x\)[ 	]+__extension__\( \\
+[ 	]+\{ __typeof\(x\) __x_s = \(x\); \\
+[ 	]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
+[ 	]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
+[ 	]+sizeof \(__x_s\) == sizeof \(double\) \? \\
+[ 	]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
+[ 	]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
+#endif
+_EOArg_;
+    test_text = << _EOText_
+/* @(#)math_c99.h	1.14	13/03/27 */
+#undef	signbit
+#if defined(__sparc)
+#define	signbit(x)	__extension__( \\
+				{ __typeof(x) __x_s = (x); \\
+				(int) (*(unsigned *) &__x_s >> 31); })
+#elif defined(__i386) || defined(__amd64)
+#define	signbit(x)	__extension__( \\
+			{ __typeof(x) __x_s = (x); \\
+			(sizeof (__x_s) == sizeof (float) ? \\
+			(int) (*(unsigned *) &__x_s >> 31) : \\
+			sizeof (__x_s) == sizeof (double) ? \\
+			(int) (((unsigned *) &__x_s)[1] >> 31) : \\
+			(int) (((unsigned short *) &__x_s)[4] >> 15)); })
+#endif
+_EOText_;
+};
+
+/*
+ * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
+ */
+fix = {
+    hackname  = solaris_math_12;
+    files     = math.h;
+    mach      = '*-*-solaris2*';
+    select    = '#undef.*_GLIBCXX_USE_C99_MATH';
+    sed       = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
+    test_text = << _EOText_
+#if __cplusplus >= 201103L
+#undef  _GLIBCXX_USE_C99_MATH
+#undef  _GLIBCXX_USE_C99_MATH_TR1
+#endif
+_EOText_;
+};
+
+/*
+ * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
+ * structure.  As such, it need two levels of brackets, but only
+ * contains one.  Wrap the macro definition in an extra layer.
+ */
+fix = {
+    hackname = solaris_once_init_1;
     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
     files = pthread.h;
-    /*
-     * On Solaris 10, this fix is unnecessary because upad64_t is
-     * always defined correctly regardless of the definition of the
-     * __STDC__ macro.  The first "mach" pattern matches up to
-     * solaris9.  The second "mach" pattern will not match any two (or
-     * more) digit solaris version, but it will match e.g. 2.5.1.
-     */
-    mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
+    mach = '*-*-solaris*';
     c_fix = format;
-    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
-                "%0\n"
-                "#else\n"
-                "%1, {0}}%4\n"
-                "#endif";
-    c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
-                "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
-                ",[ \t]*0\\}" "(|[ \t].*)$";
+    c_fix_arg = "%1{%2}%3";
+    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
+    test_text =
+    '#pragma ident	"@(#)pthread.h	1.37	04/09/28 SMI"'"\n"
+    "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
+};
+
+/*
+ * 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 =
-    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
-    "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
-    "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
-    "#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\\\\\n"
-    "	{{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
-    "#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\\\\\n"
-    "	{{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
-};
-
+    "char *const argv[_RESTRICT_KYWD],\n"
+    "char *const envp[_RESTRICT_KYWD]);";
+};
+
+/*
+ *  The pow overloads with int were removed in C++ 2011 DR 550.
+ */
+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 = "#if __cplusplus < 201103L\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
@@ -3542,155 +3918,40 @@
     "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
 };
 
-
-/*
- * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
- * structure.  As such, it need two levels of brackets, but only
- * contains one.  Wrap the macro definition in an extra layer.
- */
-fix = {
-    hackname = solaris_once_init_1;
-    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
-    files = pthread.h;
-    mach = '*-*-solaris*';
-    c_fix = format;
-    c_fix_arg = "%1{%2}%3";
-    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
-    test_text =
-    '#pragma ident	"@(#)pthread.h	1.37	04/09/28 SMI"'"\n"
-    "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
-};
-
-
-/*
- * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
- *  fields of the pthread_once_t structure, which are of type
- *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
- *  defined (e.g. by -ansi) it is a union. So change the initializer
- *  to "{0}" instead.  This test relies on solaris_once_init_1.
- */
-fix = {
-    hackname = solaris_once_init_2;
-    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
-    files = pthread.h;
-    /*
-     * On Solaris 10, this fix is unnecessary because upad64_t is
-     * always defined correctly regardless of the definition of the
-     * __STDC__ macro.  The first "mach" pattern matches up to
-     * solaris9.  The second "mach" pattern will not match any two (or
-     * more) digit solaris version, but it will match e.g. 2.5.1.
-     */
-    mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
-    c_fix = format;
-    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
-                "%0\n"
-                "#else\n"
-                "%1{0}, {0}, {0}, {%3}%4\n"
-                "#endif";
-    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
-                "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
-    test_text =
-    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
-    "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
-};
-
-
-/*
- * 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;
+/*
+ * 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 = "#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_arg = "%1#ifndef _LP64\n"
+		"using std::__filbuf;\n"
+		"using std::__flsbuf;\n"
+		"#endif\n%2";
+
+    test_text = "using std::perror;\n"
+		"#endif";
+};
+
+/*
+ *  Solaris <stdio.h> shouldn't use std::gets for C++14.
+ */
+fix = {
+    hackname  = solaris_std_gets_cxx14;
+    mach      = "*-*-solaris2*";
+    files     = "stdio.h";
+    select    = "using std::gets;";
+
     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";
-};
-
+    c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
+
+    test_text = "using std::gets;";
+};
 
 /*
  * Sun Solaris 8 has what appears to be some gross workaround for
@@ -3710,34 +3971,20 @@
     test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
 };
 
-
-/*
- * 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";
-};
-
+/*
+ *  Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
+ */
+fix = {
+    hackname  = solaris_stdlib_noreturn;
+    mach      = "*-*-solaris2*";
+    files     = "iso/stdlib_c99.h";
+    select    = "(extern) _Noreturn (void quick_exit\\(int\\));";
+
+    c_fix     = format;
+    c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
+
+    test_text = "extern _Noreturn void quick_exit(int);";
+};
 
 /*
  *  a missing semi-colon at the end of the statsswtch structure definition.
@@ -3751,7 +3998,6 @@
     test_text = "struct statswtch {\n  int boottime\n};";
 };
 
-
 /*
  *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
  *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
@@ -3775,22 +4021,17 @@
     test_text = "";
 };
 
-
 /*
  *  Don't use or define the name va_list in stdio.h.  This is for
  *  ANSI.  Note _BSD_VA_LIST_ is dealt with elsewhere.  The presence
  *  of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
  *  indicate that the header knows what it's doing -- under SUSv2,
  *  stdio.h is required to define va_list, and we shouldn't break
- *  that.  On IRIX 6.5, internal/wchar_core.h used to get its
- *  definition of va_list from stdio.h.  Since this doesn't happen any
- *  longer, use __gnuc_va_list there, too.
+ *  that.
  */
 fix = {
     hackname = stdio_va_list;
     files    = stdio.h;
-    files    = internal/stdio_core.h;
-    files    = internal/wchar_core.h;
     bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
     /* 
      * On Solaris 10, the definition in 
@@ -3827,7 +4068,6 @@
     test_text = "extern void mumble( va_list);";
 };
 
-
 /*
  *  Fix headers that use va_list from stdio.h to use the updated
  *  va_list from the stdio_va_list change.  Note _BSD_VA_LIST_ is
@@ -3877,7 +4117,6 @@
     test_text = "extern void mumble( va_list);";
 };
 
-
 /*
  *  "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
  *  is "!defined( __STRICT_ANSI__ )"
@@ -3940,7 +4179,6 @@
                "int foo;\n#endif";
 };
 
-
 /*
  *  "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
  *  is "defined( __STRICT_ANSI__ )"
@@ -3960,7 +4198,6 @@
     test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
 };
 
-
 /*
  *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
  *  in prototype without previous definition.
@@ -3974,7 +4211,6 @@
     test_text = "extern void xdrstdio_create( struct __file_s* );";
 };
 
-
 /*
  *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
  *  in prototype without previous definition.
@@ -3993,7 +4229,6 @@
     test_text = "extern AUTH* authdes_create( struct sockaddr* );";
 };
 
-
 /*
  *  Apply fix this to all OSs since this problem seems to effect
  *  more than just SunOS.
@@ -4021,7 +4256,6 @@
     "};";
 };
 
-
 /*
  *  Fix bogus #ifdef on SunOS 4.1.
  */
@@ -4036,7 +4270,6 @@
     test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
 };
 
-
 /*
  *  Fix the CAT macro in SunOS memvar.h.
  */
@@ -4055,7 +4288,6 @@
     "#define CAT(a,b)\ta/**/b";
 };
 
-
 /*
  *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
  *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
@@ -4079,7 +4311,6 @@
     "char*\trealloc();";
 };
 
-
 /*
  *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
  */
@@ -4091,7 +4322,6 @@
     test_text = "struct mumble\n  int _cnt\n};";
 };
 
-
 /*
  *  signal.h on SunOS defines signal using (),
  *  which causes trouble when compiling with g++ -pedantic.
@@ -4111,7 +4341,6 @@
     test_text = "void\t(*signal())();";
 };
 
-
 /*
  *  Correct the return type for strlen in strings.h in SunOS 4.
  */
@@ -4124,6 +4353,19 @@
     test_text = " int\tstrlen(); /* string length */";
 };
 
+/*
+ *  Linux kernel's vt.h breaks C++
+ */
+fix = {
+    hackname  = suse_linux_vt_cxx;
+    files     = linux/vt.h;
+
+    select    = "^[ \t]*unsigned int new;";
+    c_fix     = format;
+    c_fix_arg = "unsigned int newev;";
+
+    test_text = "        unsigned int new;      /* New console (if changing) */";
+};
 
 /*
  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
@@ -4138,7 +4380,6 @@
     test_text = "#define strlen __std_hdr_strlen\n";
 };
 
-
 /*
  *   Fix broken decl of getcwd present on some svr4 systems.
  */
@@ -4155,7 +4396,6 @@
     test_text = "extern char* getcwd(char *, int);";
 };
 
-
 /*
  *   Fix broken decl of profil present on some svr4 systems.
  */
@@ -4166,9 +4406,6 @@
 
     select    =
     'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
-    /* The fix is wrong on IRIX 5/6 and creates a conflict with another
-       prototype in <sys/profil.h>.  */
-    bypass    = 'Silicon Graphics';
     c_fix     = format;
     c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
 
@@ -4176,7 +4413,6 @@
     'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
 };
 
-
 /*
  * Correct types for signal handler constants like SIG_DFL; they might be
  * void (*) (), and should be void (*) (int).  C++ doesn't like the
@@ -4192,7 +4428,6 @@
                 "#define SIG_IGN (void (*)())0\n";
 };
 
-
 /*
  *  Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
  *  function 'getrnge' in <regexp.h> before they declare it.  For these
@@ -4221,7 +4456,6 @@
                 "{}";
 };
 
-
 /*
  *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
  *  in string.h on sysV68
@@ -4269,7 +4503,6 @@
     "\tstrlen(), strspn();";
 };
 
-
 /*
  *  Fix return type of calloc, malloc, realloc, bsearch and exit
  */
@@ -4289,14 +4522,13 @@
     "extern char*\tbsearch(void*,size_t,size_t);\n";
 };
 
-
 /*
  * __thread is now a keyword.
  */
 fix = {
     hackname  = thread_keyword;
     files     = "pthread.h";
-    files     = "bits/sigthread.h";
+    files     = bits/sigthread.h, '*/bits/sigthread.h';
     select    = "([* ])__thread([,)])";
     c_fix     = format;
     c_fix_arg = "%1__thr%2";
@@ -4321,7 +4553,6 @@
     test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
 };
 
-
 /*
  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
  */
@@ -4343,7 +4574,6 @@
     "extern int scanf( char *__format, ...);\n";
 };
 
-
 /*
  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
  */
@@ -4365,7 +4595,6 @@
     "extern char *tempnam(char*,char*);\n";
 };
 
-
 /*
  *  Fix definitions of macros used by va-i960.h in VxWorks header file.
  */
@@ -4384,6 +4613,189 @@
     "#define __alignof__(x) ...";
 };
 
+/*
+ * On VMS, add missing braces around sigset_t constants.
+ */
+fix = {
+    hackname  = vms_add_missing_braces;
+    select    = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
+    mach      = "*-*-*vms*";
+    files     = "rtldef/signal.h";
+    c_fix     = format;
+
+    c_fix_arg = '%1 {%2} ';
+
+    test_text = "static const __sigset_t _SIG_EMPTY_SET  = "
+                "{0x00000000, 0x00000000},\n"
+                " _SIG_FULL_SET   = {0xFFFFFFFF, 0xFFFFFFFF};\n";
+};
+
+/*
+ * On VMS, some DEC-C builtins are directly used.
+ */
+fix = {
+    hackname  = vms_decc_builtin;
+    select    = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
+    mach      = "*-*-*vms*";
+    files     = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
+                rtldef/socket.h;
+    sed       = "s@__MEMSET@memset@";
+    sed       = "s@__MEMMOVE@memmove@";
+    sed       = "s@__MEMCPY@memcpy@";
+    sed       = "s@__STRLEN@strlen@";
+    sed       = "s@__STRCPY@strcpy@";
+
+    test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
+};
+
+/*
+ *  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, 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";
+};
+
+/*
+ * On VMS, fix incompatible redeclaration of hostalias.
+ */
+fix = {
+    hackname  = vms_do_not_redeclare_hostalias;
+    select    = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
+                "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
+    mach      = "*-*-*vms*";
+    files     = "rtldef/resolv.h";
+    c_fix     = format;
+
+    c_fix_arg = "%1\n"
+                "/* %2 */";
+
+    test_text = "void		fp_nquery (const u_char *, int, FILE *);\n"
+                "__char_ptr32	hostalias (const char *);\n";
+};
+
+/*
+ * On VMS, forward declare structure before referencing them in prototypes.
+ */
+fix = {
+    hackname  = vms_forward_declare_struct;
+    select    = "(/\\* forward decls for C\\+\\+ \\*/\n)"
+                "#ifdef __cplusplus\n";
+    mach      = "*-*-*vms*";
+    files     = rtldef/if.h;
+    c_fix     = format;
+
+    c_fix_arg = "%1"
+                "#if defined (__cplusplus) || defined (__GNUC__)\n";
+
+    test_text = "/* forward decls for C++ */\n"
+                "#ifdef __cplusplus\n"
+                "struct foo;\n"
+                "#endif\n";
+};
+
+/*
+ * On VMS, do not declare getopt and al if pointers are 64 bit.
+ */
+fix = {
+    hackname  = vms_no_64bit_getopt;
+    select    = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
+                "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
+    mach      = "*-*-*vms*";
+    files     = rtldef/stdio.h, rtldef/unistd.h;
+    c_fix     = format;
+
+    c_fix_arg = <<- _EOArg_
+	#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only.  */
+	%0#endif
+
+	_EOArg_;
+
+    test_text = "int getopt (int, char * const [], const char *);";
+};
+
+/*
+ * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
+ * which is not yet fully supported by gcc.
+ */
+fix = {
+    hackname  = vms_use_fast_setjmp;
+    select    = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
+    mach      = "*-*-*vms*";
+    files     = rtldef/setjmp.h;
+    c_fix     = format;
+
+    c_fix_arg = "%0 defined (__GNUC__) ||";
+
+    test_text = "#   if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
+};
+
+/*
+ * 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, change <resource.h> to <sys/resource.h> to avoid a
+ * conflict while building gcc.  Likewise for <builtins.h>
+ */
+fix = {
+    hackname  = vms_use_quoted_include;
+    select    = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
+    mach      = "*-*-*vms*";
+    files     = rtldef/wait.h, starlet_c/pthread.h;
+    c_fix     = format;
+
+    c_fix_arg = '%1<sys/%2.h>';
+
+    test_text = "#   include <resource.h>";
+};
 
 /*
  *  AIX and Interix headers define NULL to be cast to a void pointer,
@@ -4391,26 +4803,29 @@
  */
 fix = {
     hackname  = void_null;
-    files     = curses.h;
-    files     = dbm.h;
-    files     = locale.h;
-    files     = stdio.h;
-    files     = stdlib.h;
-    files     = string.h;
-    files     = time.h;
-    files     = unistd.h;
-    files     = sys/dir.h;
-    files     = sys/param.h;
-    files     = sys/types.h;
+    files     = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
+    time.h, unistd.h, sys/dir.h, sys/param.h, 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";
+    c_fix_arg = <<- _EOFix_
+	#ifndef NULL
+	#ifdef __cplusplus
+	#ifdef __GNUG__
+	#define NULL __null
+	#else /* ! __GNUG__  */
+	#define NULL 0L
+	#endif /* __GNUG__  */
+	#else /* ! __cplusplus  */
+	#define NULL ((void *)0)
+	#endif /* __cplusplus  */
+	#endif /* !NULL  */
+	_EOFix_;
     test_text = "# define\tNULL \t((void *)0)  /* typed NULL */";
 };
 
-
 /*
  *  Make VxWorks header which is almost gcc ready fully gcc ready.
  */
@@ -4451,6 +4866,40 @@
     "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
 };
 
+/*
+ *  Wrap VxWorks ioctl to keep everything pretty
+ */
+fix = {
+    hackname    = vxworks_ioctl_macro;
+    files       = ioLib.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "%0\n"
+        "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
+    c_fix_arg   = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
+        
+    test_text   = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
+};
+
+/*
+ *  Wrap VxWorks mkdir to be posix compliant
+ */
+fix = {
+    hackname    = vxworks_mkdir_macro;
+    files       = sys/stat.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "%0\n"
+                "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
+    c_fix_arg   = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
+                "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
+                "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
+                "\\)[\t ]*;";
+        
+    test_text   = "extern STATUS mkdir (const char * _qwerty) ;";
+};
 
 /*
  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
@@ -4464,7 +4913,6 @@
     test_text = "uint_t\t_clocks_per_sec;";
 };
 
-
 /*
  *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
  */
@@ -4484,6 +4932,19 @@
     "# define\t__INCstath <sys/stat.h>";
 };
 
+/*
+ *  Make it so VxWorks does not include gcc/regs.h accidentally
+ */
+fix = {
+    hackname    = vxworks_regs;
+    mach        = "*-*-vxworks*";
+
+    select      = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
+    c_fix       = format;
+    c_fix_arg   = "#include <arch/../regs.h>";
+        
+    test_text   = "#include <regs.h>\n";
+};
 
 /*
  *  Another bad dependency in VxWorks 5.2 <time.h>.
@@ -4511,6 +4972,23 @@
                 "#define VOIDFUNCPTR (void(*)())";
 };
 
+/*
+ *  This hack makes write const-correct on VxWorks
+ */
+fix = {
+    hackname    = vxworks_write_const;
+    files       = ioLib.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "extern int  write (int, const char*, size_t);";
+    c_fix_arg   = "extern[\t ]+int[\t ]+write[\t ]*\\("
+                "[\t ]*int[\t ]*,"
+                "[\t ]*char[\t ]*\\*[\t ]*,"
+                "[\t ]*size_t[\t ]*\\)[\t ]*;";
+
+    test_text       = "extern int write ( int , char * , size_t ) ;";
+};
 
 /*
  *  There are several name conflicts with C++ reserved words in X11 header
@@ -4531,7 +5009,6 @@
     "} mumble;\n";
 };
 
-
 /*
  *  class in Xm/BaseClassI.h
  */
@@ -4547,7 +5024,6 @@
     test_text = "extern mumble (int  class);\n";
 };
 
-
 /*
  *  new in Xm/Traversal.h
  */
@@ -4571,7 +5047,6 @@
     "};\nextern Wedged( Widget new, Widget old );";
 };
 
-
 /*
  *  Incorrect sprintf declaration in X11/Xmu.h
  */
@@ -4586,5 +5061,4 @@
 
     test_text = "extern char *\tsprintf();";
 };
-
 /*EOF*/