OSDN Git Service

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