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