OSDN Git Service

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