1/* -*- Mode: C -*-  */
2
3autogen definitions fixincl;
4
5/* Define all the fixes we know about for repairing damaged headers.
6   Please see the README before adding or changing entries in this file.
7
8   This is the sort command:
9
10   blocksort output=inclhack.sorted \
11          pattern='^/\*$' \
12          trailer='^/\*EOF\*[/]' \
13          input=inclhack.def \
14          key=$'hackname[ \t]*=[ \t]*(.*);'
15
16   Set up a debug test so we can make the templates emit special
17   code while debugging these fixes:  */
18
19#ifdef DEBUG
20FIXINC_DEBUG = yes;
21#endif
22
23/* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
29 */
30fix = {
31    hackname  = AAB_aix_stdio;
32    files     = stdio.h;
33    select    = "define fopen fopen64";
34    mach      = "*-*-aix*";
35    test-text = ''; /* no way to test */
36
37    c_fix     = wrap;
38
39    c_fix_arg = "";
40
41    c_fix_arg = <<- _EOArg_
42
43	#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44	#define __need__aix_stdio_h_fix
45	#ifdef __need__aix_stdio_h_fix
46	#undef fseeko
47	#undef ftello
48	#undef fgetpos
49	#undef fsetpos
50	#undef fopen
51	#undef freopen
52	/* Alias the symbols using asm */
53	extern "C" {
54	extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55	extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56	extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57	extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58	extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59	extern off64_t ftello(FILE *) __asm__("ftello64");
60	}
61	#endif
62	#endif
63
64	_EOArg_;
65};
66
67/* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64.  This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
71 */
72fix = {
73    hackname  = AAB_aix_fcntl;
74    files     = fcntl.h;
75    select    = "define open[ \t]open64";
76    mach      = "*-*-aix*";
77    test-text = ''; /* no way to test */
78
79    c_fix     = wrap;
80
81    c_fix_arg = "";
82
83    c_fix_arg = <<- _EOArg_
84
85	#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86	#define __need__aix_fcntl_h_fix
87	#ifdef __need__aix_fcntl_h_fix
88	#undef open
89	#undef creat
90	#undef openat
91	/* Alias the symbols using asm */
92	extern "C" {
93	extern int open(const char *, int, ...) __asm__("open64");
94	extern int creat(const char *, mode_t) __asm__("creat64");
95	#if (_XOPEN_SOURCE >= 700)
96	extern int openat(int, const char *, int, ...) __asm__("open64at");
97	#endif
98	}
99	#endif
100	#endif
101
102	_EOArg_;
103};
104
105/*
106 *  On Mac OS 10.3.9, the 'long double' functions are available in
107 *  libSystem, but are not prototyped in math.h.
108 */
109fix = {
110  hackname  = AAB_darwin7_9_long_double_funcs;
111  mach      = "*-*-darwin7.9*";
112  files     = architecture/ppc/math.h;
113  bypass    = "powl";
114  replace = <<- _EndOfHeader_
115	/* This file prototypes the long double functions available on Mac OS
116	   10.3.9.  */
117	#ifndef __MATH__
118	# undef __APPLE_CC__
119	# define __APPLE_CC__  1345
120	# include_next <architecture/ppc/math.h>
121	# undef __APPLE_CC__
122	# define __APPLE_CC__ 1
123	# ifndef __LIBMLDBL_COMPAT
124	#  ifdef __LONG_DOUBLE_128__
125	#   define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
126	#  else
127	#   define __LIBMLDBL_COMPAT(sym)
128	#  endif /* __LONG_DOUBLE_128__ */
129	# endif /* __LIBMLDBL_COMPAT */
130	# ifdef __cplusplus
131	   extern "C" {
132	# endif
133	  extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134	  extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135	  extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136	  extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137	  extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138	  extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139	  extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140	  extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141	  extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142	  extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143	  extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144	  extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145	  extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146	  extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147	  extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148	  extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149	  extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150	  extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151	  extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152	  extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153	  extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154	  extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155	  extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156	  extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157	  extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158	  extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159	  extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160	  extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161	  extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162	  extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163	  extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164	  extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165	  extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166	  extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167	  extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168	  extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169	  extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170	  extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171	  extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172	  extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173	  extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174	  extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175	  extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176	  extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177	  extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178	  extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179	  extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180	  extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181	  extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182	  extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183	  extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184	  extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185	  extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186	  extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187	  extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188	  extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189	  extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
190	# ifdef __cplusplus
191	   }
192	# endif
193	#endif /* __MATH__ */
194	_EndOfHeader_;
195};
196
197/*
198 *  SDKs for 10.13 and 10.14 omit the definitions for API_AVAILABLE where
199 *  __attribute__((availability)) is not supported.
200 */
201fix = {
202    hackname  = darwin_api_availability;
203    mach      = "*-*-darwin*";
204    files     = os/availability.h;
205    bypass    = "__IPHONE_OS_VERSION_MIN_REQUIRED";
206    select    =
207    " *#define __API_AVAILABLE.*\n"
208    " *#define __API_DEPRECATED.*\n"
209    " *#define __API_DEPRECATED_WITH_REPLACEMENT.*\n"
210    " *#define __API_UNAVAILABLE.*\n";
211    c_fix     = format;
212    c_fix_arg =
213    "    #define API_AVAILABLE(...)\n"
214    "    #define API_DEPRECATED(...)\n"
215    "    #define API_DEPRECATED_WITH_REPLACEMENT(...)\n"
216    "    #define API_UNAVAILABLE(...)\n";
217    test_text =
218    "#define __API_AVAILABLE(...)\n"
219    "#define __API_DEPRECATED(...)\n"
220    "#define __API_DEPRECATED_WITH_REPLACEMENT(...)\n"
221    "#define __API_UNAVAILABLE(...)\n";
222};
223
224/*
225 *  This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
226 */
227fix = {
228    hackname = AAB_fd_zero_asm_posix_types_h;
229    files    = asm/posix_types.h;
230    mach     = 'i[34567]86-*-linux*';
231    bypass   = '} while';
232    bypass   = 'x86_64';
233    bypass   = 'posix_types_64';
234
235    /*
236     * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
237     * the start, so that if #include_next gets another instance of
238     * the wrapper, this will follow the #include_next chain until
239     * we arrive at the real <asm/posix_types.h>.
240     */
241    replace  = <<-  _EndOfHeader_
242	/* This file fixes a bug in the __FD_ZERO macro
243	   for older versions of the Linux kernel. */
244	#ifndef _POSIX_TYPES_H_WRAPPER
245	#include <features.h>
246	 #include_next <asm/posix_types.h>
247
248	#if defined(__FD_ZERO) && !defined(__GLIBC__)
249	#undef __FD_ZERO
250	#define __FD_ZERO(fdsetp) \
251	  do { \
252	    int __d0, __d1; \
253		__asm__ __volatile__("cld ; rep ; stosl" \
254			: "=&c" (__d0), "=&D" (__d1) \
255			: "a" (0), "0" (__FDSET_LONGS), \
256			  "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
257	  } while (0)
258	#endif
259
260	#define _POSIX_TYPES_H_WRAPPER
261	#endif /* _POSIX_TYPES_H_WRAPPER */
262	_EndOfHeader_;
263};
264
265/*
266 *  This fixes __FD_ZERO bug for glibc-1.x
267 */
268fix = {
269    hackname = AAB_fd_zero_gnu_types_h;
270    files    = gnu/types.h;
271    mach     = 'i[34567]86-*-linux*';
272
273    /*
274     * Define _TYPES_H_WRAPPER at the end of the wrapper, not
275     * the start, so that if #include_next gets another instance of
276     * the wrapper, this will follow the #include_next chain until
277     * we arrive at the real <gnu/types.h>.
278     */
279    replace  = <<-  _EndOfHeader_
280	/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
281	#ifndef _TYPES_H_WRAPPER
282	#include <features.h>
283	#include_next <gnu/types.h>
284
285	#if defined(__FD_ZERO) && !defined(__GLIBC__)
286	#undef __FD_ZERO
287	# define __FD_ZERO(fdsetp) \
288	  do { \
289	    int __d0, __d1; \
290	        __asm__ __volatile__("cld ; rep ; stosl" \
291	        : "=&c" (__d0), "=&D" (__d1) \
292	        : "a" (0), "0" (__FDSET_LONGS), \
293	          "1" ((__fd_set *) (fdsetp)) :"memory"); \
294	  } while (0)
295	#endif
296
297	#define _TYPES_H_WRAPPER
298	#endif /* _TYPES_H_WRAPPER */
299	_EndOfHeader_;
300};
301
302/*
303 *  This fixes __FD_ZERO bug for glibc-2.0.x
304 */
305fix = {
306    hackname = AAB_fd_zero_selectbits_h;
307    files    = selectbits.h;
308    mach     = 'i[34567]86-*-linux*';
309
310    /*
311     * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
312     * the start, so that if #include_next gets another instance of
313     * the wrapper, this will follow the #include_next chain until
314     * we arrive at the real <selectbits.h>.
315     */
316    replace  = <<-  _EndOfHeader_
317	/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
318	#ifndef _SELECTBITS_H_WRAPPER
319	  #include <features.h>
320	  #include_next <selectbits.h>
321
322	  #if defined(__FD_ZERO) && defined(__GLIBC__) \\
323	  && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
324	  && __GLIBC_MINOR__ == 0
325	     #undef __FD_ZERO
326	     #define __FD_ZERO(fdsetp) \\
327	     do { \\
328	        int __d0, __d1; \\
329	      __asm__ __volatile__ ("cld; rep; stosl" \\
330                        : "=&c" (__d0), "=&D" (__d1) \\
331                        : "a" (0), "0" (sizeof (__fd_set) \\
332                                        / sizeof (__fd_mask)), \\
333                          "1" ((__fd_mask *) (fdsetp)) \\
334                        : "memory"); \\
335	      } while (0)
336	  #endif
337
338	  #define _SELECTBITS_H_WRAPPER
339	#endif /* _SELECTBITS_H_WRAPPER */
340	_EndOfHeader_;
341};
342
343/*
344 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
345 * the same interface as <stdarg.h>.  No idea why they couldn't have just
346 * used the standard header.
347 */
348fix = {
349    hackname = AAB_solaris_sys_varargs_h;
350    files    = "sys/varargs.h";
351    mach     = '*-*-solaris*';
352    replace  = <<-  _EndOfHeader_
353	#ifdef __STDC__
354	  #include <stdarg.h>
355	#else
356	  #include <varargs.h>
357	#endif
358	_EndOfHeader_;
359};
360
361/*
362 *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
363 *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
364 *  many other systems have similar text but correct versions of the file.
365 *  To ensure only Sun's is fixed, we grep for a likely unique string.
366 *  Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
367 */
368fix = {
369    hackname = AAB_sun_memcpy;
370    files    = memory.h;
371    select   = "/\\*\t@\\(#\\)"
372             "(head/memory.h\t50.1\t "
373             "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
374
375    replace = <<-  _EndOfHeader_
376	/* This file was generated by fixincludes */
377	#ifndef __memory_h__
378	  #define __memory_h__
379
380	  #ifdef __STDC__
381	    extern void *memccpy();
382	    extern void *memchr();
383	    extern void *memcpy();
384	    extern void *memset();
385	  #else
386	    extern char *memccpy();
387	    extern char *memchr();
388	    extern char *memcpy();
389	    extern char *memset();
390	  #endif /* __STDC__ */
391
392	  extern int memcmp();
393
394	#endif /* __memory_h__ */
395	_EndOfHeader_;
396};
397
398/*
399 * Fix assert.h on VxWorks:
400 */
401fix = {
402    hackname    = AAB_vxworks_assert;
403    files       = assert.h;
404    mach        = "*-*-vxworks*";
405
406    replace     = <<- _EndOfHeader_
407	#ifndef _ASSERT_H
408	#define _ASSERT_H
409
410	#ifdef assert
411	#undef assert
412	#endif
413
414	#if defined(__STDC__) || defined(__cplusplus)
415	extern void __assert (const char*);
416	#else
417	extern void __assert ();
418	#endif
419
420	#ifdef NDEBUG
421	#define assert(ign) ((void)0)
422	#else
423
424	#define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
425	#define ASSERT_STRINGIFY_HELPER(str) #str
426
427	#define assert(test) ((void) \
428	        ((test) ? ((void)0) : \
429	        __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
430	        __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
431
432	#endif
433
434	#endif
435	_EndOfHeader_;
436};
437
438/*
439 * Add needed include to regs.h (NOT the gcc header) on VxWorks
440 */
441
442fix = {
443    hackname    = AAB_vxworks_regs_vxtypes;
444    files       = regs.h;
445    mach        = "*-*-vxworks*";
446
447    replace     = <<- _EndOfHeader_
448	#ifndef _REGS_H
449	#define _REGS_H
450	#include <types/vxTypesOld.h>
451	#include_next <arch/../regs.h>
452	#endif
453	_EndOfHeader_;
454};
455
456/*
457 *  This hack makes makes unistd.h more POSIX-compliant on VxWorks
458 */
459fix = {
460    hackname    = AAB_vxworks_unistd;
461    files       = unistd.h;
462    mach        = "*-*-vxworks*";
463
464    replace     = <<- _EndOfHeader_
465	#ifndef _UNISTD_H
466	#define _UNISTD_H
467	#include_next <unistd.h>
468	#include <ioLib.h>
469	#ifndef STDIN_FILENO
470	#define STDIN_FILENO 0
471	#endif
472	#ifndef STDOUT_FILENO
473	#define STDOUT_FILENO 1
474	#endif
475	#ifndef STDERR_FILENO
476	#define STDERR_FILENO 2
477	#endif
478	#endif /* _UNISTD_H */
479	_EndOfHeader_;
480};
481
482/*
483 * assert.h on AIX 7 redefines static_assert as _Static_assert without
484 * protecting C++.
485 */
486fix = {
487    hackname  = aix_assert;
488    mach      = "*-*-aix*";
489    files     = assert.h;
490    select    = "#define[ \t]static_assert[ \t]_Static_assert";
491    c_fix     = format;
492    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
493    test_text = "#define static_assert _Static_assert";
494};
495
496/*
497 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
498 * which only is provided by AIX xlc C99.
499 */
500fix = {
501    hackname  = aix_complex;
502    mach      = "*-*-aix*";
503    files     = complex.h;
504    select    = "#define[ \t]_Complex_I[ \t]__I";
505    c_fix     = format;
506    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
507    test_text = "#define _Complex_I	__I\n";
508};
509
510/*
511 *  On AIX some headers are not properly guarded by 'extern "C"'.
512 */
513fix = {
514  hackname  = aix_externc;
515  mach      = "*-*-aix*";
516  files     = ctype.h;
517  files     = fcntl.h;
518  files     = langinfo.h;
519  files     = ldfcn.h;
520  files     = sys/localedef.h;
521  files     = sys/times.h;
522  bypass    = "extern \"C\"";
523  c_fix     = wrap;
524  c_fix_arg = "#ifdef __cplusplus\n"
525              "extern \"C\" {\n"
526              "#endif\n";
527  c_fix_arg = "#ifdef __cplusplus\n"
528              "}\n"
529              "#endif\n";
530  test_text = "extern int __n_pthreads;\n";
531};
532
533/*
534 *  On AIX sys/socket.h assumes C++.
535 */
536fix = {
537  hackname  = aix_externcpp1;
538  mach      = "*-*-aix*";
539  files     = "sys/socket.h";
540  select    = "#ifdef __cplusplus";
541  c_fix     = format;
542  c_fix_arg = "#ifdef __cplusplus\n"
543              "extern \"C++\" {";
544  test_text = "#ifdef __cplusplus";
545
546};
547
548fix = {
549  hackname  = aix_externcpp2;
550  mach      = "*-*-aix*";
551  files     = "sys/socket.h";
552  select    = "#else  /\\* __cplusplus \\*/";
553  c_fix     = format;
554  c_fix_arg = "} /* extern \"C++\" */\n"
555              "#else  /* __cplusplus */";
556  test_text = "#else  /* __cplusplus */";
557
558};
559
560/*
561 *  malloc.h on AIX6 uses XLC++ specific builtin syntax
562 */
563fix = {
564    hackname  = aix_malloc;
565    mach      = "*-*-aix*";
566    files     = "malloc.h";
567    select    = "#ifdef __cplusplus";
568    c_fix     = format;
569    c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
570    test_text = "#ifdef __cplusplus";
571};
572
573/*
574 * net/if_arp.h defines a variable fc_softc instead of adding a
575 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
576 */
577fix = {
578    hackname  = aix_net_if_arp;
579    mach      = "*-*-aix*";
580    files     = "net/if_arp.h";
581    select    = "^struct  fc_softc \\{";
582    c_fix     = format;
583    c_fix_arg = "typedef struct _fc_softc {";
584    test_text = "struct  fc_softc {\n  int a;\n};";
585};
586
587/*
588 *  Fix AIX definition of NULL for G++.
589 */
590fix = {
591    hackname  = aix_null;
592    mach      = "*-*-aix*";
593    files     = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
594    time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
595    bypass    = __null;
596    select    = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
597    c_fix     = format;
598    c_fix_arg = <<- _EOFix_
599	#ifndef NULL
600	#ifdef __cplusplus
601	#ifdef __GNUG__
602	#define NULL __null
603	#else /* ! __GNUG__  */
604	#define NULL 0L
605	#endif /* __GNUG__  */
606	#else /* ! __cplusplus  */
607	#define NULL ((void *)0)
608	#endif /* __cplusplus  */
609	#endif /* !NULL  */
610	_EOFix_;
611    test_text = "# define\tNULL \t(0L)  /* typed NULL */";
612};
613
614/*
615 *  pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
616 *  PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
617 *  braces.
618 */
619fix = {
620    hackname  = aix_once_init_1;
621    mach      = "*-*-aix*";
622    files     = "pthread.h";
623    select    = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
624		"\\{ \\\\\n";
625    c_fix     = format;
626    c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
627		"{{ \\\n";
628    test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
629		"{ \\\\\n";
630};
631
632fix = {
633    hackname  = aix_once_init_2;
634    mach      = "*-*-aix*";
635    files     = "pthread.h";
636    select    = "[ \t]0 \\\\\n"
637		"\\}\n";
638    c_fix     = format;
639    c_fix_arg = "	0 \\\n"
640		"}}\n";
641    test_text = "	0 \\\\\n"
642		"}\n";
643};
644
645fix = {
646    hackname  = aix_mutex_initializer_1;
647    mach      = "*-*-aix*";
648    files     = "pthread.h";
649    select    = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
650		"\\{ \\\\\n";
651    c_fix     = format;
652    c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
653		"{{ \\\n";
654    test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
655		"{ \\\\\n";
656};
657
658fix = {
659    hackname  = aix_cond_initializer_1;
660    mach      = "*-*-aix*";
661    files     = "pthread.h";
662    select    = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
663		"\\{ \\\\\n";
664    c_fix     = format;
665    c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
666		"{{ \\\n";
667    test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
668		"{ \\\\\n";
669};
670
671fix = {
672    hackname  = aix_rwlock_initializer_1;
673    mach      = "*-*-aix*";
674    files     = "pthread.h";
675    select    = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
676		"\\{ \\\\\n";
677    c_fix     = format;
678    c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
679		"{{ \\\n";
680    test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
681		"{ \\\\\n";
682};
683
684/*
685 *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
686 *  which violates a requirement of ISO C.
687 */
688fix = {
689    hackname  = aix_pthread;
690    files     = "pthread.h";
691    select    = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
692    c_fix     = format;
693    c_fix_arg = "%1 %2";
694    test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
695                "{...init stuff...}";
696};
697
698/*
699 *  AIX stdint.h fixes.
700 */
701fix = {
702    hackname  = aix_stdint_1;
703    mach      = "*-*-aix*";
704    files     = stdint-aix.h, stdint.h;
705    select    = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
706		"#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
707    c_fix     = format;
708    c_fix_arg = "#define UINT8_MAX	(255)\n"
709		"#define UINT16_MAX	(65535)";
710    test_text = "#define UINT8_MAX	(255U)\n"
711		"#define UINT16_MAX	(65535U)";
712};
713
714/*
715 * aix_stdint_2
716 */
717fix = {
718    hackname  = aix_stdint_2;
719    mach      = "*-*-aix*";
720    files     = stdint-aix.h, stdint.h;
721    select    = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
722		"#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
723		"#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
724		"#else\n"
725		"#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
726		"#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
727		"#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
728    c_fix     = format;
729    c_fix_arg = "#define INTPTR_MIN	(-INTPTR_MAX-1)\n"
730		"#define INTPTR_MAX	9223372036854775807L\n"
731		"#define UINTPTR_MAX	18446744073709551615UL\n"
732		"#else\n"
733		"#define INTPTR_MIN	(-INTPTR_MAX-1)\n"
734		"#define INTPTR_MAX	2147483647L\n"
735		"#define UINTPTR_MAX	4294967295UL";
736    test_text = "#define INTPTR_MIN	INT64_MIN\n"
737		"#define INTPTR_MAX	INT64_MAX\n"
738		"#define UINTPTR_MAX	UINT64_MAX\n"
739		"#else\n"
740		"#define INTPTR_MIN	INT32_MIN\n"
741		"#define INTPTR_MAX	INT32_MAX\n"
742		"#define UINTPTR_MAX	UINT32_MAX";
743};
744
745/*
746 * aix_stdint_3
747 */
748fix = {
749    hackname  = aix_stdint_3;
750    mach      = "*-*-aix*";
751    files     = stdint-aix.h, stdint.h;
752    select    = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
753		"#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
754		"#else\n"
755		"#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
756		"#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
757    c_fix     = format;
758    c_fix_arg = "#define PTRDIFF_MIN	(-9223372036854775807L - 1)\n"
759		"#define PTRDIFF_MAX	9223372036854775807L\n"
760		"#else\n"
761		"#define PTRDIFF_MIN	(-2147483647L - 1)\n"
762		"#define PTRDIFF_MAX	2147483647L";
763    test_text = "#define PTRDIFF_MIN	INT64_MIN\n"
764		"#define PTRDIFF_MAX	INT64_MAX\n"
765		"#else\n"
766		"#define PTRDIFF_MIN     INT32_MIN\n"
767		"#define PTRDIFF_MAX	INT32_MAX";
768};
769
770/*
771 * aix_stdint_4
772 */
773fix = {
774    hackname  = aix_stdint_4;
775    mach      = "*-*-aix*";
776    files     = stdint-aix.h, stdint.h;
777    select    = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
778		"#else\n"
779		"#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
780    c_fix     = format;
781    c_fix_arg = "#define SIZE_MAX	18446744073709551615UL\n"
782		"#else\n"
783		"#define SIZE_MAX	4294967295UL";
784    test_text = "#define SIZE_MAX	UINT64_MAX\n"
785		"#else\n"
786		"#define SIZE_MAX        UINT32_MAX";
787};
788
789/*
790 * aix_stdint_5
791 */
792fix = {
793    hackname  = aix_stdint_5;
794    mach      = "*-*-aix*";
795    files     = stdint-aix.h, stdint.h;
796    select    = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
797		"#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
798    c_fix     = format;
799    c_fix_arg = "#define UINT8_C(c)	c\n"
800		"#define UINT16_C(c)	c";
801    test_text = "#define UINT8_C(c)	__CONCAT__(c,U)\n"
802		"#define UINT16_C(c)	__CONCAT__(c,U)";
803};
804
805/*
806 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
807   produces wrong code with G++.
808 */
809fix = {
810    hackname  = aix_stdio_inline;
811    mach      = "*-*-aix*";
812    files     = stdio.h;
813    select    = "#ifdef __cplusplus\\\n"
814                "}\\\n\\\n"
815                "#ifdef ferror\\\n";
816    c_fix     = format;
817    c_fix_arg = "#ifdef __cplusplus\n"
818                "}\n"
819                "#endif\n\n"
820                "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
821                "#ifdef ferror\n";
822    test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
823};
824
825/*
826 * stdlib.h on AIX uses #define on malloc and friends.
827 */
828fix = {
829    hackname  = aix_stdlib_malloc;
830    mach      = "*-*-aix*";
831    files     = stdlib.h;
832    select    = "#define[ \t]+malloc[ \t]+__linux_malloc";
833    c_fix     = format;
834    c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
835    test_text = "#define malloc __linux_malloc";
836};
837
838fix = {
839    hackname  = aix_stdlib_realloc;
840    mach      = "*-*-aix*";
841    files     = stdlib.h;
842    select    = "#define[ \t]+realloc[ \t]+__linux_realloc";
843    c_fix     = format;
844    c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
845    test_text = "#define realloc __linux_realloc";
846};
847
848fix = {
849    hackname  = aix_stdlib_calloc;
850    mach      = "*-*-aix*";
851    files     = stdlib.h;
852    select    = "#define[ \t]+calloc[ \t]+__linux_calloc";
853    c_fix     = format;
854    c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
855    test_text = "#define calloc __linux_calloc";
856};
857
858fix = {
859    hackname  = aix_stdlib_valloc;
860    mach      = "*-*-aix*";
861    files     = stdlib.h;
862    select    = "#define[ \t]+valloc[ \t]+__linux_valloc";
863    c_fix     = format;
864    c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
865    test_text = "#define valloc __linux_valloc";
866};
867
868fix = {
869    hackname  = aix_stdlib_vec_malloc;
870    mach      = "*-*-aix*";
871    files     = stdlib.h;
872    select    = "#define[ \t]+malloc[ \t]+vec_malloc";
873    c_fix     = format;
874    c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
875    test_text = "#define malloc vec_malloc";
876};
877
878fix = {
879    hackname  = aix_stdlib_vec_calloc;
880    mach      = "*-*-aix*";
881    files     = stdlib.h;
882    select    = "#define[ \t]+calloc[ \t]+vec_calloc";
883    c_fix     = format;
884    c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
885    test_text = "#define calloc vec_calloc";
886};
887
888/*
889 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
890 */
891fix = {
892    hackname  = aix_strtof_const;
893    mach      = "*-*-aix*";
894    files     = stdlib.h;
895    select    = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
896    c_fix     = format;
897    c_fix_arg = "%1(const char *, char **);";
898    test_text = "extern float    strtof(char *, char **);";
899};
900
901/*
902 *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
903 *  in an otherwise harmless (and #ifed out) macro definition
904 */
905fix = {
906    hackname  = aix_sysmachine;
907    mach      = "*-*-aix*";
908    files     = sys/machine.h;
909    select    = "\\\\ +\n";
910    c_fix     = format;
911    c_fix_arg = "\\\n";
912    test_text = "#define FOO \\\n"
913    " bar \\ \n baz \\ \n bat";
914};
915
916/*
917 *  sys/wait.h on AIX 5.2 defines macros that have both signed and
918 *  unsigned types in conditional expressions.
919 */
920fix = {
921    hackname  = aix_syswait_2;
922    mach      = "*-*-aix*";
923    files     = sys/wait.h;
924    select    = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
925    c_fix     = format;
926    c_fix_arg = "? (int)%1";
927    test_text = "#define WSTOPSIG(__x)    "
928        "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
929};
930
931/*
932 *  sys/signal.h on some versions of AIX uses volatile in the typedef of
933 *  sig_atomic_t, which causes gcc to generate a warning about duplicate
934 *  volatile when a sig_atomic_t variable is declared volatile, as
935 *  required by ANSI C.
936 */
937fix = {
938    hackname  = aix_volatile;
939    mach      = "*-*-aix*";
940    files     = sys/signal.h;
941    select    = "typedef volatile int sig_atomic_t";
942    c_fix     = format;
943    c_fix_arg = "typedef int sig_atomic_t";
944    test_text = "typedef volatile int sig_atomic_t;";
945};
946
947/*
948 *  Fix __assert declaration in assert.h on Alpha OSF/1.
949 */
950fix = {
951    hackname  = alpha___assert;
952    files     = "assert.h";
953    select    = '__assert\(char \*, char \*, int\)';
954    c_fix     = format;
955    c_fix_arg = "__assert(const char *, const char *, int)";
956    test_text = 'extern void __assert(char *, char *, int);';
957};
958
959/*
960 *  Fix assert macro in assert.h on Alpha OSF/1.
961 *  The superfluous int cast breaks C++.
962 */
963fix = {
964    hackname  = alpha_assert;
965    files     = "assert.h";
966    select    = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
967    c_fix     = format;
968    c_fix_arg = "%1(EX)";
969    test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
970                ': __assert(#EX, __FILE__, __LINE__))';
971};
972
973/*
974 *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
975 */
976fix = {
977    hackname  = alpha_getopt;
978    files     = "stdio.h";
979    files     = "stdlib.h";
980    select    = 'getopt\(int, char \*\[\], *char \*\)';
981    c_fix     = format;
982    c_fix_arg = "getopt(int, char *const[], const char *)";
983    test_text = 'extern int getopt(int, char *[], char *);';
984};
985
986/*
987 *  Fix missing semicolon on Alpha OSF/4 in <net/if.h>
988 */
989fix = {
990    hackname  = alpha_if_semicolon;
991    files     = net/if.h;
992    select    = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
993    c_fix     = format;
994    c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
995    test_text = '     struct  sockaddr vmif_paddr     /* protocol address */';
996};
997
998/*
999 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1000 */
1001fix = {
1002    hackname  = alpha_parens;
1003    files     = sym.h;
1004    select    = '#ifndef\(__mips64\)';
1005    c_fix     = format;
1006    c_fix_arg = "#ifndef __mips64";
1007    test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1008};
1009
1010/*
1011 *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1012 *  And OpenBSD.
1013 */
1014fix = {
1015    hackname = alpha_sbrk;
1016    files    = unistd.h;
1017    select   = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1018    c_fix     = format;
1019    c_fix_arg = "void *sbrk(";
1020    test_text = "extern char* sbrk(ptrdiff_t increment);";
1021};
1022
1023/*
1024 *  For C++, avoid any typedef or macro definition of bool,
1025 *  and use the built in type instead.
1026 *  HP/UX 10.20 also has it in curses_colr/curses.h.
1027 */
1028fix = {
1029    hackname  = avoid_bool_define;
1030    files     = curses.h;
1031    files     = curses_colr/curses.h;
1032    files     = term.h;
1033    files     = tinfo.h;
1034
1035    select    = "#[ \t]*define[ \t]+bool[ \t]";
1036    bypass    = "__cplusplus";
1037
1038    c_fix     = format;
1039    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1040    c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1041
1042    test_text = "# define bool\t char \n";
1043};
1044
1045/*
1046 * avoid_bool_type
1047 */
1048fix = {
1049    hackname = avoid_bool_type;
1050    files    = curses.h;
1051    files    = curses_colr/curses.h;
1052    files    = term.h;
1053    files    = tinfo.h;
1054
1055    select    = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1056    bypass    = "__cplusplus";
1057
1058    c_fix     = format;
1059    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1060
1061    test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1062};
1063
1064/*
1065 *  For C++, avoid any typedef definition of wchar_t,
1066 *  and use the built in type instead.
1067 *  Don't do this for headers that are smart enough to do the right
1068 *  thing (recent [n]curses.h and Xlib.h).
1069 *  Don't do it for <linux/nls.h> which is never used from C++ anyway,
1070 *  and will be broken by the edit.
1071 */
1072
1073fix = {
1074    hackname = avoid_wchar_t_type;
1075
1076    select    = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1077    bypass    = "__cplusplus";
1078    bypass    = "_LINUX_NLS_H";
1079    bypass    = "XFree86: xc/lib/X11/Xlib\\.h";
1080
1081    c_fix     = format;
1082    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1083
1084    test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1085};
1086
1087/*
1088 *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1089 */
1090fix = {
1091    hackname  = bad_struct_term;
1092    files     = curses.h;
1093    select    = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1094    c_fix     = format;
1095    c_fix_arg = "struct term;";
1096
1097    test_text = 'typedef struct term;';
1098};
1099
1100/*
1101 *  Fix one other error in this file:
1102 *  a mismatched quote not inside a C comment.
1103 */
1104fix = {
1105    hackname  = badquote;
1106    files     = sundev/vuid_event.h;
1107    select    = "doesn't";
1108    c_fix     = format;
1109    c_fix_arg = "does not";
1110
1111    test_text = "/* doesn't have matched single quotes */";
1112};
1113
1114/*
1115 *  check for broken assert.h that needs stdio.h
1116 */
1117fix = {
1118    hackname  = broken_assert_stdio;
1119    files     = assert.h;
1120    select    = stderr;
1121    bypass    = "include.*stdio\\.h";
1122    c_fix     = wrap;
1123    c_fix_arg = "#include <stdio.h>\n";
1124    test_text = "extern FILE* stderr;";
1125};
1126
1127/*
1128 *  check for broken assert.h that needs stdlib.h
1129 */
1130fix = {
1131    hackname  = broken_assert_stdlib;
1132    files     = assert.h;
1133    select    = 'exit *\(|abort *\(';
1134    bypass    = "include.*stdlib\\.h";
1135    c_fix     = wrap;
1136    c_fix_arg = "#ifdef __cplusplus\n"
1137                "#include <stdlib.h>\n"
1138                "#endif\n";
1139    test_text = "extern void exit ( int );";
1140};
1141
1142/*
1143 *  Remove `extern double cabs' declarations from math.h.
1144 *  This conflicts with C99.  Discovered on AIX.
1145 *  Darwin hides its broken cabs in architecture-specific subdirs.
1146 */
1147fix = {
1148    hackname = broken_cabs;
1149    files    = math.h, "architecture/*/math.h";
1150    select   = "^extern[ \t]+double[ \t]+cabs";
1151
1152    sed       = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1153    sed       = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1154
1155    test_text = "#ifdef __STDC__\n"
1156                "extern     double   cabs(struct dbl_hypot);\n"
1157                "#else\n"
1158                "extern     double   cabs();\n"
1159                "#endif\n"
1160                "extern double cabs ( _Complex z );";
1161};
1162
1163/*
1164 * Fixup Darwin's broken check for __builtin_nanf.
1165 */
1166fix = {
1167    hackname  = broken_nan;
1168    /*
1169     *  It is tempting to omit the first "files" entry.  Do not.
1170     *  The testing machinery will take the first "files" entry as the name
1171     *  of a test file to play with.  It would be a nuisance to have a directory
1172     *  with the name "*".
1173     */
1174    files     = "architecture/ppc/math.h";
1175    files     = "architecture/*/math.h";
1176    select    = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1177    bypass    = "powl";
1178    c_fix     = format;
1179    c_fix_arg = "#if 1";
1180    test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1181};
1182
1183/*
1184 *  Various systems derived from BSD4.4 contain a macro definition
1185 *  for vfscanf that interacts badly with requirements of builtin-attrs.def.
1186 *  Known to be fixed in FreeBSD 5 system headers.
1187 */
1188fix = {
1189    hackname  = bsd_stdio_attrs_conflict;
1190    mach      = "*-*-*bsd*";
1191    mach      = "*-*-*darwin*";
1192    files     = stdio.h;
1193    select    = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1194    c_fix     = format;
1195    c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1196		'#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1197		'int vfscanf(FILE *, const char *, __builtin_va_list) '
1198		'__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1199    test_text = '#define  vfscanf	__svfscanf';
1200};
1201
1202/*
1203 *  Fix various macros used to define ioctl numbers.
1204 *  The traditional syntax was:
1205 *
1206 *    #define _CTRL(n, x) (('n'<<8)+x)
1207 *    #define TCTRLCFOO _CTRL(T, 1)
1208 *
1209 *  but this does not work with the C standard, which disallows macro
1210 *  expansion inside strings.  We have to rewrite it thus:
1211 *
1212 *    #define _CTRL(n, x) ((n<<8)+x)
1213 *    #define TCTRLCFOO  _CTRL('T', 1)
1214 *
1215 *  The select expressions match too much, but the c_fix code is cautious.
1216 *
1217 *  CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1218 */
1219fix = {
1220    hackname  = ctrl_quotes_def;
1221    select    = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1222    c_fix     = char_macro_def;
1223    c_fix_arg = "CTRL";
1224
1225    /*
1226     *  This is two tests in order to ensure that the "CTRL(c)" can
1227     *  be selected in isolation from the multi-arg format
1228     */
1229    test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1230    test_text = "#define _CTRL(c) ('c'&037)";
1231};
1232
1233/*
1234 *  Fix various macros used to define ioctl numbers.
1235 */
1236fix = {
1237    hackname  = ctrl_quotes_use;
1238    select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1239    c_fix     = char_macro_use;
1240    c_fix_arg = "CTRL";
1241    test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1242};
1243
1244/*
1245 *  sys/mman.h on HP/UX is not C++ ready,
1246 *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1247 *
1248 *  rpc/types.h on OSF1/2.0 is not C++ ready,
1249 *  even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1250 *
1251 *  The problem is the declaration of malloc.
1252 */
1253fix = {
1254    hackname = cxx_unready;
1255    files    = sys/mman.h;
1256    files    = rpc/types.h;
1257    select   = '[^#]+malloc.*;';  /* Catch any form of declaration
1258				     not within a macro.  */
1259    bypass   = '"C"|__BEGIN_DECLS';
1260
1261    c_fix     = wrap;
1262    c_fix_arg = "#ifdef __cplusplus\n"
1263                "extern \"C\" {\n"
1264                "#endif\n";
1265    c_fix_arg = "#ifdef __cplusplus\n"
1266                "}\n"
1267                "#endif\n";
1268    test_text = "extern void* malloc( size_t );";
1269};
1270
1271/*
1272 *  macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1273 *  unconditionally.
1274 */
1275fix = {
1276    hackname  = darwin_availabilityinternal;
1277    mach      = "*-*-darwin*";
1278    files     = AvailabilityInternal.h;
1279    select    = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1280    c_fix     = format;
1281    c_fix_arg = <<- _EOFix_
1282	#if defined(__has_attribute)
1283	  #if __has_attribute(availability)
1284	%0
1285	  #else
1286	    #define %1
1287	  #endif
1288	#else
1289	    #define %1
1290	#endif
1291	_EOFix_;
1292
1293    test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1294		"#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1295};
1296
1297/*
1298 *  For the AAB_darwin7_9_long_double_funcs fix (and later fixes for long long)
1299 *  to be useful, the main math.h must use <> and not "" includes.
1300 */
1301fix = {
1302    hackname  = darwin_9_long_double_funcs_2;
1303    mach      = "*-*-darwin*";
1304    files     = math.h;
1305    select    = '#include[ \t]+\"';
1306    c_fix     = format;
1307    c_fix_arg = "%1<%2.h>";
1308
1309    c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1310
1311    test_text = '#include <architecture/ppc/math.h>';
1312};
1313
1314/*
1315 *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1316 *  by 'extern "C"'.  On darwin7 some mach/ headers aren't properly guarded.
1317 */
1318fix = {
1319  hackname  = darwin_externc;
1320  mach      = "*-*-darwin*";
1321  files     = mach-o/swap.h;
1322  files     = mach/mach_time.h;
1323  files     = mach/mach_traps.h;
1324  files     = mach/message.h;
1325  files     = mach/mig.h;
1326  files     = mach/semaphore.h;
1327  bypass    = "extern \"C\"";
1328  bypass    = "__BEGIN_DECLS";
1329  c_fix     = wrap;
1330  c_fix_arg = "#ifdef __cplusplus\n"
1331              "extern \"C\" {\n"
1332              "#endif\n";
1333  c_fix_arg = "#ifdef __cplusplus\n"
1334              "}\n"
1335              "#endif\n";
1336  test_text = "extern void swap_fat_header();\n";
1337};
1338
1339/*
1340 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1341 * bad __GNUC__ tests.
1342 */
1343fix = {
1344  hackname  = darwin_gcc4_breakage;
1345  mach      = "*-*-darwin*";
1346  files     = AvailabilityMacros.h;
1347  select    = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1348  c_fix     = format;
1349  c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1350  test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1351  	      "(__GNUC_MINOR__ >= 1)\n";
1352};
1353
1354/*
1355 * math.h hides the long long functions that are available on the system for
1356 * 10.5 and 10.6 SDKs, we expect to use them in G++ without specifying a value
1357 * for __STDC_VERSION__, or switching __STRICT_ANSI__ off.
1358 */
1359fix = {
1360  hackname  = darwin_ll_funcs_avail;
1361  mach      = "*-*-darwin*";
1362  files     = architecture/ppc/math.h, architecture/i386/math.h;
1363  select    = "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
1364	      "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
1365  sed       = "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
1366	      "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
1367  test_text = "#if\ !(__DARWIN_NO_LONG_LONG)";
1368};
1369
1370/*
1371 *  Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1372 */
1373fix = {
1374    hackname  = darwin_longjmp_noreturn;
1375    mach      = "*-*-darwin*";
1376    files     = "i386/setjmp.h";
1377    bypass    = "__dead2";
1378    select    = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1379    c_fix     = format;
1380    c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1381
1382    test_text = "void siglongjmp(sigjmp_buf, int);";
1383};
1384
1385/*
1386 *  Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1387 */
1388fix = {
1389  hackname  = darwin_os_trace_1;
1390  mach      = "*-*-darwin*";
1391  files     = os/trace.h;
1392  select    = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1393  c_fix     = format;
1394  c_fix_arg = "%1";
1395  test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1396};
1397
1398/*
1399 *  Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1400 *  extension without guard.
1401 */
1402fix = {
1403  hackname  = darwin_os_trace_2;
1404  mach      = "*-*-darwin*";
1405  files     = os/trace.h;
1406  select    = "typedef.*\\^os_trace_payload_t.*";
1407  c_fix     = format;
1408  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1409  test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1410};
1411
1412/*
1413 *  In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1414 *  os_trace_payload_t typedef, too.
1415 */
1416fix = {
1417  hackname  = darwin_os_trace_3;
1418  mach      = "*-*-darwin*";
1419  files     = os/trace.h;
1420  select    = <<- _EOSelect_
1421	__(API|OSX)_.*
1422	OS_EXPORT.*
1423	.*
1424	_os_trace.*os_trace_payload_t payload);
1425	_EOSelect_;
1426  c_fix     = format;
1427  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1428  test_text = <<- _EOText_
1429	__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1430	OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1431	void
1432	_os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1433
1434	__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1435	OS_EXPORT OS_NOTHROW
1436	void
1437	_os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1438	_EOText_;
1439};
1440
1441/*
1442 *  In macOS 10.10 <os/base.h>, doesn't have __has_extension guarded.
1443 */
1444fix = {
1445  hackname  = darwin_os_base_1;
1446  mach      = "*-*-darwin*";
1447  files     = os/base.h;
1448  select    = <<- OS_BASE_1_SEL
1449#define __has_attribute.*
1450#endif
1451OS_BASE_1_SEL;
1452  c_fix     = format;
1453  c_fix_arg = <<- OS_BASE_1_FIX
1454%0
1455#ifndef __has_extension
1456#define __has_extension(x) 0
1457#endif
1458OS_BASE_1_FIX;
1459  test_text = <<- OS_BASE_1_TEST
1460#define __has_attribute(x) 0
1461#endif
1462
1463#if __GNUC__
1464OS_BASE_1_TEST;
1465};
1466
1467/*
1468 *  In macOS 10.10 <dispatch/object.h>, has unguarded block syntax.
1469 */
1470fix = {
1471  hackname  = darwin_dispatch_object_1;
1472  mach      = "*-*-darwin*";
1473  files     = dispatch/object.h;
1474  select    = "typedef void.*\\^dispatch_block_t.*";
1475  c_fix     = format;
1476  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1477  test_text = <<- DISPATCH_OBJECT_1_TEST
1478typedef void (^dispatch_block_t)(void);
1479
1480__BEGIN_DECLS
1481DISPATCH_OBJECT_1_TEST;
1482};
1483
1484/*
1485 *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
1486 *  why would you ever put it in a system header file?
1487 */
1488fix = {
1489  hackname  = darwin_private_extern;
1490  mach      = "*-*-darwin*";
1491  files     = mach-o/dyld.h;
1492  select    = "__private_extern__ [a-z_]+ _dyld_";
1493  c_fix     = format;
1494  c_fix_arg = "extern";
1495  c_fix_arg = "__private_extern__";
1496  test_text = "__private_extern__ int _dyld_func_lookup(\n"
1497	      "const char *dyld_func_name,\n"
1498	      "unsigned long *address);\n";
1499};
1500
1501/*
1502 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1503 * unsigned constants.
1504 */
1505fix = {
1506    hackname  = darwin_stdint_1;
1507    mach      = "*-*-darwin*";
1508    files     = stdint-darwin.h, stdint.h;
1509    c_fix     = format;
1510    c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1511    select    = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1512		"#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1513    test_text = "#define UINT8_C(v)   (v ## U)\n"
1514		"#define UINT16_C(v)  (v ## U)";
1515};
1516
1517/*
1518 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1519 * with wrong types.
1520 */
1521fix = {
1522    hackname  = darwin_stdint_2;
1523    mach      = "*-*-darwin*";
1524    files     = stdint-darwin.h, stdint.h;
1525    c_fix     = format;
1526    c_fix_arg = "#if __WORDSIZE == 64\n"
1527		"#define INTPTR_MAX 9223372036854775807L\n"
1528		"#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1529		"#else\n"
1530		"#define INTPTR_MAX 2147483647L\n"
1531		"#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1532		"#endif";
1533    select    = "#if __WORDSIZE == 64\n"
1534		"#define INTPTR_MIN[ \t]+INT64_MIN\n"
1535		"#define INTPTR_MAX[ \t]+INT64_MAX\n"
1536		"#else\n"
1537		"#define INTPTR_MIN[ \t]+INT32_MIN\n"
1538		"#define INTPTR_MAX[ \t]+INT32_MAX\n"
1539		"#endif";
1540    test_text = "#if __WORDSIZE == 64\n"
1541		"#define INTPTR_MIN        INT64_MIN\n"
1542		"#define INTPTR_MAX        INT64_MAX\n"
1543		"#else\n"
1544		"#define INTPTR_MIN        INT32_MIN\n"
1545		"#define INTPTR_MAX        INT32_MAX\n"
1546		"#endif";
1547};
1548
1549/*
1550 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1551 */
1552fix = {
1553    hackname  = darwin_stdint_3;
1554    mach      = "*-*-darwin*";
1555    files     = stdint-darwin.h, stdint.h;
1556    c_fix     = format;
1557    c_fix_arg = "#if __WORDSIZE == 64\n"
1558		"#define UINTPTR_MAX 18446744073709551615UL\n"
1559		"#else\n"
1560		"#define UINTPTR_MAX 4294967295UL\n"
1561		"#endif";
1562    select    = "#if __WORDSIZE == 64\n"
1563		"#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1564		"#else\n"
1565		"#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1566		"#endif";
1567    test_text = "#if __WORDSIZE == 64\n"
1568		"#define UINTPTR_MAX       UINT64_MAX\n"
1569		"#else\n"
1570		"#define UINTPTR_MAX       UINT32_MAX\n"
1571		"#endif";
1572};
1573
1574/*
1575 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1576 */
1577fix = {
1578    hackname  = darwin_stdint_4;
1579    mach      = "*-*-darwin*";
1580    files     = stdint-darwin.h, stdint.h;
1581    c_fix     = format;
1582    c_fix_arg = "#if __WORDSIZE == 64\n"
1583		"#define SIZE_MAX 18446744073709551615UL\n"
1584		"#else\n"
1585		"#define SIZE_MAX 4294967295UL\n"
1586		"#endif";
1587    select    = "#if __WORDSIZE == 64\n"
1588		"#define SIZE_MAX[ \t]+UINT64_MAX\n"
1589		"#else\n"
1590		"#define SIZE_MAX[ \t]+UINT32_MAX\n"
1591		"#endif";
1592    test_text = "#if __WORDSIZE == 64\n"
1593		"#define SIZE_MAX          UINT64_MAX\n"
1594		"#else\n"
1595		"#define SIZE_MAX          UINT32_MAX\n"
1596		"#endif";
1597};
1598
1599/*
1600 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1601 * with a wrong type.
1602 */
1603fix = {
1604    hackname  = darwin_stdint_5;
1605    mach      = "*-*-darwin*";
1606    files     = stdint-darwin.h, stdint.h;
1607    c_fix     = format;
1608    c_fix_arg = "#if __WORDSIZE == 64\n"
1609		"#define INTMAX_MIN   (-9223372036854775807L - 1)\n"
1610		"#define INTMAX_MAX   9223372036854775807L\n"
1611		"#define UINTMAX_MAX  18446744073709551615UL\n"
1612		"#else\n"
1613		"#define INTMAX_MIN   (-9223372036854775807LL - 1)\n"
1614		"#define INTMAX_MAX   9223372036854775807LL\n"
1615		"#define UINTMAX_MAX  18446744073709551615ULL\n"
1616		"#endif";
1617    select    = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1618		"#define INTMAX_MAX[ \t]+INT64_MAX\n"
1619		"\n"
1620		"#define UINTMAX_MAX[ \t]+UINT64_MAX";
1621    test_text = "#define INTMAX_MIN        INT64_MIN\n"
1622		"#define INTMAX_MAX        INT64_MAX\n"
1623		"\n"
1624		"#define UINTMAX_MAX       UINT64_MAX";
1625};
1626
1627/*
1628 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1629 * with a wrong type.
1630 */
1631fix = {
1632    hackname  = darwin_stdint_6;
1633    mach      = "*-*-darwin*";
1634    files     = stdint-darwin.h, stdint.h;
1635    c_fix     = format;
1636    c_fix_arg = "#if __WORDSIZE == 64\n"
1637		"#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1638		"#define PTRDIFF_MAX 9223372036854775807L\n"
1639		"#else\n"
1640		"#define PTRDIFF_MIN (-2147483647 - 1)\n"
1641		"#define PTRDIFF_MAX 2147483647\n"
1642		"#endif";
1643    select    = "#if __WORDSIZE == 64\n"
1644		"#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1645		"#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1646		"#else\n"
1647		"#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1648		"#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1649		"#endif";
1650    test_text = "#if __WORDSIZE == 64\n"
1651		"#define PTRDIFF_MIN       INT64_MIN\n"
1652		"#define PTRDIFF_MAX       INT64_MAX\n"
1653		"#else\n"
1654		"#define PTRDIFF_MIN       INT32_MIN\n"
1655		"#define PTRDIFF_MAX       INT32_MAX\n"
1656		"#endif";
1657};
1658
1659/*
1660 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1661 * with a wrong type.
1662 */
1663fix = {
1664    hackname  = darwin_stdint_7;
1665    mach      = "*-*-darwin*";
1666    files     = stdint-darwin.h, stdint.h;
1667    c_fix     = format;
1668    c_fix_arg = "#if __WORDSIZE == 64\n"
1669		"#define INTMAX_C(v)  (v ## L)\n"
1670		"#define UINTMAX_C(v) (v ## UL)\n"
1671		"#else\n"
1672		"#define INTMAX_C(v)  (v ## LL)\n"
1673		"#define UINTMAX_C(v) (v ## ULL)\n"
1674		"#endif";
1675    select    = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1676		"#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1677    test_text = "#define INTMAX_C(v)  (v ## LL)\n"
1678		"#define UINTMAX_C(v) (v ## ULL)";
1679};
1680
1681/*  The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
1682    C11 _Atomic keyword (exposing it to C++ code).  The work-around here follows
1683    the header in declaring the entity volatile when _Atomic is not available.
1684*/
1685fix = {
1686    hackname  = darwin_ucred__Atomic;
1687    mach      = "*-*-darwin*";
1688    files     = sys/ucred.h;
1689    select    = "_Atomic";
1690    c_fix     = wrap;
1691    c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1692		"# define _Atomic volatile\n"
1693		"#endif\n";
1694    c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1695		"# undef _Atomic\n"
1696		"#endif\n";
1697    test_text = ""; /* Don't provide this for wrap fixes.  */
1698};
1699
1700/*
1701 *  Fix <c_asm.h> on Digital UNIX V4.0:
1702 *  It contains a prototype for a DEC C internal asm() function,
1703 *  clashing with gcc's asm keyword.  So protect this with __DECC.
1704 */
1705fix = {
1706    hackname = dec_intern_asm;
1707    files    = c_asm.h;
1708    sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1709    sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1710          "#endif\n";
1711    test_text =
1712    "float fasm {\n"
1713    "    ... asm stuff ...\n"
1714    "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1715};
1716
1717/*
1718 * Fix typo in <wchar.h> on DJGPP 2.03.
1719 */
1720fix = {
1721    hackname  = djgpp_wchar_h;
1722    file      = wchar.h;
1723    select    = "__DJ_wint_t";
1724    bypass    = "sys/djtypes.h";
1725    c_fix     = format;
1726    c_fix_arg = "%0\n#include <sys/djtypes.h>";
1727    c_fix_arg = "#include <stddef.h>";
1728    test_text = "#include <stddef.h>\n"
1729                "extern __DJ_wint_t x;\n";
1730};
1731
1732/*
1733 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1734 */
1735fix = {
1736    hackname  = ecd_cursor;
1737    files     = "sunwindow/win_lock.h";
1738    files     = "sunwindow/win_cursor.h";
1739    select    = 'ecd\.cursor';
1740    c_fix     = format;
1741    c_fix_arg = 'ecd_cursor';
1742
1743    test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1744};
1745
1746/*
1747 *  Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1748 *  that fails when compiling for SSE-less 32-bit x86.
1749 */
1750fix = {
1751    hackname  = feraiseexcept_nosse_divbyzero;
1752    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1753    files     = bits/fenv.h, '*/bits/fenv.h';
1754    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1755		": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1756    bypass    = "\"fdivp .*; fwait\"";
1757
1758    c_fix     = format;
1759    c_fix_arg = <<- _EOText_
1760	# ifdef __SSE_MATH__
1761	%0
1762	# else
1763	%1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1764	%1			: "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1765	# endif
1766	_EOText_;
1767
1768    test_text = <<- _EOText_
1769	  __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1770	_EOText_;
1771};
1772
1773/*
1774 *  Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1775 *  that fails when compiling for SSE-less 32-bit x86.
1776 */
1777fix = {
1778    hackname  = feraiseexcept_nosse_invalid;
1779    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1780    files     = bits/fenv.h, '*/bits/fenv.h';
1781    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1782		": \"x\" \\(__f\\)\\);$";
1783    bypass    = "\"fdiv .*; fwait\"";
1784
1785    c_fix     = format;
1786    c_fix_arg = <<- _EOText_
1787	# ifdef __SSE_MATH__
1788	%0
1789	# else
1790	%1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1791	%1			: "=t" (__f) : "0" (__f));
1792	# endif
1793	_EOText_;
1794
1795    test_text = <<- _EOText_
1796	  __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1797	_EOText_;
1798};
1799
1800/*
1801 *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1802 *  neither the existence of GCC 3 nor its exact feature set yet break
1803 *  (by design?) when __GNUC__ is set beyond 2.
1804 */
1805fix = {
1806    hackname  = freebsd_gcc3_breakage;
1807    mach      = "*-*-freebsd*";
1808    files     = sys/cdefs.h;
1809    select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1810    bypass    = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1811    c_fix     = format;
1812    c_fix_arg = '%0 || __GNUC__ >= 3';
1813    test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1814};
1815
1816/*
1817 *  Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1818 *  neither the existence of GCC 4 nor its exact feature set yet break
1819 *  (by design?) when __GNUC__ is set beyond 3.
1820 */
1821fix = {
1822    hackname  = freebsd_gcc4_breakage;
1823    mach      = "*-*-freebsd*";
1824    files     = sys/cdefs.h;
1825    select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1826    c_fix     = format;
1827    c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1828    test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1829};
1830
1831/*
1832 *  Some versions of glibc don't expect the C99 inline semantics.
1833 */
1834fix = {
1835    hackname  = glibc_c99_inline_1;
1836    files     = features.h, '*/features.h';
1837    select    = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1838    c_fix     = format;
1839    c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1840    test_text = <<-EOT
1841	#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1842	    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1843	# define __USE_EXTERN_INLINES	1
1844	#endif
1845	EOT;
1846};
1847
1848/*
1849 *  Similar, but a version that didn't have __NO_INLINE__
1850 */
1851fix = {
1852    hackname  = glibc_c99_inline_1a;
1853    files     = features.h, '*/features.h';
1854    select    = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1855		"(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1856    c_fix     = format;
1857    c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1858    test_text = <<-EOT
1859	#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1860	# define __USE_EXTERN_INLINES	1
1861	#endif
1862	EOT;
1863};
1864
1865/*
1866 * The glibc_c99_inline_1 fix should have fixed everything.  Unfortunately
1867 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1868 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1869 */
1870fix = {
1871    hackname  = glibc_c99_inline_2;
1872    files     = sys/stat.h, '*/sys/stat.h';
1873    select    = "extern __inline__ int";
1874    sed     = "s/extern int \\(stat\\)/"
1875              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1876              "__inline__ int \\1/";
1877    sed     = "s/extern int \\([lf]stat\\)/"
1878              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1879              "__inline__ int \\1/";
1880    sed     = "s/extern int \\(mknod\\)/"
1881              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1882              "__inline__ int \\1/";
1883    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1884              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1885              "__inline__ int __REDIRECT\\1 (\\2/";
1886    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1887              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1888              "__inline__ int __REDIRECT\\1 (\\2/";
1889    sed     = "s/^extern __inline__ int/"
1890              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1891              "__inline__ int/";
1892    test_text = <<-EOT
1893	extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1894	extern __inline__ int
1895	__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1896	{}
1897	EOT;
1898};
1899
1900/*
1901 * glibc_c99_inline_3
1902 */
1903fix = {
1904    hackname  = glibc_c99_inline_3;
1905    files     = bits/string2.h, '*/bits/string2.h';
1906    select    = "extern __inline";
1907    bypass    = "__extern_inline|__GNU_STDC_INLINE__";
1908    c_fix     = format;
1909    c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1910    c_fix_arg = "^# ifdef __cplusplus$";
1911    test_text = <<-EOT
1912	# ifdef __cplusplus
1913	#  define __STRING_INLINE inline
1914	# else
1915	#  define __STRING_INLINE extern __inline
1916	# endif
1917	EOT;
1918};
1919
1920/*
1921 * glibc_c99_inline_4
1922 */
1923fix = {
1924    hackname  = glibc_c99_inline_4;
1925    files     = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1926    pthread.h, '*/pthread.h';
1927    bypass    = "__extern_inline|__gnu_inline__";
1928    select    = "(^| )extern __inline";
1929    c_fix     = format;
1930    c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1931    test_text = <<-EOT
1932	__extension__ extern __inline unsigned int
1933	extern __inline unsigned int
1934	EOT;
1935};
1936
1937/*  glibc-2.3.5 defines pthread mutex initializers incorrectly,
1938 *  so we replace them with versions that correspond to the
1939 *  definition.
1940 */
1941fix = {
1942    hackname = glibc_mutex_init;
1943    files    = pthread.h;
1944    select   = '\{ *\{ *0, *\} *\}';
1945    sed      = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1946               "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1947    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1948               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1949    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1950               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1951    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1952               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1953    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1954               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1955    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1956               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1957    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1958               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1959    sed      = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1960               "N;s/^[ \t]*#[ \t]*"
1961               "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1962               "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1963               "#  \\1\\\n"
1964               "  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1965               "# else\\\n"
1966               "#  \\1\\\n"
1967               "  { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1968               "# endif/";
1969    sed      = "s/{ \\(0, 0, 0, 0, 0, 0, "
1970               "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1971    sed      = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1972               "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1973
1974    test_text = <<- _EOText_
1975	#define PTHREAD_MUTEX_INITIALIZER \\
1976	  { { 0, } }
1977	#ifdef __USE_GNU
1978	# if __WORDSIZE == 64
1979	#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1980	  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1981	#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1982	  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1983	#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1984	  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1985	# else
1986	#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1987	  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1988	#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1989	  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1990	#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1991	  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1992	# endif
1993	#endif
1994	# define PTHREAD_RWLOCK_INITIALIZER \\
1995	  { { 0, } }
1996	# ifdef __USE_GNU
1997	#  if __WORDSIZE == 64
1998	#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1999	  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			      \\
2000	      PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2001	#  else
2002	#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2003	  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2004	#  endif
2005	# endif
2006	#define PTHREAD_COND_INITIALIZER { { 0, } }
2007	_EOText_;
2008};
2009
2010/* glibc versions before 2.5 have a version of stdint.h that defines
2011   UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2012   versions with stdint.h based on those glibc versions.  */
2013fix = {
2014    hackname  = glibc_stdint;
2015    files     = stdint.h;
2016    select    = "GNU C Library";
2017    c_fix     = format;
2018    c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2019    c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2020    test_text = "/* This file is part of the GNU C Library.  */\n"
2021        "# define UINT8_C(c)\tc ## U\n"
2022        "# define UINT16_C(c)\tc ## U";
2023};
2024
2025/* Some versions of glibc have a version of bits/string2.h that
2026   produces "value computed is not used" warnings from strncpy; fix
2027   this definition by using __builtin_strncpy instead as in newer
2028   versions.  */
2029fix = {
2030    hackname  = glibc_strncpy;
2031    files     = bits/string2.h, '*/bits/string2.h';
2032    bypass    = "__builtin_strncpy";
2033    c_fix     = format;
2034    c_fix_arg = "#  define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2035    c_fix_arg = "#  define strncpy([^\n]*\\\\\n)*[^\n]*";
2036    test_text = <<-EOT
2037	#  define strncpy(dest, src, n) \
2038	  (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \\
2039			  ? (strlen (src) + 1 >= ((size_t) (n))			      \\
2040			     ? (char *) memcpy (dest, src, n)			      \\
2041			     : strncpy (dest, src, n))				      \\
2042			  : strncpy (dest, src, n)))
2043	EOT;
2044
2045};
2046
2047/* glibc's tgmath.h relies on an expression that is not an integer
2048   constant expression being treated as it was by GCC 4.4 and
2049   earlier.  */
2050fix = {
2051    hackname  = glibc_tgmath;
2052    files     = tgmath.h;
2053    select    = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2054    bypass    = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2055    c_fix     = format;
2056    c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
2057        "(__builtin_classify_type ((type) 0) == 9 && "
2058            "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2059    test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2060};
2061
2062/*
2063 * Fix these files to use the types we think they should for
2064 * ptrdiff_t, size_t, and wchar_t.
2065 *
2066 * This defines the types in terms of macros predefined by our 'cpp'.
2067 * This is supposedly necessary for glibc's handling of these types.
2068 * It's probably not necessary for anyone else, but it doesn't hurt.
2069 */
2070fix = {
2071    hackname  = gnu_types;
2072    files  = "sys/types.h";
2073    files  = "stdlib.h";
2074    files  = "sys/stdtypes.h";
2075    files  = "stddef.h";
2076    files  = "memory.h";
2077    files  = "unistd.h";
2078    bypass    = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2079    select    = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2080    c_fix     = gnu_type;
2081    /* The Solaris 10 headers already define these types correctly.  */
2082    mach   = '*-*-solaris2.1[0-9]*';
2083    not_machine = true;
2084
2085    test_text = "typedef long int ptrdiff_t; /* long int */\n"
2086                "typedef uint_t size_t; /* uint_t */\n"
2087                "typedef ushort_t wchar_t; /* ushort_t */";
2088};
2089
2090/*
2091 *  Fix HP & Sony's use of "../machine/xxx.h"
2092 *  to refer to:  <machine/xxx.h>
2093 */
2094fix = {
2095    hackname  = hp_inline;
2096    files     = sys/spinlock.h;
2097    files     = machine/machparam.h;
2098    select    = "[ \t]*#[ \t]*include[ \t]+"  '"\.\./machine/';
2099
2100    c_fix     = format;
2101    c_fix_arg = "%1<machine/%2.h>";
2102
2103    c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)"  '"\.\./machine/'
2104                '([a-z]+)\.h"';
2105
2106    test_text = ' # include "../machine/mumble.h"';
2107};
2108
2109/*
2110 *  Check for (...) in C++ code in HP/UX sys/file.h.
2111 */
2112fix = {
2113    hackname  = hp_sysfile;
2114    files     = sys/file.h;
2115    select    = "HPUX_SOURCE";
2116
2117    c_fix     = format;
2118    c_fix_arg = "(struct file *, ...)";
2119    c_fix_arg = '\(\.\.\.\)';
2120
2121    test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2122};
2123
2124/*
2125 *  Un-Hide a series of five FP defines from post-1999 compliance GCC:
2126 *  FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2127 */
2128fix = {
2129     hackname  = hppa_hpux_fp_macros;
2130     mach      = "hppa*-hp-hpux11*";
2131     files     = math.h;
2132     select    = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2133		 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2134		 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2135		 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2136		 "#[ \t]*define[ \t]*FP_NAN.*\n";
2137     c_fix     = format;
2138     c_fix_arg = <<- _EOFix_
2139	#endif /* _INCLUDE_HPUX_SOURCE */
2140
2141	#if defined(_INCLUDE_HPUX_SOURCE) || \
2142	   (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2143	%0#endif
2144
2145	#ifdef _INCLUDE_HPUX_SOURCE
2146
2147	_EOFix_;
2148
2149     test_text =
2150            "#  define FP_NORMAL     0\n"
2151            "#  define FP_ZERO       1\n"
2152            "#  define FP_INFINITE   2\n"
2153            "#  define FP_SUBNORMAL  3\n"
2154            "#  define FP_NAN        4\n";
2155};
2156
2157/*
2158 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2159 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2160 */
2161fix = {
2162    hackname  = hpux10_cpp_pow_inline;
2163    files     = fixinc-test-limits.h, math.h;
2164    select    = <<-	END_POW_INLINE
2165	^# +ifdef +__cplusplus
2166	 +\}
2167	 +inline +double +pow\(double +__d,int +__expon\) +\{
2168	[ 	]+return +pow\(__d,\(double\)__expon\);
2169	 +\}
2170	 +extern +"C" +\{
2171	#else
2172	# +endif
2173	END_POW_INLINE;
2174
2175    c_fix     = format;
2176    c_fix_arg = "";
2177
2178    test_text =
2179	"#    ifdef __cplusplus\n"
2180	"     }\n"
2181	"     inline double pow(double __d,int __expon) {\n"
2182	"\t return pow(__d,(double)__expon);\n"
2183	"     }\n"
2184	'     extern "C"' " {\n"
2185	"#else\n"
2186	"#    endif";
2187};
2188
2189fix = {
2190     hackname  = hpux11_cpp_pow_inline;
2191     files     = math.h;
2192     select    = " +inline double pow\\(double d,int expon\\) \\{\n"
2193                 " +return pow\\(d, \\(double\\)expon\\);\n"
2194                 " +\\}\n";
2195     c_fix     = format;
2196     c_fix_arg = "";
2197
2198     test_text =
2199            "   inline double pow(double d,int expon) {\n"
2200            "     return pow(d, (double)expon);\n"
2201            "   }\n";
2202};
2203
2204/*
2205 *  Fix hpux 10.X missing ctype declarations 1
2206 */
2207fix = {
2208    hackname = hpux10_ctype_declarations1;
2209    files    = ctype.h;
2210    select   = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2211    bypass   = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2212    c_fix     = format;
2213    c_fix_arg = "#ifdef _PROTOTYPES\n"
2214		"extern int __tolower(int);\n"
2215		"extern int __toupper(int);\n"
2216		"#else /* NOT _PROTOTYPES */\n"
2217		"extern int __tolower();\n"
2218		"extern int __toupper();\n"
2219		"#endif /* _PROTOTYPES */\n\n"
2220		"%0\n";
2221
2222    test_text = "#  define _toupper(__c)         __toupper(__c)\n";
2223};
2224
2225/*
2226 *  Fix hpux 10.X missing ctype declarations 2
2227 */
2228fix = {
2229    hackname = hpux10_ctype_declarations2;
2230    files    = ctype.h;
2231    select   = "^#  if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2232    bypass   = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2233    c_fix     = format;
2234    c_fix_arg = "%0\n\n"
2235		"#ifdef _PROTOTYPES\n"
2236		"     extern int _isalnum(int);\n"
2237		"     extern int _isalpha(int);\n"
2238		"     extern int _iscntrl(int);\n"
2239		"     extern int _isdigit(int);\n"
2240		"     extern int _isgraph(int);\n"
2241		"     extern int _islower(int);\n"
2242		"     extern int _isprint(int);\n"
2243		"     extern int _ispunct(int);\n"
2244		"     extern int _isspace(int);\n"
2245		"     extern int _isupper(int);\n"
2246		"     extern int _isxdigit(int);\n"
2247		"#  else /* not _PROTOTYPES */\n"
2248		"     extern int _isalnum();\n"
2249		"     extern int _isalpha();\n"
2250		"     extern int _iscntrl();\n"
2251		"     extern int _isdigit();\n"
2252		"     extern int _isgraph();\n"
2253		"     extern int _islower();\n"
2254		"     extern int _isprint();\n"
2255		"     extern int _ispunct();\n"
2256		"     extern int _isspace();\n"
2257		"     extern int _isupper();\n"
2258		"     extern int _isxdigit();\n"
2259		"#endif /* _PROTOTYPES */\n";
2260
2261    test_text = "#  if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2262		"     extern unsigned int *__SB_masks;\n";
2263};
2264
2265/*
2266 *  Fix hpux 10.X missing stdio declarations
2267 */
2268fix = {
2269    hackname = hpux10_stdio_declarations;
2270    files    = stdio.h;
2271    select   = "^#[ \t]*define _iob[ \t]*__iob";
2272    bypass   = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2273    c_fix     = format;
2274    c_fix_arg = "%0\n\n"
2275	"#  if defined(__STDC__) || defined(__cplusplus)\n"
2276	"     extern int snprintf(char *, size_t, const char *, ...);\n"
2277	"     extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2278	"#  else /* not __STDC__) || __cplusplus */\n"
2279	"     extern int snprintf();\n"
2280	"     extern int vsnprintf();\n"
2281	"#  endif /* __STDC__) || __cplusplus */\n";
2282
2283    test_text = "#  define _iob __iob\n";
2284};
2285
2286/*
2287 *  The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2288 *  As a result, we need to include sys/stdsyms.h in alloca.h.
2289 */
2290fix = {
2291    hackname  = hppa_hpux11_alloca;
2292    mach      = "hppa*-*-hpux11*";
2293    files     = alloca.h;
2294    select    = "#ifndef _STDDEF_INCLUDED";
2295    c_fix     = format;
2296    c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2297		"#  include <sys/stdsyms.h>\n"
2298		"#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2299		"%0";
2300
2301    test_text = "#ifndef _STDDEF_INCLUDED";
2302};
2303
2304/*
2305 *  Make sure hpux defines abs in header.
2306 */
2307fix = {
2308    hackname  = hpux11_abs;
2309    mach      = "*-hp-hpux11*";
2310    files     = stdlib.h;
2311    select    = "ifndef _MATH_INCLUDED";
2312    c_fix     = format;
2313    c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2314    test_text = "#ifndef _MATH_INCLUDED";
2315};
2316
2317/*
2318 *  Fix hpux11 __LWP_RWLOCK_VALID define
2319 */
2320fix = {
2321    hackname  = hpux11_lwp_rwlock_valid;
2322    mach      = "*-hp-hpux11*";
2323    files     = sys/pthread.h;
2324    select    = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2325    c_fix     = format;
2326    c_fix_arg = "#define __LWP_RWLOCK_VALID              -29551";
2327    test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2328};
2329
2330/*
2331 * hpux sendfile()
2332 */
2333fix = {
2334    hackname  = hpux11_extern_sendfile;
2335    mach      = "*-hp-hpux11.[12]*";
2336    files     = sys/socket.h;
2337    select    = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2338    c_fix     = format;
2339    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2340    test_text = "   extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2341        "                               const struct iovec *, int));\n";
2342};
2343
2344/*
2345 * hpux sendpath()
2346 */
2347fix = {
2348    hackname  = hpux11_extern_sendpath;
2349    mach      = "*-hp-hpux11.[12]*";
2350    files     = sys/socket.h;
2351    select    = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2352    c_fix     = format;
2353    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2354    test_text = "   extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2355        "                               const struct iovec *, int));\n";
2356};
2357
2358/*
2359 *  Keep HP-UX 11 from stomping on C++ math namespace
2360 *  with defines for fabsf.
2361 */
2362fix = {
2363    hackname  = hpux11_fabsf;
2364    mach      = "*-hp-hpux11*";
2365    files     = math.h;
2366    select    = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2367
2368    c_fix     = format;
2369    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2370
2371    test_text =
2372    "#ifdef _PA_RISC\n"
2373    "#  define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2374    "#endif";
2375};
2376
2377/*
2378 *  The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2379 *  in pthread.h need to be constant expressions to be standard complient.
2380 *  As a result, we need to remove the void * casts in the initializers
2381 *  (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2382 *  to use the long type.
2383 */
2384fix = {
2385    hackname  = hpux11_pthread_pointer;
2386    mach      = "*-hp-hpux11.[0-3]*";
2387    files     = sys/pthread.h;
2388    select    = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2389
2390    c_fix     = format;
2391    c_fix_arg = "long\t%2%3";
2392    test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2393};
2394
2395/*
2396 *  Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2397 */
2398fix = {
2399    hackname  = hpux11_pthread_const;
2400    mach      = "*-hp-hpux11.[0-3]*";
2401    files     = sys/pthread.h;
2402    select    = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2403
2404    c_fix     = format;
2405    c_fix_arg = "%11";
2406    test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2407};
2408
2409/*
2410 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2411 * being defined by having it define _hpux_size_t instead.
2412 */
2413fix = {
2414    hackname  = hpux11_size_t;
2415    mach      = "*-hp-hpux11*";
2416    select    = "__size_t";
2417
2418    c_fix     = format;
2419    c_fix_arg = "_hpux_size_t";
2420
2421    test_text =
2422    "#define __size_t size_t\n"
2423    "       extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2424};
2425
2426/*
2427 *  Fix hpux 11.00 broken snprintf declaration
2428 *  (third argument is char *, needs to be const char * to prevent
2429 *  spurious warnings with -Wwrite-strings or in C++).
2430 */
2431fix = {
2432    hackname = hpux11_snprintf;
2433    files    = stdio.h;
2434    select   = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2435                                    ' *(char *\*, *\.\.\.\);)';
2436    c_fix     = format;
2437    c_fix_arg = '%1 const %3';
2438
2439    test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2440                "extern int snprintf(char *, __size_t, char *, ...);\n"
2441                "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2442};
2443
2444/*
2445 *  Fix hpux 11.00 broken vsnprintf declaration
2446 */
2447fix = {
2448    hackname = hpux11_vsnprintf;
2449    files    = stdio.h;
2450    select   = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2451                                     'const char \*,) __va__list\);';
2452    c_fix     = format;
2453    c_fix_arg = "%1 __va_list);";
2454
2455    test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2456                                     ' __va__list);';
2457};
2458
2459/*
2460 *  Fix missing const in hpux vsscanf declaration
2461 */
2462fix = {
2463    hackname = hpux_vsscanf;
2464    mach    = "*-*-hpux*";
2465    files   = stdio.h;
2466    select  = '(extern int vsscanf\()char';
2467    c_fix   = format;
2468    c_fix_arg = "%1const char";
2469
2470    test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2471};
2472
2473/*
2474 *  get rid of bogus inline definitions in HP-UX 8.0
2475 */
2476fix = {
2477    hackname = hpux8_bogus_inlines;
2478    files    = math.h;
2479    select   = inline;
2480    bypass   = "__GNUG__";
2481    sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2482           "@extern \"C\" int abs(int);@";
2483    sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2484    sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2485    sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2486    test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2487                "inline double sqr(double v) { return v**0.5; }";
2488};
2489
2490/*
2491 * hpux intptr
2492 */
2493fix = {
2494    hackname  = hpux_c99_intptr;
2495    mach      = "*-hp-hpux11.3*";
2496    files     = stdint-hpux11.h, stdint.h;
2497    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2498        "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2499    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2500        "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2501    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2502        "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2503    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2504        "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2505    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2506        "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2507    sed       = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2508        "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2509    test_text = "#define PTRDIFF_MAX	INT32_MAX\n"
2510		"#define PTRDIFF_MIN	INT32_MIN\n"
2511		"#define INTPTR_MAX	INT32_MAX\n"
2512		"#define INTPTR_MIN	INT32_MIN\n"
2513		"#define UINTPTR_MAX	UINT32_MAX\n"
2514		"#define SIZE_MAX	UINT32_MAX\n";
2515};
2516
2517/*
2518 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2519 */
2520fix = {
2521    hackname  = hpux_c99_inttypes;
2522    mach      = "*-hp-hpux11.[23]*";
2523    files     = inttypes.h;
2524    files     = stdint-hpux11.h, stdint.h;
2525    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2526        "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2527    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2528        "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2529    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2530        "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2531    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2532        "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2533    test_text = "#define UINT8_C(__c)     __CONCAT_U__(__c)\n"
2534                "#define UINT16_C(__c)    __CONCAT_U__(__c)\n"
2535		"#define INT32_C(__c)     __CONCAT__(__c,l)\n"
2536		"#define UINT32_C(__c)     __CONCAT__(__c,ul)\n";
2537};
2538
2539/*
2540 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2541 */
2542fix = {
2543    hackname  = hpux_c99_inttypes2;
2544    mach      = "*-hp-hpux11.2*";
2545    files     = stdint-hpux11.h, stdint.h;
2546    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2547        "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2548    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2549        "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2550    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2551        "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2552    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2553        "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2554    test_text = "#  define	INT8_C(__c)	((signed char)(__c))\n"
2555                "#  define      UINT8_C(__c)    ((unsigned char)(__c))\n"
2556		"#  define      INT16_C(__c)    ((short)(__c))\n"
2557		"#  define	UINT16_C(__c)	((unsigned short)(__c))\n";
2558};
2559
2560/*
2561 * Fix broken and missing defines in inttypes.h
2562 */
2563fix = {
2564    hackname  = hpux_c99_inttypes3;
2565    mach      = "hppa*-hp-hpux11*";
2566    files     = inttypes.h;
2567    select    = "#define[ \t]INTPTR_MAX[ \t]*\n"
2568		"#define[ \t]UINTPTR_MAX[ \t]*\n";
2569    c_fix     = format;
2570    c_fix_arg = "#undef SIZE_MAX\n"
2571		"#define SIZE_MAX __SIZE_MAX__\n"
2572		"#ifdef __INTPTR_MAX__\n"
2573		"# undef INTPTR_MAX\n"
2574		"# define INTPTR_MAX __INTPTR_MAX__\n"
2575		"# undef INTPTR_MIN\n"
2576		"# define INTPTR_MIN (-INTPTR_MAX - 1)\n"
2577		"#endif\n"
2578		"#ifdef __UINTPTR_MAX__\n"
2579		"# undef UINTPTR_MAX\n"
2580		"# define UINTPTR_MAX __UINTPTR_MAX__\n"
2581		"#endif\n";
2582    test_text = "#define INTPTR_MAX\n"
2583		"#define UINTPTR_MAX\n";
2584};
2585
2586/*
2587 *  Fix hpux broken ctype macros
2588 */
2589fix = {
2590    hackname = hpux_ctype_macros;
2591    files    = ctype.h;
2592    select   = '((: |\()__SB_masks \? )'
2593	       '(__SB_masks\[__(alnum|c)\] & _IS)';
2594    c_fix     = format;
2595    c_fix_arg = "%1(int)%3";
2596
2597    test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2598		"# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2599};
2600
2601/*
2602 * hpux errno()
2603 */
2604fix = {
2605    hackname  = hpux_extern_errno;
2606    mach      = "*-hp-hpux10.*";
2607    mach      = "*-hp-hpux11.[0-2]*";
2608    files     = errno.h;
2609    select    = "^[ \t]*extern int errno;$";
2610    c_fix     = format;
2611    c_fix_arg = "#ifdef __cplusplus\n"
2612        "extern \"C\" {\n"
2613        "#endif\n"
2614        "%0\n"
2615        "#ifdef __cplusplus\n"
2616        "}\n"
2617        "#endif";
2618    test_text = "   extern int errno;\n";
2619};
2620
2621/*
2622 *  Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2623 */
2624fix = {
2625    hackname = hpux_htonl;
2626    files    = netinet/in.h;
2627    select   = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2628               "(/\\*\n"
2629               " \\* Macros for number representation conversion\\.\n"
2630               " \\*/\n"
2631               "#ifndef ntohl)";
2632    c_fix     = format;
2633    c_fix_arg = "#if 1\n%1";
2634
2635    test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2636                "/*\n"
2637                " * Macros for number representation conversion.\n"
2638                " */\n"
2639                "#ifndef ntohl\n"
2640                "#define ntohl(x)        (x)\n"
2641                "#define ntohs(x)        (x)\n"
2642                "#define htonl(x)        (x)\n"
2643                "#define htons(x)        (x)\n"
2644                "#endif\n"
2645                "#endif  /* ! _XOPEN_SOURCE_EXTENDED */";
2646};
2647
2648/*
2649 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2650 */
2651fix = {
2652    hackname  = hpux_imaginary_i;
2653    mach      = "ia64-hp-hpux11.*";
2654    files     = complex.h;
2655    select    = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2656    c_fix     = format;
2657    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2658    test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2659};
2660
2661/*
2662 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2663 */
2664fix = {
2665    hackname  = hpux_inttype_int8_t;
2666    mach      = "*-hp-hpux1[01].*";
2667    files     = sys/_inttypes.h;
2668    select    = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2669    c_fix     = format;
2670    c_fix_arg = "typedef signed char int%18_t;";
2671    test_text = "typedef char int_least8_t;\n"
2672                "typedef char int8_t;\n";
2673};
2674
2675/*
2676 * HP-UX long_double
2677 */
2678fix = {
2679    hackname  = hpux_long_double;
2680    mach      = "*-*-hpux10*";
2681    mach      = "*-*-hpux11.[012]*";
2682    files     = stdlib.h;
2683    select    = "extern[ \t]long_double[ \t]strtold";
2684    bypass    = "long_double_t";
2685    sed       = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2686    sed       = "s/long_double/long double/g";
2687
2688    test_text = "#  ifndef _LONG_DOUBLE\n"
2689		"#    define _LONG_DOUBLE\n"
2690		"     typedef struct {\n"
2691		"       unsigned int word1, word2, word3, word4;\n"
2692		"     } long_double;\n"
2693		"#  endif /* _LONG_DOUBLE */\n"
2694		"extern long_double strtold(const char *, char **);\n";
2695};
2696
2697/*
2698 * We cannot use the above rule on 11.31 because it removes the strtold
2699 * definition.  ia64 is OK with no hack, PA needs some help.
2700 */
2701fix = {
2702    hackname  = hpux_long_double_2;
2703    mach      = "hppa*-*-hpux11.3*";
2704    files     = stdlib.h;
2705    select    = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2706        "defined\\(_PROTOTYPES\\) \\|\\| "
2707        "defined\\(_LONG_DOUBLE_STRUCT\\)";
2708    c_fix     = format;
2709    c_fix_arg = "#  if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2710
2711    test_text = "#  if !defined(__ia64) || "
2712        "!defined(_PROTOTYPES) || "
2713        "defined(_LONG_DOUBLE_STRUCT)\n";
2714};
2715
2716/*
2717 *  Add missing braces to pthread initializer defines.
2718 */
2719fix = {
2720    hackname  = hpux_pthread_initializers;
2721    mach      = "*-hp-hpux11.[0-3]*";
2722    files     = sys/pthread.h;
2723    sed       = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2724		 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2725    sed       = "s@^[ \t]*1,[ \t]*\\\\"
2726		 "@\t{ 1, 0 }@";
2727    sed       = "/^[ \t]*0$/d";
2728    sed       = "s@__PTHREAD_MUTEX_VALID, 0"
2729		 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2730    sed       = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2731		 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2732    sed       = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2733		 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2734    sed       = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2735		 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2736    sed       = "s@^[ \t]*0, 0[ \t]*\\\\"
2737		 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2738    sed       = "s@__PTHREAD_COND_VALID, 0"
2739		 "@{ __PTHREAD_COND_VALID, 0 }@";
2740    sed       = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2741		 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2742    sed       = "s@__PTHREAD_RWLOCK_VALID, 0"
2743		 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2744    sed       = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2745		 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2746    sed       = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2747		 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2748    test_text = "#define PTHREAD_MUTEX_INITIALIZER  {\t\t\t\t\t\\\\\n"
2749		"\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2750		"\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2751		"\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2752		"\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2753		"\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2754		"\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2755		"}\n";
2756};
2757
2758/*
2759 *  Wrap spu_info in ifdef _KERNEL.  GCC cannot handle an array of unknown
2760 *  type and mpinfou is only defined when _KERNEL is set.
2761 */
2762fix = {
2763    hackname = hpux_spu_info;
2764    mach     = "*-hp-hpux*";
2765    /*
2766     *  It is tempting to omit the first "files" entry.  Do not.
2767     *  The testing machinery will take the first "files" entry as the name
2768     *  of a test file to play with.  It would be a nuisance to have a directory
2769     *  with the name "*".
2770     */
2771    files    = "ia64/sys/getppdp.h";
2772    files    = "*/sys/getppdp.h";
2773    select   = "^.*extern.*spu_info.*";
2774
2775    c_fix     = format;
2776    c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2777
2778    test_text = "extern union mpinfou spu_info[];";
2779};
2780
2781/*
2782 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2783 */
2784fix = {
2785    hackname  = hpux_stdint_least_fast;
2786    mach      = "*-hp-hpux11.2*";
2787    files     = stdint-hpux11.h, stdint.h;
2788    select    =
2789        "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2790    c_fix     = format;
2791    c-fix-arg = "#  define	UINT_%164_MAX	__UINT64_MAX__";
2792    test-text = "#  define       UINT_FAST64_MAX        ULLONG_MAX\n"
2793		"#  define       UINT_LEAST64_MAX        ULLONG_MAX\n";
2794};
2795
2796/*
2797 *  Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2798 */
2799fix = {
2800    hackname = hpux_longjmp;
2801    mach     = "*-hp-hpux*";
2802    files    = setjmp.h;
2803    select   = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2804
2805    c_fix     = format;
2806    c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2807
2808    test_text = 'extern void	longjmp __((jmp_buf, int));';
2809};
2810
2811/*
2812 *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2813 */
2814fix = {
2815    hackname = hpux_systime;
2816    files    = sys/time.h;
2817    select   = "^extern struct sigevent;";
2818
2819    c_fix     = format;
2820    c_fix_arg = "struct sigevent;";
2821
2822    test_text = 'extern struct sigevent;';
2823};
2824
2825/*
2826 *  Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2827 */
2828fix = {
2829    hackname  = huge_val_hex;
2830    files     = bits/huge_val.h, '*/bits/huge_val.h';
2831    select    = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2832    bypass    = "__builtin_huge_val";
2833
2834    c_fix     = format;
2835    c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2836
2837    test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2838};
2839
2840/*
2841 *  Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2842 */
2843fix = {
2844    hackname  = huge_valf_hex;
2845    files     = bits/huge_val.h, '*/bits/huge_val.h';
2846    select    = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2847    bypass    = "__builtin_huge_valf";
2848
2849    c_fix     = format;
2850    c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2851
2852    test_text = "#  define HUGE_VALF (__extension__ 0x1.0p255f)";
2853};
2854
2855/*
2856 *  Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2857 */
2858fix = {
2859    hackname  = huge_vall_hex;
2860    files     = bits/huge_val.h, '*/bits/huge_val.h';
2861    select    = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2862    bypass    = "__builtin_huge_vall";
2863
2864    c_fix     = format;
2865    c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2866
2867    test_text = "#  define HUGE_VALL (__extension__ 0x1.0p32767L)";
2868};
2869
2870/*
2871 *  Fix return type of abort and free
2872 */
2873fix = {
2874    hackname  = int_abort_free_and_exit;
2875    files     = stdlib.h;
2876    select    = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2877    bypass    = "_CLASSIC_ANSI_TYPES";
2878
2879    c_fix     = format;
2880    c_fix_arg = "void\t%1(";
2881
2882    test_text = "extern int abort(int);\n"
2883                "extern int free(void*);\n"
2884                "extern int exit(void*);";
2885};
2886
2887/*
2888 *  Fix various macros used to define ioctl numbers.
2889 *  The traditional syntax was:
2890 *
2891 *    #define _IO(n, x) (('n'<<8)+x)
2892 *    #define TIOCFOO _IO(T, 1)
2893 *
2894 *  but this does not work with the C standard, which disallows macro
2895 *  expansion inside strings.  We have to rewrite it thus:
2896 *
2897 *    #define _IO(n, x) ((n<<8)+x)
2898 *    #define TIOCFOO  _IO('T', 1)
2899 *
2900 *  The select expressions match too much, but the c_fix code is cautious.
2901 *
2902 *  _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2903 */
2904fix = {
2905    hackname  = io_quotes_def;
2906    select    = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2907    c_fix     = char_macro_def;
2908    c_fix_arg = "IO";
2909    test_text =
2910    "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2911    "#define _IOWN(x,y,t)  (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2912    "#define _IO(x,y)      ('x'<<8|y)";
2913    test_text =
2914    "#define XX_IO(x)        ('x'<<8|256)";
2915};
2916
2917/*
2918 *  Fix the usage of the ioctl macro numbers.
2919 */
2920fix = {
2921    hackname  = io_quotes_use;
2922    select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2923                "\\( *[^,']";
2924    c_fix     = char_macro_use;
2925    c_fix_arg = "IO";
2926    test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2927                "#define TIOCFOO \\\\\n"
2928                "BSD43__IOWR(T, 1) /* Some are multi-line */";
2929};
2930
2931/*
2932 *  Check for missing ';' in struct
2933 */
2934fix = {
2935    hackname = ip_missing_semi;
2936    files    = netinet/ip.h;
2937    select   = "}$";
2938    sed      = "/^struct/,/^};/s/}$/};/";
2939    test_text=
2940    "struct mumble {\n"
2941    "  union {\n"
2942    "    int x;\n"
2943    "  }\n"
2944    "}; /* mumbled struct */\n";
2945};
2946
2947/*
2948 *  Non-traditional "const" declaration in Irix's limits.h.
2949 */
2950fix = {
2951    hackname    = irix_limits_const;
2952    files       = fixinc-test-limits.h, limits.h;
2953    select      = "^extern const ";
2954    c_fix       = format;
2955    c_fix_arg   = "extern __const ";
2956    test_text   = "extern const char limit; /* test limits */";
2957};
2958
2959/*
2960 *  IRIX 5.x's stdio.h declares some functions that take a va_list as
2961 *  taking char *.  However, GCC uses void * for va_list, so
2962 *  calling vfprintf with a va_list fails in C++.  */
2963fix = {
2964    hackname  = irix_stdio_va_list;
2965    files     = stdio.h;
2966
2967    select = '/\* va_list \*/ char \*';
2968    c_fix  = format;
2969    c_fix_arg = "__gnuc_va_list";
2970    test_text =
2971    "extern int printf( const char *, /* va_list */ char * );";
2972};
2973
2974/*
2975 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2976 * use / * * / to concatenate tokens.
2977 */
2978fix = {
2979    hackname = kandr_concat;
2980    files  = "sparc/asm_linkage.h";
2981    files  = "sun*/asm_linkage.h";
2982    files  = "arm/as_support.h";
2983    files  = "arm/mc_type.h";
2984    files  = "arm/xcb.h";
2985    files  = "dev/chardefmac.h";
2986    files  = "dev/ps_irq.h";
2987    files  = "dev/screen.h";
2988    files  = "dev/scsi.h";
2989    files  = "sys/tty.h";
2990    files  = "Xm.acorn/XmP.h";
2991    files  = bsd43/bsd43_.h;
2992    select = '/\*\*/';
2993    c_fix     = format;
2994    c_fix_arg = '##';
2995    test_text = "#define __CONCAT__(a,b) a/**/b";
2996};
2997
2998/*
2999 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
3000 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
3001 * constant on recent versions of g++.
3002 */
3003fix = {
3004    hackname = linux_ia64_ucontext;
3005    files = "sys/ucontext.h";
3006    mach = "ia64-*-linux*";
3007    select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
3008             '->sc_gr\[0\]\) - \(char \*\) 0\)';
3009    c_fix = format;
3010    c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
3011    test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
3012	"\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
3013};
3014
3015/*
3016 *  Remove header file warning from sys/time.h.  Autoconf's
3017 *  AC_HEADER_TIME recommends to include both sys/time.h and time.h
3018 *  which causes warning on LynxOS.  Remove the warning.
3019 */
3020fix = {
3021    hackname  = lynxos_no_warning_in_sys_time_h;
3022    files     = sys/time.h;
3023    select    = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
3024    c_fix     = format;
3025    c_fix_arg = "";
3026    test_text = "#warning Using <time.h> instead of <sys/time.h>";
3027};
3028
3029/*
3030 *  Add missing declaration for putenv.
3031 */
3032fix = {
3033    hackname  = lynxos_missing_putenv;
3034    mach      = '*-*-lynxos*';
3035    files     = stdlib.h;
3036    bypass    = 'putenv[ \t]*\\(';
3037    select    = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3038    c_fix     = format;
3039    c_fix_arg = "%0\n"
3040        "extern int putenv				_AP((char *));";
3041    c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3042    test_text = "extern char *getenv	_AP((const char *));";
3043};
3044
3045/*
3046 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3047 *
3048 * On NetBSD, machine is a symbolic link to an architecture specific
3049 * directory name, so we can't match a specific file name here.
3050 */
3051fix = {
3052    hackname = machine_ansi_h_va_list;
3053    select   = "define[ \t]+_BSD_VA_LIST_[ \t]";
3054    bypass   = '__builtin_va_list';
3055
3056    c_fix     = format;
3057    c_fix_arg = "%1__builtin_va_list";
3058    c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3059
3060    test_text = " # define _BSD_VA_LIST_\tchar**";
3061};
3062
3063/*
3064 *  Fix non-ansi machine name defines
3065 */
3066fix = {
3067    hackname  = machine_name;
3068    c_test    = machine_name;
3069    c_fix     = machine_name;
3070
3071    test_text = "/* MACH_DIFF: */\n"
3072    "#if defined( i386 ) || defined( sparc ) || defined( vax )"
3073    "\n/* no uniform test, so be careful  :-) */";
3074};
3075
3076/*
3077 *  Some math.h files define struct exception (it's in the System V
3078 *  Interface Definition), which conflicts with the class exception defined
3079 *  in the C++ file std/stdexcept.h.  We redefine it to __math_exception.
3080 *  This is not a great fix, but I haven't been able to think of anything
3081 *  better.
3082 */
3083fix = {
3084    hackname  = math_exception;
3085    files     = math.h;
3086    select    = "struct exception";
3087    /*
3088     * This should be bypassed on __cplusplus, but some supposedly C++
3089     * aware headers, such as Solaris 8 and 9, don't wrap their struct
3090     * exception either.  So currently we bypass only for glibc, based on a
3091     * comment in the fixed glibc header.  Ick.
3092     */
3093    bypass    = 'We have a problem when using C\+\+|for C\+\+, '
3094		'_[a-z0-9A-Z_]+_exception; for C, exception';
3095    /* The Solaris 10 headers already get this right.  */
3096    mach   = '*-*-solaris2.1[0-9]*';
3097    not_machine = true;
3098    c_fix     = wrap;
3099
3100    c_fix_arg = "#ifdef __cplusplus\n"
3101                "#define exception __math_exception\n"
3102                "#endif\n";
3103
3104    c_fix_arg = "#ifdef __cplusplus\n"
3105                "#undef exception\n"
3106                "#endif\n";
3107
3108    test_text = "typedef struct exception t_math_exception;";
3109};
3110
3111/*
3112 *  This looks pretty broken to me.  ``dbl_max_def'' will contain
3113 *  "define DBL_MAX " at the start, when what we really want is just
3114 *  the value portion.  Can't figure out how to write a test case
3115 *  for this either  :-(
3116 */
3117fix = {
3118    hackname = math_huge_val_from_dbl_max;
3119    files    = math.h;
3120
3121    /*
3122     * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3123     * in math.h, this fix applies.
3124     */
3125    select   = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3126    bypass   = "define[ \t]+DBL_MAX";
3127
3128    shell    =
3129    /*
3130     *  See if we have a definition for DBL_MAX in float.h.
3131     *  If we do, we will replace the one in math.h with that one.
3132     */
3133
3134    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3135                   "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3136
3137    "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3138    "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3139			"s@DBL_MAX@'\"$dbl_max_def@\"\n"
3140    "\telse cat\n"
3141    "\tfi";
3142
3143    test_text =
3144    "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3145    "#define HUGE_VAL DBL_MAX";
3146};
3147
3148/*
3149 *  nested comment
3150 */
3151fix = {
3152    hackname  = nested_auth_des;
3153    files     = rpc/rpc.h;
3154    select    = '(/\*.*rpc/auth_des\.h>.*)/\*';
3155    c_fix     = format;
3156    c_fix_arg = "%1*/ /*";
3157    test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3158};
3159
3160/*
3161 *  Some versions of NetBSD don't expect the C99 inline semantics.
3162 */
3163fix = {
3164    hackname  = netbsd_c99_inline_1;
3165    mach      = "*-*-netbsd*";
3166    files     = signal.h;
3167    select    = "extern __inline int";
3168
3169    c_fix     = format;
3170    c_fix_arg = "extern\n"
3171		"#ifdef __GNUC_STDC_INLINE__\n"
3172		"__attribute__((__gnu_inline__))\n"
3173		"#endif\n"
3174		"__inline int";
3175
3176    test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3177};
3178
3179/*
3180 * netbsd_c99_inline_2
3181 */
3182fix = {
3183    hackname  = netbsd_c99_inline_2;
3184    mach      = "*-*-netbsd*";
3185    files     = signal.h;
3186    select    = "#define _SIGINLINE extern __inline";
3187
3188    c_fix     = format;
3189    c_fix_arg = <<- _EOArg_
3190	#ifdef __GNUC_STDC_INLINE__
3191	#define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3192	#else
3193	%0
3194	#endif
3195	_EOArg_;
3196
3197    test_text = "#define _SIGINLINE extern __inline";
3198};
3199
3200/*
3201 * NetBSD has a semicolon after the ending '}' for some extern "C".
3202 */
3203fix = {
3204    hackname  = netbsd_extra_semicolon;
3205    mach      = "*-*-netbsd*";
3206    files     = sys/cdefs.h;
3207    select    = "#define[ \t]*__END_DECLS[ \t]*};";
3208
3209    c_fix     = format;
3210    c_fix_arg = "#define __END_DECLS }";
3211
3212    test_text = "#define __END_DECLS };";
3213};
3214
3215/*
3216 * newlib's stdint.h has several failures to conform to C99.  The fix
3217 *  for these removed a comment that can be matched to identify unfixed
3218 *  versions.
3219 */
3220fix = {
3221    hackname  = newlib_stdint_1;
3222    files     = stdint-newlib.h, stdint.h;
3223    select    = "@todo - Add support for wint_t types";
3224    sed       = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3225    sed       = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3226    sed       = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3227    sed       = "s@#define INT_LEAST32_MIN.*@"
3228                  "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3229    sed       = "s@#define INT_LEAST32_MAX.*@"
3230                  "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3231    sed       = "s@#define UINT_LEAST32_MAX.*@"
3232                  "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3233    sed       = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3234                  '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3235    sed       = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3236                  '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3237    sed       = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3238                  '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3239    sed       = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3240    sed       = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3241    sed       = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3242    sed       = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3243    sed       = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3244    test_text = "/* @todo - Add support for wint_t types. */\n"
3245                "#define INT32_MIN (-2147483647-1)\n"
3246                "#define INT32_MAX 2147483647\n"
3247                "#define UINT32_MAX 4294967295U\n"
3248                "#define INT_LEAST32_MIN (-2147483647-1)\n"
3249                "#define INT_LEAST32_MAX 2147483647\n"
3250                "#define UINT_LEAST32_MAX 4294967295U\n"
3251                "#define INT_FAST8_MIN INT8_MIN\n"
3252                "#define INT_FAST8_MAX INT8_MAX\n"
3253                "#define UINT_FAST8_MAX UINT8_MAX\n"
3254                "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3255                "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3256                "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3257                "#define UINT8_C(x) x##U\n"
3258                "#define UINT16_C(x) x##U";
3259};
3260
3261/*
3262 * newlib_stdint_2
3263 */
3264fix = {
3265    hackname  = newlib_stdint_2;
3266    files     = stdint-newlib.h, stdint.h;
3267    select    = "@todo - Add support for wint_t types";
3268    c_fix     = format;
3269    c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3270                "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3271                "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3272                "#define WCHAR_MAX __WCHAR_MAX__\n"
3273                "#define WCHAR_MIN __WCHAR_MIN__\n"
3274                "#define WINT_MAX __WINT_MAX__\n"
3275                "#define WINT_MIN __WINT_MIN__\n\n"
3276                "%0";
3277    c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3278    test_text = "/* @todo - Add support for wint_t types. */\n"
3279                "/** Macros for minimum-width integer constant expressions */";
3280};
3281
3282/*
3283 *  NeXT 3.2 adds const prefix to some math functions.
3284 *  These conflict with the built-in functions.
3285 */
3286fix = {
3287    hackname  = next_math_prefix;
3288    files     = ansi/math.h;
3289    select    = "^extern[ \t]+double[ \t]+__const__[ \t]";
3290
3291    c_fix     = format;
3292    c_fix_arg = "extern double %1(";
3293    c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3294
3295    test_text = "extern\tdouble\t__const__\tmumble();";
3296};
3297
3298/*
3299 *  NeXT 3.2 uses the word "template" as a parameter for some
3300 *  functions. GCC reports an invalid use of a reserved key word
3301 *  with the built-in functions.
3302 */
3303fix = {
3304    hackname = next_template;
3305    files    = bsd/libc.h;
3306    select   = "[ \t]template\\)";
3307
3308    c_fix     = format;
3309    c_fix_arg = "(%1)";
3310    c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3311    test_text = "extern mumble( char * template); /* fix */";
3312};
3313
3314/*
3315 *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
3316 *  function prototypes. That conflicts with the  built-in functions.
3317 */
3318fix = {
3319    hackname = next_volitile;
3320    files    = ansi/stdlib.h;
3321    select   = "^extern[ \t]+volatile[ \t]+void[ \t]";
3322
3323    c_fix     = format;
3324    c_fix_arg = "extern void %1(";
3325    c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3326
3327    test_text = "extern\tvolatile\tvoid\tabort();";
3328};
3329
3330/*
3331 *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3332 *  Note that version 3 of the NeXT system has wait.h in a different directory,
3333 *  so that this code won't do anything.  But wait.h in version 3 has a
3334 *  conditional, so it doesn't need this fix.  So everything is okay.
3335 */
3336fix = {
3337    hackname  = next_wait_union;
3338    files     = sys/wait.h;
3339
3340    select    = 'wait\(union wait';
3341    c_fix     = format;
3342    c_fix_arg = "wait(void";
3343    test_text = "extern pid_d wait(union wait*);";
3344};
3345
3346/*
3347 *  a missing semi-colon at the end of the nodeent structure definition.
3348 */
3349fix = {
3350    hackname  = nodeent_syntax;
3351    files     = netdnet/dnetdb.h;
3352    select    = "char[ \t]*\\*na_addr[ \t]*$";
3353    c_fix     = format;
3354    c_fix_arg = "%0;";
3355    test_text = "char *na_addr\t";
3356};
3357
3358/*
3359 * Fix OpenBSD's NULL definition.
3360 */
3361fix = {
3362  hackname  = openbsd_null_definition;
3363  mach      = "*-*-openbsd*";
3364  files     = locale.h, stddef.h, stdio.h, string.h,
3365  time.h, unistd.h, wchar.h, sys/param.h;
3366  select    = "__GNUG__";
3367  c_fix = format;
3368  c_fix_arg = "#ifndef NULL\n"
3369	      "#ifdef __cplusplus\n"
3370	      "#ifdef __GNUG__\n"
3371	      "#define NULL\t__null\n"
3372	      "#else\t /* ! __GNUG__  */\n"
3373	      "#define NULL\t0L\n"
3374              "#endif\t /* __GNUG__  */\n"
3375	      "#else\t /* ! __cplusplus  */\n"
3376	      "#define NULL\t((void *)0)\n"
3377              "#endif\t /* __cplusplus  */\n"
3378              "#endif\t /* !NULL  */";
3379
3380  c_fix_arg = "^#ifndef[ \t]*NULL\n"
3381	      "^#ifdef[ \t]*__GNUG__\n"
3382  	      "^#define[ \t]*NULL[ \t]*__null\n"
3383  	      "^#else\n"
3384              "^#define[ \t]*NULL[ \t]*0L\n"
3385              "^#endif\n"
3386              "^#endif";
3387  test_text =
3388	"#ifndef NULL\n"
3389	"#ifdef  __GNUG__\n"
3390	"#define NULL    __null\n"
3391	"#else\n"
3392	"#define NULL    0L\n"
3393	"#endif\n"
3394	"#endif\n";
3395};
3396
3397/*
3398 *  obstack.h used casts as lvalues.
3399 *
3400 *  We need to change postincrements of casted pointers (which are
3401 *  then dereferenced and assigned into) of the form
3402 *
3403 *    *((TYPE*)PTRVAR)++ = (VALUE)
3404 *
3405 *  into expressions like
3406 *
3407 *    ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3408 *
3409 *  which is correct for the cases used in obstack.h since PTRVAR is
3410 *  of type char * and the value of the expression is not used.
3411 */
3412fix = {
3413    hackname  = obstack_lvalue_cast;
3414    files     = obstack.h;
3415    select    = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3416    c_fix     = format;
3417    c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3418    test_text = "*((void **) (h)->next_free)++ = (aptr)";
3419};
3420
3421/*
3422 * Fix OpenBSD's va_start define.
3423 */
3424fix = {
3425  hackname  = openbsd_va_start;
3426  mach      = "*-*-openbsd*";
3427  files     = stdarg.h;
3428  select    = '__builtin_stdarg_start';
3429  c_fix     = format;
3430  c_fix_arg = __builtin_va_start;
3431
3432  test_text = "#define va_start(v,l)   __builtin_stdarg_start((v),l)";
3433};
3434
3435/*
3436 *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3437 *  defining regex.h related types.  This causes libg++ build and usage
3438 *  failures.  Fixing this correctly requires checking and modifying 3 files.
3439 */
3440fix = {
3441    hackname = osf_namespace_a;
3442    files    = reg_types.h;
3443    files    = sys/lc_core.h;
3444    test     = " -r reg_types.h";
3445    test     = " -r sys/lc_core.h";
3446    test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
3447    test     = " -z \"`grep __regex_t regex.h`\"";
3448
3449    c_fix     = format;
3450    c_fix_arg = "__%0";
3451    c_fix_arg = "reg(ex|off|match)_t";
3452
3453    test_text = "`touch sys/lc_core.h`"
3454    "typedef struct {\n  int stuff, mo_suff;\n} regex_t;\n"
3455    "extern regex_t    re;\n"
3456    "extern regoff_t   ro;\n"
3457    "extern regmatch_t rm;\n";
3458};
3459
3460fix = {
3461    hackname = osf_namespace_c;
3462    files    = regex.h;
3463    test     = " -r reg_types.h";
3464    test     = " -r sys/lc_core.h";
3465    test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
3466    test     = " -z \"`grep __regex_t regex.h`\"";
3467
3468    select    = "#include <reg_types\.h>.*";
3469    c_fix     = format;
3470    c_fix_arg = "%0\n"
3471                "typedef __regex_t\tregex_t;\n"
3472                "typedef __regoff_t\tregoff_t;\n"
3473                "typedef __regmatch_t\tregmatch_t;";
3474
3475    test_text = "#include <reg_types.h>";
3476};
3477
3478/*
3479 * On broken glibc-2.3.3 systems an array of incomplete structures is
3480 * passed to __sigsetjmp.  Fix that to take a pointer instead.
3481 */
3482fix = {
3483    hackname  = pthread_incomplete_struct_argument;
3484    files     = pthread.h;
3485    select    = "struct __jmp_buf_tag";
3486    c_fix     = format;
3487    c_fix_arg = "%1 *%2%3";
3488    c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3489        "(__env)\\[1\\](.*)$";
3490    test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3491        "int __savemask);";
3492};
3493
3494/*
3495 *  Fix return type of fread and fwrite on sysV68
3496 */
3497fix = {
3498    hackname = read_ret_type;
3499    files    = stdio.h;
3500    select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3501    c_fix     = format;
3502    c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3503    c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3504
3505    test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3506};
3507
3508/*
3509 *  Fix casts as lvalues in glibc's <rpc/xdr.h>.
3510 */
3511fix = {
3512    hackname  = rpc_xdr_lvalue_cast_a;
3513    files     = rpc/xdr.h;
3514    select    = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3515    c_fix     = format;
3516    c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3517    test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3518                "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3519};
3520
3521/*
3522 * rpc_xdr_lvalue_cast_b
3523 */
3524fix = {
3525    hackname  = rpc_xdr_lvalue_cast_b;
3526    files     = rpc/xdr.h;
3527    select    = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3528    c_fix     = format;
3529    c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3530    test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3531                "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3532};
3533
3534/*
3535 *  function class(double x) conflicts with C++ keyword on rs/6000
3536 */
3537fix = {
3538    hackname  = rs6000_double;
3539    files     = math.h;
3540    select    = '[^a-zA-Z_]class\(';
3541
3542    c_fix     = format;
3543    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3544    c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3545
3546    test_text = "extern int class();";
3547};
3548
3549/*
3550 *  Wrong fchmod prototype on RS/6000.
3551 */
3552fix = {
3553    hackname  = rs6000_fchmod;
3554    files     = sys/stat.h;
3555    select    = 'fchmod\(char \*';
3556    c_fix     = format;
3557    c_fix_arg = "fchmod(int";
3558    test_text = "extern int fchmod(char *, mode_t);";
3559};
3560
3561/*
3562 *  parameters conflict with C++ new on rs/6000
3563 */
3564fix = {
3565    hackname  = rs6000_param;
3566    files     = "stdio.h";
3567    files     = "unistd.h";
3568
3569    select    = 'rename\(const char \*old, const char \*new\)';
3570    c_fix     = format;
3571    c_fix_arg = 'rename(const char *_old, const char *_new)';
3572
3573    test_text = 'extern int rename(const char *old, const char *new);';
3574};
3575
3576/*
3577 *  Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3578 *  for C99.  This is wrong for C++, which needs many C99 features, but
3579 *  only supports __restrict.
3580 */
3581fix = {
3582    hackname  = solaris___restrict;
3583    files     = sys/feature_tests.h;
3584    select    = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3585    mach      = "*-*-solaris2*";
3586    c_fix     = format;
3587    c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3588    	        "#else\n%0\n#endif";
3589    test_text = "#define	_RESTRICT_KYWD	restrict";
3590};
3591
3592/*
3593 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3594 * themselves, which are Sun Studio compiler intrinsics.  Remove _Imaginary_I
3595 * and imaginary definitions which are not supported by GCC.
3596 */
3597fix = {
3598    hackname  = solaris_complex;
3599    mach      = "*-*-solaris2.*";
3600    files     = complex.h;
3601    select    = "#define[ \t]_Complex_I[ \t]_Complex_I";
3602    sed	      = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3603		"#define\t_Complex_I\t(__extension__ 1.0iF)/";
3604    sed	      = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3605    sed	      = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3606    sed       = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3607    test_text = "#define	_Complex_I	_Complex_I\n"
3608    		"#define	complex		_Complex\n"
3609		"#define	_Imaginary_I	_Imaginary_I\n"
3610		"#define	imaginary	_Imaginary\n"
3611		"#undef	I\n"
3612		"#define	I		_Imaginary_I";
3613};
3614
3615/*
3616 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus.  Wrap in
3617 * extern "C" instead so libstdc++ can use it.
3618 */
3619fix = {
3620    hackname  = solaris_complex_cxx;
3621    mach      = "*-*-solaris2.*";
3622    files     = complex.h;
3623    sed	      = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3624    		"#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3625    sed	      = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3626		"#ifdef\t__cplusplus\\\n}\\\n#endif";
3627    test_text = "#if !defined(__cplusplus)\n"
3628		"#endif	/* !defined(__cplusplus) */";
3629};
3630
3631/*
3632 *  g++ rejects functions declared with both C and C++ linkage.
3633 */
3634fix = {
3635    hackname  = solaris_cxx_linkage;
3636    mach      = '*-*-solaris2*';
3637    files     = "iso/stdlib_iso.h";
3638    select    = "(#if __cplusplus >= 199711L)\n"
3639	        "(extern \"C\\+\\+\" \\{\n)"
3640	        "(.*(bsearch|qsort).*)";
3641    c_fix     = format;
3642    c_fix_arg = "%1 && !__GNUG__\n%2%3";
3643
3644    test_text =
3645    "#if __cplusplus >= 199711L\n"
3646    "extern \"C++\" {\n"
3647    "	void *bsearch(const void *, const void *, size_t, size_t,";
3648};
3649
3650/*
3651 *  Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3652 *  _STRICT_STDC, but uses it.
3653 */
3654fix = {
3655    hackname  = solaris_getc_strict_stdc;
3656    mach      = "*-*-solaris2*";
3657    files     = "iso/stdio_iso.h";
3658    select    = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3659    c_fix     = format;
3660    c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3661
3662    test_text =
3663    "#if	!defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3664};
3665
3666/*
3667 *  Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3668 */
3669fix = {
3670    hackname  = solaris_gets_c11;
3671    mach      = "*-*-solaris2*";
3672    files     = "iso/stdio_iso.h";
3673    select    = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3674
3675    c_fix     = format;
3676    c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3677    		"%1 __attribute__((__deprecated__));\n"
3678		"#endif";
3679
3680    test_text = "extern char	*gets(char *);";
3681};
3682
3683/*
3684 *  Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3685 */
3686fix = {
3687    hackname  = solaris_gets_cxx14;
3688    mach      = "*-*-solaris2*";
3689    files     = "iso/stdio_iso.h";
3690    select    = <<- _EOSelect_
3691(#if __STDC_VERSION__ < 201112L)
3692(extern char	\*gets\(char \*\) __ATTR_DEPRECATED;)
3693_EOSelect_;
3694    c_fix     = format;
3695    c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3696
3697    test_text = <<- _EOText_
3698#if __STDC_VERSION__ < 201112L
3699extern char	*gets(char *) __ATTR_DEPRECATED;
3700_EOText_;
3701};
3702
3703/*
3704 * Sun Solaris 2 has a version of sys/int_const.h that defines
3705 * UINT8_C and UINT16_C to unsigned constants.
3706 */
3707fix = {
3708    hackname  = solaris_int_const;
3709    files     = sys/int_const.h;
3710    mach      = '*-*-solaris2*';
3711    c_fix     = format;
3712    c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3713                "%1\n"
3714                "#define\tUINT16_C(c)\t(c)";
3715    select    = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3716                "(/\*.*\*/)\n"
3717                "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3718    test_text =
3719    "#define	UINT8_C(c)	__CONCAT__(c,u)\n"
3720    "/* CSTYLED */\n"
3721    "#define	UINT16_C(c)	__CONCAT__(c,u)";
3722};
3723
3724/*
3725 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3726 * UINT8_MAX and UINT16_MAX to unsigned constants.
3727 */
3728fix = {
3729    hackname  = solaris_int_limits_1;
3730    files     = sys/int_limits.h;
3731    mach      = '*-*-solaris2*';
3732    c_fix     = format;
3733    c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3734                "#define\tUINT16_MAX\t(65535)";
3735    select    = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3736                "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3737    test_text =
3738    "#define	UINT8_MAX	(255U)\n"
3739    "#define	UINT16_MAX	(65535U)";
3740};
3741
3742/*
3743 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3744 * INT_FAST16 limits to wrong values for sys/int_types.h.
3745 */
3746fix = {
3747    hackname  = solaris_int_limits_2;
3748    files     = sys/int_limits.h;
3749    mach      = '*-*-solaris2*';
3750    c_fix     = format;
3751    c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3752    select    = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3753    test_text =
3754    "#define	INT_FAST16_MAX INT16_MAX\n"
3755    "#define	UINT_FAST16_MAX UINT16_MAX\n"
3756    "#define	INT_FAST16_MIN	INT16_MIN";
3757};
3758
3759/*
3760 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3761 * SIZE_MAX as unsigned long.
3762 */
3763fix = {
3764    hackname  = solaris_int_limits_3;
3765    files     = sys/int_limits.h;
3766    mach      = '*-*-solaris2*';
3767    c_fix     = format;
3768    c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3769    select    = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3770    test_text =
3771    "#define	SIZE_MAX	4294967295UL";
3772};
3773
3774/*
3775 * Sun Solaris 10 defines several C99 math macros in terms of
3776 * builtins specific to the Studio compiler, in particular not
3777 * compatible with the GNU compiler.
3778 */
3779fix = {
3780    hackname = solaris_math_1;
3781    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3782    bypass = "__GNUC__";
3783    files = iso/math_c99.h;
3784    c_fix = format;
3785    c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3786    c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3787    test_text =
3788    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3789    "#undef	HUGE_VAL\n"
3790    "#define	HUGE_VAL	__builtin_huge_val\n"
3791    "#undef	HUGE_VALF\n"
3792    "#define	HUGE_VALF	__builtin_huge_valf\n"
3793    "#undef	HUGE_VALL\n"
3794    "#define	HUGE_VALL	__builtin_huge_vall";
3795};
3796
3797/*
3798 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3799 * exception.  Provide an alternative using GCC's builtin.
3800 */
3801fix = {
3802    hackname  = solaris_math_10;
3803    select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3804    files     = iso/math_c99.h;
3805    c_fix     = format;
3806    c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3807    c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3808                "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3809                    "[ \t]*\\\\\n"
3810                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3811                    "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3812                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3813                    "\\(-INFINITY\\);[ \t]*\\}\\)";
3814    test_text =
3815    '#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"'"\n"
3816    "#undef	isinf\n"
3817    "#define	isinf(x)	__extension__( \\\\\n"
3818    "			{ __typeof(x) __x_i = (x); \\\\\n"
3819    "			__x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3820    "			__x_i == (__typeof(__x_i)) (-INFINITY); })";
3821};
3822
3823/*
3824 * Solaris math INFINITY
3825 */
3826fix = {
3827    hackname = solaris_math_2;
3828    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3829    bypass = "__GNUC__";
3830    files = iso/math_c99.h;
3831    c_fix = format;
3832    c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3833    c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3834    test_text =
3835    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3836    "#undef	INFINITY\n"
3837    "#define	INFINITY	__builtin_infinity";
3838};
3839
3840/*
3841 * Solaris math NAN
3842 */
3843fix = {
3844    hackname = solaris_math_3;
3845    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3846    bypass = "__GNUC__";
3847    files = iso/math_c99.h;
3848    c_fix = format;
3849    c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3850    c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3851    test_text =
3852    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3853    "#undef	NAN\n"
3854    "#define	NAN	__builtin_nan";
3855};
3856
3857/*
3858 * Solaris math fpclassify
3859 */
3860fix = {
3861    hackname = solaris_math_4;
3862    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3863    bypass = "__GNUC__";
3864    files = iso/math_c99.h;
3865    c_fix = format;
3866    c_fix_arg = "#define\tfpclassify(x) \\\n"
3867                "  __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3868                    "FP_SUBNORMAL, FP_ZERO, (x))";
3869    c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3870    test_text =
3871    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3872    "#undef	fpclassify\n"
3873    "#define	fpclassify(x)	__builtin_fpclassify(x)";
3874};
3875
3876/*
3877 * Solaris math signbit
3878 */
3879fix = {
3880    hackname = solaris_math_8;
3881    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3882    bypass = "__GNUC__";
3883    files = iso/math_c99.h;
3884    c_fix = format;
3885    c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3886                "\t\t\t   ? __builtin_signbitf(x) \\\n"
3887                "\t\t\t   : sizeof(x) == sizeof(long double) \\\n"
3888                "\t\t\t     ? __builtin_signbitl(x) \\\n"
3889                "\t\t\t     : __builtin_signbit(x))";
3890    c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3891    test_text = <<- _EOText_
3892	#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"
3893	#undef	signbit
3894	#define	signbit(x)	__builtin_signbit(x)
3895	_EOText_;
3896};
3897
3898/*
3899 * Solaris math comparison macros
3900 */
3901fix = {
3902    hackname = solaris_math_9;
3903    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3904    bypass = "__GNUC__";
3905    files = iso/math_c99.h;
3906    c_fix = format;
3907    c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3908    c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3909                    "__builtin_[a-z]+\\(y\\)\\)";
3910    test_text =
3911    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3912    "#undef	isgreater\n"
3913    "#define	isgreater(x, y)		((x) __builtin_isgreater(y))\n"
3914    "#undef	isgreaterequal\n"
3915    "#define	isgreaterequal(x, y)	((x) __builtin_isgreaterequal(y))\n"
3916    "#undef	isless\n"
3917    "#define	isless(x, y)		((x) __builtin_isless(y))\n"
3918    "#undef	islessequal\n"
3919    "#define	islessequal(x, y)	((x) __builtin_islessequal(y))\n"
3920    "#undef	islessgreater\n"
3921    "#define	islessgreater(x, y)	((x) __builtin_islessgreater(y))\n"
3922    "#undef	isunordered\n"
3923    "#define	isunordered(x, y)	((x) __builtin_isunordered(y))";
3924};
3925
3926/*
3927 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3928 * warnings.
3929 */
3930fix = {
3931    hackname = solaris_math_11;
3932    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3933    files = iso/math_c99.h;
3934    c_fix = format;
3935    c_fix_arg = << _EOArg_
3936#undef	signbit
3937#define	signbit(x)	(sizeof(x) == sizeof(float) \
3938			   ? __builtin_signbitf(x) \
3939			   : sizeof(x) == sizeof(long double) \
3940			     ? __builtin_signbitl(x) \
3941			     : __builtin_signbit(x))
3942_EOArg_;
3943    c_fix_arg = << _EOArg_
3944^#undef[ 	]+signbit
3945#if defined\(__sparc\)
3946#define[ 	]+signbit\(x\)[ 	]+__extension__\( \\
3947[ 	]+\{[ 	]*__typeof\(x\)[ 	]*__x_s[ 	]*=[ 	]*\(x\);[ 	]*\\
3948[ 	]+\(int\)[ 	]*\(\*\(unsigned[ 	]*\*\)[ 	]*\&__x_s[ 	]*>>[ 	]*31\);[ 	]*\}\)
3949#elif defined\(__i386\) \|\| defined\(__amd64\)
3950#define[ 	]+signbit\(x\)[ 	]+__extension__\( \\
3951[ 	]+\{ __typeof\(x\) __x_s = \(x\); \\
3952[ 	]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3953[ 	]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3954[ 	]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3955[ 	]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3956[ 	]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3957#endif
3958_EOArg_;
3959    test_text = << _EOText_
3960/* @(#)math_c99.h	1.14	13/03/27 */
3961#undef	signbit
3962#if defined(__sparc)
3963#define	signbit(x)	__extension__( \\
3964				{ __typeof(x) __x_s = (x); \\
3965				(int) (*(unsigned *) &__x_s >> 31); })
3966#elif defined(__i386) || defined(__amd64)
3967#define	signbit(x)	__extension__( \\
3968			{ __typeof(x) __x_s = (x); \\
3969			(sizeof (__x_s) == sizeof (float) ? \\
3970			(int) (*(unsigned *) &__x_s >> 31) : \\
3971			sizeof (__x_s) == sizeof (double) ? \\
3972			(int) (((unsigned *) &__x_s)[1] >> 31) : \\
3973			(int) (((unsigned short *) &__x_s)[4] >> 15)); })
3974#endif
3975_EOText_;
3976};
3977
3978/*
3979 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3980 */
3981fix = {
3982    hackname  = solaris_math_12;
3983    files     = math.h;
3984    mach      = '*-*-solaris2*';
3985    select    = '#undef.*_GLIBCXX_USE_C99_MATH';
3986    sed       = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3987    test_text = << _EOText_
3988#if __cplusplus >= 201103L
3989#undef  _GLIBCXX_USE_C99_MATH
3990#undef  _GLIBCXX_USE_C99_MATH_TR1
3991#endif
3992_EOText_;
3993};
3994
3995/*
3996 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3997 * structure.  As such, it need two levels of brackets, but only
3998 * contains one.  Wrap the macro definition in an extra layer.
3999 */
4000fix = {
4001    hackname = solaris_once_init_1;
4002    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4003    files = pthread.h;
4004    mach = '*-*-solaris*';
4005    c_fix = format;
4006    c_fix_arg = "%1{%2}%3";
4007    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
4008    test_text =
4009    '#pragma ident	"@(#)pthread.h	1.37	04/09/28 SMI"'"\n"
4010    "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
4011};
4012
4013/*
4014 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
4015 * posix_spawn declarations, which doesn't work with C++.
4016 */
4017fix = {
4018    hackname  = solaris_posix_spawn_restrict;
4019    files     = spawn.h;
4020    mach      = '*-*-solaris2*';
4021    c_fix     = format;
4022    c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
4023    select    = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
4024    test_text =
4025    "char *const argv[_RESTRICT_KYWD],\n"
4026    "char *const envp[_RESTRICT_KYWD]);";
4027};
4028
4029/*
4030 *  The pow overloads with int were removed in C++ 2011 DR 550.
4031 */
4032fix = {
4033    hackname  = solaris_pow_int_overload;
4034    mach      = '*-*-solaris2*';
4035    files     = "iso/math_iso.h";
4036    select    = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4037		" *\\{[^{}]*\n[^{}]*\\}";
4038    c_fix     = format;
4039    c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4040
4041    test_text =
4042    "	inline long double pow(long double __X, int __Y) { return\n"
4043    "		__powl(__X, (long double) (__Y)); }";
4044};
4045
4046/*
4047 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4048 *  fields of the pthread_rwlock_t structure, which are of type
4049 *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
4050 *  defined (e.g. by -ansi) it is a union. So change the initializer
4051 *  to "{0}" instead.
4052 */
4053fix = {
4054    hackname = solaris_rwlock_init_1;
4055    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4056    files = pthread.h;
4057    mach = '*-*-solaris*';
4058    c_fix = format;
4059    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4060                "%0\n"
4061                "#else\n"
4062                "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4063                "#endif";
4064    c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4065                "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4066
4067    test_text =
4068    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
4069    "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4070};
4071
4072/*
4073 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
4074 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
4075 */
4076fix = {
4077    hackname  = solaris_std___filbuf;
4078    files     = stdio.h;
4079    mach      = '*-*-solaris2*';
4080    bypass    = "using std::__filbuf";
4081    select    = "(using std::perror;\n)(#endif)";
4082    c_fix     = format;
4083    c_fix_arg = "%1#ifndef _LP64\n"
4084		"using std::__filbuf;\n"
4085		"using std::__flsbuf;\n"
4086		"#endif\n%2";
4087
4088    test_text = "using std::perror;\n"
4089		"#endif";
4090};
4091
4092/*
4093 *  Solaris <stdio.h> shouldn't use std::gets for C++14.
4094 */
4095fix = {
4096    hackname  = solaris_std_gets_cxx14;
4097    mach      = "*-*-solaris2*";
4098    files     = "stdio.h";
4099    select    = "using std::gets;";
4100
4101    c_fix     = format;
4102    c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4103
4104    test_text = "using std::gets;";
4105};
4106
4107/*
4108 * Sun Solaris 8 has what appears to be some gross workaround for
4109 * some old version of their c++ compiler.  G++ doesn't want it
4110 * either, but doesn't want to be tied to SunPRO version numbers.
4111 */
4112fix = {
4113    hackname = solaris_stdio_tag;
4114    files    = stdio_tag.h;
4115
4116    select   = '__cplusplus < 54321L';
4117    /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4118       "!defined(__GNUC__)" so we no longer need to fix it.  */
4119    bypass   = '__GNUC__';
4120    sed      = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4121
4122    test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4123};
4124
4125/*
4126 *  Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4127 */
4128fix = {
4129    hackname  = solaris_stdlib_noreturn;
4130    mach      = "*-*-solaris2*";
4131    files     = "iso/stdlib_c99.h";
4132    select    = "(extern) _Noreturn (void quick_exit\\(int\\));";
4133
4134    c_fix     = format;
4135    c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4136
4137    test_text = "extern _Noreturn void quick_exit(int);";
4138};
4139
4140/*
4141 *  a missing semi-colon at the end of the statsswtch structure definition.
4142 */
4143fix = {
4144    hackname  = statsswtch;
4145    files     = rpcsvc/rstat.h;
4146    select    = "boottime$";
4147    c_fix     = format;
4148    c_fix_arg = "boottime;";
4149    test_text = "struct statswtch {\n  int boottime\n};";
4150};
4151
4152/*
4153 *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4154 *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4155 *  OK too.
4156 */
4157fix = {
4158    hackname = stdio_stdarg_h;
4159    files    = stdio.h;
4160    bypass   = "include.*(stdarg\.h|machine/ansi\.h)";
4161    /*
4162     * On Solaris 10, this fix is unncessary; <stdio.h> includes
4163     * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4164      */
4165    mach     = '*-*-solaris2.1[0-9]*';
4166    not_machine = true;
4167
4168    c_fix     = wrap;
4169
4170    c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4171
4172    test_text = "";
4173};
4174
4175/*
4176 *  Don't use or define the name va_list in stdio.h.  This is for
4177 *  ANSI.  Note _BSD_VA_LIST_ is dealt with elsewhere.  The presence
4178 *  of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4179 *  indicate that the header knows what it's doing -- under SUSv2,
4180 *  stdio.h is required to define va_list, and we shouldn't break
4181 *  that.
4182 */
4183fix = {
4184    hackname = stdio_va_list;
4185    files    = stdio.h;
4186    bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4187    /*
4188     * On Solaris 10, the definition in
4189     * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4190     * there is therefore no need for this fix there.
4191     */
4192    mach = '*-*-solaris2.1[0-9]*';
4193    not_machine = true;
4194
4195    /*
4196     * Use __gnuc_va_list in arg types in place of va_list.
4197     * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
4198     * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
4199     * trailing parentheses and semicolon save all other systems from this.
4200     * Define __not_va_list__ (something harmless and unused)
4201     * instead of va_list.
4202     * Don't claim to have defined va_list.
4203     */
4204    sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4205	  "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4206          "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4207          "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4208          "s@ va_list@ __not_va_list__@\n"
4209          "s@\\*va_list@*__not_va_list__@\n"
4210          "s@ __va_list)@ __gnuc_va_list)@\n"
4211          "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4212           "@typedef \\1 __not_va_list__;@\n"
4213	  "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4214          "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4215          "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4216          "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4217          "s@VA_LIST@DUMMY_VA_LIST@\n"
4218          "s@_Va_LIST@_VA_LIST@";
4219    test_text = "extern void mumble( va_list);";
4220};
4221
4222/*
4223 *  Fix headers that use va_list from stdio.h to use the updated
4224 *  va_list from the stdio_va_list change.  Note _BSD_VA_LIST_ is
4225 *  dealt with elsewhere.  The presence of __gnuc_va_list,
4226 *  __DJ_va_list, or _G_va_list is taken to indicate that the header
4227 *  knows what it's doing.
4228 */
4229fix = {
4230    hackname = stdio_va_list_clients;
4231    files    = com_err.h;
4232    files    = cps.h;
4233    files    = curses.h;
4234    files    = krb5.h;
4235    files    = lc_core.h;
4236    files    = pfmt.h;
4237    files    = wchar.h;
4238    files    = curses_colr/curses.h;
4239    bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4240    /* Don't fix, if we use va_list from stdarg.h, or if the use is
4241       otherwise protected.  */
4242    bypass   = 'include <stdarg\.h>|#ifdef va_start';
4243
4244    /*
4245     * Use __gnuc_va_list in arg types in place of va_list.
4246     * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
4247     * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
4248     * trailing parentheses and semicolon save all other systems from this.
4249     * Define __not_va_list__ (something harmless and unused)
4250     * instead of va_list.
4251     * Don't claim to have defined va_list.
4252     */
4253    sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4254	  "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4255          "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4256          "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4257          "s@ va_list@ __not_va_list__@\n"
4258          "s@\\*va_list@*__not_va_list__@\n"
4259          "s@ __va_list)@ __gnuc_va_list)@\n"
4260          "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4261           "@typedef \\1 __not_va_list__;@\n"
4262	  "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4263          "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4264          "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4265          "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4266          "s@VA_LIST@DUMMY_VA_LIST@\n"
4267          "s@_Va_LIST@_VA_LIST@";
4268    test_text = "extern void mumble( va_list);";
4269};
4270
4271/*
4272 *  "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4273 *  is "!defined( __STRICT_ANSI__ )"
4274 */
4275fix = {
4276    hackname = strict_ansi_not;
4277    select   = "^([ \t]*#[ \t]*if.*)"
4278               "(!__STDC__"
4279               "|__STDC__[ \t]*==[ \t]*0"
4280               "|__STDC__[ \t]*!=[ \t]*1"
4281               "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4282    /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4283    bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4284    /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4285       is not defined by GCC, so it is safe.  */
4286    bypass = '__SCO_VERSION__.*__STDC__ != 1';
4287    c_test   = stdc_0_in_system_headers;
4288
4289    c_fix     = format;
4290    c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4291
4292    test_text = "#if !__STDC__ \n"
4293                "#if __STDC__ == 0\n"
4294                "#if __STDC__ != 1\n"
4295                "#if __STDC__ - 0 == 0"
4296               "/* not std C */\nint foo;\n"
4297               "\n#end-end-end-end-if :-)";
4298};
4299
4300/*
4301 *  "__STDC__-0==0"
4302 *  is "!defined( __STRICT_ANSI__ )" on continued #if-s
4303 */
4304fix = {
4305    hackname = strict_ansi_not_ctd;
4306    files    = math.h, limits.h, stdio.h, signal.h,
4307               stdlib.h, sys/signal.h, time.h;
4308    /*
4309     * Starting at the beginning of a line, skip white space and
4310     * a leading "(" or "&&" or "||".  One of those must be found.
4311     * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4312     * expression.  If these are nested, then they must accumulate
4313     * because we won't match any closing parentheses.  Finally,
4314     * after skipping over all that, we must then match our suspect
4315     * phrase:  "__STDC__-0==0" with or without white space.
4316     */
4317    select   = "^([ \t]*" '(\(|&&|\|\|)'
4318               "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4319               "[ \t(]*)"
4320               "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4321    c_test   = stdc_0_in_system_headers;
4322
4323    c_fix     = format;
4324    c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4325
4326    test_text = "#if 1 && \\\\\n"
4327               "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4328               "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4329               "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4330               "int foo;\n#endif";
4331};
4332
4333/*
4334 *  "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4335 *  is "defined( __STRICT_ANSI__ )"
4336 */
4337fix = {
4338    hackname = strict_ansi_only;
4339    select   = "^([ \t]*#[ \t]*if.*)"
4340               "(__STDC__[ \t]*!=[ \t]*0"
4341               "|__STDC__[ \t]*==[ \t]*1"
4342               "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4343               "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4344    c_test   = stdc_0_in_system_headers;
4345
4346    c_fix     = format;
4347    c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4348
4349    test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4350};
4351
4352/*
4353 *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4354 *  in prototype without previous definition.
4355 */
4356fix = {
4357    hackname  = struct_file;
4358    files     = rpc/xdr.h;
4359    select    = '^.*xdrstdio_create.*struct __file_s';
4360    c_fix     = format;
4361    c_fix_arg = "struct __file_s;\n%0";
4362    test_text = "extern void xdrstdio_create( struct __file_s* );";
4363};
4364
4365/*
4366 *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4367 *  in prototype without previous definition.
4368 *
4369 *  Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4370 *  function, and does define it.
4371 */
4372fix = {
4373    hackname  = struct_sockaddr;
4374    files     = rpc/auth.h;
4375    select    = "^.*authdes_create.*struct sockaddr[^_]";
4376    bypass    = "<sys/socket\.h>";
4377    bypass    = "struct sockaddr;\n";
4378    c_fix     = format;
4379    c_fix_arg = "struct sockaddr;\n%0";
4380    test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4381};
4382
4383/*
4384 *  Apply fix this to all OSs since this problem seems to effect
4385 *  more than just SunOS.
4386 */
4387fix = {
4388    hackname = sun_auth_proto;
4389    files    = rpc/auth.h;
4390    files    = rpc/clnt.h;
4391    files    = rpc/svc.h;
4392    files    = rpc/xdr.h;
4393    bypass   = "__cplusplus";
4394    /*
4395     *  Select those files containing '(*name)()'.
4396     */
4397    select    = '\(\*[a-z][a-z_]*\)\(\)';
4398
4399    c_fix     = format;
4400    c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4401                "#else\n%1();%2\n#endif";
4402    c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4403
4404    test_text =
4405    "struct auth_t {\n"
4406    "    int (*name)(); /* C++ bad */\n"
4407    "};";
4408};
4409
4410/*
4411 *  Fix bogus #ifdef on SunOS 4.1.
4412 */
4413fix = {
4414    hackname  = sun_bogus_ifdef;
4415    files     = "hsfs/hsfs_spec.h";
4416    files     = "hsfs/iso_spec.h";
4417    select    = '#ifdef(.*\|\|.*)';
4418    c_fix     = format;
4419    c_fix_arg = "#if%1";
4420
4421    test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
4422};
4423
4424/*
4425 *  Fix the CAT macro in SunOS memvar.h.
4426 */
4427fix = {
4428    hackname  = sun_catmacro;
4429    files     = pixrect/memvar.h;
4430    select    = "^#define[ \t]+CAT\\(a,b\\).*";
4431    c_fix     = format;
4432
4433    c_fix_arg =
4434    "#ifdef __STDC__\n"
4435    "#  define CAT(a,b) a##b\n"
4436    "#else\n%0\n#endif";
4437
4438    test_text =
4439    "#define CAT(a,b)\ta/**/b";
4440};
4441
4442/*
4443 *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4444 *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4445 */
4446fix = {
4447    hackname = sun_malloc;
4448    files    = malloc.h;
4449    bypass   = "_CLASSIC_ANSI_TYPES";
4450
4451    sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4452    sed   = "s/int[ \t][ \t]*free/void\tfree/g";
4453    sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4454    sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4455    sed   = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4456
4457    test_text =
4458    "typedef char *\tmalloc_t;\n"
4459    "int \tfree();\n"
4460    "char*\tmalloc();\n"
4461    "char*\tcalloc();\n"
4462    "char*\trealloc();";
4463};
4464
4465/*
4466 *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
4467 */
4468fix = {
4469    hackname = sun_rusers_semi;
4470    files    = rpcsvc/rusers.h;
4471    select   = "_cnt$";
4472    sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
4473    test_text = "struct mumble\n  int _cnt\n};";
4474};
4475
4476/*
4477 *  signal.h on SunOS defines signal using (),
4478 *  which causes trouble when compiling with g++ -pedantic.
4479 */
4480fix = {
4481    hackname = sun_signal;
4482    files    = sys/signal.h;
4483    files    = signal.h;
4484    select   = "^void\t" '\(\*signal\(\)\)\(\);.*';
4485
4486    c_fix     = format;
4487    c_fix_arg =
4488          "#ifdef __cplusplus\n"
4489          "void\t(*signal(...))(...);\n"
4490          "#else\n%0\n#endif";
4491
4492    test_text = "void\t(*signal())();";
4493};
4494
4495/*
4496 *  Correct the return type for strlen in strings.h in SunOS 4.
4497 */
4498fix = {
4499    hackname = sunos_strlen;
4500    files    = strings.h;
4501    select   = "int[ \t]*strlen\\(\\);(.*)";
4502    c_fix     = format;
4503    c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4504    test_text = " int\tstrlen(); /* string length */";
4505};
4506
4507/*
4508 *  Linux kernel's vt.h breaks C++
4509 */
4510fix = {
4511    hackname  = suse_linux_vt_cxx;
4512    files     = linux/vt.h;
4513
4514    select    = "^[ \t]*unsigned int new;";
4515    c_fix     = format;
4516    c_fix_arg = "unsigned int newev;";
4517
4518    test_text = "        unsigned int new;      /* New console (if changing) */";
4519};
4520
4521/*
4522 *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4523 *  that is visible to any ANSI compiler using this include.  Simply
4524 *  delete the lines that #define some string functions to internal forms.
4525 */
4526fix = {
4527    hackname = svr4_disable_opt;
4528    files    = string.h;
4529    select   = '#define.*__std_hdr_';
4530    sed      = '/#define.*__std_hdr_/d';
4531    test_text = "#define strlen __std_hdr_strlen\n";
4532};
4533
4534/*
4535 *   Fix broken decl of getcwd present on some svr4 systems.
4536 */
4537fix = {
4538    hackname = svr4_getcwd;
4539    files    = stdlib.h;
4540    files    = unistd.h;
4541    files    = prototypes.h;
4542    select   = 'getcwd\(char \*, int\)';
4543
4544    c_fix     = format;
4545    c_fix_arg = "getcwd(char *, size_t)";
4546
4547    test_text = "extern char* getcwd(char *, int);";
4548};
4549
4550/*
4551 *   Fix broken decl of profil present on some svr4 systems.
4552 */
4553fix = {
4554    hackname = svr4_profil;
4555    files    = stdlib.h;
4556    files    = unistd.h;
4557
4558    select    =
4559    'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4560    c_fix     = format;
4561    c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4562
4563    test_text =
4564    'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4565};
4566
4567/*
4568 * Correct types for signal handler constants like SIG_DFL; they might be
4569 * void (*) (), and should be void (*) (int).  C++ doesn't like the
4570 * old style.
4571 */
4572fix = {
4573    hackname = svr4_sighandler_type;
4574    files = sys/signal.h;
4575    select = 'void *\(\*\)\(\)';
4576    c_fix = format;
4577    c_fix_arg = "void (*)(int)";
4578    test_text = "#define SIG_DFL (void(*)())0\n"
4579                "#define SIG_IGN (void (*)())0\n";
4580};
4581
4582/*
4583 *  Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4584 *  function 'getrnge' in <regexp.h> before they declare it.  For these
4585 *  systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4586 *  early on.
4587 *
4588 *  'getrnge' traditionally manipulates a file-scope global called 'size',
4589 *  so put the declaration right after the declaration of 'size'.
4590 *
4591 *  Don't do this if there is already a `static void getrnge' declaration
4592 *  present, since this would cause a redeclaration error.  Solaris 2.x has
4593 *  such a declaration.
4594 */
4595fix = {
4596    hackname  = svr4_undeclared_getrnge;
4597    files     = regexp.h;
4598    select    = "getrnge";
4599    bypass    = "static void getrnge";
4600    c_fix     = format;
4601    c_fix_arg = "%0\n"
4602                "static int getrnge ();";
4603    c_fix_arg = "^static int[ \t]+size;";
4604    test_text = "static int size;\n"
4605                "/* stuff which calls getrnge() */\n"
4606                "static getrnge()\n"
4607                "{}";
4608};
4609
4610/*
4611 *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4612 *  in string.h on sysV68
4613 *  Correct the return type for strlen in string.h on Lynx.
4614 *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4615 *  Add missing const for strdup on OSF/1 V3.0.
4616 *  On sysV88 layout is slightly different.
4617 */
4618fix = {
4619    hackname = sysv68_string;
4620    files    = testing.h;
4621    files    = string.h;
4622    bypass   = "_CLASSIC_ANSI_TYPES";
4623
4624    sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4625    sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4626    sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4627
4628    sed = "/^extern char$/N";
4629    sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4630
4631    sed = "/^extern int$/N";
4632    sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4633
4634    sed = "/^\tstrncmp(),$/N";
4635    sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4636            '\1;' "\\\nextern unsigned int\\\n\\2/";
4637
4638    test_text =
4639    "extern int strlen();\n"
4640
4641    "extern int ffs(long);\n"
4642
4643    "extern char\n"
4644    "\t*memccpy(),\n"
4645    "\tmemcpy();\n"
4646
4647    "extern int\n"
4648    "\tstrcmp(),\n"
4649    "\tstrncmp(),\n"
4650    "\tstrlen(),\n"
4651    "\tstrspn();\n"
4652
4653    "extern int\n"
4654    "\tstrlen(), strspn();";
4655};
4656
4657/*
4658 *  Fix return type of calloc, malloc, realloc, bsearch and exit
4659 */
4660fix = {
4661    hackname = sysz_stdlib_for_sun;
4662    files    = stdlib.h;
4663    bypass   = "_CLASSIC_ANSI_TYPES";
4664
4665    select    = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4666    c_fix     = format;
4667    c_fix_arg = "void *\t%1(";
4668
4669    test_text =
4670    "extern char*\tcalloc(size_t);\n"
4671    "extern char*\tmalloc(size_t);\n"
4672    "extern char*\trealloc(void*,size_t);\n"
4673    "extern char*\tbsearch(void*,size_t,size_t);\n";
4674};
4675
4676/*
4677 * __thread is now a keyword.
4678 */
4679fix = {
4680    hackname  = thread_keyword;
4681    files     = "pthread.h";
4682    files     = bits/sigthread.h, '*/bits/sigthread.h';
4683    select    = "([* ])__thread([,)])";
4684    c_fix     = format;
4685    c_fix_arg = "%1__thr%2";
4686
4687    test_text =
4688	"extern int pthread_create (pthread_t *__restrict __thread,\n"
4689	"extern int pthread_kill (pthread_t __thread, int __signo);\n"
4690	"extern int pthread_cancel (pthread_t __thread);";
4691};
4692
4693/*
4694 *  if the #if says _cplusplus, not the double underscore __cplusplus
4695 *  that it should be
4696 */
4697fix = {
4698    hackname = tinfo_cplusplus;
4699    files    = tinfo.h;
4700    select   = "[ \t]_cplusplus";
4701
4702    c_fix     = format;
4703    c_fix_arg = " __cplusplus";
4704    test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4705};
4706
4707/*
4708 *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
4709 */
4710fix = {
4711    hackname  = ultrix_const;
4712    files     = stdio.h;
4713    select    = 'perror\( char \*';
4714
4715    c_fix     = format;
4716    c_fix_arg = "%1 const %3 *__";
4717    c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4718                "[ \t]+(char|void) \\*__";
4719
4720    test_text =
4721    "extern void perror( char *__s );\n"
4722    "extern int fputs( char *__s, FILE *);\n"
4723    "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4724    "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4725    "extern int scanf( char *__format, ...);\n";
4726};
4727
4728/*
4729 *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
4730 */
4731fix = {
4732    hackname  = ultrix_const2;
4733    files     = stdio.h;
4734
4735    select    = '\*fopen\( char \*';
4736    c_fix     = format;
4737    c_fix_arg = "%1( const char *%3, const char *";
4738    c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4739               "[ \t]*char[ \t]*\\*([^,]*),"
4740               "[ \t]*char[ \t]*\\*[ \t]*";
4741
4742    test_text =
4743    "extern FILE *fopen( char *__filename, char *__type );\n"
4744    "extern int sscanf( char *__s, char *__format, ...);\n"
4745    "extern FILE *popen(char *, char *);\n"
4746    "extern char *tempnam(char*,char*);\n";
4747};
4748
4749/*
4750 *  Fix definitions of macros used by va-i960.h in VxWorks header file.
4751 */
4752fix = {
4753    hackname  = va_i960_macro;
4754    files     = arch/i960/archI960.h;
4755    select    = "__(vsiz|vali|vpad|alignof__)";
4756
4757    c_fix     = format;
4758    c_fix_arg = "__vx%1";
4759
4760    test_text =
4761    "extern int __vsiz vsiz;\n"
4762    "extern int __vali vali;\n"
4763    "extern int __vpad vpad;\n"
4764    "#define __alignof__(x) ...";
4765};
4766
4767/*
4768 * On VMS, add missing braces around sigset_t constants.
4769 */
4770fix = {
4771    hackname  = vms_add_missing_braces;
4772    select    = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4773    mach      = "*-*-*vms*";
4774    files     = "rtldef/signal.h";
4775    c_fix     = format;
4776
4777    c_fix_arg = '%1 {%2} ';
4778
4779    test_text = "static const __sigset_t _SIG_EMPTY_SET  = "
4780                "{0x00000000, 0x00000000},\n"
4781                " _SIG_FULL_SET   = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4782};
4783
4784/*
4785 * On VMS, some DEC-C builtins are directly used.
4786 */
4787fix = {
4788    hackname  = vms_decc_builtin;
4789    select    = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4790    mach      = "*-*-*vms*";
4791    files     = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4792                rtldef/socket.h;
4793    sed       = "s@__MEMSET@memset@";
4794    sed       = "s@__MEMMOVE@memmove@";
4795    sed       = "s@__MEMCPY@memcpy@";
4796    sed       = "s@__STRLEN@strlen@";
4797    sed       = "s@__STRCPY@strcpy@";
4798
4799    test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4800};
4801
4802/*
4803 *  Define __CAN_USE_EXTERN_PREFIX on vms.
4804 */
4805fix = {
4806    hackname  = vms_define_can_use_extern_prefix;
4807    files     = "rtldef/decc$types.h";
4808    select    = "#[ \t]*else\n"
4809		"#[ \t]*if defined\\(__DECCXX\\)\n"
4810		"#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4811    mach      = "*-*-*vms*";
4812    c_fix     = format;
4813
4814    c_fix_arg = "%0"
4815		"#    elif defined (__GNUC__)\n"
4816		"#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4817
4818    test_text = "# else\n"
4819		"#    if defined(__DECCXX)\n"
4820		"#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4821		"#    endif\n"
4822		"# endif\n";
4823};
4824
4825/*
4826 * On VMS, disable the use of dec-c string builtins
4827 */
4828fix = {
4829    hackname  = vms_disable_decc_string_builtins;
4830    select    = "#if !defined\\(__VAX\\)\n";
4831    mach      = "*-*-*vms*";
4832    files     = "rtldef/string.h";
4833    c_fix     = format;
4834
4835    c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4836
4837    test_text = "#if !defined(__VAX)\n";
4838};
4839
4840/*
4841 * On VMS, fix incompatible redeclaration of hostalias.
4842 */
4843fix = {
4844    hackname  = vms_do_not_redeclare_hostalias;
4845    select    = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4846                "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4847    mach      = "*-*-*vms*";
4848    files     = "rtldef/resolv.h";
4849    c_fix     = format;
4850
4851    c_fix_arg = "%1\n"
4852                "/* %2 */";
4853
4854    test_text = "void		fp_nquery (const u_char *, int, FILE *);\n"
4855                "__char_ptr32	hostalias (const char *);\n";
4856};
4857
4858/*
4859 * On VMS, forward declare structure before referencing them in prototypes.
4860 */
4861fix = {
4862    hackname  = vms_forward_declare_struct;
4863    select    = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4864                "#ifdef __cplusplus\n";
4865    mach      = "*-*-*vms*";
4866    files     = rtldef/if.h;
4867    c_fix     = format;
4868
4869    c_fix_arg = "%1"
4870                "#if defined (__cplusplus) || defined (__GNUC__)\n";
4871
4872    test_text = "/* forward decls for C++ */\n"
4873                "#ifdef __cplusplus\n"
4874                "struct foo;\n"
4875                "#endif\n";
4876};
4877
4878/*
4879 * On VMS, do not declare getopt and al if pointers are 64 bit.
4880 */
4881fix = {
4882    hackname  = vms_no_64bit_getopt;
4883    select    = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4884                "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4885    mach      = "*-*-*vms*";
4886    files     = rtldef/stdio.h, rtldef/unistd.h;
4887    c_fix     = format;
4888
4889    c_fix_arg = <<- _EOArg_
4890	#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only.  */
4891	%0#endif
4892
4893	_EOArg_;
4894
4895    test_text = "int getopt (int, char * const [], const char *);";
4896};
4897
4898/*
4899 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4900 * which is not yet fully supported by gcc.
4901 */
4902fix = {
4903    hackname  = vms_use_fast_setjmp;
4904    select    = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4905    mach      = "*-*-*vms*";
4906    files     = rtldef/setjmp.h;
4907    c_fix     = format;
4908
4909    c_fix_arg = "%0 defined (__GNUC__) ||";
4910
4911    test_text = "#   if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4912};
4913
4914/*
4915 * On VMS, use pragma extern_model instead of VAX-C keywords.
4916 */
4917fix = {
4918    hackname  = vms_use_pragma_extern_model;
4919    select    = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4920		"# pragma extern_model __save\n";
4921    mach      = "*-*-*vms*";
4922    c_fix     = format;
4923
4924    c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4925		"# pragma extern_model __save\n";
4926
4927    test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4928		"# pragma extern_model __save\n"
4929		"# pragma extern_model strict_refdef\n"
4930		"   extern struct x zz$yy;\n"
4931		"# pragma extern_model __restore\n"
4932		"#endif\n";
4933};
4934
4935/*
4936 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4937 * conflict while building gcc.  Likewise for <builtins.h>
4938 */
4939fix = {
4940    hackname  = vms_use_quoted_include;
4941    select    = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4942    mach      = "*-*-*vms*";
4943    files     = rtldef/wait.h, starlet_c/pthread.h;
4944    c_fix     = format;
4945
4946    c_fix_arg = '%1<sys/%2.h>';
4947
4948    test_text = "#   include <resource.h>";
4949};
4950
4951/*
4952 *  AIX and Interix headers define NULL to be cast to a void pointer,
4953 *  which is illegal in ANSI C++.
4954 */
4955fix = {
4956    hackname  = void_null;
4957    files     = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4958    time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4959    /* avoid changing C++ friendly NULL */
4960    bypass    = __cplusplus;
4961    bypass    = __null;
4962    select    = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4963    c_fix     = format;
4964    c_fix_arg = <<- _EOFix_
4965	#ifndef NULL
4966	#ifdef __cplusplus
4967	#ifdef __GNUG__
4968	#define NULL __null
4969	#else /* ! __GNUG__  */
4970	#define NULL 0L
4971	#endif /* __GNUG__  */
4972	#else /* ! __cplusplus  */
4973	#define NULL ((void *)0)
4974	#endif /* __cplusplus  */
4975	#endif /* !NULL  */
4976	_EOFix_;
4977    test_text = "# define\tNULL \t((void *)0)  /* typed NULL */";
4978};
4979
4980/*
4981 *  Make VxWorks header which is almost gcc ready fully gcc ready.
4982 */
4983fix = {
4984    hackname = vxworks_gcc_problem;
4985    files    = types/vxTypesBase.h;
4986    select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4987
4988    sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4989          "#if 1/";
4990
4991    sed = "/[ \t]size_t/i\\\n"
4992        "#ifndef _GCC_SIZE_T\\\n"
4993        "#define _GCC_SIZE_T\n";
4994
4995    sed = "/[ \t]size_t/a\\\n"
4996        "#endif\n";
4997
4998    sed = "/[ \t]ptrdiff_t/i\\\n"
4999        "#ifndef _GCC_PTRDIFF_T\\\n"
5000        "#define _GCC_PTRDIFF_T\n";
5001
5002    sed = "/[ \t]ptrdiff_t/a\\\n"
5003        "#endif\n";
5004
5005    sed = "/[ \t]wchar_t/i\\\n"
5006        "#ifndef _GCC_WCHAR_T\\\n"
5007        "#define _GCC_WCHAR_T\n";
5008
5009    sed = "/[ \t]wchar_t/a\\\n"
5010        "#endif\n";
5011
5012    test_text =
5013    "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
5014    "typedef unsigned int size_t;\n"
5015    "typedef long ptrdiff_t;\n"
5016    "typedef unsigned short wchar_t;\n"
5017    "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
5018};
5019
5020/*
5021 *  Wrap VxWorks ioctl to keep everything pretty
5022 */
5023fix = {
5024    hackname    = vxworks_ioctl_macro;
5025    files       = ioLib.h;
5026    mach        = "*-*-vxworks*";
5027
5028    c_fix       = format;
5029    c_fix_arg   = "%0\n"
5030        "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
5031    c_fix_arg   = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
5032
5033    test_text   = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5034};
5035
5036/*
5037 *  Wrap VxWorks mkdir to be posix compliant
5038 */
5039fix = {
5040    hackname    = vxworks_mkdir_macro;
5041    files       = sys/stat.h;
5042    mach        = "*-*-vxworks*";
5043
5044    c_fix       = format;
5045    c_fix_arg   = "%0\n"
5046                "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5047    c_fix_arg   = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5048                "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5049                "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5050                "\\)[\t ]*;";
5051
5052    test_text   = "extern STATUS mkdir (const char * _qwerty) ;";
5053};
5054
5055/*
5056 *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
5057 */
5058fix = {
5059    hackname  = vxworks_needs_vxtypes;
5060    files     = time.h;
5061    select    = "uint_t([ \t]+_clocks_per_sec)";
5062    c_fix     = format;
5063    c_fix_arg = "unsigned int%1";
5064    test_text = "uint_t\t_clocks_per_sec;";
5065};
5066
5067/*
5068 *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5069 */
5070fix = {
5071    hackname = vxworks_needs_vxworks;
5072    files    = sys/stat.h;
5073    test     = " -r types/vxTypesOld.h";
5074    test     = " -n \"`egrep '#include' $file`\"";
5075    test     = " -n \"`egrep ULONG $file`\"";
5076    select   = "#[ \t]define[ \t]+__INCstath";
5077
5078    sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5079          "#include <types/vxTypesOld.h>\n";
5080
5081    test_text = "`touch types/vxTypesOld.h`"
5082    "#include </dev/null> /* ULONG */\n"
5083    "# define\t__INCstath <sys/stat.h>";
5084};
5085
5086/*
5087 *  Make it so VxWorks does not include gcc/regs.h accidentally
5088 */
5089fix = {
5090    hackname    = vxworks_regs;
5091    mach        = "*-*-vxworks*";
5092
5093    select      = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5094    c_fix       = format;
5095    c_fix_arg   = "#include <arch/../regs.h>";
5096
5097    test_text   = "#include <regs.h>\n";
5098};
5099
5100/*
5101 *  Another bad dependency in VxWorks 5.2 <time.h>.
5102 */
5103fix = {
5104    hackname = vxworks_time;
5105    files    = time.h;
5106    test     = " -r vxWorks.h";
5107
5108    select    = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5109    c_fix     = format;
5110
5111    c_fix_arg =
5112    "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5113    "#ifdef __cplusplus\n"
5114    "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5115    "#else\n"
5116    "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5117    "#endif\n"
5118    "#define __gcc_VOIDFUNCPTR_defined\n"
5119    "#endif\n"
5120    "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5121
5122    test_text = "`touch vxWorks.h`"
5123                "#define VOIDFUNCPTR (void(*)())";
5124};
5125
5126/*
5127 *  This hack makes write const-correct on VxWorks
5128 */
5129fix = {
5130    hackname    = vxworks_write_const;
5131    files       = ioLib.h;
5132    mach        = "*-*-vxworks*";
5133
5134    c_fix       = format;
5135    c_fix_arg   = "extern int  write (int, const char*, size_t);";
5136    c_fix_arg   = "extern[\t ]+int[\t ]+write[\t ]*\\("
5137                "[\t ]*int[\t ]*,"
5138                "[\t ]*char[\t ]*\\*[\t ]*,"
5139                "[\t ]*size_t[\t ]*\\)[\t ]*;";
5140
5141    test_text       = "extern int write ( int , char * , size_t ) ;";
5142};
5143
5144/*
5145 *  There are several name conflicts with C++ reserved words in X11 header
5146 *  files.  These are fixed in some versions, so don't do the fixes if
5147 *  we find __cplusplus in the file.  These were found on the RS/6000.
5148 */
5149fix = {
5150    hackname  = x11_class;
5151    files     = X11/ShellP.h;
5152    bypass    = __cplusplus;
5153    select    = "^([ \t]*char \\*)class;(.*)";
5154    c_fix     = format;
5155    c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5156                "#else\n%1class;%2\n#endif";
5157    test_text =
5158    "struct {\n"
5159    "   char *class;\n"
5160    "} mumble;\n";
5161};
5162
5163/*
5164 *  class in Xm/BaseClassI.h
5165 */
5166fix = {
5167    hackname = x11_class_usage;
5168    files    = Xm/BaseClassI.h;
5169    bypass   = "__cplusplus";
5170
5171    select    = " class\\)";
5172    c_fix     = format;
5173    c_fix_arg = " c_class)";
5174
5175    test_text = "extern mumble (int  class);\n";
5176};
5177
5178/*
5179 *  new in Xm/Traversal.h
5180 */
5181fix = {
5182    hackname = x11_new;
5183    files    = Xm/Traversal.h;
5184    bypass   = __cplusplus;
5185
5186    sed      = "/Widget\told, new;/i\\\n"
5187                   "#ifdef __cplusplus\\\n"
5188                   "\\\tWidget\told, c_new;\\\n"
5189                   "#else\n";
5190
5191    sed      = "/Widget\told, new;/a\\\n"
5192                   "#endif\n";
5193
5194    sed      = "s/Widget new,/Widget c_new,/g";
5195    test_text =
5196    "struct wedge {\n"
5197    "   Widget\told, new;\n"
5198    "};\nextern Wedged( Widget new, Widget old );";
5199};
5200
5201/*
5202 *  Incorrect sprintf declaration in X11/Xmu.h
5203 */
5204fix = {
5205    hackname = x11_sprintf;
5206    files    = X11/Xmu.h;
5207    files    = X11/Xmu/Xmu.h;
5208    select   = "^extern char \\*\tsprintf\\(\\);$";
5209
5210    c_fix     = format;
5211    c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5212
5213    test_text = "extern char *\tsprintf();";
5214};
5215/*EOF*/
5216