OSDN Git Service

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