OSDN Git Service

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