OSDN Git Service

* fixinc/inclhack.def (solaris_mutex_init_2): Escape braces
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / 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 /*
24  *  This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
25  */
26 fix = {
27     hackname = AAB_fd_zero_asm_posix_types_h;
28     files    = asm/posix_types.h;
29     mach     = 'i[34567]86-*-linux*';
30     bypass   = '} while';
31
32     /*
33      * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
34      * the start, so that if #include_next gets another instance of
35      * the wrapper, this will follow the #include_next chain until
36      * we arrive at the real <asm/posix_types.h>.
37      */
38     replace  = <<-  _EndOfHeader_
39         /* This file fixes a bug in the __FD_ZERO macro
40            for older versions of the Linux kernel. */
41         #ifndef _POSIX_TYPES_H_WRAPPER
42         #include <features.h>
43          #include_next <asm/posix_types.h>
44         
45         #if defined(__FD_ZERO) && !defined(__GLIBC__)
46         #undef __FD_ZERO
47         #define __FD_ZERO(fdsetp) \
48           do { \
49             int __d0, __d1; \
50                         __asm__ __volatile__("cld ; rep ; stosl" \
51                                 : "=&c" (__d0), "=&D" (__d1) \
52                                 : "a" (0), "0" (__FDSET_LONGS), \
53                                   "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
54           } while (0)
55         #endif
56         
57         #define _POSIX_TYPES_H_WRAPPER
58         #endif /* _POSIX_TYPES_H_WRAPPER */
59         _EndOfHeader_;
60 };
61
62
63 /*
64  *  This fixes __FD_ZERO bug for glibc-1.x
65  */
66 fix = {
67     hackname = AAB_fd_zero_gnu_types_h;
68     files    = gnu/types.h;
69     mach     = 'i[34567]86-*-linux*';
70
71     /*
72      * Define _TYPES_H_WRAPPER at the end of the wrapper, not
73      * the start, so that if #include_next gets another instance of
74      * the wrapper, this will follow the #include_next chain until
75      * we arrive at the real <gnu/types.h>.
76      */
77     replace  = <<-  _EndOfHeader_
78         /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
79         #ifndef _TYPES_H_WRAPPER
80         #include <features.h>
81         #include_next <gnu/types.h>
82
83         #if defined(__FD_ZERO) && !defined(__GLIBC__)
84         #undef __FD_ZERO
85         # define __FD_ZERO(fdsetp) \\
86           do { \\
87             int __d0, __d1; \\
88                 __asm__ __volatile__("cld ; rep ; stosl" \\
89                 : "=&c" (__d0), "=&D" (__d1) \\
90                 : "a" (0), "0" (__FDSET_LONGS), \\
91                   "1" ((__fd_set *) (fdsetp)) :"memory"); \\
92           } while (0)
93         #endif
94
95         #define _TYPES_H_WRAPPER
96         #endif /* _TYPES_H_WRAPPER */
97         _EndOfHeader_;
98 };
99
100
101 /*
102  *  This fixes __FD_ZERO bug for glibc-2.0.x
103  */
104 fix = {
105     hackname = AAB_fd_zero_selectbits_h;
106     files    = selectbits.h;
107     mach     = 'i[34567]86-*-linux*';
108
109     /*
110      * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
111      * the start, so that if #include_next gets another instance of
112      * the wrapper, this will follow the #include_next chain until
113      * we arrive at the real <selectbits.h>.
114      */
115     replace  = <<-  _EndOfHeader_
116         /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
117         #ifndef _SELECTBITS_H_WRAPPER
118           #include <features.h>
119           #include_next <selectbits.h>
120
121           #if defined(__FD_ZERO) && defined(__GLIBC__) \\
122           && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
123           && __GLIBC_MINOR__ == 0
124              #undef __FD_ZERO
125              #define __FD_ZERO(fdsetp) \\
126              do { \\
127                 int __d0, __d1; \\
128               __asm__ __volatile__ ("cld; rep; stosl" \\
129                         : "=&c" (__d0), "=&D" (__d1) \\
130                         : "a" (0), "0" (sizeof (__fd_set) \\
131                                         / sizeof (__fd_mask)), \\
132                           "1" ((__fd_mask *) (fdsetp)) \\
133                         : "memory"); \\
134               } while (0)
135           #endif
136
137           #define _SELECTBITS_H_WRAPPER
138         #endif /* _SELECTBITS_H_WRAPPER */
139         _EndOfHeader_;
140 };
141
142
143 /*
144  * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
145  * the same interface as <stdarg.h>.  No idea why they couldn't have just
146  * used the standard header.
147  */
148 fix = {
149     hackname = AAB_solaris_sys_varargs_h;
150     files    = "sys/varargs.h";
151     mach     = '*-*-solaris*';
152     replace  = <<-  _EndOfHeader_
153         #ifdef __STDC__
154           #include <stdarg.h>
155         #else
156           #include <varargs.h>
157         #endif
158         _EndOfHeader_;
159 };
160
161
162 /*
163  *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
164  *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
165  *  many other systems have similar text but correct versions of the file.
166  *  To ensure only Sun's is fixed, we grep for a likely unique string.
167  *  Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
168  */
169 fix = {
170     hackname = AAB_sun_memcpy;
171     files    = memory.h;
172     select   = "/\\*\t@\\(#\\)"
173              "(head/memory.h\t50.1\t "
174              "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
175
176     replace = <<-  _EndOfHeader_
177         /* This file was generated by fixincludes */
178         #ifndef __memory_h__
179           #define __memory_h__
180
181           #ifdef __STDC__
182             extern void *memccpy();
183             extern void *memchr();
184             extern void *memcpy();
185             extern void *memset();
186           #else
187             extern char *memccpy();
188             extern char *memchr();
189             extern char *memcpy();
190             extern char *memset();
191           #endif /* __STDC__ */
192
193           extern int memcmp();
194
195         #endif /* __memory_h__ */
196         _EndOfHeader;
197 };
198
199
200 /*
201  *  Completely replace <sys/varargs.h> with a file that includes gcc's
202  *  stdarg.h or varargs.h files as appropriate.
203  */
204 #ifdef SVR4
205 fix = {
206     hackname = AAB_svr4_no_varargs;
207     files    = sys/varargs.h;
208     replace  = "/* This file was generated by fixincludes.  */\n"
209                "#ifndef _SYS_VARARGS_H\n"
210                "#define _SYS_VARARGS_H\n\n"
211
212                "#ifdef __STDC__\n"
213                "#include <stdarg.h>\n"
214                "#else\n"
215                "#include <varargs.h>\n"
216                "#endif\n\n"
217
218                "#endif  /* _SYS_VARARGS_H */\n";
219 };
220 #endif
221
222
223 /*
224  *  Completely replace <sys/byteorder.h>; with a file that implements gcc's
225  *  optimized byteswapping.
226  */
227 fix = {
228     hackname = AAB_svr4_replace_byteorder;
229     mach     = "*-*-sysv4*";
230     mach     = "i[34567]86-*-sysv5*";
231     mach     = "i[34567]86-*-sco3.2v5*";
232     mach     = "i[34567]86-*-udk*";
233     mach     = "i[34567]86-*-solaris2.[0-4]";
234     mach     = "powerpcle-*-solaris2.[0-4]";
235     mach     = "sparc-*-solaris2.[0-4]";
236     files    = sys/byteorder.h;
237     replace  = <<-  _EndOfHeader_
238         #ifndef _SYS_BYTEORDER_H
239         #define _SYS_BYTEORDER_H
240
241         /* Functions to convert `short' and `long' quantities from host byte order
242            to (internet) network byte order (i.e. big-endian).
243
244            Written by Ron Guilmette (rfg@ncd.com).
245
246            This isn't actually used by GCC.  It is installed by fixinc.svr4.
247
248            For big-endian machines these functions are essentially no-ops.
249
250            For little-endian machines, we define the functions using specialized
251            asm sequences in cases where doing so yields better code (e.g. i386).  */
252
253         #if !defined (__GNUC__) && !defined (__GNUG__)
254           #error You lose!  This file is only useful with GNU compilers.
255         #endif
256
257         #ifndef __BYTE_ORDER__
258           /* Byte order defines.  These are as defined on UnixWare 1.1, but with
259              double underscores added at the front and back.  */
260           #define __LITTLE_ENDIAN__   1234
261           #define __BIG_ENDIAN__      4321
262           #define __PDP_ENDIAN__      3412
263         #endif
264
265         #ifdef __STDC__
266           static __inline__ unsigned long htonl (unsigned long);
267           static __inline__ unsigned short htons (unsigned int);
268           static __inline__ unsigned long ntohl (unsigned long);
269           static __inline__ unsigned short ntohs (unsigned int);
270         #endif /* defined (__STDC__) */
271
272         #if defined (__i386__)
273
274           #ifndef __BYTE_ORDER__
275             #define __BYTE_ORDER__ __LITTLE_ENDIAN__
276           #endif
277
278           /* Convert a host long to a network long.  */
279
280           /* We must use a new-style function definition, so that this will also
281              be valid for C++.  */
282           static __inline__ unsigned long
283           htonl (unsigned long __arg)
284           {
285             register unsigned long __result;
286
287             __asm__ ("xchg%B0 %b0,%h0
288                   ror%L0 $16,%0
289                   xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
290             return __result;
291           }
292
293           /* Convert a host short to a network short.  */
294
295           static __inline__ unsigned short
296           htons (unsigned int __arg)
297           {
298             register unsigned short __result;
299
300             __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
301             return __result;
302           }
303
304         #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
305
306           #ifndef __BYTE_ORDER__
307             #define __BYTE_ORDER__ __LITTLE_ENDIAN__
308           #endif
309
310           /* For other little-endian machines, using C code is just as efficient as
311              using assembly code.  */
312
313           /* Convert a host long to a network long.  */
314
315           static __inline__ unsigned long
316           htonl (unsigned long __arg)
317           {
318             register unsigned long __result;
319
320             __result = (__arg >> 24) & 0x000000ff;
321             __result |= (__arg >> 8) & 0x0000ff00;
322             __result |= (__arg << 8) & 0x00ff0000;
323             __result |= (__arg << 24) & 0xff000000;
324             return __result;
325           }
326
327           /* Convert a host short to a network short.  */
328
329           static __inline__ unsigned short
330           htons (unsigned int __arg)
331           {
332             register unsigned short __result;
333
334             __result = (__arg << 8) & 0xff00;
335             __result |= (__arg >> 8) & 0x00ff;
336             return __result;
337           }
338
339         #else /* must be a big-endian machine */
340
341           #ifndef __BYTE_ORDER__
342             #define __BYTE_ORDER__ __BIG_ENDIAN__
343           #endif
344
345           /* Convert a host long to a network long.  */
346
347           static __inline__ unsigned long
348           htonl (unsigned long __arg)
349           {
350             return __arg;
351           }
352
353           /* Convert a host short to a network short.  */
354
355           static __inline__ unsigned short
356           htons (unsigned int __arg)
357           {
358             return __arg;
359           }
360
361         #endif /* big-endian */
362
363         /* Convert a network long to a host long.  */
364
365         static __inline__ unsigned long
366         ntohl (unsigned long __arg)
367         {
368           return htonl (__arg);
369         }
370
371         /* Convert a network short to a host short.  */
372
373         static __inline__ unsigned short
374         ntohs (unsigned int __arg)
375         {
376           return htons (__arg);
377         }
378         #endif
379         _EndOfHeader_;
380 };
381
382
383 /*
384  *  Cancel out ansi_compat.h on Ultrix.  Replace it with an empty file.
385  */
386 fix = {
387     hackname = AAB_ultrix_ansi_compat;
388     files    = ansi_compat.h;
389     select   = ULTRIX;
390     replace  = "/* This file intentionally left blank.  */\n";
391 };
392
393
394 /*
395  *  The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
396  *  Replace limits.h with a file that includes sys/limits.h.
397  */
398 fix = {
399     hackname = AAB_ultrix_limits;
400     files    = limits.h;
401     mach     = "*-*-ultrix4.3";
402     replace  = <<-  _EndOfHeader_
403         #ifndef _LIMITS_INCLUDED
404           #define _LIMITS_INCLUDED
405           #include <sys/limits.h>
406         #endif /* _LIMITS_INCLUDED */
407         _EndOfHeader_;
408 };
409
410
411 /*
412  *  The ULTRIX 4.3 version of memory.h duplicates definitions
413  *  present in strings.h.  Replace memory.h with a file that includes
414  *  strings.h to prevent problems from multiple inclusion.
415  */
416 fix = {
417     hackname = AAB_ultrix_memory;
418     files    = memory.h;
419     mach     = "*-*-ultrix4.3";
420     replace  = <<-  _EndOfHeader_
421         #ifndef _MEMORY_INCLUDED
422           #define _MEMORY_INCLUDED
423           #include <strings.h>
424         #endif /* _MEMORY_INCLUDED */
425         _EndOfHeader_;
426 };
427
428
429 /*
430  *  The Ultrix 4.3 file string.h is a symbolic link to strings.h.
431  *  Replace string.h link with a file that includes strings.h to prevent
432  *  problems from multiple inclusion.
433  */
434 fix = {
435     hackname = AAB_ultrix_string;
436     files    = string.h;
437     mach     = "*-*-ultrix4.3";
438     replace  = <<-  _EndOfHeader_
439         #ifndef _STRING_INCLUDED
440           #define _STRING_INCLUDED
441           #include <strings.h>
442         #endif /* _STRING_INCLUDED */
443         _EndOfHeader_;
444 };
445
446
447 /*
448  *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
449  *  which violates a requirement of ISO C.
450  */
451 fix = {
452     hackname  = aix_pthread;
453     files     = "pthread.h";
454     select    = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
455     c_fix     = format;
456     c_fix_arg = "%1 %2";
457     test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
458                 "{...init stuff...}";
459 };
460
461
462 /*
463  *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
464  *  in an otherwise harmless (and #ifed out) macro definition
465  */
466 fix = {
467     hackname  = aix_sysmachine;
468     files     = sys/machine.h;
469     select    = "\\\\ +\n";
470     c_fix     = format;
471     c_fix_arg = "\\\n";
472     test_text = "#define FOO \\\n"
473     " bar \\ \n baz \\ \n bat";
474 };
475
476
477 /*
478  *  sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
479  *  definition of struct rusage, so the prototype added by fixproto fails.
480  */
481 fix = {
482     hackname  = aix_syswait;
483     files     = sys/wait.h;
484     select    = "^extern pid_t wait3\\(\\);\n";
485     select    = "bos325,";
486     c_fix     = format;
487     c_fix_arg = "struct rusage;\n%0";
488     test_text = "/* bos325, */\n"
489     "extern pid_t wait3();\n"
490     "\t/* pid_t wait3(int *, int, struct rusage *); */";
491 };
492
493
494 /*
495  *  sys/signal.h on some versions of AIX uses volatile in the typedef of
496  *  sig_atomic_t, which causes gcc to generate a warning about duplicate
497  *  volatile when a sig_atomic_t variable is declared volatile, as
498  *  required by ANSI C.
499  */
500 fix = {
501     hackname  = aix_volatile;
502     files     = sys/signal.h;
503     select    = "typedef volatile int sig_atomic_t";
504     c_fix     = format;
505     c_fix_arg = "typedef int sig_atomic_t";
506     test_text = "typedef volatile int sig_atomic_t;";
507 };
508
509
510 /*
511  *  Fix __assert declaration in assert.h on Alpha OSF/1.
512  */
513 fix = {
514     hackname  = alpha___assert;
515     files     = "assert.h";
516     select    = '__assert\(char \*, char \*, int\)';
517     c_fix     = format;
518     c_fix_arg = "__assert(const char *, const char *, int)";
519     test_text = 'extern void __assert(char *, char *, int);';
520 };
521
522
523 /*
524  *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
525  */
526 fix = {
527     hackname  = alpha___extern_prefix;
528     files     = sys/stat.h;
529     select    = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
530
531     mach      = "alpha*-dec-osf5*";
532     c_fix     = format;
533     c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
534
535     test_text = "#   if defined(__DECC)";
536 };
537
538
539 /*
540  *  Fix assert macro in assert.h on Alpha OSF/1.
541  *  The superfluous int cast breaks C++.
542  */
543 fix = {
544     hackname  = alpha_assert;
545     files     = "assert.h";
546     select    = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
547     c_fix     = format;
548     c_fix_arg = "%1(EX)";
549     test_text = '#define assert(EX) (((int) (EX)) ? (void)0 : __assert(#EX, __FILE__, __LINE__))';
550 };
551
552
553 /*
554  *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
555  */
556 fix = {
557     hackname  = alpha_getopt;
558     files     = "stdio.h";
559     files     = "stdlib.h";
560     select    = 'getopt\(int, char \*\[\], *char \*\)';
561     c_fix     = format;
562     c_fix_arg = "getopt(int, char *const[], const char *)";
563     test_text = 'extern int getopt(int, char *[], char *);';
564 };
565
566
567 /*
568  * Remove erroneous parentheses in sym.h on Alpha OSF/1.
569  */
570 fix = {
571     hackname  = alpha_parens;
572     files     = sym.h;
573     select    = '#ifndef\(__mips64\)';
574     c_fix     = format;
575     c_fix_arg = "#ifndef __mips64";
576     test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
577 };
578
579
580 /*
581  *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
582  *  And OpenBSD.
583  */
584 fix = {
585     hackname = alpha_sbrk;
586     files    = unistd.h;
587     select   = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
588     c_fix     = format;
589     c_fix_arg = "void *sbrk(";
590     test_text = "extern char* sbrk(ptrdiff_t increment);";
591 };
592
593
594 /*
595  *  For C++, avoid any typedef or macro definition of bool,
596  *  and use the built in type instead.
597  *  HP/UX 10.20 also has it in curses_colr/curses.h.
598  */
599 fix = {
600     hackname  = avoid_bool_define;
601     files     = curses.h;
602     files     = curses_colr/curses.h;
603     files     = term.h;
604     files     = tinfo.h;
605
606     select    = "#[ \t]*define[ \t]+bool[ \t]";
607     bypass    = "__cplusplus";
608
609     c_fix     = format;
610     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
611     c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
612
613     test_text = "# define bool\t char \n";
614 };
615
616
617 fix = {
618     hackname = avoid_bool_type;
619     files    = curses.h;
620     files    = curses_colr/curses.h;
621     files    = term.h;
622     files    = tinfo.h;
623
624     select    = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
625     bypass    = "__cplusplus";
626
627     c_fix     = format;
628     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
629
630     test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
631 };
632
633
634 /*
635  *  For C++, avoid any typedef definition of wchar_t,
636  *  and use the built in type instead.
637  *  Don't do this for headers that are smart enough to do the right
638  *  thing (recent [n]curses.h and Xlib.h).
639  *  Don't do it for <linux/nls.h> which is never used from C++ anyway,
640  *  and will be broken by the edit.
641  */
642
643 fix = {
644     hackname = avoid_wchar_t_type;
645
646     select    = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
647     bypass    = "__cplusplus";
648     bypass    = "_LINUX_NLS_H";
649     bypass    = "XFree86: xc/lib/X11/Xlib\\.h";
650
651     c_fix     = format;
652     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
653
654     test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
655 };
656
657
658 /*
659  *  Fix #defines under Alpha OSF/1:
660  *  The following files contain '#pragma extern_prefix "_FOO"' followed by
661  *  a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
662  *  statements is to reduce namespace pollution.  While these macros work
663  *  properly in most cases, they don't allow you to take a pointer to the
664  *  "something" being modified.  To get around this limitation, change these
665  *  statements to be of the form '#define something _FOOsomething'.
666  *
667  *  sed ain't egrep, lesson 2463:  sed can use self-referential
668  *  regular expressions.  In the substitute expression below,
669  *  "\\1" and "\\2" refer to subexpressions found earlier in the
670  *  same match.  So, we continue to use sed.  "extern_prefix" will
671  *  be a rare match anyway...
672  */
673 fix = {
674     hackname = bad_lval;
675
676     select   = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
677
678     files    = libgen.h;
679     files    = dirent.h;
680     files    = ftw.h;
681     files    = grp.h;
682     files    = ndbm.h;
683     files    = pthread.h;
684     files    = pwd.h;
685     files    = signal.h;
686     files    = standards.h;
687     files    = stdlib.h;
688     files    = string.h;
689     files    = stropts.h;
690     files    = time.h;
691     files    = unistd.h;
692
693     sed      =
694         "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
695                "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
696
697     test_text = '#pragma extern_prefix "_FOO"'"\n"
698                 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
699                 "#define mumble _FOOmumble";
700 };
701
702
703 /*
704  *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
705  */
706 fix = {
707     hackname  = bad_struct_term;
708     files     = curses.h;
709     select    = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
710     c_fix     = format;
711     c_fix_arg = "struct term;";
712
713     test_text = 'typedef struct term;';
714 };
715
716
717 /*
718  *  Fix one other error in this file:
719  *  a mismatched quote not inside a C comment.
720  */
721 fix = {
722     hackname  = badquote;
723     files     = sundev/vuid_event.h;
724     select    = "doesn't";
725     c_fix     = format;
726     c_fix_arg = "does not";
727
728     test_text = "/* doesn't have matched single quotes */";
729 };
730
731
732 /*
733  *  check for broken assert.h that needs stdio.h
734  */
735 fix = {
736     hackname  = broken_assert_stdio;
737     files     = assert.h;
738     select    = stderr;
739     bypass    = "include.*stdio\\.h";
740     c_fix     = wrap;
741     c_fix_arg = "#include <stdio.h>\n";
742     test_text = "extern FILE* stderr;";
743 };
744
745
746 /*
747  *  check for broken assert.h that needs stdlib.h
748  */
749 fix = {
750     hackname  = broken_assert_stdlib;
751     files     = assert.h;
752     select    = 'exit *\(|abort *\(';
753     bypass    = "include.*stdlib\\.h";
754     c_fix     = wrap;
755     c_fix_arg = "#ifdef __cplusplus\n"
756                 "#include <stdlib.h>\n"
757                 "#endif\n";
758     test_text = "extern void exit ( int );";
759 };
760
761
762 /*
763  *  Remove `extern double cabs' declarations from math.h.
764  *  This conflicts with C99.  Discovered on AIX.
765  *  SunOS4 has its cabs() declaration followed by a comment which
766  *  terminates on the following line.
767  */
768 fix = {
769     hackname = broken_cabs;
770     files  = "math.h";
771     select = '^extern[ \t]+double[ \t]+cabs';
772
773     c_fix     = format;
774     c_fix_arg = "";
775     c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
776
777     test_text = "#ifdef __STDC__\n"
778                 "extern     double   cabs(struct dbl_hypot);\n"
779                 "#else\n"
780                 "extern     double   cabs();\n"
781                 "#endif\n"
782                 "extern double cabs(); /* This is a comment\n"
783                 "                         and it ends here. */";
784 };
785
786
787 /*
788  *  Various systems derived from BSD4.4 contain a macro definition
789  *  for vfscanf that interacts badly with requirements of builtin-attrs.def.
790  *  Known to be fixed in FreeBSD 5 system headers.
791  */
792 fix = {
793     hackname  = bsd_stdio_attrs_conflict;
794     mach      = *-*-*bsd*;
795     mach      = *-*-*darwin*;
796     files     = stdio.h;
797     select    = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
798     c_fix     = format;
799     c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
800                 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
801                 'int vfscanf(FILE *, const char *, __builtin_va_list) '
802                 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
803     test_text = '#define  vfscanf       __svfscanf';
804 };
805
806
807 /*
808  *  Fix various macros used to define ioctl numbers.
809  *  The traditional syntax was:
810  *
811  *    #define _CTRL(n, x) (('n'<<8)+x)
812  *    #define TCTRLCFOO _CTRL(T, 1)
813  *
814  *  but this does not work with the C standard, which disallows macro
815  *  expansion inside strings.  We have to rewrite it thus:
816  *
817  *    #define _CTRL(n, x) ((n<<8)+x)
818  *    #define TCTRLCFOO  _CTRL('T', 1)
819  *
820  *  The select expressions match too much, but the c_fix code is cautious.
821  *
822  *  CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
823  */
824 fix = {
825     hackname  = ctrl_quotes_def;
826     select    = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
827     c_fix     = char_macro_def;
828     c_fix_arg = "CTRL";
829
830     /*
831      *  This is two tests in order to ensure that the "CTRL(c)" can
832      *  be selected in isolation from the multi-arg format
833      */
834     test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
835     test_text = "#define _CTRL(c) ('c'&037)";
836 };
837
838 fix = {
839     hackname  = ctrl_quotes_use;
840     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
841     c_fix     = char_macro_use;
842     c_fix_arg = "CTRL";
843     test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
844 };
845
846
847 /*
848  *  sys/mman.h on HP/UX is not C++ ready,
849  *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
850  *
851  *  rpc/types.h on OSF1/2.0 is not C++ ready,
852  *  even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
853  *
854  *  The problem is the declaration of malloc.
855  */
856 fix = {
857     hackname = cxx_unready;
858     files    = sys/mman.h;
859     files    = rpc/types.h;
860     select   = '[^#]+malloc.*;';  /* Catch any form of declaration
861                                      not within a macro.  */
862     bypass   = '"C"|__BEGIN_DECLS';
863
864     c_fix     = wrap;
865     c_fix_arg = "#ifdef __cplusplus\n"
866                 "extern \"C\" {\n"
867                 "#endif\n";
868     c_fix_arg = "#ifdef __cplusplus\n"
869                 "}\n"
870                 "#endif\n";
871     test_text = "extern void* malloc( size_t );";
872 };
873
874
875 /*
876  *  Fix <c_asm.h> on Digital UNIX V4.0:
877  *  It contains a prototype for a DEC C internal asm() function,
878  *  clashing with gcc's asm keyword.  So protect this with __DECC.
879  */
880 fix = {
881     hackname = dec_intern_asm;
882     files    = c_asm.h;
883     sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
884     sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
885           "#endif\n";
886     test_text =
887     "float fasm {\n"
888     "    ... asm stuff ...\n"
889     "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
890 };
891
892
893 /*
894  * Fix typo in <wchar.h> on DJGPP 2.03.
895  */
896 fix = {
897     hackname  = djgpp_wchar_h;
898     file      = wchar.h;
899     select    = "__DJ_wint_t";
900     bypass    = "sys/djtypes.h";
901     c_fix     = format;
902     c_fix_arg = "%0\n#include <sys/djtypes.h>";
903     c_fix_arg = "#include <stddef.h>";
904     test_text = "#include <stddef.h>\n"
905                 "extern __DJ_wint_t x;\n";
906 };
907
908
909 /*
910  * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
911  */
912 fix = {
913     hackname  = ecd_cursor;
914     files     = "sunwindow/win_lock.h";
915     files     = "sunwindow/win_cursor.h";
916     select    = 'ecd\.cursor';
917     c_fix     = format;
918     c_fix_arg = 'ecd_cursor';
919
920     test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
921 };
922
923
924 /*
925  *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
926  *  neither the existence of GCC 3 nor its exact feature set yet break
927  *  (by design?) when __GNUC__ is set beyond 2.
928  */
929 fix = {
930     hackname  = freebsd_gcc3_breakage;
931     mach      = *-*-freebsd*;
932     files     = sys/cdefs.h;
933     select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
934     bypass    = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
935     c_fix     = format;
936     c_fix_arg = '%0 || __GNUC__ >= 3';
937     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
938 };
939
940
941 /*
942  * Fix these files to use the types we think they should for
943  * ptrdiff_t, size_t, and wchar_t.
944  *
945  * This defines the types in terms of macros predefined by our 'cpp'.
946  * This is supposedly necessary for glibc's handling of these types.
947  * It's probably not necessary for anyone else, but it doesn't hurt.
948  */
949 fix = {
950     hackname  = gnu_types;
951     files  = "sys/types.h";
952     files  = "stdlib.h";
953     files  = "sys/stdtypes.h";
954     files  = "stddef.h";
955     files  = "memory.h";
956     files  = "unistd.h";
957     bypass    = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
958     select    = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
959     c_fix     = gnu_type;
960
961     test_text = "typedef long int ptrdiff_t; /* long int */\n"
962                 "typedef uint_t size_t; /* uint_t */\n"
963                 "typedef ushort_t wchar_t; /* ushort_t */";
964 };
965
966
967 /*
968  *  Fix HP & Sony's use of "../machine/xxx.h"
969  *  to refer to:  <machine/xxx.h>
970  */
971 fix = {
972     hackname  = hp_inline;
973     files     = sys/spinlock.h;
974     files     = machine/machparam.h;
975     select    = "[ \t]*#[ \t]*include[ \t]+"  '"\.\./machine/';
976
977     c_fix     = format;
978     c_fix_arg = "%1<machine/%2.h>";
979
980     c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)"  '"\.\./machine/'
981                 '([a-z]+)\.h"';
982
983     test_text = ' # include "../machine/mumble.h"';
984 };
985
986
987 /*
988  *  Check for (...) in C++ code in HP/UX sys/file.h.
989  */
990 fix = {
991     hackname  = hp_sysfile;
992     files     = sys/file.h;
993     select    = "HPUX_SOURCE";
994
995     c_fix     = format;
996     c_fix_arg = "(struct file *, ...)";
997     c_fix_arg = '\(\.\.\.\)';
998
999     test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1000 };
1001
1002
1003 /*
1004  * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1005  * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1006  */
1007 fix = {
1008     hackname  = hpux10_cpp_pow_inline;
1009     files     = fixinc-test-limits.h, math.h;
1010     select    = <<-     END_POW_INLINE
1011         ^# +ifdef +__cplusplus
1012          +\}
1013          +inline +double +pow\(double +__d,int +__expon\) +\{
1014         [       ]+return +pow\(__d,\(double\)__expon\);
1015          +\}
1016          +extern +"C" +\{
1017         #else
1018         # +endif
1019         END_POW_INLINE;
1020  
1021     c_fix     = format;
1022     c_fix_arg = "";
1023
1024     test_text =
1025         "#    ifdef __cplusplus\n"
1026         "     }\n"
1027         "     inline double pow(double __d,int __expon) {\n"
1028         "\t return pow(__d,(double)__expon);\n"
1029         "     }\n"
1030         '     extern "C"' " {\n"
1031         "#else\n"
1032         "#    endif";
1033 };
1034
1035 fix = {
1036      hackname  = hpux11_cpp_pow_inline;
1037      files     = math.h;
1038      select    = " +inline double pow\\(double d,int expon\\) \\{\n"
1039                  " +return pow\\(d, \\(double\\)expon\\);\n"
1040                  " +\\}\n";
1041      c_fix     = format;
1042      c_fix_arg = "";
1043
1044      test_text =
1045             "   inline double pow(double d,int expon) {\n"
1046             "     return pow(d, (double)expon);\n"
1047             "   }\n";
1048 };
1049
1050
1051 /*
1052  *  Fix hpux 10.X missing ctype declarations 1
1053  */
1054 fix = {
1055     hackname = hpux10_ctype_declarations1;
1056     files    = ctype.h;
1057     select   = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1058     bypass   = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1059     c_fix     = format;
1060     c_fix_arg = "#ifdef _PROTOTYPES\n"
1061                 "extern int __tolower(int);\n"
1062                 "extern int __toupper(int);\n"
1063                 "#else /* NOT _PROTOTYPES */\n"
1064                 "extern int __tolower();\n"
1065                 "extern int __toupper();\n"
1066                 "#endif /* _PROTOTYPES */\n\n"
1067                 "%0\n";
1068
1069     test_text = "#  define _toupper(__c)         __toupper(__c)\n";
1070 };
1071
1072
1073 /*
1074  *  Fix hpux 10.X missing ctype declarations 2
1075  */
1076 fix = {
1077     hackname = hpux10_ctype_declarations2;
1078     files    = ctype.h;
1079     select   = "^#  if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1080     bypass   = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1081     c_fix     = format;
1082     c_fix_arg = "%0\n\n"
1083                 "#ifdef _PROTOTYPES\n"
1084                 "     extern int _isalnum(int);\n"
1085                 "     extern int _isalpha(int);\n"
1086                 "     extern int _iscntrl(int);\n"
1087                 "     extern int _isdigit(int);\n"
1088                 "     extern int _isgraph(int);\n"
1089                 "     extern int _islower(int);\n"
1090                 "     extern int _isprint(int);\n"
1091                 "     extern int _ispunct(int);\n"
1092                 "     extern int _isspace(int);\n"
1093                 "     extern int _isupper(int);\n"
1094                 "     extern int _isxdigit(int);\n"
1095                 "#  else /* not _PROTOTYPES */\n"
1096                 "     extern int _isalnum();\n"
1097                 "     extern int _isalpha();\n"
1098                 "     extern int _iscntrl();\n"
1099                 "     extern int _isdigit();\n"
1100                 "     extern int _isgraph();\n"
1101                 "     extern int _islower();\n"
1102                 "     extern int _isprint();\n"
1103                 "     extern int _ispunct();\n"
1104                 "     extern int _isspace();\n"
1105                 "     extern int _isupper();\n"
1106                 "     extern int _isxdigit();\n"
1107                 "#endif /* _PROTOTYPES */\n";
1108
1109     test_text = "#  if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1110                 "     extern unsigned int *__SB_masks;\n";
1111 };
1112
1113
1114 /*
1115  *  Make sure hpux defines abs in header.
1116  */
1117 fix = {
1118     hackname  = hpux11_abs;
1119     mach      = ia64-hp-hpux11*;
1120     files     = stdlib.h;
1121     select    = "ifndef _MATH_INCLUDED";
1122     c_fix     = format;
1123     c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1124 //  sed       = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1125     test_text = "#ifndef _MATH_INCLUDED";
1126 };
1127
1128
1129 /*
1130  *  Keep HP-UX 11 from stomping on C++ math namespace
1131  *  with defines for fabsf.
1132  */
1133 fix = {
1134     hackname  = hpux11_fabsf;
1135     files     = math.h;
1136     select    = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1137     bypass    = "__cplusplus";
1138
1139     c_fix     = format;
1140     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1141
1142     test_text =
1143     "#ifdef _PA_RISC\n"
1144     "#  define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1145     "#endif";
1146 };
1147
1148
1149 /*
1150  * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1151  * being defined by having it define _hpux_size_t instead.
1152  */
1153 fix = {
1154     hackname  = hpux11_size_t;
1155     mach      = "*-hp-hpux11*";
1156     select    = "__size_t";
1157
1158     c_fix     = format;
1159     c_fix_arg = "_hpux_size_t";
1160
1161     test_text =
1162     "#define __size_t size_t\n"
1163     "       extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1164 };
1165
1166
1167 /*
1168  * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1169  * of UINT32_C has undefined behavior according to ISO/ANSI:
1170  * the arguments to __CONCAT__ are not macro expanded before the
1171  * concatination happens so the trailing ')' in the first argument
1172  * is concatinated with the 'l' in the second argument creating an
1173  * invalid pp token.  The behavior of invalid pp tokens is undefined.
1174  * GCC does not handle these invalid tokens the way the HP compiler does.
1175  * This problem will potentially occur anytime macros are used in the
1176  * arguments to __CONCAT__.  A general solution to this problem would be to
1177  * insert another layer of macro between __CONCAT__ and its use
1178  * in UINT32_C.  An example of this solution can be found in the C standard.
1179  * A more specific solution, the one used here, is to change the UINT32_C
1180  * macro to not used macros in the arguments to __CONCAT__.
1181  */
1182 fix = {
1183     hackname = hpux11_uint32_c;
1184     files    = inttypes.h;
1185     select   = "^#define UINT32_C\\(__c\\)[ \t]*"
1186                          "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1187     c_fix    = format;
1188     c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1189     test_text =
1190     "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1191     "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1192 };
1193
1194
1195 /*
1196  *  Fix hpux 11.00 broken vsnprintf declaration
1197  */
1198 fix = {
1199     hackname = hpux11_vsnprintf;
1200     files    = stdio.h;
1201     select   = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1202                                      'const char \*,) __va__list\);';
1203     c_fix     = format;
1204     c_fix_arg = "%1 __va_list);";
1205
1206     test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1207                                      ' __va__list);';
1208 };
1209
1210
1211 /*
1212  *  get rid of bogus inline definitions in HP-UX 8.0
1213  */
1214 fix = {
1215     hackname = hpux8_bogus_inlines;
1216     files    = math.h;
1217     select   = inline;
1218     sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1219            "@extern \"C\" int abs(int);@";
1220     sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1221     sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1222     sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1223     test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1224                 "inline double sqr(double v) { return v**0.5; }";
1225 };
1226
1227
1228 /*
1229  *  Fix hpux broken ctype macros
1230  */
1231 fix = {
1232     hackname = hpux_ctype_macros;
1233     files    = ctype.h;
1234     select   = '((: |\()__SB_masks \? )'
1235                '(__SB_masks\[__(alnum|c)\] & _IS)';
1236     c_fix     = format;
1237     c_fix_arg = "%1(int)%3";
1238
1239     test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1240                 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1241 };
1242
1243
1244 /*
1245  * HP-UX long_double
1246  */
1247 fix = {
1248     hackname  = hpux_long_double;
1249     files     = stdlib.h;
1250     select    = "extern[ \t]long_double[ \t]strtold";
1251     bypass    = "long_double_t";
1252     sed       = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1253     sed       = "s/long_double/long double/g";
1254
1255     test_text = "#  ifndef _LONG_DOUBLE\n"
1256                 "#    define _LONG_DOUBLE\n"
1257                 "     typedef struct {\n"
1258                 "       unsigned int word1, word2, word3, word4;\n"
1259                 "     } long_double;\n"
1260                 "#  endif /* _LONG_DOUBLE */\n"
1261                 "extern long_double strtold(const char *, char **);\n";
1262 };
1263
1264
1265 /*
1266  *  HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1267  */
1268 fix = {
1269     hackname  = hpux_maxint;
1270     files     = sys/param.h;
1271     files     = values.h;
1272     select    = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1273     bypass    = "^#[ \t]*ifndef[ \t]+MAXINT";
1274     test =
1275     "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1276
1277     c_fix     = format;
1278     c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1279     c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1280
1281     test_text = '#define MAXINT 0x7FFFFFFF';
1282 };
1283
1284
1285 /*
1286  *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1287  */
1288 fix = {
1289     hackname = hpux_systime;
1290     files    = sys/time.h;
1291     select   = "^extern struct sigevent;";
1292
1293     c_fix     = format;
1294     c_fix_arg = "struct sigevent;";
1295
1296     test_text = 'extern struct sigevent;';
1297 };
1298
1299
1300 /*
1301  *  Fix return type of abort and free
1302  */
1303 fix = {
1304     hackname  = int_abort_free_and_exit;
1305     files     = stdlib.h;
1306     select    = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1307
1308     c_fix     = format;
1309     c_fix_arg = "void\t%1(";
1310
1311     test_text = "extern int abort(int);\n"
1312                 "extern int free(void*);\n"
1313                 "extern int exit(void*);";
1314 };
1315
1316
1317 /*
1318  *  Fix various macros used to define ioctl numbers.
1319  *  The traditional syntax was:
1320  *
1321  *    #define _IO(n, x) (('n'<<8)+x)
1322  *    #define TIOCFOO _IO(T, 1)
1323  *
1324  *  but this does not work with the C standard, which disallows macro
1325  *  expansion inside strings.  We have to rewrite it thus:
1326  *
1327  *    #define _IO(n, x) ((n<<8)+x)
1328  *    #define TIOCFOO  _IO('T', 1)
1329  *
1330  *  The select expressions match too much, but the c_fix code is cautious.
1331  *
1332  *  _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1333  */
1334 fix = {
1335     hackname  = io_quotes_def;
1336     select    = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1337     c_fix     = char_macro_def;
1338     c_fix_arg = "IO";
1339     test_text =
1340     "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1341     "#define _IOWN(x,y,t)  (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1342     "#define _IO(x,y)      ('x'<<8|y)";
1343     test_text =
1344     "#define XX_IO(x)        ('x'<<8|256)";
1345 };
1346
1347 fix = {
1348     hackname  = io_quotes_use;
1349     select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1350                 "\\( *[^,']";
1351     c_fix     = char_macro_use;
1352     c_fix_arg = "IO";
1353     test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1354                 "#define TIOCFOO \\\\\n"
1355                 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1356 };
1357
1358
1359 /*
1360  *  Check for missing ';' in struct
1361  */
1362 fix = {
1363     hackname = ip_missing_semi;
1364     files    = netinet/ip.h;
1365     select   = "}$";
1366     sed      = "/^struct/,/^};/s/}$/};/";
1367     test_text=
1368     "struct mumble {\n"
1369     "  union {\n"
1370     "    int x;\n"
1371     "  }\n"
1372     "}; /* mumbled struct */\n";
1373 };
1374
1375
1376 /*
1377  *  IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1378  *  __restrict as restrict iff __c99.  This is wrong for C++, which
1379  *  needs many C99 features, but only supports __restrict.
1380  */
1381 fix = {
1382     hackname  = irix___restrict;
1383     files     = internal/sgimacros.h;
1384     select    = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1385
1386     mach      = "mips-sgi-irix6.5";
1387     c_fix     = format;
1388     c_fix_arg = "%1"
1389                 "#  ifndef __cplusplus\n%2\n#  endif";
1390
1391     test_text = "#ifdef __c99\n#  define __restrict restrict";
1392 };
1393
1394 /*
1395  *  IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1396  *  that causes the assembly preprocessor to complain about an
1397  *  unterminated character constant.
1398  */
1399 fix = {
1400     hackname  = irix_asm_apostrophe;
1401     files     = sys/asm.h;
1402
1403     select    = "^[ \t]*#.*[Ww]e're";
1404     c_fix     = format;
1405     c_fix_arg = "%1 are";
1406     c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1407     test_text = "\t# and we're on vacation";
1408 };
1409
1410
1411 /*
1412  *  Non-traditional "const" declaration in Irix's limits.h.
1413  */
1414 fix = {
1415     hackname    = irix_limits_const;
1416     files       = fixinc-test-limits.h, limits.h;
1417     select      = "^extern const ";
1418     c_fix       = format;
1419     c_fix_arg   = "extern __const ";
1420     test_text   = "extern const char limit; /* test limits */";
1421 };
1422
1423
1424 /*
1425  *  IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
1426  *  Various socket function prototypes use different types instead,
1427  *  depending on the API in use (BSD, XPG4/5), but the socklen_t
1428  *  definition doesn't reflect this (SGI Bug Id 864477, fixed in
1429  *  IRIX 6.5.19).
1430  */
1431 fix = {
1432     hackname  = irix_socklen_t;
1433     files     = sys/socket.h;
1434     select    = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
1435
1436     mach      = "mips-sgi-irix6.5";
1437     c_fix     = format;
1438     c_fix_arg = "%1"
1439                 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
1440                 "typedef int socklen_t;\n"
1441                 "#else\n"
1442                 "%2\n"
1443                 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
1444
1445     test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
1446 };
1447
1448 /*
1449  *  IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
1450  *  some functions that take a va_list as
1451  *  taking char *.  However, GCC uses void * for va_list, so
1452  *  calling vfprintf with a va_list fails in C++.  */
1453 fix = {
1454     hackname  = irix_stdio_va_list;
1455     files     = stdio.h;
1456     files     = internal/stdio_core.h;
1457
1458     select = '(printf\(.*), /\* va_list \*/ char \*';
1459     c_fix  = format;
1460     c_fix_arg = "%1, __gnuc_va_list";
1461     test_text =
1462     "extern int printf( const char *, /* va_list */ char * );";
1463 };
1464
1465
1466 /*
1467  *  IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
1468  *  wcsftime by default.  ISO C99 requires the XPG5 variant instead.
1469  */
1470 fix = {
1471     hackname  = irix_wcsftime;
1472     files     = internal/wchar_core.h;
1473     select    = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
1474
1475     mach      = "mips-sgi-irix6.5";
1476     c_fix     = format;
1477     c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
1478
1479     test_text = "#if _NO_XOPEN5\n"
1480                 "extern size_t          wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
1481 };
1482
1483 /*
1484  * Fixing ISC fmod declaration
1485  */
1486 fix = {
1487     hackname  = isc_fmod;
1488     files     = math.h;
1489     select    = 'fmod\(double\)';
1490     c_fix     = format;
1491     c_fix_arg = "fmod(double, double)";
1492     test_text = "extern double  fmod(double);";
1493 };
1494
1495
1496 /*
1497  *  On Interactive Unix 2.2, certain traditional Unix definitions
1498  *  (notably getc and putc in stdio.h) are omitted if __STDC__ is
1499  *  defined, not just if _POSIX_SOURCE is defined.  This makes it
1500  *  impossible to compile any nontrivial program except with -posix.
1501  */
1502 fix = {
1503     hackname = isc_omits_with_stdc;
1504
1505     files     = "stdio.h";
1506     files     = "math.h";
1507     files     = "ctype.h";
1508     files     = "sys/limits.h";
1509     files     = "sys/fcntl.h";
1510     files     = "sys/dirent.h";
1511
1512     select    = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1513     c_fix     = format;
1514     c_fix_arg = '!defined(_POSIX_SOURCE)';
1515     test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1516                 "\nint foo;\n#endif";
1517 };
1518
1519
1520 /*
1521  * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1522  * use / * * / to concatenate tokens.
1523  */
1524 fix = {
1525     hackname = kandr_concat;
1526     files  = "sparc/asm_linkage.h";
1527     files  = "sun3/asm_linkage.h";
1528     files  = "sun3x/asm_linkage.h";
1529     files  = "sun4/asm_linkage.h";
1530     files  = "sun4c/asm_linkage.h";
1531     files  = "sun4m/asm_linkage.h";
1532     files  = "sun4c/debug/asm_linkage.h";
1533     files  = "sun4m/debug/asm_linkage.h";
1534     files  = "arm/as_support.h";
1535     files  = "arm/mc_type.h";
1536     files  = "arm/xcb.h";
1537     files  = "dev/chardefmac.h";
1538     files  = "dev/ps_irq.h";
1539     files  = "dev/screen.h";
1540     files  = "dev/scsi.h";
1541     files  = "sys/tty.h";
1542     files  = "Xm.acorn/XmP.h";
1543     files  = bsd43/bsd43_.h;
1544     select = '/\*\*/';
1545     c_fix     = format;
1546     c_fix_arg = '##';
1547     test_text = "#define __CONCAT__(a,b) a/**/b";
1548 };
1549
1550
1551 /*
1552  *  Fix libc1 _G_va_list definition, used in declarations of several
1553  *  more-or-less standard functions, for example vasprintf.
1554  */
1555 fix = {
1556     hackname = libc1_G_va_list;
1557     files    = _G_config.h;
1558     mach     = '*-*-linux*libc1';
1559     select   = 'typedef void \* _G_va_list;';
1560     c_fix     = format;
1561     c_fix_arg = "typedef __builtin_va_list _G_va_list;";
1562     test_text = 'typedef void * _G_va_list;';
1563 };
1564
1565
1566 /*
1567  *  GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1568  *  versions > 1.  This fix will open up the declaration for all
1569  *  versions of GCC and for g++.
1570  */
1571 fix = {
1572     hackname  = libc1_ifdefd_memx;
1573
1574     /* The string.h result is overwritten by AAB_ultrix_string when doing
1575        "make check" and will fail.  Therefore, we add the following kludgery
1576        to insert the test_text into the special testing header.  :-}  */
1577     files     = testing.h;
1578     files     = string.h;
1579
1580     c_fix     = format;
1581     select    = "' is a built-in function for gcc 2\\.x\\. \\*/";
1582     bypass    = __cplusplus;
1583     c_fix_arg = "%1";
1584     c_fix_arg =
1585        '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1586        '#if defined\(__STDC__\) && __GNUC__ < 2'                 "\n"
1587        "(/\\* .* \\*/\n"
1588        "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1589        "#endif";
1590
1591     test_text =
1592     "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1593     "#if defined(__STDC__) && __GNUC__ < 2\n"
1594     "/* Copy N bytes of SRC to DEST.  */\n"
1595     "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1596     "                         size_t __n));\n"
1597     "#endif";
1598 };
1599
1600
1601 /*
1602  *  In limits.h, put #ifndefs around things that are supposed to be defined
1603  *  in float.h to avoid redefinition errors if float.h is included first.
1604  *  On HP/UX this patch does not work, because on HP/UX limits.h uses
1605  *  multi line comments and the inserted #endif winds up inside the
1606  *  comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
1607  *  we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1608  *  are there, and we do not add them ourselves.
1609  *
1610  *  QNX Software Systems also guards the defines, but doesn't define
1611  *  FLT_MIN.  Therefore, bypass the fix for *either* guarded FLT_MIN
1612  *  or guarded FLT_MAX.
1613  */
1614 fix = {
1615     hackname = limits_ifndefs;
1616     files  = "sys/limits.h";
1617     files  = "limits.h";
1618     select = "^[ \t]*#[ \t]*define[ \t]+"
1619              "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1620     bypass = "ifndef[ \t]+FLT_(MIN|MAX)";
1621
1622     c_fix     = format;
1623     c_fix_arg = "#ifndef %1\n%0\n#endif";
1624     /* Second arg is select expression */
1625     test_text = " #\tdefine\tDBL_DIG \t 0  /* somthin' */";
1626 };
1627
1628
1629 /*
1630  *  Delete the '#define void int' line from curses.h on Lynx
1631  */
1632 fix = {
1633     hackname  = lynx_void_int;
1634     files     = curses.h;
1635     select    = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1636     c_fix     = format;
1637     c_fix_arg = "";
1638     test_text = "# define\tvoid\tint \t/* curses foiled again */";
1639 };
1640
1641
1642 /*
1643  *  Fix fcntl prototype in fcntl.h on LynxOS.
1644  */
1645 fix = {
1646     hackname  = lynxos_fcntl_proto;
1647     files     = fcntl.h;
1648     select    = "fcntl[ \t]*" '\(int, int, int\)';
1649     c_fix     = format;
1650     c_fix_arg = '%1...)';
1651     c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1652     test_text = "extern int fcntl(int, int, int);";
1653 };
1654
1655
1656 /*
1657  * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1658  *
1659  * On NetBSD, machine is a symbolic link to an architecture specific
1660  * directory name, so we can't match a specific file name here.
1661  */
1662 fix = {
1663     hackname = machine_ansi_h_va_list;
1664     select   = "define[ \t]+_BSD_VA_LIST_[ \t]";
1665     bypass   = '__builtin_va_list';
1666
1667     c_fix     = format;
1668     c_fix_arg = "%1__builtin_va_list";
1669     c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1670
1671     test_text = " # define _BSD_VA_LIST_\tchar**";
1672 };
1673
1674
1675 /*
1676  *  Fix non-ansi machine name defines
1677  */
1678 fix = {
1679     hackname  = machine_name;
1680     c_test    = machine_name;
1681     c_fix     = machine_name;
1682
1683     test_text = "/* MACH_DIFF: */\n"
1684     "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1685     "\n/* no uniform test, so be careful  :-) */";
1686 };
1687
1688
1689 /*
1690  *  Some math.h files define struct exception (it's in the System V
1691  *  Interface Definition), which conflicts with
1692  *  the class exception defined in the C++ file std/stdexcept.h.  We
1693  *  redefine it to __math_exception.  This is not a great fix, but I
1694  *  haven't been able to think of anything better.
1695  *  Note that we have to put the #ifdef/#endif blocks at beginning
1696  *  and end of file, because fixproto runs after us and may insert
1697  *  additional references to struct exception.
1698  */
1699 fix = {
1700     hackname  = math_exception;
1701     files     = math.h;
1702     select    = "struct exception";
1703     bypass    = '__cplusplus';
1704     c_fix     = wrap;
1705
1706     c_fix_arg = "#ifdef __cplusplus\n"
1707                 "#define exception __math_exception\n"
1708                 "#endif\n";
1709
1710     c_fix_arg = "#ifdef __cplusplus\n"
1711                 "#undef exception\n"
1712                 "#endif\n";
1713
1714     test_text = "typedef struct exception t_math_exception;";
1715 };
1716
1717
1718 /*
1719  *  This looks pretty broken to me.  ``dbl_max_def'' will contain
1720  *  "define DBL_MAX " at the start, when what we really want is just
1721  *  the value portion.  Can't figure out how to write a test case
1722  *  for this either  :-(
1723  */
1724 fix = {
1725     hackname = math_huge_val_from_dbl_max;
1726     files    = math.h;
1727
1728     /*
1729      * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1730      * in math.h, this fix applies.
1731      */
1732     select   = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1733     bypass   = "define[ \t]+DBL_MAX";
1734
1735     shell    =
1736     /*
1737      *  See if we have a definition for DBL_MAX in float.h.
1738      *  If we do, we will replace the one in math.h with that one.
1739      */
1740
1741     "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1742                    "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1743
1744     "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1745     "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1746                         "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1747     "\telse cat\n"
1748     "\tfi";
1749
1750     test_text =
1751     "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1752     "#define HUGE_VAL DBL_MAX";
1753 };
1754
1755
1756 /*
1757  * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1758  */
1759 fix = {
1760     hackname = math_huge_val_ifndef;
1761     files    = math.h;
1762     files    = math/math.h;
1763     select   = "define[ \t]+HUGE_VAL";
1764
1765     c_fix     = format;
1766     c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1767     c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1768
1769     test_text = "# define\tHUGE_VAL 3.4e+40";
1770 };
1771
1772
1773 /*
1774  *  nested comment
1775  */
1776 fix = {
1777     hackname  = nested_auth_des;
1778     files     = rpc/rpc.h;
1779     select    = '(/\*.*rpc/auth_des\.h>.*)/\*';
1780     c_fix     = format;
1781     c_fix_arg = "%1*/ /*";
1782     test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1783 };
1784
1785
1786 /*
1787  * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1788  */
1789 fix = {
1790     hackname = nested_motorola;
1791     mach     = "m68k-motorola-sysv*";
1792     files    = sys/limits.h;
1793     files    = limits.h;
1794     select   = "max # bytes atomic in write|error value returned by Math lib";
1795
1796     sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1797                    "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1798     sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1799           "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1800
1801     test_text =
1802     "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1803     "\t\t/* PIPE */\n"
1804     "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1805 };
1806
1807
1808 /*
1809  * Fixing nested comments in ISC <sys/limits.h>
1810  */
1811 fix = {
1812     hackname = nested_sys_limits;
1813     files  = sys/limits.h;
1814     select = CHILD_MAX;
1815     sed    = "/CHILD_MAX/s,/\\* Max, Max,";
1816     sed    = "/OPEN_MAX/s,/\\* Max, Max,";
1817     test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1818                 "#define OPEN_MAX  20 /* Max, Max, ... */\n";
1819 };
1820
1821
1822 /*
1823  * NetBSD has a semicolon after the ending '}' for some extern "C".
1824  */
1825 fix = {
1826     hackname  = netbsd_extra_semicolon;
1827     mach      = *-*-netbsd*;
1828     files     = sys/cdefs.h;
1829     select    = "#define[ \t]*__END_DECLS[ \t]*};";
1830
1831     c_fix     = format;
1832     c_fix_arg = "#define __END_DECLS }";
1833
1834     test_text = "#define __END_DECLS };";
1835 };
1836
1837
1838 /*
1839  *  NeXT 3.2 adds const prefix to some math functions.
1840  *  These conflict with the built-in functions.
1841  */
1842 fix = {
1843     hackname  = next_math_prefix;
1844     files     = ansi/math.h;
1845     select    = "^extern[ \t]+double[ \t]+__const__[ \t]";
1846
1847     c_fix     = format;
1848     c_fix_arg = "extern double %1(";
1849     c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1850
1851     test_text = "extern\tdouble\t__const__\tmumble();";
1852 };
1853
1854
1855 /*
1856  *  NeXT 3.2 uses the word "template" as a parameter for some
1857  *  functions. GCC reports an invalid use of a reserved key word
1858  *  with the built-in functions.
1859  */
1860 fix = {
1861     hackname = next_template;
1862     files    = bsd/libc.h;
1863     select   = "[ \t]template\\)";
1864
1865     c_fix     = format;
1866     c_fix_arg = "(%1)";
1867     c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1868     test_text = "extern mumble( char * template); /* fix */";
1869 };
1870
1871
1872 /*
1873  *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
1874  *  function prototypes. That conflicts with the  built-in functions.
1875  */
1876 fix = {
1877     hackname = next_volitile;
1878     files    = ansi/stdlib.h;
1879     select   = "^extern[ \t]+volatile[ \t]+void[ \t]";
1880
1881     c_fix     = format;
1882     c_fix_arg = "extern void %1(";
1883     c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1884
1885     test_text = "extern\tvolatile\tvoid\tabort();";
1886 };
1887
1888
1889 /*
1890  *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1891  *  Note that version 3 of the NeXT system has wait.h in a different directory,
1892  *  so that this code won't do anything.  But wait.h in version 3 has a
1893  *  conditional, so it doesn't need this fix.  So everything is okay.
1894  */
1895 fix = {
1896     hackname  = next_wait_union;
1897     files     = sys/wait.h;
1898
1899     select    = 'wait\(union wait';
1900     c_fix     = format;
1901     c_fix_arg = "wait(void";
1902     test_text = "extern pid_d wait(union wait*);";
1903 };
1904
1905
1906 /*
1907  *  a missing semi-colon at the end of the nodeent structure definition.
1908  */
1909 fix = {
1910     hackname  = nodeent_syntax;
1911     files     = netdnet/dnetdb.h;
1912     select    = "char[ \t]*\\*na_addr[ \t]*$";
1913     c_fix     = format;
1914     c_fix_arg = "%0;";
1915     test_text = "char *na_addr\t";
1916 };
1917
1918
1919 /*
1920  *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1921  *  defining regex.h related types.  This causes libg++ build and usage
1922  *  failures.  Fixing this correctly requires checking and modifying 3 files.
1923  */
1924 fix = {
1925     hackname = osf_namespace_a;
1926     files    = reg_types.h;
1927     files    = sys/lc_core.h;
1928     test     = " -r reg_types.h";
1929     test     = " -r sys/lc_core.h";
1930     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1931     test     = " -z \"`grep __regex_t regex.h`\"";
1932
1933     c_fix     = format;
1934     c_fix_arg = "__%0";
1935     c_fix_arg = "reg(ex|off|match)_t";
1936
1937     test_text = "`touch sys/lc_core.h`"
1938     "typedef struct {\n  int stuff, mo_suff;\n} regex_t;\n"
1939     "extern regex_t    re;\n"
1940     "extern regoff_t   ro;\n"
1941     "extern regmatch_t rm;\n";
1942 };
1943
1944 fix = {
1945     hackname = osf_namespace_c;
1946     files    = regex.h;
1947     test     = " -r reg_types.h";
1948     test     = " -r sys/lc_core.h";
1949     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
1950     test     = " -z \"`grep __regex_t regex.h`\"";
1951
1952     select    = "#include <reg_types\.h>.*";
1953     c_fix     = format;
1954     c_fix_arg = "%0\n"
1955                 "typedef __regex_t\tregex_t;\n"
1956                 "typedef __regoff_t\tregoff_t;\n"
1957                 "typedef __regmatch_t\tregmatch_t;";
1958
1959     test_text = "#include <reg_types.h>";
1960 };
1961
1962
1963 /*
1964  *  Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1965  *  The original ones fail if uninitialized externs are not common.
1966  *  This is the default for all ANSI standard C++ compilers.
1967  */
1968 fix = {
1969     hackname  = pthread_page_size;
1970     files     = pthread.h;
1971     select    = "^int __page_size";
1972     c_fix     = format;
1973     c_fix_arg = "extern %0";
1974     test_text = "int __page_size;";
1975 };
1976
1977
1978 /*
1979  *  Fix return type of fread and fwrite on sysV68
1980  */
1981 fix = {
1982     hackname = read_ret_type;
1983     files    = stdio.h;
1984     select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1985     c_fix     = format;
1986     c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1987     c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1988
1989     test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1990 };
1991
1992
1993 /*
1994  *  function class(double x) conflicts with C++ keyword on rs/6000
1995  */
1996 fix = {
1997     hackname  = rs6000_double;
1998     files     = math.h;
1999     select    = '[^a-zA-Z_]class\(';
2000
2001     c_fix     = format;
2002     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2003     c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2004
2005     test_text = "extern int class();";
2006 };
2007
2008
2009 /*
2010  *  Wrong fchmod prototype on RS/6000.
2011  */
2012 fix = {
2013     hackname  = rs6000_fchmod;
2014     files     = sys/stat.h;
2015     select    = 'fchmod\(char \*';
2016     c_fix     = format;
2017     c_fix_arg = "fchmod(int";
2018     test_text = "extern int fchmod(char *, mode_t);";
2019 };
2020
2021
2022 /*
2023  *  parameters conflict with C++ new on rs/6000
2024  */
2025 fix = {
2026     hackname  = rs6000_param;
2027     files     = "stdio.h";
2028     files     = "unistd.h";
2029
2030     select    = 'rename\(const char \*old, const char \*new\)';
2031     c_fix     = format;
2032     c_fix_arg = 'rename(const char *_old, const char *_new)';
2033
2034     test_text = 'extern int rename(const char *old, const char *new);';
2035 };
2036
2037
2038 /*
2039  *  On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2040  *  __builtin_generic. We fix that usage to use the GCC equivalent.
2041  * It also has a plethora of inline functions that conflict with libstdc++.
2042  */
2043 fix = {
2044     hackname = sco_math;
2045     files    = math.h;
2046     files    = ansi/math.h;
2047     files    = posix/math.h;
2048     files    = xpg4/math.h;
2049     files    = xpg4v2/math.h;
2050     files    = xpg4plus/math.h;
2051     files    = ods_30_compat/math.h;
2052     files    = oldstyle/math.h;
2053     select   = "inline double abs";
2054     sed      = "/#define.*__fp_class(a) \\\\/i\\\n"
2055                "#ifndef __GNUC__\n";
2056     sed      =
2057 "/.*__builtin_generic/a\\\n"
2058 "#else\\\n"
2059 "#define __fp_class(a) \\\\\\\n"
2060 "  __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
2061 "   __fpclassifyl(a), \\\\\\\n"
2062 "    __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
2063 "      __fpclassifyf(a),__fpclassify(a)))\\\n"
2064 "#endif";
2065
2066     sed      = "/extern \"C\\+\\+\"/N;"
2067                "/inline double abs/i\\\n"
2068                "#ifndef __GNUC__\n";
2069     sed      = "/inline long double trunc/N;"
2070                "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
2071                "#endif /* ! __GNUC__ */";
2072
2073     test_text =
2074     "#define __fp_class(a) \\\\\n"
2075     " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
2076
2077 };
2078
2079
2080 /*
2081  *  On SCO OpenServer prior to 5.0.7UP1, <sys/regset.h> and <ieeefp.h>
2082  *  have a clash on struct _fpstate and struct fpstate.
2083  */
2084 fix = {
2085     hackname = sco_regset;
2086     files    = sys/regset.h;
2087     mach     = "*-*-sco3.2v5*";
2088     select   = "(struct[ \t]+.*)fpstate";
2089     c_fix     = format;
2090     c_fix_arg = "%1rsfpstate";
2091
2092     test_text =
2093     "union u_fps {\n"
2094     "    struct\tfpstate\n"
2095     "    {\n"
2096     "       int whatever;\n"
2097     "    }\n"
2098     "};\n"
2099     "union _u_fps {\n"
2100     "    struct _fpstate\n"
2101     "    {\n"
2102     "       int whatever;\n"
2103     "    }\n"
2104     "};\n";
2105 };
2106
2107
2108 /*
2109  *  The static functions lstat() and fchmod() in <sys/stat.h>
2110  *  cause G++ grief since they're not wrapped in "if __cplusplus".
2111  *
2112  *  On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
2113  *  tiny static wrappers that aren't C++ safe.
2114  */
2115 fix = {
2116     hackname = sco_static_func;
2117     files    = sys/stat.h;
2118     mach     = "i?86-*-sco3.2*";
2119     select   = "^static int";
2120
2121     sed      = "/^static int/i\\\n"
2122                "#if __cplusplus\\\n"
2123                "extern \"C\" {\\\n"
2124                "#endif /* __cplusplus */";
2125
2126     sed      = "/^}$/a\\\n"
2127                "#if __cplusplus\\\n"
2128                " }\\\n"
2129                "#endif /* __cplusplus */";
2130
2131     test_text =
2132     "#ifdef __STDC__\n"
2133     "static int\tstat(const char *__f, struct stat *__p) {\n"
2134     "\treturn __stat32(__f, __p);\n"
2135     "}\n\n#  else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n"
2136
2137     "static int\tstat(__f, __p)\n"
2138     "\tchar *__f;\n"
2139     "\tstruct stat *__p;\n"
2140     "{\n"
2141     "\treturn __stat32(__f, __p);\n"
2142     "}\n"
2143     "#endif";
2144 };
2145
2146
2147 /*
2148  *  Fix prototype declaration of utime in sys/times.h.
2149  *  In 3.2v4.0 the const is missing.
2150  */
2151 fix = {
2152     hackname  = sco_utime;
2153     files     = sys/times.h;
2154     mach      = "i?86-*-sco3.2v4*";
2155
2156     select    = '\(const char \*, struct utimbuf \*\);';
2157     c_fix     = format;
2158     c_fix_arg = '(const char *, const struct utimbuf *);';
2159
2160     test_text = "extern int utime(const char *, struct utimbuf *);";
2161 };
2162
2163
2164 /*
2165  *  Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
2166  *  incorrectly, so we replace them with versions that correspond to
2167  *  the definition.  We also explicitly name this fix "1" and the next
2168  *  fix "2" because this one does not deal with the last field.  This
2169  *  fix needs to run before the next.
2170  */
2171 fix = {
2172     hackname = solaris_mutex_init_1;
2173     select = '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI";
2174     files = pthread.h;
2175     sed   = "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n"
2176             "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/";
2177     test_text =
2178     '#ident "@(#)pthread.h  1.16    97/05/05 SMI"'"\n"
2179     "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n"
2180     "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n";
2181 };
2182
2183
2184 /*
2185  * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2186  * "0" for the last field of the pthread_mutex_t structure, which is
2187  * of type upad64_t, which itself is typedef'd to int64_t, but with
2188  * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2189  * initializer to "{0}" instead
2190  */
2191 fix = {
2192     hackname = solaris_mutex_init_2;
2193     select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2194     files = pthread.h;
2195     c_fix = format;
2196     c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2197                 "%0\n"
2198                 "#else\n"
2199                 "%1, {0}}%3\n"
2200                 "#endif";
2201     c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+\\{.*)"
2202                 ",[ \t]*0\\}" "(|[ \t].*)$";
2203     test_text =
2204     '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
2205     "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
2206     "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
2207     "#define PTHREAD_RWLOCK_INITIALIZER\t"
2208              "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
2209 };
2210
2211
2212 /*
2213  * Solaris 2.5.1 and 2.6 use an outdated prototype for send & recv
2214  * in sys/socket.h.  This is corrected in Solaris 7 and up.
2215  */
2216 fix = {
2217     hackname = solaris_socket;
2218     files = sys/socket.h;
2219     select = '@\(#\)socket.h' "[ \t]+1.[123][0-9][ \t]+9[567]/[0-9/]+ SMI";
2220     c_fix = format;
2221     c_fix_arg = "extern int %1(int, %2void *, int, int);";
2222     c_fix_arg = '^extern int (recv|send)\(int,'
2223                 ' (const )*char '
2224                 '\*, int, int\);';
2225
2226     test_text = '#ident   "@(#)socket.h   1.30    97/01/20 SMI"'"\n"
2227                 "extern int recv(int, char *, int, int);\n"
2228                 "extern int send(int, const char *, int, int);";
2229 };
2230
2231
2232 /*
2233  * Solaris 2.8 has what appears to be some gross workaround for 
2234  * some old version of their c++ compiler.  G++ doesn't want it
2235  * either, but doesn't want to be tied to SunPRO version numbers.
2236  */
2237 fix = {
2238     hackname = solaris_stdio_tag;
2239     files    = stdio_tag.h;
2240
2241     select   = '__cplusplus < 54321L';
2242     sed      = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
2243
2244     test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
2245 };
2246
2247
2248 /*
2249  * Sun Solaris 2.5.1 doesn't define 'getpagesize' in <unistd.h>, as is done
2250  * on Solaris 2.6 and up.
2251  */
2252 fix = {
2253     hackname  = solaris_unistd;
2254     files = unistd.h;
2255     select = '@\(#\)unistd.h' "[ \t]+1.3[0-9][ \t]+9[567]/[0-9/]+ SMI";
2256     bypass = "getpagesize";
2257     c_fix = format;
2258     c_fix_arg = "extern int getpagesize();\n%0";
2259     c_fix_arg = '^extern (pid_t|int) getpgid\(.*\);';
2260     test_text = '#ident "@(#)unistd.h   1.33    95/08/28 SMI"'"\n"
2261                 "extern pid_t getpgid(pid_t);\n"
2262                 "extern int getpgid();";
2263 };
2264
2265
2266 /*
2267  * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h>
2268  * functions, breaking their prototypes if that file is included afterwards.
2269  * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6
2270  * and up.
2271  */
2272 fix = {
2273     hackname  = solaris_widec;
2274     files     = widec.h;
2275     mach      = '*-*-solaris2.[0-5]*';
2276     bypass    = "include.*wchar\\.h";
2277     select    = "#include <euc.h>";
2278     c_fix     = format;
2279     c_fix_arg = "%0\n#include <wchar.h>";
2280     test_text = "#include <euc.h>";
2281 };
2282
2283
2284 /*
2285  *  Add a `static' declaration of `getrnge' into <regexp.h>.
2286  *
2287  *  Don't do this if there is already a `static void getrnge' declaration
2288  *  present, since this would cause a redeclaration error.  Solaris 2.x has
2289  *  such a declaration.
2290  */
2291 #ifdef SVR4
2292 fix = {
2293     hackname = static_getrnge;
2294     files    = regexp.h;
2295     bypass   = "static void getrnge";
2296     sed      = "/^static int[ \t]*size;/c\\\n"
2297                "static int      size ;\\\n\\\n"
2298                "static int getrnge ();";
2299 };
2300 #endif
2301
2302
2303 /*
2304  *  a missing semi-colon at the end of the statsswtch structure definition.
2305  */
2306 fix = {
2307     hackname  = statsswtch;
2308     files     = rpcsvc/rstat.h;
2309     select    = "boottime$";
2310     c_fix     = format;
2311     c_fix_arg = "boottime;";
2312     test_text = "struct statswtch {\n  int boottime\n};";
2313 };
2314
2315
2316 /*
2317  *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2318  *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2319  *  OK too.
2320  */
2321 fix = {
2322     hackname = stdio_stdarg_h;
2323     files    = stdio.h;
2324     bypass   = "include.*(stdarg\.h|machine/ansi\.h)";
2325
2326     c_fix     = wrap;
2327
2328     c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2329
2330     test_text = "";
2331 };
2332
2333
2334 /*
2335  *  Don't use or define the name va_list in stdio.h.
2336  *  This is for ANSI and also to interoperate properly with gcc's
2337  *  varargs.h.  Note _BSD_VA_LIST_ is dealt with elsewhere.  The
2338  *  presence of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken
2339  *  to indicate that the header knows what it's doing -- under SUSv2,
2340  *  stdio.h is required to define va_list, and we shouldn't break that.
2341  *  On IRIX 6.5, internal/wchar_core.h used to get its definition of
2342  *  va_list from stdio.h.  Since this doesn't happen any longer, use
2343  *  __gnuc_va_list there, too.
2344  */
2345 fix = {
2346     hackname = stdio_va_list;
2347     files    = stdio.h;
2348     files    = internal/stdio_core.h;
2349     files    = internal/wchar_core.h;
2350     bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
2351
2352     /*
2353      * Use __gnuc_va_list in arg types in place of va_list.
2354      * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
2355      * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
2356      * trailing parentheses and semicolon save all other systems from this.
2357      * Define __not_va_list__ (something harmless and unused)
2358      * instead of va_list.
2359      * Don't claim to have defined va_list.
2360      */
2361     sed = "s@ va_list @ __gnuc_va_list @\n"
2362           "s@ va_list)@ __gnuc_va_list)@\n"
2363           "s@va_list _ap;@__gnuc_va_list _ap;@\n"
2364           "s@(va_list)&@(__gnuc_va_list)\\&@\n"
2365           "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2366           "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
2367           "s@ va_list@ __not_va_list__@\n"
2368           "s@\\*va_list@*__not_va_list__@\n"
2369           "s@ __va_list)@ __gnuc_va_list)@\n"
2370           "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2371            "@typedef \\1 __not_va_list__;@\n"
2372           "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
2373           "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2374           "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2375           "s@VA_LIST@DUMMY_VA_LIST@\n"
2376           "s@_Va_LIST@_VA_LIST@";
2377     test_text = "extern void mumble( va_list);";
2378 };
2379
2380
2381 /*
2382  *  "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
2383  *  is "!defined( __STRICT_ANSI__ )"
2384  */
2385 fix = {
2386     hackname = strict_ansi_not;
2387     select   = "^([ \t]*#[ \t]*if.*)"
2388                "(!__STDC__"
2389                "|__STDC__[ \t]*==[ \t]*0"
2390                "|__STDC__[ \t]*!=[ \t]*1"
2391                "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
2392     /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
2393     bypass = 'GNU and MIPS C compilers define __STDC__ differently';
2394     /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
2395        is not defined by GCC, so it is safe.  */
2396     bypass = '__SCO_VERSION__.*__STDC__ != 1';
2397     c_test   = stdc_0_in_system_headers;
2398
2399     c_fix     = format;
2400     c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2401
2402     test_text = "#if !__STDC__ \n"
2403                 "#if __STDC__ == 0\n"
2404                 "#if __STDC__ != 1\n"
2405                 "#if __STDC__ - 0 == 0"
2406                "/* not std C */\nint foo;\n"
2407                "\n#end-end-end-end-if :-)";
2408 };
2409
2410 /*
2411  *  "__STDC__-0==0"
2412  *  is "!defined( __STRICT_ANSI__ )" on continued #if-s
2413  */
2414 fix = {
2415     hackname = strict_ansi_not_ctd;
2416     files    = math.h, limits.h, stdio.h, signal.h,
2417                stdlib.h, sys/signal.h, time.h;
2418     /*
2419      * Starting at the beginning of a line, skip white space and
2420      * a leading "(" or "&&" or "||".  One of those must be found.
2421      * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
2422      * expression.  If these are nested, then they must accumulate
2423      * because we won't match any closing parentheses.  Finally,
2424      * after skipping over all that, we must then match our suspect
2425      * phrase:  "__STDC__-0==0" with or without white space.
2426      */
2427     select   = "^([ \t]*" '(\(|&&|\|\|)'
2428                "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
2429                "[ \t(]*)"
2430                "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
2431     c_test   = stdc_0_in_system_headers;
2432
2433     c_fix     = format;
2434     c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2435
2436     test_text = "#if 1 && \\\\\n"
2437                "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
2438                "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
2439                "|| __STDC__ - 0 == 0 ) /* not std C */\n"
2440                "int foo;\n#endif";
2441 };
2442
2443
2444 /*
2445  *  "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2446  *  is "defined( __STRICT_ANSI__ )"
2447  */
2448 fix = {
2449     hackname = strict_ansi_only;
2450     select   = "^([ \t]*#[ \t]*if.*)"
2451                "(__STDC__[ \t]*!=[ \t]*0"
2452                "|__STDC__[ \t]*==[ \t]*1"
2453                "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2454                "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
2455     c_test   = stdc_0_in_system_headers;
2456
2457     c_fix     = format;
2458     c_fix_arg = "%1 defined(__STRICT_ANSI__)";
2459
2460     test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2461 };
2462
2463
2464 /*
2465  *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2466  *  in prototype without previous definition.
2467  */
2468 fix = {
2469     hackname  = struct_file;
2470     files     = rpc/xdr.h;
2471     select    = '^.*xdrstdio_create.*struct __file_s';
2472     c_fix     = format;
2473     c_fix_arg = "struct __file_s;\n%0";
2474     test_text = "extern void xdrstdio_create( struct __file_s* );";
2475 };
2476
2477
2478 /*
2479  *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2480  *  in prototype without previous definition.
2481  *
2482  *  Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
2483  *  function, and does define it.
2484  */
2485 fix = {
2486     hackname  = struct_sockaddr;
2487     files     = rpc/auth.h;
2488     select    = "^.*authdes_create.*struct sockaddr[^_]";
2489     bypass    = "<sys/socket\.h>";
2490     bypass    = "struct sockaddr;\n";
2491     c_fix     = format;
2492     c_fix_arg = "struct sockaddr;\n%0";
2493     test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2494 };
2495
2496
2497 /*
2498  *  Apply fix this to all OSs since this problem seems to effect
2499  *  more than just SunOS.
2500  */
2501 fix = {
2502     hackname = sun_auth_proto;
2503     files    = rpc/auth.h;
2504     files    = rpc/clnt.h;
2505     files    = rpc/svc.h;
2506     files    = rpc/xdr.h;
2507     /*
2508      *  Select those files containing '(*name)()'.
2509      */
2510     select    = '\(\*[a-z][a-z_]*\)\(\)';
2511
2512     c_fix     = format;
2513     c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2514                 "#else\n%1();%2\n#endif";
2515     c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2516
2517     test_text =
2518     "struct auth_t {\n"
2519     "    int (*name)(); /* C++ bad */\n"
2520     "};";
2521 };
2522
2523
2524 /*
2525  *  Fix bogus #ifdef on SunOS 4.1.
2526  */
2527 fix = {
2528     hackname  = sun_bogus_ifdef;
2529     files     = "hsfs/hsfs_spec.h";
2530     files     = "hsfs/iso_spec.h";
2531     select    = '#ifdef(.*\|\|.*)';
2532     c_fix     = format;
2533     c_fix_arg = "#if%1";
2534
2535     test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
2536 };
2537
2538
2539 /*
2540  *  Fix the CAT macro in SunOS memvar.h.
2541  */
2542 fix = {
2543     hackname  = sun_catmacro;
2544     files     = pixrect/memvar.h;
2545     select    = "^#define[ \t]+CAT\\(a,b\\).*";
2546     c_fix     = format;
2547
2548     c_fix_arg =
2549     "#ifdef __STDC__\n"
2550     "#  define CAT(a,b) a##b\n"
2551     "#else\n%0\n#endif";
2552
2553     test_text =
2554     "#define CAT(a,b)\ta/**/b";
2555 };
2556
2557
2558 /*
2559  *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2560  *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2561  */
2562 fix = {
2563     hackname = sun_malloc;
2564     files    = malloc.h;
2565
2566     sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2567     sed   = "s/int[ \t][ \t]*free/void\tfree/g";
2568     sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2569     sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2570     sed   = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2571
2572     test_text =
2573     "typedef char *\tmalloc_t;\n"
2574     "int \tfree();\n"
2575     "char*\tmalloc();\n"
2576     "char*\tcalloc();\n"
2577     "char*\trealloc();";
2578 };
2579
2580
2581 /*
2582  *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
2583  */
2584 fix = {
2585     hackname = sun_rusers_semi;
2586     files    = rpcsvc/rusers.h;
2587     select   = "_cnt$";
2588     sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
2589     test_text = "struct mumble\n  int _cnt\n};";
2590 };
2591
2592
2593 /*
2594  *  signal.h on SunOS defines signal using (),
2595  *  which causes trouble when compiling with g++ -pedantic.
2596  */
2597 fix = {
2598     hackname = sun_signal;
2599     files    = sys/signal.h;
2600     files    = signal.h;
2601     select   = "^void\t" '\(\*signal\(\)\)\(\);.*';
2602
2603     c_fix     = format;
2604     c_fix_arg =
2605           "#ifdef __cplusplus\n"
2606           "void\t(*signal(...))(...);\n"
2607           "#else\n%0\n#endif";
2608
2609     test_text = "void\t(*signal())();";
2610 };
2611
2612
2613 /*
2614  *  math.h on SunOS 4 puts the declaration of matherr before the definition
2615  *  of struct exception, so the prototype (added by fixproto) causes havoc.
2616  */
2617 fix = {
2618     hackname  = sunos_matherr_decl;
2619     files     = math.h;
2620
2621     /*  If matherr has a prototype already, the header needs no fix.  */
2622     bypass    = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2623     select    = matherr;
2624
2625     c_fix     = wrap;
2626     c_fix_arg = "struct exception;\n";
2627
2628     test_text = "extern int matherr();";
2629 };
2630
2631
2632 /*
2633  *  Correct the return type for strlen in strings.h in SunOS 4.
2634  */
2635 fix = {
2636     hackname = sunos_strlen;
2637     files    = strings.h;
2638     select   = "int[ \t]*strlen\\(\\);(.*)";
2639     c_fix     = format;
2640     c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2641     test_text = " int\tstrlen(); /* string length */";
2642 };
2643
2644
2645 /*
2646  *  Solaris math.h and floatingpoint.h define __P without protection,
2647  *  which conflicts with the fixproto definition.  The fixproto
2648  *  definition and the Solaris definition are used the same way.
2649  */
2650 fix = {
2651     hackname = svr4__p;
2652     files    = math.h;
2653     files    = floatingpoint.h;
2654     select   = "^#define[ \t]+__P.*";
2655     c_fix     = format;
2656     c_fix_arg = "#ifndef __P\n%0\n#endif";
2657
2658     test_text = "#define __P(a) a";
2659 };
2660
2661
2662 /*
2663  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2664  *  that is visible to any ANSI compiler using this include.  Simply
2665  *  delete the lines that #define some string functions to internal forms.
2666  */
2667 fix = {
2668     hackname = svr4_disable_opt;
2669     files    = string.h;
2670     select   = '#define.*__std_hdr_';
2671     sed      = '/#define.*__std_hdr_/d';
2672     test_text = "#define strlen __std_hdr_strlen\n";
2673 };
2674
2675
2676 /*
2677  *  Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2678  *  On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2679  *  but we still "hijack" it and redirect it to the GNU byteorder.h..
2680  */
2681 #ifdef SVR5
2682 fix = {
2683     hackname = svr4_endian;
2684     files    = sys/endian.h;
2685 #ifdef LATER
2686     /*
2687      * since we emit our own sys/byteorder.h,
2688      * this fix can never be applied to that file.
2689      */
2690     files    = sys/byteorder.h;
2691 #endif
2692     bypass   = '__GNUC__';
2693
2694     sed      = "/#\tifdef\t__STDC__/i\\\n"
2695                "#   if !defined (__GNUC__) && !defined (__GNUG__)\n";
2696
2697     sed      = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/   /";
2698
2699     sed      = "/#   include\t<sys\\/byteorder.h>/i\\\n"
2700                "#   endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2701 };
2702 #endif /* SVR5 */
2703
2704
2705 /*
2706  *  Remove useless extern keyword from struct forward declarations
2707  *  in <sys/stream.h> and <sys/strsubr.h>
2708  */
2709 #ifdef SVR4
2710 fix = {
2711     hackname = svr4_extern_struct;
2712     files    = sys/stream.h;
2713     files    = sys/strsubr.h;
2714     select   = 'extern struct [a-z_]*;';
2715     sed      = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2716 };
2717 #endif
2718
2719 /*
2720  *  Fix declarations of `ftw' and `nftw' in <ftw.h>.  On some/most SVR4
2721  *  systems the file <ftw.h> contains extern declarations of these
2722  *  functions followed by explicitly `static' definitions of these
2723  *  functions... and that's not allowed according to ANSI C.  (Note
2724  *  however that on Solaris, this header file glitch has been pre-fixed by
2725  *  Sun.  In the Solaris version of <ftw.h> there are no static
2726  *  definitions of any function so we don't need to do any of this stuff
2727  *  when on Solaris.
2728  */
2729 #ifdef SVR4
2730 #ifndef SOLARIS
2731 fix = {
2732     hackname = svr4_ftw;
2733     files    = ftw.h;
2734     select   = '^extern int ftw\(const';
2735
2736     sed = '/^extern int ftw(const/i' "\\\n"
2737             "#if !defined(_STYPES)\\\n"
2738             "static\\\n"
2739             "#else\\\n"
2740             "extern\\\n"
2741             "#endif";
2742     sed = 's/extern \(int ftw(const.*\)$/\1/';
2743     sed = "/^extern int nftw/i\\\n"
2744             "#if defined(_STYPES)\\\n"
2745             "static\\\n"
2746             "#else\\\n"
2747             "extern\\\n"
2748             "#endif";
2749     sed = 's/extern \(int nftw.*\)$/\1/';
2750     sed = "/^extern int ftw(),/c\\\n"
2751             "#if !defined(_STYPES)\\\n"
2752             "static\\\n"
2753             "#else\\\n"
2754             "extern\\\n"
2755             "#endif\\\n"
2756             "  int ftw();\\\n"
2757             "#if defined(_STYPES)\\\n"
2758             "static\\\n"
2759             "#else\\\n"
2760             "extern\\\n"
2761             "#endif\\\n"
2762             "  int nftw();";
2763 };
2764 #endif
2765 #endif
2766
2767
2768 /*
2769  *   Fix broken decl of getcwd present on some svr4 systems.
2770  */
2771 fix = {
2772     hackname = svr4_getcwd;
2773     files    = stdlib.h;
2774     files    = unistd.h;
2775     files    = prototypes.h;
2776     select   = 'getcwd\(char \*, int\)';
2777
2778     c_fix     = format;
2779     c_fix_arg = "getcwd(char *, size_t)";
2780
2781     test_text = "extern char* getcwd(char *, int);";
2782 };
2783
2784
2785 /*
2786  *  set ifdef _KERNEL
2787  */
2788 #ifdef SVR4
2789 fix = {
2790     hackname = svr4_kernel;
2791     files    = fs/rfs/rf_cache.h;
2792     files    = sys/erec.h;
2793     files    = sys/err.h;
2794     files    = sys/char.h;
2795     files    = sys/getpages.h;
2796     files    = sys/map.h;
2797     files    = sys/cmn_err.h;
2798     files    = sys/kdebugger.h;
2799     bypass   = '_KERNEL';
2800     c_fix     = wrap;
2801
2802     c_fix_arg = "#ifdef _KERNEL\n";
2803     c_fix_arg = "#endif /* _KERNEL */\n";
2804     test_text = "";
2805 };
2806 #endif
2807
2808 /*
2809  *  Delete any #defines of `__i386' which may be present in <ieeefp.h>.  They
2810  *  tend to conflict with the compiler's own definition of this symbol.  (We
2811  *  will use the compiler's definition.)
2812  *  Likewise __sparc, for Solaris, and __i860, and a few others
2813  *  (guessing it is necessary for all of them).
2814  */
2815 #ifdef SVR4
2816 fix = {
2817     hackname = svr4_mach_defines;
2818     files    = ieeefp.h;
2819     select   = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
2820     sed      = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
2821 };
2822 #endif
2823
2824
2825 /*
2826  *  Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2827  *  They are declared as non-static then immediately redeclared as static.
2828  */
2829 #ifdef SVR5
2830 fix = {
2831     hackname = svr4_mkdev;
2832     files    = sys/mkdev.h;
2833     select   = '^static';
2834
2835     sed      = "/^dev_t makedev(/s/^/static /";
2836     sed      = "/^major_t major(/s/^/static /";
2837     sed      = "/^minor_t minor(/s/^/static /";
2838 };
2839 #endif /* SVR5 */
2840
2841
2842 /*
2843  *  Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2844  *  Also fix types of array initializers.
2845  */
2846 #ifdef SVR4
2847 fix = {
2848     hackname = svr4_netcspace;
2849     files    = sys/netcspace.h;
2850     select   = 'NC_NPI_RAW';
2851     sed      = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2852     sed      = 's/NC_/(unsigned long) NC_/';
2853 };
2854 #endif
2855
2856 /*
2857  *  Fix reference to NMSZ in <sys/adv.h>.
2858  */
2859 #ifdef SVR4
2860 fix = {
2861     hackname = svr4_nmsz;
2862     files    = sys/adv.h;
2863     select   = '\[NMSZ\]';
2864     sed      = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2865 };
2866 #endif
2867
2868
2869 /*
2870  *   Fix broken decl of profil present on some svr4 systems.
2871  */
2872 fix = {
2873     hackname = svr4_profil;
2874     files    = stdlib.h;
2875     files    = unistd.h;
2876
2877     select    =
2878     'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2879     c_fix     = format;
2880     c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2881
2882     test_text =
2883     'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2884 };
2885
2886
2887 /*
2888  *  Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2889  */
2890 #ifdef SVR4
2891 fix = {
2892     hackname = svr4_proto_form;
2893     files    = sys/stat.h;
2894     select   = 'const extern';
2895
2896     sed      = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2897                    "s/(.*)\\n/( /\n"
2898                    "s/;\\n/, /\n"
2899                    "s/;$/)/\n"  "}";
2900
2901     sed      = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2902                    "s/(.*)\\n/( /\n"
2903                    "s/;\\n/, /\n"
2904                    "s/;$/)/\n"  "}";
2905
2906     sed      = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2907                    "s/(.*)\\n/( /\n"
2908                    "s/;\\n/, /\n"
2909                    "s/;$/)/\n"  "}";
2910
2911     sed      = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2912                    "s/(.*)\\n/( /\n"
2913                    "s/;\\n/, /g\n"
2914                    "s/;$/)/\n"  "}";
2915
2916     sed      = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2917     sed      = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2918     sed      = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2919     sed      = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2920     sed      = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2921     sed      = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2922 };
2923 #endif
2924
2925 /*
2926  *  Add a prototyped declaration of mmap to <sys/mman.h>.
2927  */
2928 #ifdef SVR4
2929 fix = {
2930     hackname = svr4_proto_mmap;
2931     files    = sys/mman.h;
2932     select   = '^extern caddr_t mmap();$';
2933     sed = '/^extern caddr_t mmap();$/c' "\\\n"
2934           "#ifdef __STDC__\\\n"
2935           "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2936           "#else /* !defined(__STDC__) */\\\n"
2937           "extern caddr_t mmap ();\\\n"
2938           "#endif /* !defined(__STDC__) */\\\n";
2939 };
2940 #endif
2941
2942 /*
2943  *  Add a #define of _SIGACTION_ into <sys/signal.h>.
2944  */
2945 #ifdef SVR4
2946 fix = {
2947     hackname = svr4_sigaction;
2948     files    = sys/signal.h;
2949     sed      = "/^struct sigaction {/i\\\n"
2950                "#define _SIGACTION_";
2951     sed      = 's/(void *(\*)())/(void (*)(int))/';
2952 };
2953 #endif
2954
2955 /*
2956  *  Put storage class at start of decl, to avoid warning.
2957  */
2958 #ifdef SVR4
2959 fix = {
2960     hackname = svr4_storage_class;
2961     files    = rpc/types.h;
2962     select   = 'const extern';
2963     sed      = 's/const extern/extern const/g';
2964 };
2965 #endif
2966
2967
2968 /*
2969  *  Like svr4_mach_defines, but with newfangled syntax.
2970  *  Source lines are of #define __i386 #machine(i386).   Delete them.
2971  */
2972 #ifdef SVR5
2973 fix = {
2974     hackname = svr5_mach_defines;
2975     files    = ieeefp.h;
2976     select   = "#define[ \t]*__i386.*\(i386\)";
2977     sed      = "/#define[ \t]*__i386.*/d";
2978 };
2979 #endif /*  SVR5 */
2980
2981
2982 /*
2983  *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2984  *  in string.h on sysV68
2985  *  Correct the return type for strlen in string.h on Lynx.
2986  *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2987  *  Add missing const for strdup on OSF/1 V3.0.
2988  *  On sysV88 layout is slightly different.
2989  */
2990 fix = {
2991     hackname = sysv68_string;
2992     files    = testing.h;
2993     files    = string.h;
2994
2995     sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2996     sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2997     sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2998
2999     sed = "/^extern char$/N";
3000     sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3001
3002     sed = "/^extern int$/N";
3003     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3004
3005     sed = "/^\tstrncmp(),$/N";
3006     sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3007             '\1;' "\\\nextern unsigned int\\\n\\2/";
3008
3009     test_text =
3010     "extern int strlen();\n"
3011
3012     "extern int ffs(long);\n"
3013
3014     "extern char\n"
3015     "\t*memccpy(),\n"
3016     "\tmemcpy();\n"
3017
3018     "extern int\n"
3019     "\tstrcmp(),\n"
3020     "\tstrncmp(),\n"
3021     "\tstrlen(),\n"
3022     "\tstrspn();\n"
3023
3024     "extern int\n"
3025     "\tstrlen(), strspn();";
3026 };
3027
3028
3029 /*
3030  *  Fix return type of calloc, malloc, realloc, bsearch and exit
3031  */
3032 fix = {
3033     hackname = sysz_stdlib_for_sun;
3034     files    = stdlib.h;
3035
3036     select    = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3037     c_fix     = format;
3038     c_fix_arg = "void *\t%1(";
3039
3040     test_text =
3041     "extern char*\tcalloc(size_t);\n"
3042     "extern char*\tmalloc(size_t);\n"
3043     "extern char*\trealloc(void*,size_t);\n"
3044     "extern char*\tbsearch(void*,size_t,size_t);\n";
3045 };
3046
3047
3048 /*
3049  * __thread is now a keyword.
3050  */
3051 fix = {
3052     hackname  = thread_keyword;
3053     files     = "pthread.h";
3054     files     = "bits/sigthread.h";
3055     select    = "([* ])__thread([,)])";
3056     c_fix     = format;
3057     c_fix_arg = "%1__thr%2";
3058
3059     test_text =
3060         "extern int pthread_create (pthread_t *__restrict __thread,\n"
3061         "extern int pthread_kill (pthread_t __thread, int __signo);\n"
3062         "extern int pthread_cancel (pthread_t __thread);";
3063 };
3064
3065 /*
3066  *  if the #if says _cplusplus, not the double underscore __cplusplus
3067  *  that it should be
3068  */
3069 fix = {
3070     hackname = tinfo_cplusplus;
3071     files    = tinfo.h;
3072     select   = "[ \t]_cplusplus";
3073
3074     c_fix     = format;
3075     c_fix_arg = " __cplusplus";
3076     test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
3077 };
3078
3079
3080 /*
3081  *  function parameter to atexit is missing "void" on VAX Ultrix 4.3.
3082  */
3083 fix = {
3084     hackname = ultrix_atexit_param;
3085     files    = stdlib.h;
3086     select   = 'atexit\(.*\(\)';
3087
3088     c_fix     = format;
3089     c_fix_arg = "atexit( void (*__func)( void )";
3090
3091     test_text = "int atexit( void (*__func)() );\n";
3092 };
3093
3094
3095 /*
3096  *  parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
3097  */
3098 fix = {
3099     hackname = ultrix_atof_param;
3100     files    = math.h;
3101     select   = "atof\\([ \t]*char";
3102
3103     c_fix     = format;
3104     c_fix_arg = "atof(const char";
3105
3106     test_text = "extern double atof( char *__nptr);\n";
3107 };
3108
3109
3110 /*
3111  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
3112  */
3113 fix = {
3114     hackname  = ultrix_const;
3115     files     = stdio.h;
3116     select    = 'perror\( char \*';
3117
3118     c_fix     = format;
3119     c_fix_arg = "%1 const %3 *__";
3120     c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3121                 "[ \t]+(char|void) \\*__";
3122
3123     test_text =
3124     "extern void perror( char *__s );\n"
3125     "extern int fputs( char *__s, FILE *);\n"
3126     "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3127     "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3128     "extern int scanf( char *__format, ...);\n";
3129 };
3130
3131
3132 /*
3133  *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
3134  */
3135 fix = {
3136     hackname  = ultrix_const2;
3137     files     = stdio.h;
3138
3139     select    = '\*fopen\( char \*';
3140     c_fix     = format;
3141     c_fix_arg = "%1( const char *%3, const char *";
3142     c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3143                "[ \t]*char[ \t]*\\*([^,]*),"
3144                "[ \t]*char[ \t]*\\*[ \t]*";
3145
3146     test_text =
3147     "extern FILE *fopen( char *__filename, char *__type );\n"
3148     "extern int sscanf( char *__s, char *__format, ...);\n"
3149     "extern FILE *popen(char *, char *);\n"
3150     "extern char *tempnam(char*,char*);\n";
3151 };
3152
3153
3154 /*
3155  * Ultrix V4.[35] puts the declaration of uname before the definition
3156  * of struct utsname, so the prototype (added by fixproto) causes havoc.
3157  */
3158 fix = {
3159     hackname = ultrix_fix_fixproto;
3160     files    = sys/utsname.h;
3161     select   = ULTRIX;
3162
3163     c_fix     = format;
3164     c_fix_arg = "struct utsname;\n%0";
3165     c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
3166
3167     test_text =
3168     "/* ULTRIX's uname */\nextern\tint\tuname();";
3169 };
3170
3171
3172 /*
3173  *  Check for bad #ifdef line (in Ultrix 4.1)
3174  */
3175 fix = {
3176     hackname = ultrix_ifdef;
3177     select   = "^#ifdef KERNEL[ \t]+&&";
3178     files    = sys/file.h;
3179
3180     c_fix     = format;
3181     c_fix_arg = "#if defined(KERNEL) &&";
3182
3183     test_text =
3184     "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
3185 };
3186
3187
3188 /*
3189  * Strip "|| CC$gfloat" from Ultrix math headers.
3190  */
3191 fix = {
3192     hackname  = ultrix_math_ifdef;
3193     files     = sys/limits.h;
3194     files     = float.h;
3195     files     = math.h;
3196     select    = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
3197     c_fix     = format;
3198     c_fix_arg = "%1";
3199
3200     test_text = '#if     defined(__GFLOAT) || CC\$gfloat';
3201 };
3202
3203
3204 /*
3205  *  Avoid nested comments on Ultrix 4.3.
3206  */
3207 fix = {
3208     hackname = ultrix_nested_ioctl;
3209     files    = sys/ioctl.h;
3210     select   = "^/\\* #define SIOCSCREEN";
3211     sed      = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
3212     test_text =
3213     "/* #define SIOCSCREENON _IOWR('i', 49, int)"
3214     "/* screend, net/gw_screen.h */\n";
3215 };
3216
3217
3218 fix = {
3219     hackname = ultrix_nested_svc;
3220     files    = rpc/svc.h;
3221     select   = "^ \\*[ \t]*int protocol;  */\\*";
3222     sed      = "s@^\\( \\*\tint protocol;  \\)/\\*@\\1*/ /*@";
3223     test_text =
3224     " *\tint protocol;  /* like TCP or UDP\n";
3225 };
3226
3227
3228 /*
3229  *  Add missing prototype for lstat and define for S_ISLNK
3230  *  in Ultrix V4.3 sys/stat.h.
3231  */
3232 fix = {
3233     hackname = ultrix_stat;
3234     files  = sys/stat.h;
3235     select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
3236     sed    = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
3237                 "\\\n"
3238                 "/* macro to test for symbolic link */\\\n"
3239                 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
3240                 "\n";
3241     sed    = "/^[ \t]*fstat(),$/a\\\n"
3242                 "\tlstat(),\n";
3243     test_text =
3244     "@(#)stat.h      6.1     (ULTRIX)\n"
3245     "#define S_IFPORT S_IFIFO\n"
3246     "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */";
3247 };
3248
3249
3250 /*
3251  *  Check for superfluous `static' (in Ultrix 4.2)
3252  *  On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
3253  */
3254 fix = {
3255     hackname = ultrix_static;
3256     files  = machine/cpu.h;
3257     select = '#include "r[34]_cpu';
3258     sed    = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
3259     sed    = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
3260     sed    = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
3261     test_text =
3262     "static struct tlb_pid_state {\n"
3263     "#include \"r3_cpu.h\"\n";
3264 };
3265
3266
3267 /*
3268  *  Add once-only latch to Ultrix V4.3 strings.h.
3269  */
3270 fix = {
3271     hackname = ultrix_strings;
3272     files  = strings.h;
3273     select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
3274     c_fix  = wrap;
3275     test_text =
3276     "@(#)strings.h   6.1     (ULTRIX)\n";
3277 };
3278
3279
3280 /*
3281  *  Fix multiple defines for NULL.  Sometimes, we stumble into \r\n
3282  *  terminated lines, so accommodate these.  Test both ways.
3283  */
3284 fix = {
3285     hackname  = undefine_null;
3286     select    = "^#[ \t]*define[ \t]+NULL[ \t]";
3287     bypass    = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
3288
3289     c_fix     = format;
3290     c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
3291     c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
3292
3293     test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
3294 };
3295
3296 /*
3297  * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict"
3298  * which must be replaced by __restrict__ for GCC.
3299  */
3300 fix = {
3301     hackname = unicosmk_restrict;
3302     files    = stdio.h;
3303     files    = stdlib.h;
3304     files    = wchar.h;
3305     mach     = "*-*-unicosmk*";
3306     select   = "(\\*[ \t]*)restrict([ \t]+)";
3307
3308     c_fix     = format;
3309     c_fix_arg = "%1__restrict__%2";
3310
3311     test_text = "void f (char * restrict x);";
3312 };
3313
3314 /*
3315  * If arpa/inet.h prototypes are incompatible with the ones we just
3316  * installed in <sys/byteorder.h>, just remove the protos.
3317  * Because of this close association, this patch must be applied only
3318  * on those systems where the replacement byteorder header is installed.
3319  */
3320 fix = {
3321     hackname = uw7_byteorder_fix;
3322     files    = arpa/inet.h;
3323     select   = "in_port_t";
3324     test     = "-f sys/byteorder.h";
3325 #ifndef SVR5
3326         mach = "*-*-sysv4*";
3327         mach = "i?86-*-sysv5*";
3328         mach = "i?86-*-udk*";
3329         mach = "i?86-*-solaris2.[0-4]";
3330         mach = "powerpcle-*-solaris2.[0-4]";
3331         mach = "sparc-*-solaris2.[0-4]";
3332 #endif /* SVR5 */
3333
3334     c_fix     = format;
3335     c_fix_arg = "";
3336     c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
3337
3338     test_text = "extern in_port_t\thtons __P((in_port_t));\n"
3339                 "extern in_port_t\tntohs __P((in_port_t));"
3340                 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3341                 "echo '/* DUMMY */' >> sys/byteorder.h`";
3342 };
3343
3344
3345 /*
3346  *  Fix definitions of macros used by va-i960.h in VxWorks header file.
3347  */
3348 fix = {
3349     hackname  = va_i960_macro;
3350     files     = arch/i960/archI960.h;
3351     select    = "__(vsiz|vali|vpad|alignof__)";
3352
3353     c_fix     = format;
3354     c_fix_arg = "__vx%1";
3355
3356     test_text =
3357     "extern int __vsiz vsiz;\n"
3358     "extern int __vali vali;\n"
3359     "extern int __vpad vpad;\n"
3360     "#define __alignof__(x) ...";
3361 };
3362
3363
3364 /*
3365  *  AIX and Interix headers define NULL to be cast to a void pointer,
3366  *  which is illegal in ANSI C++.
3367  */
3368 fix = {
3369     hackname  = void_null;
3370     files     = curses.h;
3371     files     = dbm.h;
3372     files     = locale.h;
3373     files     = stdio.h;
3374     files     = stdlib.h;
3375     files     = string.h;
3376     files     = time.h;
3377     files     = unistd.h;
3378     files     = sys/dir.h;
3379     files     = sys/param.h;
3380     files     = sys/types.h;
3381     select    = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3382     c_fix     = format;
3383     c_fix_arg = "#define NULL 0";
3384     test_text = "# define\tNULL \t((void *)0)  /* typed NULL */";
3385 };
3386
3387
3388 /*
3389  *  Make VxWorks header which is almost gcc ready fully gcc ready.
3390  */
3391 fix = {
3392     hackname = vxworks_gcc_problem;
3393     files    = types/vxTypesBase.h;
3394     select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3395
3396     sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3397           "#if 1/";
3398
3399     sed = "/[ \t]size_t/i\\\n"
3400         "#ifndef _GCC_SIZE_T\\\n"
3401         "#define _GCC_SIZE_T\n";
3402
3403     sed = "/[ \t]size_t/a\\\n"
3404         "#endif\n";
3405
3406     sed = "/[ \t]ptrdiff_t/i\\\n"
3407         "#ifndef _GCC_PTRDIFF_T\\\n"
3408         "#define _GCC_PTRDIFF_T\n";
3409
3410     sed = "/[ \t]ptrdiff_t/a\\\n"
3411         "#endif\n";
3412
3413     sed = "/[ \t]wchar_t/i\\\n"
3414         "#ifndef _GCC_WCHAR_T\\\n"
3415         "#define _GCC_WCHAR_T\n";
3416
3417     sed = "/[ \t]wchar_t/a\\\n"
3418         "#endif\n";
3419
3420     test_text =
3421     "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3422     "typedef unsigned int size_t;\n"
3423     "typedef long ptrdiff_t;\n"
3424     "typedef unsigned short wchar_t;\n"
3425     "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3426 };
3427
3428
3429 /*
3430  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
3431  */
3432 fix = {
3433     hackname  = vxworks_needs_vxtypes;
3434     files     = time.h;
3435     select    = "uint_t([ \t]+_clocks_per_sec)";
3436     c_fix     = format;
3437     c_fix_arg = "unsigned int%1";
3438     test_text = "uint_t\t_clocks_per_sec;";
3439 };
3440
3441
3442 /*
3443  *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3444  */
3445 fix = {
3446     hackname = vxworks_needs_vxworks;
3447     files    = sys/stat.h;
3448     test     = " -r types/vxTypesOld.h";
3449     test     = " -n \"`egrep '#include' $file`\"";
3450     test     = " -n \"`egrep ULONG $file`\"";
3451     select   = "#[ \t]define[ \t]+__INCstath";
3452
3453     sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3454           "#include <types/vxTypesOld.h>\n";
3455
3456     test_text = "`touch types/vxTypesOld.h`"
3457     "#include </dev/null> /* ULONG */\n"
3458     "# define\t__INCstath <sys/stat.h>";
3459 };
3460
3461
3462 /*
3463  *  Another bad dependency in VxWorks 5.2 <time.h>.
3464  */
3465 fix = {
3466     hackname = vxworks_time;
3467     files    = time.h;
3468     test     = " -r vxWorks.h";
3469
3470     select    = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3471     c_fix     = format;
3472
3473     c_fix_arg =
3474     "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3475     "#ifdef __cplusplus\n"
3476     "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3477     "#else\n"
3478     "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3479     "#endif\n"
3480     "#define __gcc_VOIDFUNCPTR_defined\n"
3481     "#endif\n"
3482     "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3483
3484     test_text = "`touch vxWorks.h`"
3485                 "#define VOIDFUNCPTR (void(*)())";
3486 };
3487
3488
3489 /* 
3490  * WindISS math.h headers include bogus extern declarations of 
3491  * numerous math functions that conflict with libstdc++-v3.
3492  */
3493 fix = {
3494     hackname  = windiss_math1;
3495     files     = math.h;
3496     mach      = "*-*-windiss";
3497     sed       = "s|inline long double cosl.*|#ifndef __GNUC__|";
3498
3499     test_text = "inline long double cosl(long double);";
3500 };
3501
3502 fix = {
3503     hackname  = windiss_math2;
3504     files     = math.h;
3505     mach      = "*-*-windiss";
3506     sed       = "s|/\\* long double declarations \\*/|"
3507                   "#endif /* __GNUC__ */|";
3508
3509     test_text = "/* long double declarations */";
3510 };
3511
3512 /*
3513  * WindISS headers include "diab/va_list.h" instead of "stdarg.h"
3514  */
3515 fix = {
3516     select    = '(#include.*)diab/va_list.h';
3517     hackname  = windiss_valist;
3518     sed       = "s|diab/va_list.h|stdarg.h|";
3519     mach      = "*-*-windiss";
3520
3521     test_text = "#include <diab/va_list.h>";
3522 };
3523
3524 /*
3525  *  There are several name conflicts with C++ reserved words in X11 header
3526  *  files.  These are fixed in some versions, so don't do the fixes if
3527  *  we find __cplusplus in the file.  These were found on the RS/6000.
3528  */
3529 fix = {
3530     hackname  = x11_class;
3531     files     = X11/ShellP.h;
3532     bypass    = __cplusplus;
3533     select    = "^([ \t]*char \\*)class;(.*)";
3534     c_fix     = format;
3535     c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3536                 "#else\n%1class;%2\n#endif";
3537     test_text =
3538     "struct {\n"
3539     "   char *class;\n"
3540     "} mumble;\n";
3541 };
3542
3543
3544 /*
3545  *  class in Xm/BaseClassI.h
3546  */
3547 fix = {
3548     hackname = x11_class_usage;
3549     files    = Xm/BaseClassI.h;
3550     bypass   = "__cplusplus";
3551
3552     select    = " class\\)";
3553     c_fix     = format;
3554     c_fix_arg = " c_class)";
3555
3556     test_text = "extern mumble (int  class);\n";
3557 };
3558
3559
3560 /*
3561  *  new in Xm/Traversal.h
3562  */
3563 fix = {
3564     hackname = x11_new;
3565     files    = Xm/Traversal.h;
3566     bypass   = __cplusplus;
3567
3568     sed      = "/Widget\told, new;/i\\\n"
3569                    "#ifdef __cplusplus\\\n"
3570                    "\tWidget\told, c_new;\\\n"
3571                    "#else\n";
3572
3573     sed      = "/Widget\told, new;/a\\\n"
3574                    "#endif\n";
3575
3576     sed      = "s/Widget new,/Widget c_new,/g";
3577     test_text =
3578     "struct wedge {\n"
3579     "   Widget\told, new; /* fixinc check FAILS ON BSD */\n"
3580     "};\nextern Wedged( Widget new, Widget old );";
3581 };
3582
3583
3584 /*
3585  *  Incorrect sprintf declaration in X11/Xmu.h
3586  */
3587 fix = {
3588     hackname = x11_sprintf;
3589     files    = X11/Xmu.h;
3590     files    = X11/Xmu/Xmu.h;
3591     select   = "^extern char \\*\tsprintf\\(\\);$";
3592
3593     c_fix     = format;
3594     c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3595
3596     test_text = "extern char *\tsprintf();";
3597 };
3598
3599 /*EOF*/