OSDN Git Service

clean up fixes
[pf3gnuchains/gcc-fork.git] / fixincludes / inclhack.def
1 /* -*- Mode: C -*-  */
2
3 autogen 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[        ]*=[    ]*(.*);'
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
20 FIXINC_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  */
30 fix = {
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
68 /*
69  *  On Mac OS 10.3.9, the 'long double' functions are available in
70  *  libSystem, but are not prototyped in math.h.
71  */
72 fix = {
73   hackname  = AAB_darwin7_9_long_double_funcs;
74   mach      = "*-*-darwin7.9*";
75   files     = architecture/ppc/math.h;
76   bypass    = "powl";
77   replace = <<- _EndOfHeader_
78 /* This file prototypes the long double functions available on Mac OS
79    10.3.9.  */
80 #ifndef __MATH__
81 # undef __APPLE_CC__
82 # define __APPLE_CC__  1345
83 # include_next <architecture/ppc/math.h>
84 # undef __APPLE_CC__
85 # define __APPLE_CC__ 1
86 # ifndef __LIBMLDBL_COMPAT
87 #  ifdef __LONG_DOUBLE_128__
88 #   define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
89 #  else
90 #   define __LIBMLDBL_COMPAT(sym)
91 #  endif /* __LONG_DOUBLE_128__ */
92 # endif /* __LIBMLDBL_COMPAT */
93 # ifdef __cplusplus
94    extern "C" {
95 # endif
96   extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
97   extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
98   extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
99   extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
100   extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
101   extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
102   extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
103   extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
104   extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
105   extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
106   extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
107   extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
108   extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
109   extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
110   extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
111   extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
112   extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
113   extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
114   extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
115   extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
116   extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
117   extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
118   extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
119   extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
120   extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
121   extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
122   extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
123   extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
124   extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
125   extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
126   extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
127   extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
128   extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
129   extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
130   extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
131   extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
132   extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
133   extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
134   extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
135   extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
136   extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
137   extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
138   extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
139   extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
140   extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
141   extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
142   extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
143   extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
144   extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
145   extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
146   extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
147   extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
148   extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
149   extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
150   extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
151   extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
152   extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
153 # ifdef __cplusplus
154    }
155 # endif
156 #endif /* __MATH__ */
157 _EndOfHeader_;
158 };
159
160
161 /*
162  *  ... and for the previous fix to be useful, you have to not use ""
163  *  includes.
164  */
165 fix = {
166   hackname  = AAB_darwin7_9_long_double_funcs_2;
167   mach      = "*-*-darwin7.9*";
168   files     = math.h;
169   select    = '#include[ \t]+\"';
170   c_fix     = format;
171   c_fix_arg = "%1<%2.h>";
172   
173   c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
174   
175   test_text = '#include "architecture/ppc/math.h"';
176 };
177
178
179 /*
180  *  This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
181  */
182 fix = {
183     hackname = AAB_fd_zero_asm_posix_types_h;
184     files    = asm/posix_types.h;
185     mach     = 'i[34567]86-*-linux*';
186     bypass   = '} while';
187     bypass   = 'x86_64';
188     bypass   = 'posix_types_64';
189
190     /*
191      * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
192      * the start, so that if #include_next gets another instance of
193      * the wrapper, this will follow the #include_next chain until
194      * we arrive at the real <asm/posix_types.h>.
195      */
196     replace  = <<-  _EndOfHeader_
197         /* This file fixes a bug in the __FD_ZERO macro
198            for older versions of the Linux kernel. */
199         #ifndef _POSIX_TYPES_H_WRAPPER
200         #include <features.h>
201          #include_next <asm/posix_types.h>
202         
203         #if defined(__FD_ZERO) && !defined(__GLIBC__)
204         #undef __FD_ZERO
205         #define __FD_ZERO(fdsetp) \
206           do { \
207             int __d0, __d1; \
208                 __asm__ __volatile__("cld ; rep ; stosl" \
209                         : "=&c" (__d0), "=&D" (__d1) \
210                         : "a" (0), "0" (__FDSET_LONGS), \
211                           "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
212           } while (0)
213         #endif
214         
215         #define _POSIX_TYPES_H_WRAPPER
216         #endif /* _POSIX_TYPES_H_WRAPPER */
217         _EndOfHeader_;
218 };
219
220
221 /*
222  *  This fixes __FD_ZERO bug for glibc-1.x
223  */
224 fix = {
225     hackname = AAB_fd_zero_gnu_types_h;
226     files    = gnu/types.h;
227     mach     = 'i[34567]86-*-linux*';
228
229     /*
230      * Define _TYPES_H_WRAPPER at the end of the wrapper, not
231      * the start, so that if #include_next gets another instance of
232      * the wrapper, this will follow the #include_next chain until
233      * we arrive at the real <gnu/types.h>.
234      */
235     replace  = <<-  _EndOfHeader_
236         /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
237         #ifndef _TYPES_H_WRAPPER
238         #include <features.h>
239         #include_next <gnu/types.h>
240
241         #if defined(__FD_ZERO) && !defined(__GLIBC__)
242         #undef __FD_ZERO
243         # define __FD_ZERO(fdsetp) \
244           do { \
245             int __d0, __d1; \
246                 __asm__ __volatile__("cld ; rep ; stosl" \
247                 : "=&c" (__d0), "=&D" (__d1) \
248                 : "a" (0), "0" (__FDSET_LONGS), \
249                   "1" ((__fd_set *) (fdsetp)) :"memory"); \
250           } while (0)
251         #endif
252
253         #define _TYPES_H_WRAPPER
254         #endif /* _TYPES_H_WRAPPER */
255         _EndOfHeader_;
256 };
257
258
259 /*
260  *  This fixes __FD_ZERO bug for glibc-2.0.x
261  */
262 fix = {
263     hackname = AAB_fd_zero_selectbits_h;
264     files    = selectbits.h;
265     mach     = 'i[34567]86-*-linux*';
266
267     /*
268      * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
269      * the start, so that if #include_next gets another instance of
270      * the wrapper, this will follow the #include_next chain until
271      * we arrive at the real <selectbits.h>.
272      */
273     replace  = <<-  _EndOfHeader_
274         /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
275         #ifndef _SELECTBITS_H_WRAPPER
276           #include <features.h>
277           #include_next <selectbits.h>
278
279           #if defined(__FD_ZERO) && defined(__GLIBC__) \\
280           && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
281           && __GLIBC_MINOR__ == 0
282              #undef __FD_ZERO
283              #define __FD_ZERO(fdsetp) \\
284              do { \\
285                 int __d0, __d1; \\
286               __asm__ __volatile__ ("cld; rep; stosl" \\
287                         : "=&c" (__d0), "=&D" (__d1) \\
288                         : "a" (0), "0" (sizeof (__fd_set) \\
289                                         / sizeof (__fd_mask)), \\
290                           "1" ((__fd_mask *) (fdsetp)) \\
291                         : "memory"); \\
292               } while (0)
293           #endif
294
295           #define _SELECTBITS_H_WRAPPER
296         #endif /* _SELECTBITS_H_WRAPPER */
297         _EndOfHeader_;
298 };
299
300
301 /*
302  * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
303  * the same interface as <stdarg.h>.  No idea why they couldn't have just
304  * used the standard header.
305  */
306 fix = {
307     hackname = AAB_solaris_sys_varargs_h;
308     files    = "sys/varargs.h";
309     mach     = '*-*-solaris*';
310     replace  = <<-  _EndOfHeader_
311         #ifdef __STDC__
312           #include <stdarg.h>
313         #else
314           #include <varargs.h>
315         #endif
316         _EndOfHeader_;
317 };
318
319
320 /*
321  *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
322  *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
323  *  many other systems have similar text but correct versions of the file.
324  *  To ensure only Sun's is fixed, we grep for a likely unique string.
325  *  Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
326  */
327 fix = {
328     hackname = AAB_sun_memcpy;
329     files    = memory.h;
330     select   = "/\\*\t@\\(#\\)"
331              "(head/memory.h\t50.1\t "
332              "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
333
334     replace = <<-  _EndOfHeader_
335         /* This file was generated by fixincludes */
336         #ifndef __memory_h__
337           #define __memory_h__
338
339           #ifdef __STDC__
340             extern void *memccpy();
341             extern void *memchr();
342             extern void *memcpy();
343             extern void *memset();
344           #else
345             extern char *memccpy();
346             extern char *memchr();
347             extern char *memcpy();
348             extern char *memset();
349           #endif /* __STDC__ */
350
351           extern int memcmp();
352
353         #endif /* __memory_h__ */
354         _EndOfHeader_;
355 };
356
357
358 /*
359  *  Completely replace <sys/varargs.h> with a file that includes gcc's
360  *  stdarg.h or varargs.h files as appropriate.
361  */
362 #ifdef SVR4
363 fix = {
364     hackname = AAB_svr4_no_varargs;
365     files    = sys/varargs.h;
366     replace  = "/* This file was generated by fixincludes.  */\n"
367                "#ifndef _SYS_VARARGS_H\n"
368                "#define _SYS_VARARGS_H\n\n"
369
370                "#ifdef __STDC__\n"
371                "#include <stdarg.h>\n"
372                "#else\n"
373                "#include <varargs.h>\n"
374                "#endif\n\n"
375
376                "#endif  /* _SYS_VARARGS_H */\n";
377 };
378 #endif
379
380
381 /*
382  *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
383  *  which violates a requirement of ISO C.
384  */
385 fix = {
386     hackname  = aix_pthread;
387     files     = "pthread.h";
388     select    = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
389     c_fix     = format;
390     c_fix_arg = "%1 %2";
391     test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
392                 "{...init stuff...}";
393 };
394
395
396 /*
397  *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
398  *  in an otherwise harmless (and #ifed out) macro definition
399  */
400 fix = {
401     hackname  = aix_sysmachine;
402     files     = sys/machine.h;
403     select    = "\\\\ +\n";
404     c_fix     = format;
405     c_fix_arg = "\\\n";
406     test_text = "#define FOO \\\n"
407     " bar \\ \n baz \\ \n bat";
408 };
409
410
411 /*
412  *  sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
413  *  definition of struct rusage, so the prototype added by fixproto fails.
414  */
415 fix = {
416     hackname  = aix_syswait;
417     files     = sys/wait.h;
418     select    = "^extern pid_t wait3\\(\\);\n";
419     select    = "bos325,";
420     c_fix     = format;
421     c_fix_arg = "struct rusage;\n%0";
422     test_text = "/* bos325, */\n"
423     "extern pid_t wait3();\n"
424     "\t/* pid_t wait3(int *, int, struct rusage *); */";
425 };
426
427
428 /*
429  *  sys/wait.h on AIX 5.2 defines macros that have both signed and
430  *  unsigned types in conditional expressions.
431  */
432 fix = {
433     hackname  = aix_syswait_2;
434     files     = sys/wait.h;
435     select    = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
436     c_fix     = format;
437     c_fix_arg = "? (int)%1";
438     test_text = "#define WSTOPSIG(__x)    (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
439 };
440
441
442 /*
443  *  sys/signal.h on some versions of AIX uses volatile in the typedef of
444  *  sig_atomic_t, which causes gcc to generate a warning about duplicate
445  *  volatile when a sig_atomic_t variable is declared volatile, as
446  *  required by ANSI C.
447  */
448 fix = {
449     hackname  = aix_volatile;
450     files     = sys/signal.h;
451     select    = "typedef volatile int sig_atomic_t";
452     c_fix     = format;
453     c_fix_arg = "typedef int sig_atomic_t";
454     test_text = "typedef volatile int sig_atomic_t;";
455 };
456
457
458 /*
459  *  Fix __assert declaration in assert.h on Alpha OSF/1.
460  */
461 fix = {
462     hackname  = alpha___assert;
463     files     = "assert.h";
464     select    = '__assert\(char \*, char \*, int\)';
465     c_fix     = format;
466     c_fix_arg = "__assert(const char *, const char *, int)";
467     test_text = 'extern void __assert(char *, char *, int);';
468 };
469
470
471 /*
472  *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
473  */
474 fix = {
475     hackname  = alpha___extern_prefix;
476     select    = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
477                 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
478
479     mach      = "alpha*-dec-osf*";
480     c_fix     = format;
481     c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
482
483     test_text = "#ifdef  __DECC\n"
484                 "#pragma extern_prefix \"_P\"\n"
485                 "#   if defined(__DECC)\n"
486                 "#     pragma extern_prefix \"_E\"\n"
487                 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
488                 "#  pragma extern_prefix \"\"";
489 };
490
491
492 /*
493  *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
494  */
495 fix = {
496     hackname  = alpha___extern_prefix_standards;
497     files     = standards.h;
498     select    = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
499
500     mach      = "alpha*-dec-osf*";
501     c_fix     = format;
502     c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
503
504     test_text = "#if (_ISO_C_SOURCE>=19990L) "
505                 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
506 };
507
508
509 /*
510  *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
511  *  <sys/stat.h>.  The tests for __DECC are special in various ways, so
512  *  alpha__extern_prefix cannot be used.
513  */
514 fix = {
515     hackname  = alpha___extern_prefix_sys_stat;
516     files     = sys/stat.h;
517     files     = sys/mount.h;
518     select    = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
519
520     mach      = "alpha*-dec-osf5*";
521     c_fix     = format;
522     c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
523
524     test_text = "#   if defined(__DECC)";
525 };
526
527
528 /*
529  *  Fix assert macro in assert.h on Alpha OSF/1.
530  *  The superfluous int cast breaks C++.
531  */
532 fix = {
533     hackname  = alpha_assert;
534     files     = "assert.h";
535     select    = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
536     c_fix     = format;
537     c_fix_arg = "%1(EX)";
538     test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
539                 ': __assert(#EX, __FILE__, __LINE__))';
540 };
541
542
543 /*
544  *  Fix #defines under Alpha OSF/1:
545  *  The following files contain '#pragma extern_prefix "_FOO"' followed by
546  *  a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
547  *  statements is to reduce namespace pollution.  While these macros work
548  *  properly in most cases, they don't allow you to take a pointer to the
549  *  "something" being modified.  To get around this limitation, change these
550  *  statements to be of the form '#define something _FOOsomething'.
551  *
552  *  sed ain't egrep, lesson 2463:  sed can use self-referential
553  *  regular expressions.  In the substitute expression below,
554  *  "\\1" and "\\2" refer to subexpressions found earlier in the
555  *  same match.  So, we continue to use sed.  "extern_prefix" will
556  *  be a rare match anyway...
557  */
558 fix = {
559     hackname = alpha_bad_lval;
560
561     select   = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
562     mach      = "alpha*-dec-osf*";
563
564     sed      =
565         "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
566                "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
567
568     test_text = '#pragma extern_prefix "_FOO"'"\n"
569                 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
570                 "#define mumble _FOOmumble";
571 };
572
573
574 /*
575  *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
576  */
577 fix = {
578     hackname  = alpha_getopt;
579     files     = "stdio.h";
580     files     = "stdlib.h";
581     select    = 'getopt\(int, char \*\[\], *char \*\)';
582     c_fix     = format;
583     c_fix_arg = "getopt(int, char *const[], const char *)";
584     test_text = 'extern int getopt(int, char *[], char *);';
585 };
586
587
588 /*
589  * Remove erroneous parentheses in sym.h on Alpha OSF/1.
590  */
591 fix = {
592     hackname  = alpha_parens;
593     files     = sym.h;
594     select    = '#ifndef\(__mips64\)';
595     c_fix     = format;
596     c_fix_arg = "#ifndef __mips64";
597     test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
598 };
599
600
601 /*
602  *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
603  */
604 fix = {
605     hackname  = alpha_pthread;
606     files     = pthread.h;
607     select    = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
608                 "|def _PTHREAD_ENV_DECC)(.*))\n"
609                 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
610
611     mach      = "alpha*-dec-osf*";
612     c_fix     = format;
613     c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
614                 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
615
616     test_text = "#  if defined (_PTHREAD_ENV_DECC) "
617                       "|| defined (_PTHREAD_ENV_EPCC)\n"
618                 "#   define _PTHREAD_USE_PTDNAM_\n"
619                 "#  endif\n"
620                 "#  ifdef _PTHREAD_ENV_DECC\n"
621                 "#   define _PTHREAD_USE_PTDNAM_\n"
622                 "#  endif";
623 };
624
625
626 /*
627  *  Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
628  */
629 fix = {
630     hackname  = alpha_pthread_gcc;
631     files     = pthread.h;
632     select    = "#else\n# error <pthread.h>: unrecognized compiler.";
633
634     mach      = "alpha*-dec-osf*";
635     c_fix     = format;
636     c_fix_arg = "#elif defined (__GNUC__)\n"
637                 "# define _PTHREAD_ENV_GCC\n"
638                 "%0";
639
640     test_text = "# define _PTHREAD_ENV_INTELC\n"
641                 "#else\n"
642                 "# error <pthread.h>: unrecognized compiler.\n"
643                 "#endif";
644 };
645
646 /*
647  * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
648  * incorrectly, specifying less fields in the initializers than are
649  * defined in the corresponding structure types.  Use of these macros
650  * in user code results in spurious warnings.
651  */
652 fix = {
653     hackname  = alpha_pthread_init;
654     files     = pthread.h;
655     select    = ' \* @\(#\).RCSfile: pthread\.h,v \$'
656                 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
657                 ' .Date: 2000/08/15 15:30:13 \$';
658     mach      = "alpha*-dec-osf*";
659     sed       = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
660                 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
661                 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
662                 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
663                 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
664                 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
665     test_text = "/*\n"
666                 " * @(#)_RCSfile: pthread.h,v \\$ "
667                 "_Revision: 1.1.33.21 \\$ (DEC) "
668                 "_Date: 2000/08/15 15:30:13 \\$\n"
669                 " */\n"
670 "#ifndef _PTHREAD_NOMETER_STATIC\n"
671 "# define PTHREAD_MUTEX_INITIALIZER \\\n"
672 "    {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
673 "# define PTHREAD_COND_INITIALIZER \\\n"
674 "    {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}\n"
675 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
676 "    {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
677 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
678 "    {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
679 "#else\n"
680 "# define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
681 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
682 "    {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
683 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
684 "    {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
685 "#endif\n\n"
686 "#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}\n"
687 "#define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \\\n"
688 "        {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}\n";
689 };
690
691 /*
692  *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
693  *  And OpenBSD.
694  */
695 fix = {
696     hackname = alpha_sbrk;
697     files    = unistd.h;
698     select   = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
699     c_fix     = format;
700     c_fix_arg = "void *sbrk(";
701     test_text = "extern char* sbrk(ptrdiff_t increment);";
702 };
703
704
705 /*
706  *  Change external names of wcstok/wcsftime via asm instead of macros on
707  *  Tru64 UNIX V4.0.
708  */
709 fix = {
710     hackname = alpha_wchar;
711     files    = wchar.h;
712
713     mach     = "alpha*-dec-osf4*";
714     select   = "#define wcstok wcstok_r";
715     sed      = "s@#define wcstok wcstok_r@"
716                 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
717                           "wchar_t **)) __asm__(\"wcstok_r\");@";
718     sed      = "s@#define wcsftime __wcsftime_isoc@"
719                 "extern size_t   wcsftime __((wchar_t *, size_t, const wchar_t *"
720                           ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
721     test_text = "#define wcstok wcstok_r\n"
722                 "#define wcsftime __wcsftime_isoc";
723 };
724
725
726 /*
727  *  For C++, avoid any typedef or macro definition of bool,
728  *  and use the built in type instead.
729  *  HP/UX 10.20 also has it in curses_colr/curses.h.
730  */
731 fix = {
732     hackname  = avoid_bool_define;
733     files     = curses.h;
734     files     = curses_colr/curses.h;
735     files     = term.h;
736     files     = tinfo.h;
737
738     select    = "#[ \t]*define[ \t]+bool[ \t]";
739     bypass    = "__cplusplus";
740
741     c_fix     = format;
742     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
743     c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
744
745     test_text = "# define bool\t char \n";
746 };
747
748
749 fix = {
750     hackname = avoid_bool_type;
751     files    = curses.h;
752     files    = curses_colr/curses.h;
753     files    = term.h;
754     files    = tinfo.h;
755
756     select    = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
757     bypass    = "__cplusplus";
758
759     c_fix     = format;
760     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
761
762     test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
763 };
764
765
766 /*
767  *  For C++, avoid any typedef definition of wchar_t,
768  *  and use the built in type instead.
769  *  Don't do this for headers that are smart enough to do the right
770  *  thing (recent [n]curses.h and Xlib.h).
771  *  Don't do it for <linux/nls.h> which is never used from C++ anyway,
772  *  and will be broken by the edit.
773  */
774
775 fix = {
776     hackname = avoid_wchar_t_type;
777
778     select    = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
779     bypass    = "__cplusplus";
780     bypass    = "_LINUX_NLS_H";
781     bypass    = "XFree86: xc/lib/X11/Xlib\\.h";
782
783     c_fix     = format;
784     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
785
786     test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
787 };
788
789
790 /*
791  *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
792  */
793 fix = {
794     hackname  = bad_struct_term;
795     files     = curses.h;
796     select    = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
797     c_fix     = format;
798     c_fix_arg = "struct term;";
799
800     test_text = 'typedef struct term;';
801 };
802
803
804 /*
805  *  Fix one other error in this file:
806  *  a mismatched quote not inside a C comment.
807  */
808 fix = {
809     hackname  = badquote;
810     files     = sundev/vuid_event.h;
811     select    = "doesn't";
812     c_fix     = format;
813     c_fix_arg = "does not";
814
815     test_text = "/* doesn't have matched single quotes */";
816 };
817
818
819 /*
820  *  check for broken assert.h that needs stdio.h
821  */
822 fix = {
823     hackname  = broken_assert_stdio;
824     files     = assert.h;
825     select    = stderr;
826     bypass    = "include.*stdio\\.h";
827     c_fix     = wrap;
828     c_fix_arg = "#include <stdio.h>\n";
829     test_text = "extern FILE* stderr;";
830 };
831
832
833 /*
834  *  check for broken assert.h that needs stdlib.h
835  */
836 fix = {
837     hackname  = broken_assert_stdlib;
838     files     = assert.h;
839     select    = 'exit *\(|abort *\(';
840     bypass    = "include.*stdlib\\.h";
841     c_fix     = wrap;
842     c_fix_arg = "#ifdef __cplusplus\n"
843                 "#include <stdlib.h>\n"
844                 "#endif\n";
845     test_text = "extern void exit ( int );";
846 };
847
848
849 /*
850  *  Remove `extern double cabs' declarations from math.h.
851  *  This conflicts with C99.  Discovered on AIX.
852  *  IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
853  *  declares cabs() to take a struct __cabs_s argument.
854  *  SunOS4 has its cabs() declaration followed by a comment which
855  *  terminates on the following line.
856  *  Darwin hides its broken cabs in architecture-specific subdirs.
857  */
858 fix = {
859     hackname = broken_cabs;
860     files    = math.h, "architecture/*/math.h";
861     select   = "^extern[ \t]+double[ \t]+cabs";
862
863     sed       = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
864     sed       = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
865
866     test_text = "#ifdef __STDC__\n"
867                 "extern     double   cabs(struct dbl_hypot);\n"
868                 "#else\n"
869                 "extern     double   cabs();\n"
870                 "#endif\n"
871                 "extern double cabs ( _Complex z );\n"
872                 "extern double cabs(); /* This is a comment\n"
873                 "                         and it ends here. */\n"
874                 "extern double  cabs(struct __cabs_s);\n"
875                 "extern long double cabsl( struct __cabsl_s );";
876 };
877
878 /*
879  * Fixup Darwin's broken check for __builtin_nanf.
880  */ 
881     
882 fix = {
883     hackname  = broken_nan;
884     /*
885      *  It is tempting to omit the first "files" entry.  Do not.
886      *  The testing machinery will take the first "files" entry as the name
887      *  of a test file to play with.  It would be a nuisance to have a directory
888      *  with the name "*".
889      */
890     files     = "architecture/ppc/math.h";
891     files     = "architecture/*/math.h";
892     select    = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
893     bypass    = "powl";
894     c_fix     = format; 
895     c_fix_arg = "#if 1";
896     test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
897 }; 
898
899
900 /*
901  *  Various systems derived from BSD4.4 contain a macro definition
902  *  for vfscanf that interacts badly with requirements of builtin-attrs.def.
903  *  Known to be fixed in FreeBSD 5 system headers.
904  */
905 fix = {
906     hackname  = bsd_stdio_attrs_conflict;
907     mach      = "*-*-*bsd*";
908     mach      = "*-*-*darwin*";
909     files     = stdio.h;
910     select    = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
911     c_fix     = format;
912     c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
913                 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
914                 'int vfscanf(FILE *, const char *, __builtin_va_list) '
915                 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
916     test_text = '#define  vfscanf       __svfscanf';
917 };
918
919
920 /*
921  *  Fix various macros used to define ioctl numbers.
922  *  The traditional syntax was:
923  *
924  *    #define _CTRL(n, x) (('n'<<8)+x)
925  *    #define TCTRLCFOO _CTRL(T, 1)
926  *
927  *  but this does not work with the C standard, which disallows macro
928  *  expansion inside strings.  We have to rewrite it thus:
929  *
930  *    #define _CTRL(n, x) ((n<<8)+x)
931  *    #define TCTRLCFOO  _CTRL('T', 1)
932  *
933  *  The select expressions match too much, but the c_fix code is cautious.
934  *
935  *  CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
936  */
937 fix = {
938     hackname  = ctrl_quotes_def;
939     select    = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
940     c_fix     = char_macro_def;
941     c_fix_arg = "CTRL";
942
943     /*
944      *  This is two tests in order to ensure that the "CTRL(c)" can
945      *  be selected in isolation from the multi-arg format
946      */
947     test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
948     test_text = "#define _CTRL(c) ('c'&037)";
949 };
950
951 fix = {
952     hackname  = ctrl_quotes_use;
953     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
954     c_fix     = char_macro_use;
955     c_fix_arg = "CTRL";
956     test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
957 };
958
959
960 /*
961  *  sys/mman.h on HP/UX is not C++ ready,
962  *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
963  *
964  *  rpc/types.h on OSF1/2.0 is not C++ ready,
965  *  even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
966  *
967  *  The problem is the declaration of malloc.
968  */
969 fix = {
970     hackname = cxx_unready;
971     files    = sys/mman.h;
972     files    = rpc/types.h;
973     select   = '[^#]+malloc.*;';  /* Catch any form of declaration
974                                      not within a macro.  */
975     bypass   = '"C"|__BEGIN_DECLS';
976
977     c_fix     = wrap;
978     c_fix_arg = "#ifdef __cplusplus\n"
979                 "extern \"C\" {\n"
980                 "#endif\n";
981     c_fix_arg = "#ifdef __cplusplus\n"
982                 "}\n"
983                 "#endif\n";
984     test_text = "extern void* malloc( size_t );";
985 };
986
987
988 /*
989  *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
990  *  by 'extern "C"'.  On darwin7 some mach/ headers aren't properly guarded.
991  */
992 fix = {
993   hackname  = darwin_externc;
994   mach      = "*-*-darwin*";
995   files     = mach-o/swap.h;
996   files     = mach/mach_time.h;
997   files     = mach/mach_traps.h;
998   files     = mach/message.h;
999   files     = mach/mig.h;
1000   files     = mach/semaphore.h;
1001   bypass    = "extern \"C\"";
1002   bypass    = "__BEGIN_DECLS";
1003   c_fix     = wrap;
1004   c_fix_arg = "#ifdef __cplusplus\n"
1005               "extern \"C\" {\n"
1006               "#endif\n";
1007   c_fix_arg = "#ifdef __cplusplus\n"
1008               "}\n"
1009               "#endif\n";
1010   test_text = "extern void swap_fat_header();\n";
1011 };
1012
1013
1014 /*
1015  * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1016  * bad __GNUC__ tests.
1017  */
1018
1019 fix = {
1020   hackname  = darwin_gcc4_breakage;
1021   mach      = "*-*-darwin*";
1022   files     = AvailabilityMacros.h;
1023   select    = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1024   c_fix     = format;
1025   c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1026   test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1027               "(__GNUC_MINOR__ >= 1)\n";
1028 };
1029
1030
1031 /*
1032  *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
1033  *  why would you ever put it in a system header file?
1034  */
1035 fix = {
1036   hackname  = darwin_private_extern;
1037   mach      = "*-*-darwin*";
1038   files     = mach-o/dyld.h;
1039   select    = "__private_extern__ [a-z_]+ _dyld_";
1040   c_fix     = format;
1041   c_fix_arg = "extern";
1042   c_fix_arg = "__private_extern__";
1043   test_text = "__private_extern__ int _dyld_func_lookup(\n"
1044               "const char *dyld_func_name,\n"
1045               "unsigned long *address);\n";
1046 };
1047
1048
1049 /*
1050  *  Fix <c_asm.h> on Digital UNIX V4.0:
1051  *  It contains a prototype for a DEC C internal asm() function,
1052  *  clashing with gcc's asm keyword.  So protect this with __DECC.
1053  */
1054 fix = {
1055     hackname = dec_intern_asm;
1056     files    = c_asm.h;
1057     sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1058     sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1059           "#endif\n";
1060     test_text =
1061     "float fasm {\n"
1062     "    ... asm stuff ...\n"
1063     "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1064 };
1065
1066
1067 /*
1068  * Fix typo in <wchar.h> on DJGPP 2.03.
1069  */
1070 fix = {
1071     hackname  = djgpp_wchar_h;
1072     file      = wchar.h;
1073     select    = "__DJ_wint_t";
1074     bypass    = "sys/djtypes.h";
1075     c_fix     = format;
1076     c_fix_arg = "%0\n#include <sys/djtypes.h>";
1077     c_fix_arg = "#include <stddef.h>";
1078     test_text = "#include <stddef.h>\n"
1079                 "extern __DJ_wint_t x;\n";
1080 };
1081
1082
1083 /*
1084  * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1085  */
1086 fix = {
1087     hackname  = ecd_cursor;
1088     files     = "sunwindow/win_lock.h";
1089     files     = "sunwindow/win_cursor.h";
1090     select    = 'ecd\.cursor';
1091     c_fix     = format;
1092     c_fix_arg = 'ecd_cursor';
1093
1094     test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1095 };
1096
1097
1098 /*
1099  *  math.h on SunOS 4 puts the declaration of matherr before the definition
1100  *  of struct exception, so the prototype (added by fixproto) causes havoc.
1101  *  This must appear before the math_exception fix.
1102  */
1103 fix = {
1104     hackname  = exception_structure;
1105     files     = math.h;
1106
1107     /*  If matherr has a prototype already, the header needs no fix.  */
1108     bypass    = 'matherr.*(struct exception|__MATH_EXCEPTION|[ \t]*__FP_EXCEPTION[ \t]*\*[ \t]*)';
1109     select    = matherr;
1110
1111     c_fix     = wrap;
1112     c_fix_arg = "struct exception;\n";
1113
1114     test_text = "extern int matherr();";
1115 };
1116
1117
1118 /*
1119  *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1120  *  neither the existence of GCC 3 nor its exact feature set yet break
1121  *  (by design?) when __GNUC__ is set beyond 2.
1122  */
1123 fix = {
1124     hackname  = freebsd_gcc3_breakage;
1125     mach      = "*-*-freebsd*";
1126     files     = sys/cdefs.h;
1127     select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1128     bypass    = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1129     c_fix     = format;
1130     c_fix_arg = '%0 || __GNUC__ >= 3';
1131     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1132 };
1133
1134
1135 /*
1136  *  Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1137  *  neither the existence of GCC 4 nor its exact feature set yet break
1138  *  (by design?) when __GNUC__ is set beyond 3.
1139  */
1140 fix = {
1141     hackname  = freebsd_gcc4_breakage;
1142     mach      = "*-*-freebsd*"; 
1143     files     = sys/cdefs.h;
1144     select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1145     c_fix     = format;
1146     c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1147     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1148 };
1149
1150
1151 /*
1152  *  Some versions of glibc don't expect the C99 inline semantics.
1153  */
1154 fix = {
1155     hackname  = glibc_c99_inline_1;
1156     files     = features.h, '*/features.h';
1157     select    = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1158     c_fix     = format;
1159     c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1160     test_text = <<-EOT
1161         #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1162             && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1163         # define __USE_EXTERN_INLINES   1
1164         #endif
1165         EOT;
1166 };
1167
1168
1169 /*
1170  *  Similar, but a version that didn't have __NO_INLINE__
1171  */
1172 fix = {
1173     hackname  = glibc_c99_inline_1a;
1174     files     = features.h, '*/features.h';
1175     select    = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1176                 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1177     c_fix     = format;
1178     c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1179     test_text = <<-EOT
1180         #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1181         # define __USE_EXTERN_INLINES   1
1182         #endif
1183         EOT;
1184 };
1185
1186
1187 /*
1188  * The glibc_c99_inline_1 fix should have fixed everything.  Unfortunately
1189  * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1190  * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1191  */
1192 fix = {
1193     hackname  = glibc_c99_inline_2;
1194     files     = sys/stat.h, '*/sys/stat.h';
1195     select    = "extern __inline__ int";
1196     sed     = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
1197               "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1198               "__inline__ int \\1/";
1199     sed     = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
1200               "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1201               "__inline__ int __REDIRECT\\1 (\\2/";
1202     sed     = "s/^extern __inline__ int/"
1203               "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1204               "__inline__ int/";
1205     test_text = <<-EOT
1206         extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1207         extern __inline__ int
1208         __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1209         {}
1210         EOT;
1211 };
1212
1213
1214 fix = {
1215     hackname  = glibc_c99_inline_3;
1216     files     = bits/string2.h, '*/bits/string2.h';
1217     select    = "extern __inline";
1218     bypass    = "__extern_inline|__GNU_STDC_INLINE__";
1219     c_fix     = format;
1220     c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1221     c_fix_arg = "^# ifdef __cplusplus$";
1222     test_text = <<-EOT
1223         # ifdef __cplusplus
1224         #  define __STRING_INLINE inline
1225         # else
1226         #  define __STRING_INLINE extern __inline
1227         # endif
1228         EOT;
1229 };
1230
1231
1232 fix = {
1233     hackname  = glibc_c99_inline_4;
1234     files     = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1235     bypass    = "__extern_inline|__gnu_inline__";
1236     select    = "(^| )extern __inline";
1237     c_fix     = format;
1238     c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1239     test_text = <<-EOT
1240         __extension__ extern __inline unsigned int
1241         extern __inline unsigned int
1242         EOT;
1243 };
1244
1245
1246 /*  glibc-2.3.5 defines pthread mutex initializers incorrectly,
1247  *  so we replace them with versions that correspond to the
1248  *  definition.
1249  */
1250 fix = {
1251     hackname = glibc_mutex_init;
1252     files    = pthread.h;
1253     select   = '\{ *\{ *0, *\} *\}';
1254     sed      = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/,+1"
1255                "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/";
1256     sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1257     sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1258     sed      = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1259                "N;s/^[ \t]*#[ \t]*"
1260                "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1261                "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
1262                "#  \\1\\n"
1263                "  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1264                "# else\\n"
1265                "#  \\1\\n"
1266                "  { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1267                "# endif/";
1268     sed      = "s/{ \\(0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1269     sed      = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
1270                "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1271
1272     test_text = <<- _EOText_
1273         #define PTHREAD_MUTEX_INITIALIZER \\
1274           { { 0, } }
1275         #ifdef __USE_GNU
1276         # if __WORDSIZE == 64
1277         #  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1278           { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1279         #  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1280           { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1281         #  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1282           { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1283         # else
1284         #  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1285           { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1286         #  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1287           { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1288         #  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1289           { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1290         # endif
1291         #endif
1292         # define PTHREAD_RWLOCK_INITIALIZER \\
1293           { { 0, } }
1294         # ifdef __USE_GNU
1295         #  if __WORDSIZE == 64
1296         #   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1297           { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                           \\
1298               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1299         #  else
1300         #   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1301           { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1302         #  endif
1303         # endif
1304         #define PTHREAD_COND_INITIALIZER { { 0, } }
1305         _EOText_;
1306 };
1307
1308
1309 /*
1310  * Fix these files to use the types we think they should for
1311  * ptrdiff_t, size_t, and wchar_t.
1312  *
1313  * This defines the types in terms of macros predefined by our 'cpp'.
1314  * This is supposedly necessary for glibc's handling of these types.
1315  * It's probably not necessary for anyone else, but it doesn't hurt.
1316  */
1317 fix = {
1318     hackname  = gnu_types;
1319     files  = "sys/types.h";
1320     files  = "stdlib.h";
1321     files  = "sys/stdtypes.h";
1322     files  = "stddef.h";
1323     files  = "memory.h";
1324     files  = "unistd.h";
1325     bypass    = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1326     select    = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1327     c_fix     = gnu_type;
1328     /* The Solaris 10 headers already define these types correctly.  */
1329     mach   = '*-*-solaris2.1[0-9]*';
1330     not_machine = true;
1331
1332     test_text = "typedef long int ptrdiff_t; /* long int */\n"
1333                 "typedef uint_t size_t; /* uint_t */\n"
1334                 "typedef ushort_t wchar_t; /* ushort_t */";
1335 };
1336
1337
1338 /*
1339  *  Fix HP & Sony's use of "../machine/xxx.h"
1340  *  to refer to:  <machine/xxx.h>
1341  */
1342 fix = {
1343     hackname  = hp_inline;
1344     files     = sys/spinlock.h;
1345     files     = machine/machparam.h;
1346     select    = "[ \t]*#[ \t]*include[ \t]+"  '"\.\./machine/';
1347
1348     c_fix     = format;
1349     c_fix_arg = "%1<machine/%2.h>";
1350
1351     c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)"  '"\.\./machine/'
1352                 '([a-z]+)\.h"';
1353
1354     test_text = ' # include "../machine/mumble.h"';
1355 };
1356
1357
1358 /*
1359  *  Check for (...) in C++ code in HP/UX sys/file.h.
1360  */
1361 fix = {
1362     hackname  = hp_sysfile;
1363     files     = sys/file.h;
1364     select    = "HPUX_SOURCE";
1365
1366     c_fix     = format;
1367     c_fix_arg = "(struct file *, ...)";
1368     c_fix_arg = '\(\.\.\.\)';
1369
1370     test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1371 };
1372
1373
1374 /*
1375  * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1376  * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1377  */
1378 fix = {
1379     hackname  = hpux10_cpp_pow_inline;
1380     files     = fixinc-test-limits.h, math.h;
1381     select    = <<-     END_POW_INLINE
1382         ^# +ifdef +__cplusplus
1383          +\}
1384          +inline +double +pow\(double +__d,int +__expon\) +\{
1385         [       ]+return +pow\(__d,\(double\)__expon\);
1386          +\}
1387          +extern +"C" +\{
1388         #else
1389         # +endif
1390         END_POW_INLINE;
1391  
1392     c_fix     = format;
1393     c_fix_arg = "";
1394
1395     test_text =
1396         "#    ifdef __cplusplus\n"
1397         "     }\n"
1398         "     inline double pow(double __d,int __expon) {\n"
1399         "\t return pow(__d,(double)__expon);\n"
1400         "     }\n"
1401         '     extern "C"' " {\n"
1402         "#else\n"
1403         "#    endif";
1404 };
1405
1406 fix = {
1407      hackname  = hpux11_cpp_pow_inline;
1408      files     = math.h;
1409      select    = " +inline double pow\\(double d,int expon\\) \\{\n"
1410                  " +return pow\\(d, \\(double\\)expon\\);\n"
1411                  " +\\}\n";
1412      c_fix     = format;
1413      c_fix_arg = "";
1414
1415      test_text =
1416             "   inline double pow(double d,int expon) {\n"
1417             "     return pow(d, (double)expon);\n"
1418             "   }\n";
1419 };
1420
1421
1422 fix = {
1423      hackname  = hppa_hpux_fp_macros;
1424      mach      = "hppa*-hp-hpux11*";
1425      files     = math.h;
1426      select    = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1427                  "#[ \t]*define[ \t]*FP_ZERO.*\n"
1428                  "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1429                  "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1430                  "#[ \t]*define[ \t]*FP_NAN.*\n";
1431      c_fix     = format;
1432      c_fix_arg = "#endif /* _INCLUDE_HPUX_SOURCE */\n\n#if defined(_INCLUDE_HPUX_SOURCE) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))\n%0#endif\n\n#ifdef _INCLUDE_HPUX_SOURCE\n";
1433
1434      test_text =
1435             "#  define FP_NORMAL     0\n"
1436             "#  define FP_ZERO       1\n"
1437             "#  define FP_INFINITE   2\n"
1438             "#  define FP_SUBNORMAL  3\n"
1439             "#  define FP_NAN        4\n";
1440 };
1441
1442
1443 /*
1444  *  Fix hpux 10.X missing ctype declarations 1
1445  */
1446 fix = {
1447     hackname = hpux10_ctype_declarations1;
1448     files    = ctype.h;
1449     select   = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1450     bypass   = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1451     c_fix     = format;
1452     c_fix_arg = "#ifdef _PROTOTYPES\n"
1453                 "extern int __tolower(int);\n"
1454                 "extern int __toupper(int);\n"
1455                 "#else /* NOT _PROTOTYPES */\n"
1456                 "extern int __tolower();\n"
1457                 "extern int __toupper();\n"
1458                 "#endif /* _PROTOTYPES */\n\n"
1459                 "%0\n";
1460
1461     test_text = "#  define _toupper(__c)         __toupper(__c)\n";
1462 };
1463
1464
1465 /*
1466  *  Fix hpux 10.X missing ctype declarations 2
1467  */
1468 fix = {
1469     hackname = hpux10_ctype_declarations2;
1470     files    = ctype.h;
1471     select   = "^#  if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1472     bypass   = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1473     c_fix     = format;
1474     c_fix_arg = "%0\n\n"
1475                 "#ifdef _PROTOTYPES\n"
1476                 "     extern int _isalnum(int);\n"
1477                 "     extern int _isalpha(int);\n"
1478                 "     extern int _iscntrl(int);\n"
1479                 "     extern int _isdigit(int);\n"
1480                 "     extern int _isgraph(int);\n"
1481                 "     extern int _islower(int);\n"
1482                 "     extern int _isprint(int);\n"
1483                 "     extern int _ispunct(int);\n"
1484                 "     extern int _isspace(int);\n"
1485                 "     extern int _isupper(int);\n"
1486                 "     extern int _isxdigit(int);\n"
1487                 "#  else /* not _PROTOTYPES */\n"
1488                 "     extern int _isalnum();\n"
1489                 "     extern int _isalpha();\n"
1490                 "     extern int _iscntrl();\n"
1491                 "     extern int _isdigit();\n"
1492                 "     extern int _isgraph();\n"
1493                 "     extern int _islower();\n"
1494                 "     extern int _isprint();\n"
1495                 "     extern int _ispunct();\n"
1496                 "     extern int _isspace();\n"
1497                 "     extern int _isupper();\n"
1498                 "     extern int _isxdigit();\n"
1499                 "#endif /* _PROTOTYPES */\n";
1500
1501     test_text = "#  if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1502                 "     extern unsigned int *__SB_masks;\n";
1503 };
1504
1505
1506 /*
1507  *  Fix hpux 10.X missing stdio declarations
1508  */
1509 fix = {
1510     hackname = hpux10_stdio_declarations;
1511     files    = stdio.h;
1512     select   = "^#[ \t]*define _iob[ \t]*__iob";
1513     bypass   = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1514     c_fix     = format;
1515     c_fix_arg = "%0\n\n"
1516         "#  if defined(__STDC__) || defined(__cplusplus)\n"
1517         "     extern int snprintf(char *, size_t, const char *, ...);\n"
1518         "     extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1519         "#  else /* not __STDC__) || __cplusplus */\n"
1520         "     extern int snprintf();\n"
1521         "     extern int vsnprintf();\n"
1522         "#  endif /* __STDC__) || __cplusplus */\n";
1523
1524     test_text = "#  define _iob __iob\n";
1525 };
1526
1527
1528 /*
1529  *  Make sure hpux defines abs in header.
1530  */
1531 fix = {
1532     hackname  = hpux11_abs;
1533     mach      = "ia64-hp-hpux11*";
1534     files     = stdlib.h;
1535     select    = "ifndef _MATH_INCLUDED";
1536     c_fix     = format;
1537     c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1538 //  sed       = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1539     test_text = "#ifndef _MATH_INCLUDED";
1540 };
1541
1542
1543 /*
1544  *  Keep HP-UX 11 from stomping on C++ math namespace
1545  *  with defines for fabsf.
1546  */
1547 fix = {
1548     hackname  = hpux11_fabsf;
1549     files     = math.h;
1550     select    = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1551     bypass    = "__cplusplus";
1552
1553     c_fix     = format;
1554     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1555
1556     test_text =
1557     "#ifdef _PA_RISC\n"
1558     "#  define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1559     "#endif";
1560 };
1561
1562
1563 /*
1564  * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1565  * being defined by having it define _hpux_size_t instead.
1566  */
1567 fix = {
1568     hackname  = hpux11_size_t;
1569     mach      = "*-hp-hpux11*";
1570     select    = "__size_t";
1571
1572     c_fix     = format;
1573     c_fix_arg = "_hpux_size_t";
1574
1575     test_text =
1576     "#define __size_t size_t\n"
1577     "       extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1578 };
1579
1580
1581 /*
1582  *  Fix hpux 11.00 broken snprintf declaration
1583  *  (third argument is char *, needs to be const char * to prevent
1584  *  spurious warnings with -Wwrite-strings or in C++).
1585  */
1586 fix = {
1587     hackname = hpux11_snprintf;
1588     files    = stdio.h;
1589     select   = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1590                                     ' *(char *\*, *\.\.\.\);)';
1591     c_fix     = format;
1592     c_fix_arg = '%1 const %3';
1593
1594     test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1595                 "extern int snprintf(char *, __size_t, char *, ...);\n"
1596                 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1597 };
1598
1599
1600 /*
1601  * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1602  * of UINT32_C has undefined behavior according to ISO/ANSI:
1603  * the arguments to __CONCAT__ are not macro expanded before the
1604  * concatination happens so the trailing ')' in the first argument
1605  * is concatinated with the 'l' in the second argument creating an
1606  * invalid pp token.  The behavior of invalid pp tokens is undefined.
1607  * GCC does not handle these invalid tokens the way the HP compiler does.
1608  * This problem will potentially occur anytime macros are used in the
1609  * arguments to __CONCAT__.  A general solution to this problem would be to
1610  * insert another layer of macro between __CONCAT__ and its use
1611  * in UINT32_C.  An example of this solution can be found in the C standard.
1612  * A more specific solution, the one used here, is to change the UINT32_C
1613  * macro to not used macros in the arguments to __CONCAT__.
1614  */
1615 fix = {
1616     hackname = hpux11_uint32_c;
1617     files    = inttypes.h;
1618     select   = "^#define UINT32_C\\(__c\\)[ \t]*"
1619                          "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1620     c_fix    = format;
1621     c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1622     test_text =
1623     "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1624     "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1625 };
1626
1627
1628 /*
1629  *  Fix hpux 11.00 broken vsnprintf declaration
1630  */
1631 fix = {
1632     hackname = hpux11_vsnprintf;
1633     files    = stdio.h;
1634     select   = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1635                                      'const char \*,) __va__list\);';
1636     c_fix     = format;
1637     c_fix_arg = "%1 __va_list);";
1638
1639     test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1640                                      ' __va__list);';
1641 };
1642
1643
1644 /*
1645  *  get rid of bogus inline definitions in HP-UX 8.0
1646  */
1647 fix = {
1648     hackname = hpux8_bogus_inlines;
1649     files    = math.h;
1650     select   = inline;
1651     bypass   = "__GNUG__";
1652     sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1653            "@extern \"C\" int abs(int);@";
1654     sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1655     sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1656     sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1657     test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1658                 "inline double sqr(double v) { return v**0.5; }";
1659 };
1660
1661
1662 /*
1663  *  Fix hpux broken ctype macros
1664  */
1665 fix = {
1666     hackname = hpux_ctype_macros;
1667     files    = ctype.h;
1668     select   = '((: |\()__SB_masks \? )'
1669                '(__SB_masks\[__(alnum|c)\] & _IS)';
1670     c_fix     = format;
1671     c_fix_arg = "%1(int)%3";
1672
1673     test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1674                 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1675 };
1676
1677
1678 /*
1679  *  Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1680  */
1681 fix = {
1682     hackname = hpux_htonl;
1683     files    = netinet/in.h;
1684     select   = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1685                "(/\\*\n"
1686                " \\* Macros for number representation conversion\\.\n"
1687                " \\*/\n"
1688                "#ifndef ntohl)";
1689     c_fix     = format;
1690     c_fix_arg = "#if 1\n%1";
1691
1692     test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1693                 "/*\n"
1694                 " * Macros for number representation conversion.\n"
1695                 " */\n"
1696                 "#ifndef ntohl\n"
1697                 "#define ntohl(x)        (x)\n"
1698                 "#define ntohs(x)        (x)\n"
1699                 "#define htonl(x)        (x)\n"
1700                 "#define htons(x)        (x)\n"
1701                 "#endif\n"
1702                 "#endif  /* ! _XOPEN_SOURCE_EXTENDED */";
1703 };
1704
1705
1706 /*
1707  * HP-UX long_double
1708  */
1709 fix = {
1710     hackname  = hpux_long_double;
1711     files     = stdlib.h;
1712     select    = "extern[ \t]long_double[ \t]strtold";
1713     bypass    = "long_double_t";
1714     sed       = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1715     sed       = "s/long_double/long double/g";
1716
1717     test_text = "#  ifndef _LONG_DOUBLE\n"
1718                 "#    define _LONG_DOUBLE\n"
1719                 "     typedef struct {\n"
1720                 "       unsigned int word1, word2, word3, word4;\n"
1721                 "     } long_double;\n"
1722                 "#  endif /* _LONG_DOUBLE */\n"
1723                 "extern long_double strtold(const char *, char **);\n";
1724 };
1725
1726
1727 /*
1728  *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1729  */
1730 fix = {
1731     hackname = hpux_systime;
1732     files    = sys/time.h;
1733     select   = "^extern struct sigevent;";
1734
1735     c_fix     = format;
1736     c_fix_arg = "struct sigevent;";
1737
1738     test_text = 'extern struct sigevent;';
1739 };
1740
1741
1742 /*
1743  *  Wrap spu_info in ifdef _KERNEL.  GCC cannot handle an array of unknown
1744  *  type and mpinfou is only defined when _KERNEL is set.
1745  */
1746 fix = {
1747     hackname = hpux_spu_info;
1748     mach     = "*-hp-hpux*";
1749     files    = ia64/sys/getppdp.h;
1750     select   = "^.*extern.*spu_info.*";
1751
1752     c_fix     = format;
1753     c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
1754
1755     test_text = "extern union mpinfou spu_info[];";
1756 };
1757
1758 fix = {
1759     hackname  = hpux11_extern_sendfile;
1760     mach      = "*-hp-hpux11.[12]*";
1761     files     = sys/socket.h;
1762     select    = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
1763     c_fix     = format;
1764     c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1765     test_text = "   extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
1766 };
1767
1768 fix = {
1769     hackname  = hpux11_extern_sendpath;
1770     mach      = "*-hp-hpux11.[12]*";
1771     files     = sys/socket.h;
1772     select    = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
1773     c_fix     = format;
1774     c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1775     test_text = "   extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
1776 };
1777
1778 fix = {
1779     hackname  = hpux_extern_errno;
1780     mach      = "*-hp-hpux10.*";
1781     mach      = "*-hp-hpux11.[0-2]*";
1782     files     = errno.h;
1783     select    = "^[ \t]*extern int errno;$";
1784     c_fix     = format;
1785     c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
1786     test_text = "   extern int errno;\n";
1787 };
1788
1789 /*
1790  *  Fix C99 constant in __POINTER_SET define.
1791  */
1792 fix = {
1793     hackname  = hpux11_pthread_const;
1794     mach      = "*-hp-hpux11.[0-3]*";
1795     files     = sys/pthread.h;
1796     select    = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1797
1798     c_fix     = format;
1799     c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1800     test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1801 };
1802
1803 /*
1804  *  Add missing braces to pthread initializer defines.
1805  */
1806 fix = {
1807     hackname  = hpux_pthread_initializers;
1808     mach      = "*-hp-hpux11.[0-3]*";
1809     files     = sys/pthread.h;
1810     sed       = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
1811                  "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
1812     sed       = "s@^[ \t]*1,[ \t]*\\\\"
1813                  "@\t{ 1, 0 }@";
1814     sed       = "/^[ \t]*0$/d";
1815     sed       = "s@__PTHREAD_MUTEX_VALID, 0"
1816                  "@{ __PTHREAD_MUTEX_VALID, 0 }@";
1817     sed       = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
1818                  "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
1819     sed       = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1820                  "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1821     sed       = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1822                  "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1823     sed       = "s@^[ \t]*0, 0[ \t]*\\\\"
1824                  "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
1825     sed       = "s@__PTHREAD_COND_VALID, 0"
1826                  "@{ __PTHREAD_COND_VALID, 0 }@";
1827     sed       = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
1828                  "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
1829     sed       = "s@__PTHREAD_RWLOCK_VALID, 0"
1830                  "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
1831     sed       = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
1832                  "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
1833     sed       = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
1834                  "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
1835     test_text = "#define PTHREAD_MUTEX_INITIALIZER  {\t\t\t\t\t\\\\\n"
1836                 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
1837                 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
1838                 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
1839                 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
1840                 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
1841                 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
1842                 "}\n";
1843 };
1844
1845 /*
1846  *  Fix glibc definition of HUGE_VAL in terms of hex floating point constant
1847  */
1848 fix = {
1849     hackname  = huge_val_hex;
1850     files     = bits/huge_val.h;
1851     select    = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
1852     bypass    = "__builtin_huge_val";
1853
1854     c_fix     = format;
1855     c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
1856
1857     test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
1858 };
1859
1860
1861 /*
1862  *  Fix glibc definition of HUGE_VALF in terms of hex floating point constant
1863  */
1864 fix = {
1865     hackname  = huge_valf_hex;
1866     files     = bits/huge_val.h;
1867     select    = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
1868     bypass    = "__builtin_huge_valf";
1869
1870     c_fix     = format;
1871     c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
1872
1873     test_text = "#  define HUGE_VALF (__extension__ 0x1.0p255f)";
1874 };
1875
1876
1877 /*
1878  *  Fix glibc definition of HUGE_VALL in terms of hex floating point constant
1879  */
1880 fix = {
1881     hackname  = huge_vall_hex;
1882     files     = bits/huge_val.h;
1883     select    = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
1884     bypass    = "__builtin_huge_vall";
1885
1886     c_fix     = format;
1887     c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
1888
1889     test_text = "#  define HUGE_VALL (__extension__ 0x1.0p32767L)";
1890 };
1891
1892
1893 /*
1894  *  Fix return type of abort and free
1895  */
1896 fix = {
1897     hackname  = int_abort_free_and_exit;
1898     files     = stdlib.h;
1899     select    = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1900     bypass    = "_CLASSIC_ANSI_TYPES";
1901
1902     c_fix     = format;
1903     c_fix_arg = "void\t%1(";
1904
1905     test_text = "extern int abort(int);\n"
1906                 "extern int free(void*);\n"
1907                 "extern int exit(void*);";
1908 };
1909
1910
1911 /*
1912  *  Fix various macros used to define ioctl numbers.
1913  *  The traditional syntax was:
1914  *
1915  *    #define _IO(n, x) (('n'<<8)+x)
1916  *    #define TIOCFOO _IO(T, 1)
1917  *
1918  *  but this does not work with the C standard, which disallows macro
1919  *  expansion inside strings.  We have to rewrite it thus:
1920  *
1921  *    #define _IO(n, x) ((n<<8)+x)
1922  *    #define TIOCFOO  _IO('T', 1)
1923  *
1924  *  The select expressions match too much, but the c_fix code is cautious.
1925  *
1926  *  _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1927  */
1928 fix = {
1929     hackname  = io_quotes_def;
1930     select    = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1931     c_fix     = char_macro_def;
1932     c_fix_arg = "IO";
1933     test_text =
1934     "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1935     "#define _IOWN(x,y,t)  (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1936     "#define _IO(x,y)      ('x'<<8|y)";
1937     test_text =
1938     "#define XX_IO(x)        ('x'<<8|256)";
1939 };
1940
1941 fix = {
1942     hackname  = io_quotes_use;
1943     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1944                 "\\( *[^,']";
1945     c_fix     = char_macro_use;
1946     c_fix_arg = "IO";
1947     test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1948                 "#define TIOCFOO \\\\\n"
1949                 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1950 };
1951
1952
1953 /*
1954  *  Check for missing ';' in struct
1955  */
1956 fix = {
1957     hackname = ip_missing_semi;
1958     files    = netinet/ip.h;
1959     select   = "}$";
1960     sed      = "/^struct/,/^};/s/}$/};/";
1961     test_text=
1962     "struct mumble {\n"
1963     "  union {\n"
1964     "    int x;\n"
1965     "  }\n"
1966     "}; /* mumbled struct */\n";
1967 };
1968
1969
1970 /*
1971  *  IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1972  *  __restrict as restrict iff __c99.  This is wrong for C++, which
1973  *  needs many C99 features, but only supports __restrict.
1974  */
1975 fix = {
1976     hackname  = irix___restrict;
1977     files     = internal/sgimacros.h;
1978     select    = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1979
1980     mach      = "mips-sgi-irix6.5";
1981     c_fix     = format;
1982     c_fix_arg = "%1"
1983                 "#  ifndef __cplusplus\n%2\n#  endif";
1984
1985     test_text = "#ifdef __c99\n#  define __restrict restrict";
1986 };
1987
1988 /*
1989  * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
1990  * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit 
1991  * functions.
1992  *
1993  * This was probably introduced around IRIX 6.5.18
1994  */
1995 fix = {
1996     hackname  = irix___generic1;
1997     files     = internal/math_core.h;
1998     mach      = "mips-sgi-irix6.5";
1999     select    = "#define ([a-z]+)\\(x\\) *__generic.*";
2000
2001     c_fix     = format;
2002     c_fix_arg = "extern int %1(double);\n"
2003                 "extern int %1f(float);\n"
2004                 "extern int %1l(long double);\n"
2005                 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
2006                 "               : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
2007                 "               : _%1l(x))\n";
2008
2009     test_text = 
2010       "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2011 };
2012
2013
2014 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2015    compiler's __generic intrinsic to define isgreater, isgreaterequal,
2016    isless, islessequal, islessgreater and isunordered functions.  */
2017 fix = {
2018     hackname  = irix___generic2;
2019     files     = internal/math_core.h;
2020     mach      = "mips-sgi-irix6.5";
2021     select    = "#define ([a-z]+)\\(x,y\\) *__generic.*";
2022
2023     c_fix     = format;
2024     c_fix_arg = "#define %1(x,y) \\\n"
2025                 "  ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2026                 "   : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2027                 "   : _%1l(x,y))\n";
2028
2029     test_text = 
2030       "#define isless(x,y)         __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2031 };
2032
2033
2034 /*
2035  *  IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2036  *  that causes the assembly preprocessor to complain about an
2037  *  unterminated character constant.
2038  */
2039 fix = {
2040     hackname  = irix_asm_apostrophe;
2041     files     = sys/asm.h;
2042
2043     select    = "^[ \t]*#.*[Ww]e're";
2044     c_fix     = format;
2045     c_fix_arg = "%1 are";
2046     c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
2047     test_text = "\t# and we're on vacation";
2048 };
2049
2050
2051 /*
2052  *  Non-traditional "const" declaration in Irix's limits.h.
2053  */
2054 fix = {
2055     hackname    = irix_limits_const;
2056     files       = fixinc-test-limits.h, limits.h;
2057     select      = "^extern const ";
2058     c_fix       = format;
2059     c_fix_arg   = "extern __const ";
2060     test_text   = "extern const char limit; /* test limits */";
2061 };
2062
2063
2064 /*
2065  *  IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2066  *  Various socket function prototypes use different types instead,
2067  *  depending on the API in use (BSD, XPG4/5), but the socklen_t
2068  *  definition doesn't reflect this (SGI Bug Id 864477, fixed in
2069  *  IRIX 6.5.19).
2070  */
2071 fix = {
2072     hackname  = irix_socklen_t;
2073     files     = sys/socket.h;
2074     select    = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2075
2076     mach      = "mips-sgi-irix6.5";
2077     c_fix     = format;
2078     c_fix_arg = "%1"
2079                 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2080                 "typedef int socklen_t;\n"
2081                 "#else\n"
2082                 "%2\n"
2083                 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2084
2085     test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2086 };
2087
2088 /*
2089  *  IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2090  *  otherwise.
2091  */
2092 fix = {
2093     hackname  = irix_stdint_c99;
2094     files     = stdint.h;
2095     select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
2096
2097     mach      = "mips-sgi-irix6.5";
2098     c_fix  = format;
2099     c_fix_arg = "#if 0\n"
2100                 "%2";
2101     test_text =
2102     "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
2103 };
2104
2105
2106 /*
2107  *  IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2108  *  some functions that take a va_list as
2109  *  taking char *.  However, GCC uses void * for va_list, so
2110  *  calling vfprintf with a va_list fails in C++.  */
2111 fix = {
2112     hackname  = irix_stdio_va_list;
2113     files     = stdio.h;
2114     files     = internal/stdio_core.h;
2115
2116     select = '/\* va_list \*/ char \*';
2117     c_fix  = format;
2118     c_fix_arg = "__gnuc_va_list";
2119     test_text =
2120     "extern int printf( const char *, /* va_list */ char * );";
2121 };
2122
2123
2124 /*
2125  *  IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2126  *  wcsftime by default.  ISO C99 requires the XPG5 variant instead.
2127  */
2128 fix = {
2129     hackname  = irix_wcsftime;
2130     files     = internal/wchar_core.h;
2131     select    = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2132
2133     mach      = "mips-sgi-irix6.5";
2134     c_fix     = format;
2135     c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2136
2137     test_text = "#if _NO_XOPEN5\n"
2138                 "extern size_t          wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
2139 };
2140
2141 /*
2142  * Fixing ISC fmod declaration
2143  */
2144 fix = {
2145     hackname  = isc_fmod;
2146     files     = math.h;
2147     select    = 'fmod\(double\)';
2148     c_fix     = format;
2149     c_fix_arg = "fmod(double, double)";
2150     test_text = "extern double  fmod(double);";
2151 };
2152
2153
2154 /*
2155  *  On Interactive Unix 2.2, certain traditional Unix definitions
2156  *  (notably getc and putc in stdio.h) are omitted if __STDC__ is
2157  *  defined, not just if _POSIX_SOURCE is defined.  This makes it
2158  *  impossible to compile any nontrivial program except with -posix.
2159  */
2160 fix = {
2161     hackname = isc_omits_with_stdc;
2162
2163     files     = "stdio.h";
2164     files     = "math.h";
2165     files     = "ctype.h";
2166     files     = "sys/limits.h";
2167     files     = "sys/fcntl.h";
2168     files     = "sys/dirent.h";
2169
2170     select    = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
2171     c_fix     = format;
2172     c_fix_arg = '!defined(_POSIX_SOURCE)';
2173     test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
2174                 "\nint foo;\n#endif";
2175 };
2176
2177
2178 /*
2179  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2180  * use / * * / to concatenate tokens.
2181  */
2182 fix = {
2183     hackname = kandr_concat;
2184     files  = "sparc/asm_linkage.h";
2185     files  = "sun*/asm_linkage.h";
2186     files  = "arm/as_support.h";
2187     files  = "arm/mc_type.h";
2188     files  = "arm/xcb.h";
2189     files  = "dev/chardefmac.h";
2190     files  = "dev/ps_irq.h";
2191     files  = "dev/screen.h";
2192     files  = "dev/scsi.h";
2193     files  = "sys/tty.h";
2194     files  = "Xm.acorn/XmP.h";
2195     files  = bsd43/bsd43_.h;
2196     select = '/\*\*/';
2197     c_fix     = format;
2198     c_fix_arg = '##';
2199     test_text = "#define __CONCAT__(a,b) a/**/b";
2200 };
2201
2202
2203 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2204  * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2205  * constant on recent versions of g++.
2206  */
2207 fix = {
2208     hackname = linux_ia64_ucontext;
2209     files = "sys/ucontext.h";
2210     mach = "ia64-*-linux*";
2211     select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2212              '->sc_gr\[0\]\) - \(char \*\) 0\)';
2213     c_fix = format;
2214     c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2215     test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2216         "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2217 };
2218
2219
2220 /*
2221  * Apparently some SVR4 systems typedef longlong_t to long ?
2222  */
2223 #ifdef SVR4
2224 fix = {
2225     hackname  = longlong_t;
2226     select    = "typedef[ \t]+(unsigned[ \t]+)?long[ \t]+(u_)?longlong_t";
2227     c_fix     = format;
2228     c_fix_arg = "typedef %1long long %2longlong_t";
2229     test_text = "typedef long longlong_t\n"
2230                 "typedef unsigned long u_longlong_t";
2231 };
2232 #endif
2233
2234 /* 
2235  *  Remove header file warning from sys/time.h.  Autoconf's
2236  *  AC_HEADER_TIME recommends to include both sys/time.h and time.h
2237  *  which causes warning on LynxOS.  Remove the warning.
2238  */
2239 fix = {
2240     hackname  = lynxos_no_warning_in_sys_time_h;
2241     files     = sys/time.h;
2242     select    = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2243     c_fix     = format;
2244     c_fix_arg = "";
2245     test_text = "#warning Using <time.h> instead of <sys/time.h>";
2246 };
2247
2248
2249 /* 
2250  *  Add missing declaration for putenv.
2251  */
2252 fix = {
2253     hackname  = lynxos_missing_putenv;
2254     mach      = '*-*-lynxos*';
2255     files     = stdlib.h;
2256     bypass    = 'putenv[ \t]*\\(';
2257     select    = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2258     c_fix     = format;
2259     c_fix_arg = "%0\n"
2260         "extern int putenv                              _AP((char *));";
2261     c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2262     test_text = "extern char *getenv    _AP((const char *));";
2263 };
2264
2265
2266 /*
2267  * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2268  *
2269  * On NetBSD, machine is a symbolic link to an architecture specific
2270  * directory name, so we can't match a specific file name here.
2271  */
2272 fix = {
2273     hackname = machine_ansi_h_va_list;
2274     select   = "define[ \t]+_BSD_VA_LIST_[ \t]";
2275     bypass   = '__builtin_va_list';
2276
2277     c_fix     = format;
2278     c_fix_arg = "%1__builtin_va_list";
2279     c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2280
2281     test_text = " # define _BSD_VA_LIST_\tchar**";
2282 };
2283
2284
2285 /*
2286  *  Fix non-ansi machine name defines
2287  */
2288 fix = {
2289     hackname  = machine_name;
2290     c_test    = machine_name;
2291     c_fix     = machine_name;
2292
2293     test_text = "/* MACH_DIFF: */\n"
2294     "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2295     "\n/* no uniform test, so be careful  :-) */";
2296 };
2297
2298
2299 /*
2300  *  Some math.h files define struct exception (it's in the System V
2301  *  Interface Definition), which conflicts with the class exception defined
2302  *  in the C++ file std/stdexcept.h.  We redefine it to __math_exception.
2303  *  This is not a great fix, but I haven't been able to think of anything
2304  *  better.  Note that we have to put the #ifdef/#endif blocks at beginning
2305  *  and end of file, because fixproto runs after us and may insert
2306  *  additional references to struct exception.
2307  */
2308 fix = {
2309     hackname  = math_exception;
2310     files     = math.h;
2311     select    = "struct exception";
2312     /*
2313      * This should be bypassed on __cplusplus, but some supposedly C++ C++
2314      * aware headers, such as Solaris 8 and 9, don't wrap their struct
2315      * exception either.  So currently we bypass only for glibc, based on a
2316      * comment in the fixed glibc header.  Ick.
2317      */
2318     bypass    = 'We have a problem when using C\+\+|for C\+\+, _[a-z0-9A-Z_]+_exception; for C, exception';
2319     c_fix     = wrap;
2320
2321     c_fix_arg = "#ifdef __cplusplus\n"
2322                 "#define exception __math_exception\n"
2323                 "#endif\n";
2324
2325     c_fix_arg = "#ifdef __cplusplus\n"
2326                 "#undef exception\n"
2327                 "#endif\n";
2328
2329     test_text = "typedef struct exception t_math_exception;";
2330 };
2331
2332
2333 /*
2334  *  This looks pretty broken to me.  ``dbl_max_def'' will contain
2335  *  "define DBL_MAX " at the start, when what we really want is just
2336  *  the value portion.  Can't figure out how to write a test case
2337  *  for this either  :-(
2338  */
2339 fix = {
2340     hackname = math_huge_val_from_dbl_max;
2341     files    = math.h;
2342
2343     /*
2344      * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2345      * in math.h, this fix applies.
2346      */
2347     select   = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2348     bypass   = "define[ \t]+DBL_MAX";
2349
2350     shell    =
2351     /*
2352      *  See if we have a definition for DBL_MAX in float.h.
2353      *  If we do, we will replace the one in math.h with that one.
2354      */
2355
2356     "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2357                    "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2358
2359     "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2360     "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2361                         "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2362     "\telse cat\n"
2363     "\tfi";
2364
2365     test_text =
2366     "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2367     "#define HUGE_VAL DBL_MAX";
2368 };
2369
2370
2371 /*
2372  *  nested comment
2373  */
2374 fix = {
2375     hackname  = nested_auth_des;
2376     files     = rpc/rpc.h;
2377     select    = '(/\*.*rpc/auth_des\.h>.*)/\*';
2378     c_fix     = format;
2379     c_fix_arg = "%1*/ /*";
2380     test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2381 };
2382
2383
2384 /*
2385  * Fixing nested comments in ISC <sys/limits.h>
2386  */
2387 fix = {
2388     hackname = nested_sys_limits;
2389     files  = sys/limits.h;
2390     select = CHILD_MAX;
2391     sed    = "/CHILD_MAX/s,/\\* Max, Max,";
2392     sed    = "/OPEN_MAX/s,/\\* Max, Max,";
2393     test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
2394                 "#define OPEN_MAX  20 /* Max, Max, ... */\n";
2395 };
2396
2397
2398 /*
2399  *  Some versions of NetBSD don't expect the C99 inline semantics.
2400  */
2401 fix = {
2402     hackname  = netbsd_c99_inline_1;
2403     mach      = "*-*-netbsd*";
2404     files     = signal.h;
2405     select    = "extern __inline int";
2406
2407     c_fix     = format;
2408     c_fix_arg = "extern\n#ifdef __GNUC_STDC_INLINE__\n__attribute__((__gnu_inline__))\n#endif\n__inline int";
2409
2410     test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2411 };
2412
2413
2414 fix = {
2415     hackname  = netbsd_c99_inline_2;
2416     mach      = "*-*-netbsd*";
2417     files     = signal.h;
2418     select    = "#define _SIGINLINE extern __inline";
2419
2420     c_fix     = format;
2421     c_fix_arg = <<- _EOArg_
2422         #ifdef __GNUC_STDC_INLINE__
2423         #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2424         #else
2425         %0
2426         #endif
2427         _EOArg_;
2428
2429     test_text = "#define _SIGINLINE extern __inline";
2430 };
2431
2432
2433 /*
2434  * NetBSD has a semicolon after the ending '}' for some extern "C".
2435  */
2436 fix = {
2437     hackname  = netbsd_extra_semicolon;
2438     mach      = "*-*-netbsd*";
2439     files     = sys/cdefs.h;
2440     select    = "#define[ \t]*__END_DECLS[ \t]*};";
2441
2442     c_fix     = format;
2443     c_fix_arg = "#define __END_DECLS }";
2444
2445     test_text = "#define __END_DECLS };";
2446 };
2447
2448
2449 /*
2450  *  NeXT 3.2 adds const prefix to some math functions.
2451  *  These conflict with the built-in functions.
2452  */
2453 fix = {
2454     hackname  = next_math_prefix;
2455     files     = ansi/math.h;
2456     select    = "^extern[ \t]+double[ \t]+__const__[ \t]";
2457
2458     c_fix     = format;
2459     c_fix_arg = "extern double %1(";
2460     c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2461
2462     test_text = "extern\tdouble\t__const__\tmumble();";
2463 };
2464
2465
2466 /*
2467  *  NeXT 3.2 uses the word "template" as a parameter for some
2468  *  functions. GCC reports an invalid use of a reserved key word
2469  *  with the built-in functions.
2470  */
2471 fix = {
2472     hackname = next_template;
2473     files    = bsd/libc.h;
2474     select   = "[ \t]template\\)";
2475
2476     c_fix     = format;
2477     c_fix_arg = "(%1)";
2478     c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2479     test_text = "extern mumble( char * template); /* fix */";
2480 };
2481
2482
2483 /*
2484  *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
2485  *  function prototypes. That conflicts with the  built-in functions.
2486  */
2487 fix = {
2488     hackname = next_volitile;
2489     files    = ansi/stdlib.h;
2490     select   = "^extern[ \t]+volatile[ \t]+void[ \t]";
2491
2492     c_fix     = format;
2493     c_fix_arg = "extern void %1(";
2494     c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2495
2496     test_text = "extern\tvolatile\tvoid\tabort();";
2497 };
2498
2499
2500 /*
2501  *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2502  *  Note that version 3 of the NeXT system has wait.h in a different directory,
2503  *  so that this code won't do anything.  But wait.h in version 3 has a
2504  *  conditional, so it doesn't need this fix.  So everything is okay.
2505  */
2506 fix = {
2507     hackname  = next_wait_union;
2508     files     = sys/wait.h;
2509
2510     select    = 'wait\(union wait';
2511     c_fix     = format;
2512     c_fix_arg = "wait(void";
2513     test_text = "extern pid_d wait(union wait*);";
2514 };
2515
2516
2517 /*
2518  *  a missing semi-colon at the end of the nodeent structure definition.
2519  */
2520 fix = {
2521     hackname  = nodeent_syntax;
2522     files     = netdnet/dnetdb.h;
2523     select    = "char[ \t]*\\*na_addr[ \t]*$";
2524     c_fix     = format;
2525     c_fix_arg = "%0;";
2526     test_text = "char *na_addr\t";
2527 };
2528
2529
2530 /*
2531  *  obstack.h used casts as lvalues.
2532  *
2533  *  We need to change postincrements of casted pointers (which are
2534  *  then dereferenced and assigned into) of the form
2535  *
2536  *    *((TYPE*)PTRVAR)++ = (VALUE)
2537  *
2538  *  into expressions like
2539  *
2540  *    ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2541  *
2542  *  which is correct for the cases used in obstack.h since PTRVAR is
2543  *  of type char * and the value of the expression is not used.
2544  */
2545 fix = {
2546     hackname  = obstack_lvalue_cast;
2547     files     = obstack.h;
2548     select    = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2549     c_fix     = format;
2550     c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2551     test_text = "*((void **) (h)->next_free)++ = (aptr)";
2552 };
2553
2554
2555 /*
2556  *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2557  *  defining regex.h related types.  This causes libg++ build and usage
2558  *  failures.  Fixing this correctly requires checking and modifying 3 files.
2559  */
2560 fix = {
2561     hackname = osf_namespace_a;
2562     files    = reg_types.h;
2563     files    = sys/lc_core.h;
2564     test     = " -r reg_types.h";
2565     test     = " -r sys/lc_core.h";
2566     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
2567     test     = " -z \"`grep __regex_t regex.h`\"";
2568
2569     c_fix     = format;
2570     c_fix_arg = "__%0";
2571     c_fix_arg = "reg(ex|off|match)_t";
2572
2573     test_text = "`touch sys/lc_core.h`"
2574     "typedef struct {\n  int stuff, mo_suff;\n} regex_t;\n"
2575     "extern regex_t    re;\n"
2576     "extern regoff_t   ro;\n"
2577     "extern regmatch_t rm;\n";
2578 };
2579
2580 fix = {
2581     hackname = osf_namespace_c;
2582     files    = regex.h;
2583     test     = " -r reg_types.h";
2584     test     = " -r sys/lc_core.h";
2585     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
2586     test     = " -z \"`grep __regex_t regex.h`\"";
2587
2588     select    = "#include <reg_types\.h>.*";
2589     c_fix     = format;
2590     c_fix_arg = "%0\n"
2591                 "typedef __regex_t\tregex_t;\n"
2592                 "typedef __regoff_t\tregoff_t;\n"
2593                 "typedef __regmatch_t\tregmatch_t;";
2594
2595     test_text = "#include <reg_types.h>";
2596 };
2597
2598
2599 /*
2600  *  Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2601  *  The original ones fail if uninitialized externs are not common.
2602  *  This is the default for all ANSI standard C++ compilers.
2603  */
2604 fix = {
2605     hackname  = pthread_page_size;
2606     files     = pthread.h;
2607     select    = "^int __page_size";
2608     c_fix     = format;
2609     c_fix_arg = "extern %0";
2610     test_text = "int __page_size;";
2611 };
2612
2613 /*
2614  * On broken glibc-2.3.3 systems an array of incomplete structures is
2615  * passed to __sigsetjmp.  Fix that to take a pointer instead.
2616  */
2617 fix = {
2618     hackname  = pthread_incomplete_struct_argument;
2619     files     = pthread.h;
2620     select    = "struct __jmp_buf_tag";
2621     c_fix     = format;
2622     c_fix_arg = "%1 *%2%3";
2623     c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2624     test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2625 };
2626
2627 /*
2628  *  Fix return type of fread and fwrite on sysV68
2629  */
2630 fix = {
2631     hackname = read_ret_type;
2632     files    = stdio.h;
2633     select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2634     c_fix     = format;
2635     c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2636     c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2637
2638     test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2639 };
2640
2641
2642 /*
2643  *  Fix casts as lvalues in glibc's <rpc/xdr.h>.
2644  */
2645 fix = {
2646     hackname  = rpc_xdr_lvalue_cast_a;
2647     files     = rpc/xdr.h;
2648     select    = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2649     c_fix     = format;
2650     c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2651     test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2652                 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2653 };
2654
2655
2656 fix = {
2657     hackname  = rpc_xdr_lvalue_cast_b;
2658     files     = rpc/xdr.h;
2659     select    = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2660     c_fix     = format;
2661     c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2662     test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2663                 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2664 };
2665
2666
2667 /*
2668  *  function class(double x) conflicts with C++ keyword on rs/6000
2669  */
2670 fix = {
2671     hackname  = rs6000_double;
2672     files     = math.h;
2673     select    = '[^a-zA-Z_]class\(';
2674
2675     c_fix     = format;
2676     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2677     c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2678
2679     test_text = "extern int class();";
2680 };
2681
2682
2683 /*
2684  *  Wrong fchmod prototype on RS/6000.
2685  */
2686 fix = {
2687     hackname  = rs6000_fchmod;
2688     files     = sys/stat.h;
2689     select    = 'fchmod\(char \*';
2690     c_fix     = format;
2691     c_fix_arg = "fchmod(int";
2692     test_text = "extern int fchmod(char *, mode_t);";
2693 };
2694
2695
2696 /*
2697  *  parameters conflict with C++ new on rs/6000
2698  */
2699 fix = {
2700     hackname  = rs6000_param;
2701     files     = "stdio.h";
2702     files     = "unistd.h";
2703
2704     select    = 'rename\(const char \*old, const char \*new\)';
2705     c_fix     = format;
2706     c_fix_arg = 'rename(const char *_old, const char *_new)';
2707
2708     test_text = 'extern int rename(const char *old, const char *new);';
2709 };
2710
2711
2712 /*
2713  *  On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2714  *  __builtin_generic. We fix that usage to use the GCC equivalent.
2715  * It also has a plethora of inline functions that conflict with libstdc++.
2716  */
2717 fix = {
2718     hackname = sco_math;
2719     files    = math.h, '*/math.h';
2720     select   = "inline double abs";
2721     bypass   = "__GNUG__";
2722     sed      = "/#define.*__fp_class(a) \\\\/i\\\n"
2723                "#ifndef __GNUC__\n";
2724     sed      =
2725 "/.*__builtin_generic/a\\\n"
2726 "#else\\\n"
2727 "#define __fp_class(a) \\\\\\\n"
2728 "  __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
2729 "   __fpclassifyl(a), \\\\\\\n"
2730 "    __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
2731 "      __fpclassifyf(a),__fpclassify(a)))\\\n"
2732 "#endif";
2733
2734     sed      = "/extern \"C\\+\\+\"/N;"
2735                "/inline double abs/i\\\n"
2736                "#ifndef __GNUC__\n";
2737     sed      = "/inline long double trunc/N;"
2738                "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
2739                "#endif /* ! __GNUC__ */";
2740
2741     test_text =
2742     "#define __fp_class(a) \\\\\n"
2743     " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
2744
2745 };
2746
2747
2748 /*
2749  * Sun Solaris 10 defines several C99 math macros in terms of
2750  * builtins specific to the Studio compiler, in particular not
2751  * compatible with the GNU compiler.
2752  */
2753 fix = {
2754     hackname = solaris_math_1;
2755     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2756     bypass = "__GNUC__";
2757     files = iso/math_c99.h;
2758     c_fix = format;
2759     c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
2760     c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
2761     test_text =
2762     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2763     "#undef     HUGE_VAL\n"
2764     "#define    HUGE_VAL        __builtin_huge_val\n"
2765     "#undef     HUGE_VALF\n"
2766     "#define    HUGE_VALF       __builtin_huge_valf\n"
2767     "#undef     HUGE_VALL\n"
2768     "#define    HUGE_VALL       __builtin_huge_vall";
2769 };
2770
2771 fix = {
2772     hackname = solaris_math_2;
2773     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2774     bypass = "__GNUC__";
2775     files = iso/math_c99.h;
2776     c_fix = format;
2777     c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
2778     c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
2779     test_text =
2780     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2781     "#undef     INFINITY\n"
2782     "#define    INFINITY        __builtin_infinity";
2783 };
2784
2785 fix = {
2786     hackname = solaris_math_3;
2787     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2788     bypass = "__GNUC__";
2789     files = iso/math_c99.h;
2790     c_fix = format;
2791     c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
2792     c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
2793     test_text =
2794     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2795     "#undef     NAN\n"
2796     "#define    NAN     __builtin_nan";
2797 };
2798
2799 fix = {
2800     hackname = solaris_math_4;
2801     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2802     bypass = "__GNUC__";
2803     files = iso/math_c99.h;
2804     c_fix = format;
2805     c_fix_arg = "#define\tfpclassify(x) \\\n"
2806                 "  __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
2807     c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
2808     test_text =
2809     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2810     "#undef     fpclassify\n"
2811     "#define    fpclassify(x)   __builtin_fpclassify(x)";
2812 };
2813
2814 fix = {
2815     hackname = solaris_math_8;
2816     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2817     bypass = "__GNUC__";
2818     files = iso/math_c99.h;
2819     c_fix = format;
2820     c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
2821                 "\t\t\t   ? __builtin_signbitf(x) \\\n"
2822                 "\t\t\t   : sizeof(x) == sizeof(long double) \\\n"
2823                 "\t\t\t     ? __builtin_signbitl(x) \\\n"
2824                 "\t\t\t     : __builtin_signbit(x))";
2825     c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
2826     test_text =
2827     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2828     "#undef     signbit\n"
2829     "#define    signbit(x)      __builtin_signbit(x)";
2830 };
2831
2832 fix = {
2833     hackname = solaris_math_9;
2834     select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2835     bypass = "__GNUC__";
2836     files = iso/math_c99.h;
2837     c_fix = format;
2838     c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
2839     c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
2840     test_text =
2841     '#ident     "@(#)math_c99.h 1.9     04/11/01 SMI"'"\n"
2842     "#undef     isgreater\n"
2843     "#define    isgreater(x, y)         ((x) __builtin_isgreater(y))\n"
2844     "#undef     isgreaterequal\n"
2845     "#define    isgreaterequal(x, y)    ((x) __builtin_isgreaterequal(y))\n"
2846     "#undef     isless\n"
2847     "#define    isless(x, y)            ((x) __builtin_isless(y))\n"
2848     "#undef     islessequal\n"
2849     "#define    islessequal(x, y)       ((x) __builtin_islessequal(y))\n"
2850     "#undef     islessgreater\n"
2851     "#define    islessgreater(x, y)     ((x) __builtin_islessgreater(y))\n"
2852     "#undef     isunordered\n"
2853     "#define    isunordered(x, y)       ((x) __builtin_isunordered(y))";
2854 };
2855
2856 /*
2857  * On Solaris 11, if you do isinf(NaN) you'll get a floating point
2858  * exception.  Provide an alternative using GCC's builtin.
2859  */
2860
2861 fix = {
2862     hackname  = solaris_math_10;
2863     select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2864     files     = iso/math_c99.h;
2865     c_fix     = format;
2866     c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
2867     c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
2868                 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
2869                 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
2870                 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
2871     test_text =
2872     '#pragma ident      "@(#)math_c99.h 1.12    07/01/21 SMI"'"\n"
2873     "#undef     isinf\n"
2874     "#define    isinf(x)        __extension__( \\\\\n"
2875     "                   { __typeof(x) __x_i = (x); \\\\\n"
2876     "                   __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
2877     "                   __x_i == (__typeof(__x_i)) (-INFINITY); })";
2878 };
2879
2880 /*
2881  * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2882  * "0" for the last field of the pthread_mutex_t structure, which is
2883  * of type upad64_t, which itself is typedef'd to int64_t, but with
2884  * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2885  * initializer to "{0}" instead
2886  */
2887 fix = {
2888     hackname = solaris_mutex_init_2;
2889     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2890     files = pthread.h;
2891     /*
2892      * On Solaris 10, this fix is unnecessary because upad64_t is
2893      * always defined correctly regardless of the definition of the
2894      * __STDC__ macro.  The first "mach" pattern matches up to
2895      * solaris9.  The second "mach" pattern will not match any two (or
2896      * more) digit solaris version, but it will match e.g. 2.5.1.
2897      */
2898     mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
2899     c_fix = format;
2900     c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2901                 "%0\n"
2902                 "#else\n"
2903                 "%1, {0}}%4\n"
2904                 "#endif";
2905     c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
2906                 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
2907                 ",[ \t]*0\\}" "(|[ \t].*)$";
2908     test_text =
2909     '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
2910     "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
2911     "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
2912     "#define    PTHREAD_MUTEX_INITIALIZER               /* = DEFAULTMUTEX */    \\\\\n"
2913     "   {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
2914     "#define    PTHREAD_COND_INITIALIZER                /* = DEFAULTCV */       \\\\\n"
2915     "   {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
2916 };
2917
2918
2919 /*
2920  * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
2921  *  fields of the pthread_rwlock_t structure, which are of type
2922  *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
2923  *  defined (e.g. by -ansi) it is a union. So change the initializer
2924  *  to "{0}" instead.
2925  */
2926 fix = {
2927     hackname = solaris_rwlock_init_1;
2928     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2929     files = pthread.h;
2930     mach = '*-*-solaris*';
2931     c_fix = format;
2932     c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2933                 "%0\n"
2934                 "#else\n"
2935                 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
2936                 "#endif";
2937     c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
2938                 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
2939
2940     test_text =
2941     '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
2942     "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
2943 };
2944
2945
2946 /*
2947  * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
2948  * structure.  As such, it need two levels of brackets, but only
2949  * contains one.  Wrap the macro definition in an extra layer.
2950  */
2951 fix = {
2952     hackname = solaris_once_init_1;
2953     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2954     files = pthread.h;
2955     mach = '*-*-solaris*';
2956     c_fix = format;
2957     c_fix_arg = "%1{%2}%3";
2958     c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
2959     test_text =
2960     '#pragma ident      "@(#)pthread.h  1.37    04/09/28 SMI"'"\n"
2961     "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
2962 };
2963
2964
2965 /*
2966  * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
2967  *  fields of the pthread_once_t structure, which are of type
2968  *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
2969  *  defined (e.g. by -ansi) it is a union. So change the initializer
2970  *  to "{0}" instead.  This test relies on solaris_once_init_1.
2971  */
2972 fix = {
2973     hackname = solaris_once_init_2;
2974     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2975     files = pthread.h;
2976     /*
2977      * On Solaris 10, this fix is unnecessary because upad64_t is
2978      * always defined correctly regardless of the definition of the
2979      * __STDC__ macro.  The first "mach" pattern matches up to
2980      * solaris9.  The second "mach" pattern will not match any two (or
2981      * more) digit solaris version, but it will match e.g. 2.5.1.
2982      */
2983     mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
2984     c_fix = format;
2985     c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2986                 "%0\n"
2987                 "#else\n"
2988                 "%1{0}, {0}, {0}, {%3}%4\n"
2989                 "#endif";
2990     c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
2991                 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
2992     test_text =
2993     '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
2994     "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
2995 };
2996
2997
2998 /*
2999  * Solaris 2.8 has what appears to be some gross workaround for 
3000  * some old version of their c++ compiler.  G++ doesn't want it
3001  * either, but doesn't want to be tied to SunPRO version numbers.
3002  */
3003 fix = {
3004     hackname = solaris_stdio_tag;
3005     files    = stdio_tag.h;
3006
3007     select   = '__cplusplus < 54321L';
3008     /* In Solaris 10, the code in stdio_tag.h is conditionalized on 
3009        "!defined(__GNUC__)" so we no longer need to fix it.  */
3010     bypass   = '__GNUC__';
3011     sed      = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3012
3013     test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3014 };
3015
3016
3017 /*
3018  *  a missing semi-colon at the end of the statsswtch structure definition.
3019  */
3020 fix = {
3021     hackname  = statsswtch;
3022     files     = rpcsvc/rstat.h;
3023     select    = "boottime$";
3024     c_fix     = format;
3025     c_fix_arg = "boottime;";
3026     test_text = "struct statswtch {\n  int boottime\n};";
3027 };
3028
3029
3030 /*
3031  *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3032  *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3033  *  OK too.
3034  */
3035 fix = {
3036     hackname = stdio_stdarg_h;
3037     files    = stdio.h;
3038     bypass   = "include.*(stdarg\.h|machine/ansi\.h)";
3039     /*
3040      * On Solaris 10, this fix is unncessary; <stdio.h> includes
3041      * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3042       */
3043     mach     = '*-*-solaris2.1[0-9]*';
3044     not_machine = true;
3045
3046     c_fix     = wrap;
3047
3048     c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3049
3050     test_text = "";
3051 };
3052
3053
3054 /*
3055  *  Don't use or define the name va_list in stdio.h.  This is for
3056  *  ANSI.  Note _BSD_VA_LIST_ is dealt with elsewhere.  The presence
3057  *  of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3058  *  indicate that the header knows what it's doing -- under SUSv2,
3059  *  stdio.h is required to define va_list, and we shouldn't break
3060  *  that.  On IRIX 6.5, internal/wchar_core.h used to get its
3061  *  definition of va_list from stdio.h.  Since this doesn't happen any
3062  *  longer, use __gnuc_va_list there, too.
3063  */
3064 fix = {
3065     hackname = stdio_va_list;
3066     files    = stdio.h;
3067     files    = internal/stdio_core.h;
3068     files    = internal/wchar_core.h;
3069     bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3070     /* 
3071      * On Solaris 10, the definition in 
3072      * <stdio.h> is guarded appropriately by the _XPG4 feature macro; 
3073      * there is therefore no need for this fix there.
3074      */
3075     mach = '*-*-solaris2.1[0-9]*';
3076     not_machine = true;
3077
3078     /*
3079      * Use __gnuc_va_list in arg types in place of va_list.
3080      * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
3081      * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
3082      * trailing parentheses and semicolon save all other systems from this.
3083      * Define __not_va_list__ (something harmless and unused)
3084      * instead of va_list.
3085      * Don't claim to have defined va_list.
3086      */
3087     sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3088           "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3089           "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3090           "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3091           "s@ va_list@ __not_va_list__@\n"
3092           "s@\\*va_list@*__not_va_list__@\n"
3093           "s@ __va_list)@ __gnuc_va_list)@\n"
3094           "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3095            "@typedef \\1 __not_va_list__;@\n"
3096           "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3097           "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3098           "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3099           "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3100           "s@VA_LIST@DUMMY_VA_LIST@\n"
3101           "s@_Va_LIST@_VA_LIST@";
3102     test_text = "extern void mumble( va_list);";
3103 };
3104
3105
3106 /*
3107  *  Fix headers that use va_list from stdio.h to use the updated
3108  *  va_list from the stdio_va_list change.  Note _BSD_VA_LIST_ is
3109  *  dealt with elsewhere.  The presence of __gnuc_va_list,
3110  *  __DJ_va_list, or _G_va_list is taken to indicate that the header
3111  *  knows what it's doing.
3112  */
3113 fix = {
3114     hackname = stdio_va_list_clients;
3115     files    = com_err.h;
3116     files    = cps.h;
3117     files    = curses.h;
3118     files    = krb5.h;
3119     files    = lc_core.h;
3120     files    = pfmt.h;
3121     files    = wchar.h;
3122     files    = curses_colr/curses.h;
3123     bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3124     /* Don't fix, if we use va_list from stdarg.h, or if the use is
3125        otherwise protected.  */
3126     bypass   = 'include <stdarg\.h>|#ifdef va_start';
3127
3128     /*
3129      * Use __gnuc_va_list in arg types in place of va_list.
3130      * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
3131      * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
3132      * trailing parentheses and semicolon save all other systems from this.
3133      * Define __not_va_list__ (something harmless and unused)
3134      * instead of va_list.
3135      * Don't claim to have defined va_list.
3136      */
3137     sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3138           "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3139           "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3140           "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3141           "s@ va_list@ __not_va_list__@\n"
3142           "s@\\*va_list@*__not_va_list__@\n"
3143           "s@ __va_list)@ __gnuc_va_list)@\n"
3144           "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3145            "@typedef \\1 __not_va_list__;@\n"
3146           "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3147           "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3148           "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3149           "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3150           "s@VA_LIST@DUMMY_VA_LIST@\n"
3151           "s@_Va_LIST@_VA_LIST@";
3152     test_text = "extern void mumble( va_list);";
3153 };
3154
3155
3156 /*
3157  *  "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3158  *  is "!defined( __STRICT_ANSI__ )"
3159  */
3160 fix = {
3161     hackname = strict_ansi_not;
3162     select   = "^([ \t]*#[ \t]*if.*)"
3163                "(!__STDC__"
3164                "|__STDC__[ \t]*==[ \t]*0"
3165                "|__STDC__[ \t]*!=[ \t]*1"
3166                "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3167     /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3168     bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3169     /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3170        is not defined by GCC, so it is safe.  */
3171     bypass = '__SCO_VERSION__.*__STDC__ != 1';
3172     c_test   = stdc_0_in_system_headers;
3173
3174     c_fix     = format;
3175     c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3176
3177     test_text = "#if !__STDC__ \n"
3178                 "#if __STDC__ == 0\n"
3179                 "#if __STDC__ != 1\n"
3180                 "#if __STDC__ - 0 == 0"
3181                "/* not std C */\nint foo;\n"
3182                "\n#end-end-end-end-if :-)";
3183 };
3184
3185 /*
3186  *  "__STDC__-0==0"
3187  *  is "!defined( __STRICT_ANSI__ )" on continued #if-s
3188  */
3189 fix = {
3190     hackname = strict_ansi_not_ctd;
3191     files    = math.h, limits.h, stdio.h, signal.h,
3192                stdlib.h, sys/signal.h, time.h;
3193     /*
3194      * Starting at the beginning of a line, skip white space and
3195      * a leading "(" or "&&" or "||".  One of those must be found.
3196      * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3197      * expression.  If these are nested, then they must accumulate
3198      * because we won't match any closing parentheses.  Finally,
3199      * after skipping over all that, we must then match our suspect
3200      * phrase:  "__STDC__-0==0" with or without white space.
3201      */
3202     select   = "^([ \t]*" '(\(|&&|\|\|)'
3203                "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3204                "[ \t(]*)"
3205                "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3206     c_test   = stdc_0_in_system_headers;
3207
3208     c_fix     = format;
3209     c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3210
3211     test_text = "#if 1 && \\\\\n"
3212                "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3213                "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3214                "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3215                "int foo;\n#endif";
3216 };
3217
3218
3219 /*
3220  *  "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3221  *  is "defined( __STRICT_ANSI__ )"
3222  */
3223 fix = {
3224     hackname = strict_ansi_only;
3225     select   = "^([ \t]*#[ \t]*if.*)"
3226                "(__STDC__[ \t]*!=[ \t]*0"
3227                "|__STDC__[ \t]*==[ \t]*1"
3228                "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3229                "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3230     c_test   = stdc_0_in_system_headers;
3231
3232     c_fix     = format;
3233     c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3234
3235     test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3236 };
3237
3238
3239 /*
3240  *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3241  *  in prototype without previous definition.
3242  */
3243 fix = {
3244     hackname  = struct_file;
3245     files     = rpc/xdr.h;
3246     select    = '^.*xdrstdio_create.*struct __file_s';
3247     c_fix     = format;
3248     c_fix_arg = "struct __file_s;\n%0";
3249     test_text = "extern void xdrstdio_create( struct __file_s* );";
3250 };
3251
3252
3253 /*
3254  *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3255  *  in prototype without previous definition.
3256  *
3257  *  Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3258  *  function, and does define it.
3259  */
3260 fix = {
3261     hackname  = struct_sockaddr;
3262     files     = rpc/auth.h;
3263     select    = "^.*authdes_create.*struct sockaddr[^_]";
3264     bypass    = "<sys/socket\.h>";
3265     bypass    = "struct sockaddr;\n";
3266     c_fix     = format;
3267     c_fix_arg = "struct sockaddr;\n%0";
3268     test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3269 };
3270
3271
3272 /*
3273  *  Apply fix this to all OSs since this problem seems to effect
3274  *  more than just SunOS.
3275  */
3276 fix = {
3277     hackname = sun_auth_proto;
3278     files    = rpc/auth.h;
3279     files    = rpc/clnt.h;
3280     files    = rpc/svc.h;
3281     files    = rpc/xdr.h;
3282     bypass   = "__cplusplus";
3283     /*
3284      *  Select those files containing '(*name)()'.
3285      */
3286     select    = '\(\*[a-z][a-z_]*\)\(\)';
3287
3288     c_fix     = format;
3289     c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3290                 "#else\n%1();%2\n#endif";
3291     c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3292
3293     test_text =
3294     "struct auth_t {\n"
3295     "    int (*name)(); /* C++ bad */\n"
3296     "};";
3297 };
3298
3299
3300 /*
3301  *  Fix bogus #ifdef on SunOS 4.1.
3302  */
3303 fix = {
3304     hackname  = sun_bogus_ifdef;
3305     files     = "hsfs/hsfs_spec.h";
3306     files     = "hsfs/iso_spec.h";
3307     select    = '#ifdef(.*\|\|.*)';
3308     c_fix     = format;
3309     c_fix_arg = "#if%1";
3310
3311     test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
3312 };
3313
3314
3315 /*
3316  *  Fix the CAT macro in SunOS memvar.h.
3317  */
3318 fix = {
3319     hackname  = sun_catmacro;
3320     files     = pixrect/memvar.h;
3321     select    = "^#define[ \t]+CAT\\(a,b\\).*";
3322     c_fix     = format;
3323
3324     c_fix_arg =
3325     "#ifdef __STDC__\n"
3326     "#  define CAT(a,b) a##b\n"
3327     "#else\n%0\n#endif";
3328
3329     test_text =
3330     "#define CAT(a,b)\ta/**/b";
3331 };
3332
3333
3334 /*
3335  *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3336  *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3337  */
3338 fix = {
3339     hackname = sun_malloc;
3340     files    = malloc.h;
3341     bypass   = "_CLASSIC_ANSI_TYPES";
3342
3343     sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3344     sed   = "s/int[ \t][ \t]*free/void\tfree/g";
3345     sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3346     sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3347     sed   = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3348
3349     test_text =
3350     "typedef char *\tmalloc_t;\n"
3351     "int \tfree();\n"
3352     "char*\tmalloc();\n"
3353     "char*\tcalloc();\n"
3354     "char*\trealloc();";
3355 };
3356
3357
3358 /*
3359  *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
3360  */
3361 fix = {
3362     hackname = sun_rusers_semi;
3363     files    = rpcsvc/rusers.h;
3364     select   = "_cnt$";
3365     sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
3366     test_text = "struct mumble\n  int _cnt\n};";
3367 };
3368
3369
3370 /*
3371  *  signal.h on SunOS defines signal using (),
3372  *  which causes trouble when compiling with g++ -pedantic.
3373  */
3374 fix = {
3375     hackname = sun_signal;
3376     files    = sys/signal.h;
3377     files    = signal.h;
3378     select   = "^void\t" '\(\*signal\(\)\)\(\);.*';
3379
3380     c_fix     = format;
3381     c_fix_arg =
3382           "#ifdef __cplusplus\n"
3383           "void\t(*signal(...))(...);\n"
3384           "#else\n%0\n#endif";
3385
3386     test_text = "void\t(*signal())();";
3387 };
3388
3389
3390 /*
3391  *  Correct the return type for strlen in strings.h in SunOS 4.
3392  */
3393 fix = {
3394     hackname = sunos_strlen;
3395     files    = strings.h;
3396     select   = "int[ \t]*strlen\\(\\);(.*)";
3397     c_fix     = format;
3398     c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3399     test_text = " int\tstrlen(); /* string length */";
3400 };
3401
3402
3403 /*
3404  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3405  *  that is visible to any ANSI compiler using this include.  Simply
3406  *  delete the lines that #define some string functions to internal forms.
3407  */
3408 fix = {
3409     hackname = svr4_disable_opt;
3410     files    = string.h;
3411     select   = '#define.*__std_hdr_';
3412     sed      = '/#define.*__std_hdr_/d';
3413     test_text = "#define strlen __std_hdr_strlen\n";
3414 };
3415
3416
3417 /*
3418  *  Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
3419  *  On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
3420  *  but we still "hijack" it and redirect it to the GNU byteorder.h..
3421  */
3422 #ifdef SVR5
3423 fix = {
3424     hackname = svr4_endian;
3425     files    = sys/endian.h;
3426 #ifdef LATER
3427     /*
3428      * since we emit our own sys/byteorder.h,
3429      * this fix can never be applied to that file.
3430      */
3431     files    = sys/byteorder.h;
3432 #endif
3433     bypass   = '__GNUC__';
3434
3435     sed      = "/#\tifdef\t__STDC__/i\\\n"
3436                "#   if !defined (__GNUC__) && !defined (__GNUG__)\n";
3437
3438     sed      = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/   /";
3439
3440     sed      = "/#   include\t<sys\\/byteorder.h>/i\\\n"
3441                "#   endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
3442 };
3443 #endif /* SVR5 */
3444
3445
3446 /*
3447  *  Remove useless extern keyword from struct forward declarations
3448  *  in <sys/stream.h> and <sys/strsubr.h>
3449  */
3450 #ifdef SVR4
3451 fix = {
3452     hackname = svr4_extern_struct;
3453     files    = sys/stream.h;
3454     files    = sys/strsubr.h;
3455     select   = 'extern struct [a-z_]*;';
3456     sed      = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
3457 };
3458 #endif
3459
3460 /*
3461  *  Fix declarations of `ftw' and `nftw' in <ftw.h>.  On some/most SVR4
3462  *  systems the file <ftw.h> contains extern declarations of these
3463  *  functions followed by explicitly `static' definitions of these
3464  *  functions... and that's not allowed according to ANSI C.  (Note
3465  *  however that on Solaris, this header file glitch has been pre-fixed by
3466  *  Sun.  In the Solaris version of <ftw.h> there are no static
3467  *  definitions of any function so we don't need to do any of this stuff
3468  *  when on Solaris.
3469  */
3470 #ifdef SVR4
3471 #ifndef SOLARIS
3472 fix = {
3473     hackname = svr4_ftw;
3474     files    = ftw.h;
3475     select   = '^extern int ftw\(const';
3476
3477     sed = '/^extern int ftw(const/i' "\\\n"
3478             "#if !defined(_STYPES)\\\n"
3479             "static\\\n"
3480             "#else\\\n"
3481             "extern\\\n"
3482             "#endif";
3483     sed = 's/extern \(int ftw(const.*\)$/\1/';
3484     sed = "/^extern int nftw/i\\\n"
3485             "#if defined(_STYPES)\\\n"
3486             "static\\\n"
3487             "#else\\\n"
3488             "extern\\\n"
3489             "#endif";
3490     sed = 's/extern \(int nftw.*\)$/\1/';
3491     sed = "/^extern int ftw(),/c\\\n"
3492             "#if !defined(_STYPES)\\\n"
3493             "static\\\n"
3494             "#else\\\n"
3495             "extern\\\n"
3496             "#endif\\\n"
3497             "  int ftw();\\\n"
3498             "#if defined(_STYPES)\\\n"
3499             "static\\\n"
3500             "#else\\\n"
3501             "extern\\\n"
3502             "#endif\\\n"
3503             "  int nftw();";
3504 };
3505 #endif
3506 #endif
3507
3508
3509 /*
3510  *   Fix broken decl of getcwd present on some svr4 systems.
3511  */
3512 fix = {
3513     hackname = svr4_getcwd;
3514     files    = stdlib.h;
3515     files    = unistd.h;
3516     files    = prototypes.h;
3517     select   = 'getcwd\(char \*, int\)';
3518
3519     c_fix     = format;
3520     c_fix_arg = "getcwd(char *, size_t)";
3521
3522     test_text = "extern char* getcwd(char *, int);";
3523 };
3524
3525
3526 /*
3527  *  Delete any #defines of `__i386' which may be present in <ieeefp.h>.  They
3528  *  tend to conflict with the compiler's own definition of this symbol.  (We
3529  *  will use the compiler's definition.)
3530  *  Likewise __sparc, for Solaris, and __i860, and a few others
3531  *  (guessing it is necessary for all of them).
3532  */
3533 #ifdef SVR4
3534 fix = {
3535     hackname = svr4_mach_defines;
3536     files    = ieeefp.h;
3537     select   = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
3538     sed      = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
3539 };
3540 #endif
3541
3542
3543 /*
3544  *  Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
3545  *  They are declared as non-static then immediately redeclared as static.
3546  */
3547 #ifdef SVR5
3548 fix = {
3549     hackname = svr4_mkdev;
3550     files    = sys/mkdev.h;
3551     select   = '^static';
3552
3553     sed      = "/^dev_t makedev(/s/^/static /";
3554     sed      = "/^major_t major(/s/^/static /";
3555     sed      = "/^minor_t minor(/s/^/static /";
3556 };
3557 #endif /* SVR5 */
3558
3559
3560 /*
3561  *  Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
3562  *  Also fix types of array initializers.
3563  */
3564 #ifdef SVR4
3565 fix = {
3566     hackname = svr4_netcspace;
3567     files    = sys/netcspace.h;
3568     select   = 'NC_NPI_RAW';
3569     sed      = 's/NC_NPI_RAW/NC_TPI_RAW/g';
3570     sed      = 's/NC_/(unsigned long) NC_/';
3571 };
3572 #endif
3573
3574 /*
3575  *  Fix reference to NMSZ in <sys/adv.h>.
3576  */
3577 #ifdef SVR4
3578 fix = {
3579     hackname = svr4_nmsz;
3580     files    = sys/adv.h;
3581     select   = '\[NMSZ\]';
3582     sed      = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
3583 };
3584 #endif
3585
3586
3587 /*
3588  * Some SVR4 systems supposedly use these non-ANSI preprocessor directives.
3589  */
3590 #ifdef SVR4
3591 fix = {
3592     hackname  = svr4_preproc_lint_on;
3593     select    = '#lint\(on\)';
3594     c_fix     = format;
3595     c_fix_arg = 'defined(lint)';
3596     test_text = "#if #lint(on)";
3597 };
3598 fix = {
3599     hackname  = svr4_preproc_lint_off;
3600     select    = '#lint\(off\)';
3601     c_fix     = format;
3602     c_fix_arg = '!defined(lint)';
3603     test_text = "#if #lint(off)";
3604 };
3605 fix = {
3606     hackname  = svr4_preproc_machine;
3607     select    = '#(machine|system|cpu)\(([^)]*)\)';
3608     c_fix     = format;
3609     c_fix_arg = 'defined(__%1__)';
3610     test_text = "#if #machine(i386) || #system(vax) || #cpu(sparc)";
3611 };
3612 #endif
3613
3614
3615 /*
3616  *   Fix broken decl of profil present on some svr4 systems.
3617  */
3618 fix = {
3619     hackname = svr4_profil;
3620     files    = stdlib.h;
3621     files    = unistd.h;
3622
3623     select    =
3624     'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3625     /* The fix is wrong on IRIX 5/6 and creates a conflict with another
3626        prototype in <sys/profil.h>.  */
3627     bypass    = 'Silicon Graphics';
3628     c_fix     = format;
3629     c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3630
3631     test_text =
3632     'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3633 };
3634
3635
3636 /*
3637  *  Convert functions to prototype form, and fix arg names in <sys/stat.h>.
3638  */
3639 #ifdef SVR4
3640 fix = {
3641     hackname = svr4_proto_form;
3642     files    = sys/stat.h;
3643     select   = 'const extern';
3644
3645     sed      = "/^stat([ \t]*[^c]/ {\nN\nN\n"
3646                    "s/(.*)\\n/( /\n"
3647                    "s/;\\n/, /\n"
3648                    "s/;$/)/\n"  "}";
3649
3650     sed      = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
3651                    "s/(.*)\\n/( /\n"
3652                    "s/;\\n/, /\n"
3653                    "s/;$/)/\n"  "}";
3654
3655     sed      = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
3656                    "s/(.*)\\n/( /\n"
3657                    "s/;\\n/, /\n"
3658                    "s/;$/)/\n"  "}";
3659
3660     sed      = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
3661                    "s/(.*)\\n/( /\n"
3662                    "s/;\\n/, /g\n"
3663                    "s/;$/)/\n"  "}";
3664
3665     sed      = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
3666     sed      = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
3667     sed      = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
3668     sed      = "1,$s/ret\\([^u]\\)/__ret\\1/g";
3669     sed      = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
3670     sed      = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
3671 };
3672 #endif
3673
3674 /*
3675  *  Add a prototyped declaration of mmap to <sys/mman.h>.
3676  */
3677 #ifdef SVR4
3678 fix = {
3679     hackname = svr4_proto_mmap;
3680     files    = sys/mman.h;
3681     select   = '^extern caddr_t mmap();$';
3682     sed = '/^extern caddr_t mmap();$/c' "\\\n"
3683           "#ifdef __STDC__\\\n"
3684           "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
3685           "#else /* !defined(__STDC__) */\\\n"
3686           "extern caddr_t mmap ();\\\n"
3687           "#endif /* !defined(__STDC__) */\\\n";
3688 };
3689 #endif
3690
3691 /*
3692  *  Add a #define of _SIGACTION_ into <sys/signal.h>.
3693  */
3694 #ifdef SVR4
3695 fix = {
3696     hackname = svr4_sigaction;
3697     files    = sys/signal.h;
3698     sed      = "/^struct sigaction {/i\\\n"
3699                "#define _SIGACTION_";
3700     sed      = 's/(void *(\*)())/(void (*)(int))/';
3701 };
3702 #endif
3703
3704
3705 /*
3706  * Correct types for signal handler constants like SIG_DFL; they might be
3707  * void (*) (), and should be void (*) (int).  C++ doesn't like the
3708  * old style.
3709  */
3710 fix = {
3711     hackname = svr4_sighandler_type;
3712     files = sys/signal.h;
3713     select = 'void *\(\*\)\(\)';
3714     c_fix = format;
3715     c_fix_arg = "void (*)(int)";
3716     test_text = "#define SIG_DFL (void(*)())0\n"
3717                 "#define SIG_IGN (void (*)())0\n";
3718 };
3719
3720 /*
3721  *  Put storage class at start of decl, to avoid warning.
3722  */
3723 #ifdef SVR4
3724 fix = {
3725     hackname = svr4_storage_class;
3726     files    = rpc/types.h;
3727     select   = 'const extern';
3728     sed      = 's/const extern/extern const/g';
3729 };
3730 #endif
3731
3732
3733 /*
3734  *  Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
3735  *  function 'getrnge' in <regexp.h> before they declare it.  For these
3736  *  systems add a 'static int' declaration of 'getrnge' into <regexp.h>
3737  *  early on.
3738  *
3739  *  'getrnge' traditionally manipulates a file-scope global called 'size',
3740  *  so put the declaration right after the declaration of 'size'.
3741  *
3742  *  Don't do this if there is already a `static void getrnge' declaration
3743  *  present, since this would cause a redeclaration error.  Solaris 2.x has
3744  *  such a declaration.
3745  */
3746 fix = {
3747     hackname  = svr4_undeclared_getrnge;
3748     files     = regexp.h;
3749     select    = "getrnge";
3750     bypass    = "static void getrnge";
3751     c_fix     = format;
3752     c_fix_arg = "%0\n"
3753                 "static int getrnge ();";
3754     c_fix_arg = "^static int[ \t]+size;";
3755     test_text = "static int size;\n"
3756                 "/* stuff which calls getrnge() */\n"
3757                 "static getrnge()\n"
3758                 "{}";
3759 };
3760
3761
3762 /*
3763  *  Like svr4_mach_defines, but with newfangled syntax.
3764  *  Source lines are of #define __i386 #machine(i386).   Delete them.
3765  */
3766 #ifdef SVR5
3767 fix = {
3768     hackname = svr5_mach_defines;
3769     files    = ieeefp.h;
3770     select   = "#define[ \t]*__i386.*\(i386\)";
3771     sed      = "/#define[ \t]*__i386.*/d";
3772 };
3773 #endif /*  SVR5 */
3774
3775
3776 /*
3777  *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
3778  *  in string.h on sysV68
3779  *  Correct the return type for strlen in string.h on Lynx.
3780  *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
3781  *  Add missing const for strdup on OSF/1 V3.0.
3782  *  On sysV88 layout is slightly different.
3783  */
3784 fix = {
3785     hackname = sysv68_string;
3786     files    = testing.h;
3787     files    = string.h;
3788     bypass   = "_CLASSIC_ANSI_TYPES";
3789
3790     sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
3791     sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
3792     sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
3793
3794     sed = "/^extern char$/N";
3795     sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3796
3797     sed = "/^extern int$/N";
3798     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3799
3800     sed = "/^\tstrncmp(),$/N";
3801     sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3802             '\1;' "\\\nextern unsigned int\\\n\\2/";
3803
3804     test_text =
3805     "extern int strlen();\n"
3806
3807     "extern int ffs(long);\n"
3808
3809     "extern char\n"
3810     "\t*memccpy(),\n"
3811     "\tmemcpy();\n"
3812
3813     "extern int\n"
3814     "\tstrcmp(),\n"
3815     "\tstrncmp(),\n"
3816     "\tstrlen(),\n"
3817     "\tstrspn();\n"
3818
3819     "extern int\n"
3820     "\tstrlen(), strspn();";
3821 };
3822
3823
3824 /*
3825  *  Fix return type of calloc, malloc, realloc, bsearch and exit
3826  */
3827 fix = {
3828     hackname = sysz_stdlib_for_sun;
3829     files    = stdlib.h;
3830     bypass   = "_CLASSIC_ANSI_TYPES";
3831
3832     select    = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3833     c_fix     = format;
3834     c_fix_arg = "void *\t%1(";
3835
3836     test_text =
3837     "extern char*\tcalloc(size_t);\n"
3838     "extern char*\tmalloc(size_t);\n"
3839     "extern char*\trealloc(void*,size_t);\n"
3840     "extern char*\tbsearch(void*,size_t,size_t);\n";
3841 };
3842
3843
3844 /*
3845  * __thread is now a keyword.
3846  */
3847 fix = {
3848     hackname  = thread_keyword;
3849     files     = "pthread.h";
3850     files     = "bits/sigthread.h";
3851     select    = "([* ])__thread([,)])";
3852     c_fix     = format;
3853     c_fix_arg = "%1__thr%2";
3854
3855     test_text =
3856         "extern int pthread_create (pthread_t *__restrict __thread,\n"
3857         "extern int pthread_kill (pthread_t __thread, int __signo);\n"
3858         "extern int pthread_cancel (pthread_t __thread);";
3859 };
3860
3861 /*
3862  *  if the #if says _cplusplus, not the double underscore __cplusplus
3863  *  that it should be
3864  */
3865 fix = {
3866     hackname = tinfo_cplusplus;
3867     files    = tinfo.h;
3868     select   = "[ \t]_cplusplus";
3869
3870     c_fix     = format;
3871     c_fix_arg = " __cplusplus";
3872     test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
3873 };
3874
3875
3876 /*
3877  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
3878  */
3879 fix = {
3880     hackname  = ultrix_const;
3881     files     = stdio.h;
3882     select    = 'perror\( char \*';
3883
3884     c_fix     = format;
3885     c_fix_arg = "%1 const %3 *__";
3886     c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3887                 "[ \t]+(char|void) \\*__";
3888
3889     test_text =
3890     "extern void perror( char *__s );\n"
3891     "extern int fputs( char *__s, FILE *);\n"
3892     "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3893     "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3894     "extern int scanf( char *__format, ...);\n";
3895 };
3896
3897
3898 /*
3899  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
3900  */
3901 fix = {
3902     hackname  = ultrix_const2;
3903     files     = stdio.h;
3904
3905     select    = '\*fopen\( char \*';
3906     c_fix     = format;
3907     c_fix_arg = "%1( const char *%3, const char *";
3908     c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3909                "[ \t]*char[ \t]*\\*([^,]*),"
3910                "[ \t]*char[ \t]*\\*[ \t]*";
3911
3912     test_text =
3913     "extern FILE *fopen( char *__filename, char *__type );\n"
3914     "extern int sscanf( char *__s, char *__format, ...);\n"
3915     "extern FILE *popen(char *, char *);\n"
3916     "extern char *tempnam(char*,char*);\n";
3917 };
3918
3919
3920 /*
3921  *  Fix definitions of macros used by va-i960.h in VxWorks header file.
3922  */
3923 fix = {
3924     hackname  = va_i960_macro;
3925     files     = arch/i960/archI960.h;
3926     select    = "__(vsiz|vali|vpad|alignof__)";
3927
3928     c_fix     = format;
3929     c_fix_arg = "__vx%1";
3930
3931     test_text =
3932     "extern int __vsiz vsiz;\n"
3933     "extern int __vali vali;\n"
3934     "extern int __vpad vpad;\n"
3935     "#define __alignof__(x) ...";
3936 };
3937
3938
3939 /*
3940  *  AIX and Interix headers define NULL to be cast to a void pointer,
3941  *  which is illegal in ANSI C++.
3942  */
3943 fix = {
3944     hackname  = void_null;
3945     files     = curses.h;
3946     files     = dbm.h;
3947     files     = locale.h;
3948     files     = stdio.h;
3949     files     = stdlib.h;
3950     files     = string.h;
3951     files     = time.h;
3952     files     = unistd.h;
3953     files     = sys/dir.h;
3954     files     = sys/param.h;
3955     files     = sys/types.h;
3956     /* avoid changing C++ friendly NULL */
3957     bypass    = __cplusplus;
3958     select    = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3959     c_fix     = format;
3960     c_fix_arg = "#define NULL 0";
3961     test_text = "# define\tNULL \t((void *)0)  /* typed NULL */";
3962 };
3963
3964
3965 /*
3966  *  Make VxWorks header which is almost gcc ready fully gcc ready.
3967  */
3968 fix = {
3969     hackname = vxworks_gcc_problem;
3970     files    = types/vxTypesBase.h;
3971     select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3972
3973     sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3974           "#if 1/";
3975
3976     sed = "/[ \t]size_t/i\\\n"
3977         "#ifndef _GCC_SIZE_T\\\n"
3978         "#define _GCC_SIZE_T\n";
3979
3980     sed = "/[ \t]size_t/a\\\n"
3981         "#endif\n";
3982
3983     sed = "/[ \t]ptrdiff_t/i\\\n"
3984         "#ifndef _GCC_PTRDIFF_T\\\n"
3985         "#define _GCC_PTRDIFF_T\n";
3986
3987     sed = "/[ \t]ptrdiff_t/a\\\n"
3988         "#endif\n";
3989
3990     sed = "/[ \t]wchar_t/i\\\n"
3991         "#ifndef _GCC_WCHAR_T\\\n"
3992         "#define _GCC_WCHAR_T\n";
3993
3994     sed = "/[ \t]wchar_t/a\\\n"
3995         "#endif\n";
3996
3997     test_text =
3998     "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3999     "typedef unsigned int size_t;\n"
4000     "typedef long ptrdiff_t;\n"
4001     "typedef unsigned short wchar_t;\n"
4002     "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4003 };
4004
4005
4006 /*
4007  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
4008  */
4009 fix = {
4010     hackname  = vxworks_needs_vxtypes;
4011     files     = time.h;
4012     select    = "uint_t([ \t]+_clocks_per_sec)";
4013     c_fix     = format;
4014     c_fix_arg = "unsigned int%1";
4015     test_text = "uint_t\t_clocks_per_sec;";
4016 };
4017
4018
4019 /*
4020  *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4021  */
4022 fix = {
4023     hackname = vxworks_needs_vxworks;
4024     files    = sys/stat.h;
4025     test     = " -r types/vxTypesOld.h";
4026     test     = " -n \"`egrep '#include' $file`\"";
4027     test     = " -n \"`egrep ULONG $file`\"";
4028     select   = "#[ \t]define[ \t]+__INCstath";
4029
4030     sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4031           "#include <types/vxTypesOld.h>\n";
4032
4033     test_text = "`touch types/vxTypesOld.h`"
4034     "#include </dev/null> /* ULONG */\n"
4035     "# define\t__INCstath <sys/stat.h>";
4036 };
4037
4038
4039 /*
4040  *  Another bad dependency in VxWorks 5.2 <time.h>.
4041  */
4042 fix = {
4043     hackname = vxworks_time;
4044     files    = time.h;
4045     test     = " -r vxWorks.h";
4046
4047     select    = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4048     c_fix     = format;
4049
4050     c_fix_arg =
4051     "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4052     "#ifdef __cplusplus\n"
4053     "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4054     "#else\n"
4055     "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4056     "#endif\n"
4057     "#define __gcc_VOIDFUNCPTR_defined\n"
4058     "#endif\n"
4059     "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4060
4061     test_text = "`touch vxWorks.h`"
4062                 "#define VOIDFUNCPTR (void(*)())";
4063 };
4064
4065
4066 /*
4067  *  There are several name conflicts with C++ reserved words in X11 header
4068  *  files.  These are fixed in some versions, so don't do the fixes if
4069  *  we find __cplusplus in the file.  These were found on the RS/6000.
4070  */
4071 fix = {
4072     hackname  = x11_class;
4073     files     = X11/ShellP.h;
4074     bypass    = __cplusplus;
4075     select    = "^([ \t]*char \\*)class;(.*)";
4076     c_fix     = format;
4077     c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4078                 "#else\n%1class;%2\n#endif";
4079     test_text =
4080     "struct {\n"
4081     "   char *class;\n"
4082     "} mumble;\n";
4083 };
4084
4085
4086 /*
4087  *  class in Xm/BaseClassI.h
4088  */
4089 fix = {
4090     hackname = x11_class_usage;
4091     files    = Xm/BaseClassI.h;
4092     bypass   = "__cplusplus";
4093
4094     select    = " class\\)";
4095     c_fix     = format;
4096     c_fix_arg = " c_class)";
4097
4098     test_text = "extern mumble (int  class);\n";
4099 };
4100
4101
4102 /*
4103  *  new in Xm/Traversal.h
4104  */
4105 fix = {
4106     hackname = x11_new;
4107     files    = Xm/Traversal.h;
4108     bypass   = __cplusplus;
4109
4110     sed      = "/Widget\told, new;/i\\\n"
4111                    "#ifdef __cplusplus\\\n"
4112                    "\tWidget\told, c_new;\\\n"
4113                    "#else\n";
4114
4115     sed      = "/Widget\told, new;/a\\\n"
4116                    "#endif\n";
4117
4118     sed      = "s/Widget new,/Widget c_new,/g";
4119     test_text =
4120     "struct wedge {\n"
4121     "   Widget\told, new; /* fixinc check FAILS ON BSD */\n"
4122     "};\nextern Wedged( Widget new, Widget old );";
4123 };
4124
4125
4126 /*
4127  *  Incorrect sprintf declaration in X11/Xmu.h
4128  */
4129 fix = {
4130     hackname = x11_sprintf;
4131     files    = X11/Xmu.h;
4132     files    = X11/Xmu/Xmu.h;
4133     select   = "^extern char \\*\tsprintf\\(\\);$";
4134
4135     c_fix     = format;
4136     c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4137
4138     test_text = "extern char *\tsprintf();";
4139 };
4140
4141 /*EOF*/