OSDN Git Service

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