3 autogen definitions inclhack;
6 * Define all the fixes we know about for repairing damaged headers
10 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
11 * of struct rusage, so the prototype (added by fixproto) causes havoc.
14 hackname = aix_syswait;
17 sed = "/^extern pid_t wait3();$/i\\\n"
23 * sys/signal.h on some versions of AIX uses volatile in the typedef of
24 * sig_atomic_t, which causes gcc to generate a warning about duplicate
25 * volatile when a sig_atomic_t variable is declared volatile, as
29 hackname = aix_volatile;
31 select = "typedef volatile int sig_atomic_t";
32 sed = "s/typedef volatile int sig_atomic_t"
33 "/typedef int sig_atomic_t/";
38 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
41 hackname = alpha_getopt;
44 select = 'getopt\(int, char \*\[';
45 sed = 's/getopt(int, char \*\[\],[ ]*char \*)/'
46 'getopt(int, char *const[], const char *)/';
51 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
54 hackname = alpha_parens;
56 select = '#ifndef\(__mips64\)';
57 sed = "s/#ifndef(__mips64)/#ifndef __mips64/";
62 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
65 hackname = alpha_sbrk;
67 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
68 sed = "s/char\\([ \t]*\\*[\t ]*sbrk[ \t]*(\\)/void\\1/";
73 * Fix this ARM/RISCiX file where ___type is a Compiler
74 * hint that is specific to the Norcroft compiler.
77 hackname = arm_norcroft_hint;
78 select = "___type p_type";
79 files = "X11/Intrinsic.h";
80 sed = "s/___type p_type/p_type/";
85 * Fix this ARM/RISCiX file to avoid interfering
86 * with the use of __wchar_t in cc1plus.
91 select = "#[ \t]*define[ \t]*__wchar_t";
92 sed = "s/\\(#[ \t]*ifndef[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
93 sed = "s/\\(#[ \t]*define[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
98 * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89;
99 * gcc doesn't understand it.
104 select = "#ifndef NOINLINE";
105 sed = "s|#ifndef NOINLINE"
106 "|#if !defined(NOINLINE) \\&\\& !defined(__GNUC__)|";
111 * For C++, avoid any typedef or macro definition of bool,
112 * and use the built in type instead.
113 * HP/UX 10.20 also has it in curses_colr/curses.h.
116 hackname = avoid_bool;
118 files = curses_colr/curses.h;
122 sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/i\\\n"
123 "#ifndef __cplusplus\n";
125 sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/a\\\n"
128 sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/i\\\n"
129 "#ifndef __cplusplus\n";
131 sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/a\\\n"
134 sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/i\\\n"
135 "#ifndef __cplusplus\n";
137 sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/a\\\n"
140 sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/i\\\n"
141 "#ifndef __cplusplus\n";
143 sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/a\\\n"
146 sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/i\\\n"
147 "#ifndef __cplusplus\n";
149 sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/a\\\n"
155 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
158 hackname = bad_struct_term;
160 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
161 sed = "s/^[ \t]*typedef[ \t][ \t]*"
162 "\\(struct[ \t][ \t]*term[ \t]*;[ \t]*\\)$/\\1/";
167 * Fix one other error in this file:
168 * a mismatched quote not inside a C comment.
172 files = sundev/vuid_event.h;
173 sed = "s/doesn't/does not/";
178 * Fix #defines under Alpha OSF/1:
179 * The following files contain '#pragma extern_prefix "_FOO"' followed by
180 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
181 * statements is to reduce namespace pollution. While these macros work
182 * properly in most cases, they don't allow you to take a pointer to the
183 * "something" being modified. To get around this limitation, change these
184 * statements to be of the form '#define something _FOOsomething'.
203 "s/^[ \t]*#[ \t]*define[ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
204 "\\(_.\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
209 * check for broken assert.h that needs stdio.h
212 hackname = broken_assert_stdio;
215 bypass = "include.*stdio.h";
217 "#include <stdio.h>\n";
222 * check for broken assert.h that needs stdlib.h
225 hackname = broken_assert_stdlib;
227 select = 'exit *\(|abort *\(';
228 bypass = "include.*stdlib.h";
230 "#ifdef __cplusplus\\\n"
231 "#include <stdlib.h>\\\n"
237 * Note that BSD43_* are used on recent MIPS systems.
240 hackname = bsd43_io_macros;
241 select = "BSD43__IO";
243 * Put single quotes aroung the character that appears after '('
244 * and before ',', UNLESS it is a 'c' or 'g' or 'x'.
246 sed = "/[ \t]BSD43__IO[A-Z]*[ \t]*(/" 's/(\(.\),/(\'\1\',/';
247 sed = "/#[ \t]*define[ \t]*[ \t]BSD43__IO/" 's/\'\([cgx]\)\'/\1/g';
252 * Fix <c_asm.h> on Digital UNIX V4.0:
253 * It contains a prototype for a DEC C internal asm() function,
254 * clashing with gcc's asm keyword. So protect this with __DECC.
257 hackname = dec_intern_asm;
259 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
260 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
266 * Completely replace <_int_varargs.h> with a file that includes gcc's
267 * stdarg.h or varargs.h files as appropriate on DG/UX
270 hackname = dgux_int_varargs;
271 files = _int_varargs.h;
272 shell = "cat > /dev/null\ncat << '_EOF_'
273 \#ifndef __INT_VARARGS_H
274 \#define __INT_VARARGS_H
276 /************************************************************************/
277 /* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio. */
278 /************************************************************************/
281 ** This file is a DG internal header. Never include this
285 \#ifndef ___int_features_h
286 \#include <sys/_int_features.h>
289 \#if !(defined(_VA_LIST) || defined(_VA_LIST_))
296 typedef void * va_list;
298 typedef char * va_list;
304 \#if defined(__DCC__)
312 \#else /* ! defined(__DCC__) */
315 int __va_arg; /* argument number */
316 int *__va_stk; /* start of args passed on stack */
317 int *__va_reg; /* start of args passed in regs */
320 \#endif /* ! defined(__DCC__) */
324 \#if defined(__GNUC__) || defined(__STDC__)
325 typedef void * va_list;
327 typedef char * va_list;
330 \#endif /* _IX86_ANY */
332 \#endif /* __LINT__ */
333 \#endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
334 \#endif /* #ifndef __INT_VARARGS_H */
340 * Remove the double-slash comments
341 * They *must* be removed so it will not create nested comments!!
342 * However, they will *not* be removed if the file name ends with
343 * any of "++", ".hh" or ".H", or if the file name contains "cxx/".
345 * There *used* to be a number of similar problems in various OSes:
347 * Turning // comments into normal comments trashes this IRIX 4.0.1
348 * header file, which embeds // comments inside multi-line
349 * comments. If this looks like the IRIX header file, we refix it by
350 * just throwing away the // comments.
352 * Same problem with a file from SunOS 4.1.3 : a header file containing
353 * the string "//" embedded in "/ * * /"
355 * There is a similar problem with the VxWorks drv/netif/if_med.h file.
357 * And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
359 * Now that we delete the // comments instead of converting them to / * * /,
360 * traditional hacks like irix_bogus_cxx_cmnt, no longer work (which
361 * strangely enough was also used on alpha-dec-osf4.0d). If we skip the
362 * hack whenever we see ``"//"' ', then the need for the secondary hack
363 * disappears. Note: it is painful to ensure that the first quote
364 * exists, so we just check for the trailing quote directly abutting
365 * the //. Note: We should never touch a line that has // completely
366 * within quotes but this is somewhat hard to check for.
368 * Ultimately, this fix ought to go inside of C code where
369 * we can do a better analysis on the need and method for fixing.
372 hackname = no_double_slash;
374 * Test that the file-to-fix does not from a C++ directory
375 * Also, only accept double slashes that are not part of URL's
376 * and are not the end of a quoted string.
378 test = ' -z "`echo ${file} | egrep \'(CC|cxx|\+\+)/\'`"';
379 select = '(^|[^:])//[^"*]';
381 sed = 's,[^:]//[^"].*$,,';
386 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
389 hackname = ecd_cursor;
390 files = "sunwindow/win_lock.h";
391 files = "sunwindow/win_cursor.h";
392 sed = "s/ecd.cursor/ecd_cursor/";
396 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
397 * tiny static wrappers that aren't C++ safe.
400 hackname = sco5_stat_wrappers;
401 mach = "i*86-*-sco3.2v5*";
402 files = "sys/stat.h";
404 sed = "/^static int[ \t]*[a-z]*stat(/i\\\n"
405 "#ifdef __cplusplus\\\n"
411 "#ifdef __cplusplus\\\n"
413 "#endif \/* __cplusplus *\/\\\n";
419 * Fix else and endif directives that contain non-commentary text
422 hackname = end_else_label;
425 * Select files that contain '#endif' or '#else' directives with
426 * some sort of following junk. (Between the ascii '.'
427 * and '0' lies the character '/'. This will *NOT*
428 * match '#endif / * foo * /', but it also wont match
429 * '#endif / done' either.
431 * We have a second regexp in the selector to detect
432 * #endif followed by a / followed by anything other
433 * than a *. For example "#endif / * foo * /" or
434 * "#endif /% blah %/ which appear on OSF4.0A and AIX4.2
437 * We use the pattern [!-.0-z{|}~] instead of [^/ \t] to match a
438 * noncomment following #else or #endif because some buggy egreps
439 * think [^/] matches newline, and they thus think `#else ' matches
440 * `#e[ndiflse]*[ \t]+[^/ \t]'.
441 * [!-.0-~] does not work properly on AIX 4.1.
443 select = "^[ \t]*#[ \t]*(else|endif)[ \t]+"
444 "(" '[!-.0-z\{\|\}\~]' "|" '/[^\*]' ")";
447 * First, join the continued input lines.
448 * IF the resulting line is an endif preprocessing directive,
449 * then trim off the following patterns:
450 * 1. sequences that start with '/' and is *NOT* followed by '*'
451 * 2. Sequences that start with '*' and is *NOT* followed by '/'
452 * 3. sequences that do not start with any of '/', '*', '\t' or ' '.
454 * The fixinc_eol stuff is to work around a bug in the sed
458 's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
460 's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
462 "s%^\\([ \t]*#[ \t]*else\\)[ \t][ \t]*/[^*].*%\\1%\n"
463 "s%^\\([ \t]*#[ \t]*else\\)[ \t][ \t]*[^/ \t].*%\\1%\n"
464 "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*/[^*].*%\\1%\n"
465 "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*\*[^/].*%\\1%\n"
466 "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*[^/* \t].*%\\1%";
471 * Fix HP's use of ../machine/inline.h to refer to
472 * /usr/include/machine/inline.h
475 hackname = hp_inline;
476 files = sys/spinlock.h;
477 select = 'include.*"\.\./machine/';
478 sed = "s,\"../machine/inline.h\",<machine/inline.h>,";
479 sed = "s,\"../machine/psl.h\",<machine/psl.h>,";
484 * Check for (...) in C++ code in HP/UX sys/file.h.
487 hackname = hp_sysfile;
489 select = "HPUX_SOURCE";
490 sed = 's/(\.\.\.)/(struct file * ...)/';
495 * sys/mman.h on HP/UX is not C++ ready,
496 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
498 * rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
499 * is defined for the alpha. The problem is the declaration of malloc.
502 hackname = cxx_unready;
505 bypass = '"C"|__BEGIN_DECLS';
508 "#ifdef __cplusplus\\\n"
512 "#ifdef __cplusplus\\\n"
519 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
522 hackname = hpux_maxint;
524 sed = "/^#[ \t]*define[ \t]*MAXINT[ \t]/i\\\n"
527 sed = "/^#[ \t]*define[ \t]*MAXINT[ \t]/a\\\n"
533 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
536 hackname = hpux_systime;
538 select = "^extern struct sigevent;";
539 sed = "s/^extern struct sigevent;/struct sigevent;/";
544 * Determine if we're on Interactive Unix 2.2 or later, in which case we
545 * need to fix some additional files. This is the same test for ISC that
546 * Autoconf uses. On Interactive 2.2, certain traditional Unix
547 * definitions (notably getc and putc in stdio.h) are omitted if __STDC__
548 * is defined, not just if _POSIX_SOURCE is defined. This makes it
549 * impossible to compile any nontrivial program except with -posix.
552 hackname = interactv_add1;
554 test = " -d /etc/conf/kconfig.d";
555 test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
560 files = "sys/limits.h";
561 files = "sys/fcntl.h";
562 files = "sys/dirent.h";
564 sed = "s/!defined(__STDC__) && !defined(_POSIX_SOURCE)/"
565 "!defined(_POSIX_SOURCE)/";
569 hackname = interactv_add2;
571 test = " -d /etc/conf/kconfig.d";
572 test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
575 sed = "s/fmod(double)/fmod(double, double)/";
579 hackname = interactv_add3;
581 test = " -d /etc/conf/kconfig.d";
582 test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"';
584 files = sys/limits.h;
586 sed = "/CHILD_MAX/s,/\\* Max, Max,";
587 sed = "/OPEN_MAX/s,/\\* Max, Max,";
592 * Fix various _IO* defines, but do *not* quote the characters cgxtf.
595 hackname = io_def_quotes;
596 select = "[ \t]*[ \t](_|DES)IO[A-Z]*[ \t]*\\( *[^,']";
597 sed = "s/\\([ \t]*[ \t]_IO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/";
598 sed = "s/\\([ \t]*[ \t]DESIO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/";
599 sed = "/#[ \t]*define[ \t]*[ \t]_IO/" "s/'\\([cgxtf]\\)'/\\1/g";
600 sed = "/#[ \t]*define[ \t]*[ \t]DESIOC/" 's/\'\([cdgx]\)\'/\1/g';
607 * Basically, what is supposed to be happening is that every
608 * _invocation_ of the "_CTRL()" or "CTRL()" macros is supposed to have
609 * its argument inserted into single quotes. We _must_ do this because
610 * ANSI macro substitution rules prohibit looking inside quoted strings
611 * for the substitution names. A side effect is that the quotes are
612 * inserted in the definitions of those macros as well. So, the last
613 * several sed expressions are supposed to clean up the definitions, as
614 * long as those definitions are using "c", "g" or "x" as the macro
618 hackname = ioctl_fix_ctrl;
619 select = "CTRL[ \t]*\\(";
621 sed = "/[^A-Z0-9_]CTRL[ \t]*(/"
622 "s/\\([^']\\))/'\\1')/";
624 sed = "/[^A-Z0-9]_CTRL[ \t]*(/"
625 "s/\\([^']\\))/'\\1')/";
627 sed = "/#[ \t]*define[ \t]*[ \t]CTRL/"
628 "s/'\\([cgx]\\)'/\\1/g";
630 sed = "/#[ \t]*define[ \t]*[ \t]_CTRL/"
631 "s/'\\([cgx]\\)'/\\1/g";
633 sed = "/#[ \t]*define[ \t]*[ \t]BSD43_CTRL/"
634 "s/'\\([cgx]\\)'/\\1/g";
636 sed = "/#[ \t]*define[ \t]*[ \t][_]*ISCTRL/"
637 "s/'\\([cgx]\\)'/\\1/g";
642 * Check for missing ';' in struct
645 hackname = ip_missing_semi;
646 files = netinet/ip.h;
647 sed = "/^struct/,/^};/s/}$/};/";
652 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
653 * in prototype without previous definition.
656 hackname = irix_multiline_cmnt;
659 sed = "s@type of the result@type of the result */@";
660 sed = "s@of the sizeof@/* of the sizeof@";
665 * Some IRIX header files contain the string "//"
668 hackname = irix_sockaddr;
670 select = "authdes_create.*struct sockaddr";
671 sed = "/authdes_create.*struct sockaddr/i\\\n"
672 "struct sockaddr;\n";
677 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
678 * in prototype without previous definition.
681 hackname = irix_struct__file;
683 sed = "/xdrstdio_create.*struct __file_s/i\\\n"
684 "struct __file_s;\n";
689 * Fixing ISC fmod declaration
694 select = 'fmod\(double\)';
695 sed = "s/fmod(double)/fmod(double, double)/";
700 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
703 hackname = motorola_nested;
704 mach = "m68k-motorola-sysv*";
706 files = sys/limits.h;
707 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
708 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
709 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.40282346638528860e+38 \\)"
710 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
715 * Fixing nested comments in ISC <sys/limits.h>
718 hackname = isc_sys_limits;
719 files = sys/limits.h;
721 sed = "/CHILD_MAX/s,/\\* Max, Max,";
722 sed = "/OPEN_MAX/s,/\\* Max, Max,";
727 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
728 * use / * * / to concatenate tokens.
731 hackname = kandr_concat;
732 files = "sparc/asm_linkage.h";
733 files = "sun3/asm_linkage.h";
734 files = "sun3x/asm_linkage.h";
735 files = "sun4/asm_linkage.h";
736 files = "sun4c/asm_linkage.h";
737 files = "sun4m/asm_linkage.h";
738 files = "sun4c/debug/asm_linkage.h";
739 files = "sun4m/debug/asm_linkage.h";
740 files = "arm/as_support.h";
741 files = "arm/mc_type.h";
743 files = "dev/chardefmac.h";
744 files = "dev/ps_irq.h";
745 files = "dev/screen.h";
746 files = "dev/scsi.h";
748 files = "Xm.acorn/XmP.h";
749 files = bsd43/bsd43_.h;
751 sed = 's|/\*\*/|##|g';
756 * In limits.h, put #ifndefs around things that are supposed to be defined
757 * in float.h to avoid redefinition errors if float.h is included first.
758 * On HP/UX this patch does not work, because on HP/UX limits.h uses
759 * multi line comments and the inserted #endif winds up inside the
760 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
761 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
762 * are there, and we do not add them ourselves.
763 * Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1
766 hackname = limits_ifndefs;
768 files = "sys/limits.h";
769 bypass = "ifndef[ \t]+FLT_MIN";
771 sed = "/[ \t]FLT_MIN[ \t]/i\\\n#ifndef FLT_MIN\n";
772 sed = "/[ \t]FLT_MIN[ \t]/a\\\n#endif\n";
773 sed = "/[ \t]FLT_MAX[ \t]/i\\\n#ifndef FLT_MAX\n";
774 sed = "/[ \t]FLT_MAX[ \t]/a\\\n#endif\n";
775 sed = "/[ \t]FLT_DIG[ \t]/i\\\n#ifndef FLT_DIG\n";
776 sed = "/[ \t]FLT_DIG[ \t]/a\\\n#endif\n";
777 sed = "/[ \t]DBL_MIN[ \t]/i\\\n#ifndef DBL_MIN\n";
778 sed = "/[ \t]DBL_MIN[ \t]/a\\\n#endif\n";
779 sed = "/[ \t]DBL_MAX[ \t]/i\\\n#ifndef DBL_MAX\n";
780 sed = "/[ \t]DBL_MAX[ \t]/a\\\n#endif\n";
781 sed = "/[ \t]DBL_DIG[ \t]/i\\\n#ifndef DBL_DIG\n";
782 sed = "/[ \t]DBL_DIG[ \t]/a\\\n#endif\n";
783 sed = "/^\\(\\/\\*#define\tHUGE_VAL\t3\\.[0-9e+]* *\\)\\/\\*/s//\\1/";
788 * Delete the '#define void int' line from curses.h on Lynx
791 hackname = lynx_void_int;
793 select = "#[ \t]*define[ \t]+void[ \t]+int";
794 sed = "/#[ \t]*define[ \t][ \t]*void[ \t]int/d";
799 * Fix fcntl prototype in fcntl.h on LynxOS.
802 hackname = lynxos_fcntl_proto;
804 select = 'fcntl.*\(int, int, int\)';
805 sed = 's/\(fcntl.*(int, int, \)int)/\1...)/';
810 * libm.a on m88k-motorola-sysv3 contains a stupid optimization for
811 * function hypot(), which returns the second argument without even
812 * looking at its value, if the other is 0.0. Another drawback is
813 * that fix-header doesn't fix fabs' prototype, and I have no idea why.
816 hackname = m88k_bad_hypot_opt;
817 mach = "m88k-motorola-sysv3*";
820 sed = "s/extern double floor(), ceil(), fmod(), fabs();/"
821 "extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/";
823 sed = "/^extern double hypot();$/a\\\n"
824 "\\/* Workaround a stupid Motorola optimization if one\\\n"
825 " of x or y is 0.0 and the other is negative! *\\/\\\n"
826 "#ifdef __STDC__\\\n"
827 "static __inline__ double fake_hypot (double x, double y)\\\n"
829 "static __inline__ double fake_hypot (x, y)\\\n"
833 "\treturn fabs (hypot (x, y));\\\n"
835 "#define hypot\tfake_hypot\n";
840 * Fix incorrect S_IF* definitions on m88k-sysv3.
843 hackname = m88k_bad_s_if;
844 mach = "m88k-*-sysv3*";
846 select = "#define[ \t]+S_IS[A-Z]*(m)[ \t]";
848 sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*"
849 "(m[ \t]*&[ \t]*\\(S_IF[A-Z][A-Z][A-Z][A-Z]*\\)[ \t]*)/"
850 "\\1 (((m)\\&S_IFMT)==\\2)/";
852 sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*"
853 "(m[ \t]*&[ \t]*\\(0[0-9]*\\)[ \t]*)/"
854 "\\1 (((m)\\&S_IFMT)==\\2)/";
859 * Put cpp wrappers around these include files to avoid redeclaration
860 * errors during multiple inclusion on m88k-tektronix-sysv3.
863 hackname = m88k_multi_incl;
864 mach = "m88k-tektronix-sysv3*";
868 "echo Fixing $file, to protect against multiple inclusion. >&2
869 cpp_wrapper=`echo $file | sed -e 's,\\.,_,g' -e 's,/,_,g'`
870 echo \"#ifndef __GCC_GOT_${cpp_wrapper}_\"
871 echo \"#define __GCC_GOT_${cpp_wrapper}_\"
873 echo \"#endif /* ! __GCC_GOT_${cpp_wrapper}_ */\"";
878 * Fix non-ansi machine name defines
879 * File selection is split into two parts: the shell version as
880 * a single patch, and the program version with each patch separate.
881 * Each is substantially faster for the particular environment.
882 * You have a dual maintenance problem here.
885 hackname = machine_name;
887 * Select '#if.*' and '#elif" with possible non-ansi symbols
888 * The only non-ansi symbols we know about start with one of:
890 * If any are added to the substitution list, then add it to
891 * the selection list as well. Hopefully we can avoid names
892 * starting with "d" and "l", because this pattern would then
893 * match "defined" and "lint" as well. I suppose we could add
894 * a "bypass = lint" if we had to though.
896 * The fixinc_eol stuff is to work around a bug in the sed
898 select = "^#[ \t]*(if|elif).*"
899 "[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]";
900 exesel = "^#[ \t]*(if|elif).*[^a-zA-Z0-9_]"
904 "|_*SYSTYPE_[A-Z0-9]"
931 's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
933 's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
935 "/#[\t ]*[el]*if/ {\n"
936 "\ts/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g\n"
938 "\ts/ M32 / __M32__ /g\n"
939 "\ts/ _*MIPSE\\([LB]\\) / __MIPSE\\1__ /g\n"
940 "\ts/ _*SYSTYPE_\\([A-Z0-9]*\\) / __SYSTYPE_\\1__ /g\n"
941 "\ts/ _*\\([Rr][34]\\)000 / __\\1000__ /g\n"
942 "\ts/ _*host_mips / __host_mips__ /g\n"
943 "\ts/ _*i386 / __i386__ /g\n"
944 "\ts/ _*mips / __mips__ /g\n"
945 "\ts/ bsd4\\([0-9]\\) / __bsd4\\1__ /g\n"
946 "\ts/ is68k / __is68k__ /g\n"
947 "\ts/ m68k / __m68k__ /g\n"
948 "\ts/ m88k / __m88k__ /g\n"
949 "\ts/ mc680\\([0-9]\\)0 / __mc680\\10__ /g\n"
950 "\ts/ news\\([0-9]*\\) / __news\\1__ /g\n"
951 "\ts/ ns32000 / __ns32000__ /g\n"
952 "\ts/ pdp11 / __pdp11__ /g\n"
953 "\ts/ pyr / __pyr__ /g\n"
954 "\ts/ sel / __sel__ /g\n"
955 "\ts/ sony_news / __sony_news__ /g\n"
956 "\ts/ sparc / __sparc__ /g\n"
957 "\ts/ sun\\([a-z0-9]*\\) / __sun\\1__ /g\n"
958 "\ts/ tahoe / __tahoe__ /g\n"
959 "\ts/ tower\\([_0-9]*\\) / __tower\\1__ /g\n"
960 "\ts/ u370 / __u370__ /g\n"
961 "\ts/ u3b\\([0-9]*\\) / __u3b\\1__ /g\n"
962 "\ts/ unix / __unix__ /g\n"
963 "\ts/ vax / __vax__ /g\n"
965 "\ts/ \\([a-zA-Z0-9_][a-zA-Z0-9_]*\\) /\\1/g\n\t}";
970 * Some math.h files define struct exception, which conflicts with
971 * the class exception defined in the C++ file std/stdexcept.h. We
972 * redefine it to __math_exception. This is not a great fix, but I
973 * haven't been able to think of anything better.
976 hackname = math_exception;
978 select = "struct exception";
979 sed = "/struct exception/i\\\n"
980 "#ifdef __cplusplus\\\n"
981 "#define exception __math_exception\\\n"
983 sed = "/struct exception/a\\\n"
984 "#ifdef __cplusplus\\\n"
985 "#undef exception\\\n"
988 sed = "/matherr/i\\\n"
989 "#ifdef __cplusplus\\\n"
990 "#define exception __math_exception\\\n"
993 sed = "/matherr/a\\\n"
994 "#ifdef __cplusplus\\\n"
995 "#undef exception\\\n"
998 #ifdef MATH_EXCEPTION_FIXED
1000 I think this patch needs some more thinking.
1001 This is from SVR4.2 (With '#' replaced with '@').
1002 Perhaps we could do without the "/matherr/a" entries?
1003 Can we bypass the entire fix if someone was astute
1004 enough to have '#ifdef __cplusplus' anywhere in the file?
1007 *** /usr/include/math.h Fri Apr 3 18:54:59 1998
1008 --- math.h Sun May 9 07:28:58 1999
1015 + @ifdef __cplusplus
1016 + @define exception __math_exception
1019 + @ifdef __cplusplus
1031 + @ifdef __cplusplus
1032 + @define exception __math_exception
1034 + @ifdef __cplusplus
1035 + @define exception __math_exception
1037 extern int matherr(struct exception *);
1038 + @ifdef __cplusplus
1041 + @ifdef __cplusplus
1045 @endif /*__cplusplus*/
1051 * In math.h, put #ifndefs around things that might be defined
1052 * in a gcc specific math-*.h file.
1055 hackname = math_gcc_ifndefs;
1060 * First see if we have a definition for DBL_MAX in float.h
1061 * If we do, we will replace the one in math.h with that one.
1065 * IF we have such a define *and* HUGE_VAL is defined to be DBL_MAX
1066 * *and* DBL_MAX is _not_ defined in the current file (math.h),
1067 * THEN replace the defined value of HUGE_VAL
1068 * ELSE just copy stdin to stdout so the main filter can process it
1072 * Put conditional guards around the HUGE_VAL definition.
1075 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1078 "\tif ( test -n \"${dbl_max_def}\" \\\n"
1079 "\t\t-a -n \"`egrep '#define[ \t]*HUGE_VAL[ \t]+DBL_MAX' $file`\" \\\n"
1080 "\t\t-a -z \"`egrep '#define[ \t]+DBL_MAX[ \t]+' $file`\"\n"
1081 "\t ) > /dev/null 2>&1\n"
1082 "\tthen sed -e '/define[ \t]HUGE_VAL[ \t]DBL_MAX/s/DBL_MAX/$dbl_max_def/'"
1083 "\n\telse cat ; fi |\n"
1085 "\tsed -e '/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n' "
1086 "-e '/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n'";
1094 hackname = nested_comment;
1096 sed = 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@';
1101 * fix bogus recursive stdlib.h in NEWS-OS 4.0C
1104 hackname = news_os_recursion;
1106 select = "#include <stdlib.h>";
1107 sed = "/^#include <stdlib.h>/i\\\n"
1108 "#ifdef BOGUS_RECURSION\n";
1109 sed = "/^#include <stdlib.h>/a\\\n"
1115 * NeXT 3.2 adds const prefix to some math functions.
1116 * These conflict with the built-in functions.
1119 hackname = next_math_prefix;
1120 files = ansi/math.h;
1121 select = "^extern.*double.*__const__.*";
1123 sed = "/^extern.*double.*__const__.*sqrt(/s/__const__//";
1124 sed = "/^extern.*double.*__const__.*fabs(/s/__const__//";
1125 sed = "/^extern.*double.*__const__.*cos(/s/__const__//";
1126 sed = "/^extern.*double.*__const__.*hypot(/s/__const__//";
1127 sed = "/^extern.*double.*__const__.*sin(/s/__const__//";
1132 * NeXT 3.2 uses the word "template" as a parameter for some
1133 * functions. GCC reports an invalid use of a reserved key word
1134 * with the built-in functions. NeXT 3.2 includes the keyword
1135 * volatile in the prototype for abort(). This conflicts with
1136 * the built-in definition.
1139 hackname = next_template;
1143 sed = '/\(.*template\)/s/template//';
1144 sed = "/extern.*volatile.*void.*abort/s/volatile//";
1149 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1150 * function prototypes. That conflicts with the built-in functions.
1153 hackname = next_volitile;
1154 files = ansi/stdlib.h;
1157 sed = "/extern.*volatile.*void.*exit/s/volatile//";
1158 sed = "/extern.*volatile.*void.*abort/s/volatile//";
1163 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1164 * Note that version 3 of the NeXT system has wait.h in a different directory,
1165 * so that this code won't do anything. But wait.h in version 3 has a
1166 * conditional, so it doesn't need this fix. So everything is okay.
1169 hackname = next_wait_union;
1172 select = 'wait\(union wait';
1174 sed = "s@wait(union wait@wait(void@";
1179 * a missing semi-colon at the end of the nodeent structure definition.
1182 hackname = nodeent_syntax;
1183 files = netdnet/dnetdb.h;
1184 sed = "s/char.*na_addr *$/char *na_addr;/";
1189 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1190 * defining regex.h related types. This causes libg++ build and usage
1191 * failures. Fixing this correctly requires checking and modifying 3 files.
1194 hackname = osf_namespace_a;
1195 files = reg_types.h;
1196 files = sys/lc_core.h;
1197 test = " -r reg_types.h";
1198 test = " -r sys/lc_core.h";
1199 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1200 test = " -z \"`grep __regex_t regex.h`\"";
1202 sed = "s/regex_t/__regex_t/g";
1203 sed = "s/regoff_t/__regoff_t/g";
1204 sed = "s/regmatch_t/__regmatch_t/g";
1208 hackname = osf_namespace_b;
1210 test = " -r reg_types.h";
1211 test = " -r sys/lc_core.h";
1212 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1213 test = " -z \"`grep __regex_t regex.h`\"";
1215 sed = "/#include <reg_types.h>/a\\\n"
1216 "typedef __regex_t\tregex_t;\\\n"
1217 "typedef __regoff_t\tregoff_t;\\\n"
1218 "typedef __regmatch_t\tregmatch_t;\n";
1223 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1224 * The original ones fail if uninitialized externs are not common.
1225 * This is the default for all ANSI standard C++ compilers.
1228 hackname = pthread_page_size;
1230 select = "^int __page_size";
1231 sed = "s/^int __page_size/extern int __page_size/";
1236 * Fix return type of fread and fwrite on sysV68
1240 hackname = read_ret_type;
1242 sed = "s/^\\(extern int\tfclose(), fflush()\\), "
1243 "\\(fread(), fwrite()\\)\\(.*\\)$"
1244 "/extern unsigned int\t\\2;\\\n\\1\\3/";
1250 * function class(double x) conflicts with C++ keyword on rs/6000
1253 hackname = rs6000_double;
1255 select = '[^a-zA-Z_]class\(';
1257 sed = "/class[(]/i\\\n#ifndef __cplusplus\n";
1258 sed = "/class[(]/a\\\n#endif\n";
1263 * Wrong fchmod prototype on RS/6000.
1266 hackname = rs6000_fchmod;
1268 select = 'fchmod\(char';
1269 sed = 's/fchmod(char \*/fchmod(int/';
1274 * parameters conflict with C++ new on rs/6000
1277 hackname = rs6000_param;
1281 sed = 's@rename(const char \*old, const char \*new)@'
1282 'rename(const char *_old, const char *_new)@';
1287 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1291 hackname = sony_ctype;
1293 test = " -x /bin/sony";
1294 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1295 sed = "s/__ctype/_ctype/g";
1300 * Incorrect #include in Sony News-OS 3.2.
1303 hackname = sony_include;
1304 files = machine/machparam.h;
1305 select = '"\.\./machine/endian.h"';
1306 sed = 's@"../machine/endian.h"@<machine/endian.h>@';
1311 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1315 hackname = sony_stdio;
1317 test = " -x /bin/sony";
1318 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
1319 sed = "s/__filbuf/_filbuf/g\n"
1320 "s/__flsbuf/_flsbuf/g\n"
1326 * Add a `static' declaration of `getrnge' into <regexp.h>.
1328 * Don't do this if there is already a `static void getrnge' declaration
1329 * present, since this would cause a redeclaration error. Solaris 2.x has
1330 * such a declaration.
1334 hackname = static_getrnge;
1336 bypass = "static void getrnge";
1337 sed = "/^static int[ \t]*size;/c\\\n"
1338 "static int size ;\\\n\\\n"
1339 "static int getrnge ();";
1344 * a missing semi-colon at the end of the statsswtch structure definition.
1347 hackname = statsswtch;
1348 files = rpcsvc/rstat.h;
1349 select = "boottime$";
1350 sed = "s/boottime$/boottime;/";
1355 * Don't use or define the name va_list in stdio.h.
1356 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
1357 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1360 hackname = stdio_va_list;
1364 * Use __gnuc_va_list in arg types in place of va_list.
1365 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1366 * trailing parentheses and semicolon save all other systems from this.
1367 * Define __va_list__ (something harmless and unused) instead of va_list.
1368 * Don't claim to have defined va_list.
1371 "if ( egrep \"__need___va_list\" $file ) > /dev/null 2>&1 ; then
1374 echo \"#define __need___va_list\"
1375 echo \"#include <stdarg.h>\"
1378 sed -e 's@ va_list @ __gnuc_va_list @' \\
1379 -e 's@ va_list)@ __gnuc_va_list)@' \\
1380 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \\
1381 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \\
1382 -e 's@ va_list@ __va_list__@' \\
1383 -e 's@\\*va_list@*__va_list__@' \\
1384 -e 's@ __va_list)@ __gnuc_va_list)@' \\
1385 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \\
1386 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \\
1387 -e 's@VA_LIST@DUMMY_VA_LIST@' \\
1388 -e 's@_Va_LIST@_VA_LIST@'";
1393 * Check for strict ansi compliance
1397 hackname = strict_ansi;
1398 select = "__STDC__[ \t]*[=!]=[ \t]*[01]";
1399 sed = "s/__STDC__[ \t]*==[ \t]*0/!defined (__STRICT_ANSI__)/g";
1400 sed = "s/__STDC__[ \t]*!=[ \t]*0/defined (__STRICT_ANSI__)/g";
1401 sed = "s/__STDC__[ \t]*==[ \t]*1/defined (__STRICT_ANSI__)/g";
1402 sed = "s/__STDC__[ \t]*!=[ \t]*1/!defined (__STRICT_ANSI__)/g";
1407 * Fix bogus #ifdef on SunOS 4.1.
1410 hackname = sun_bogus_ifdef;
1411 files = "hsfs/hsfs_spec.h";
1412 files = "hsfs/iso_spec.h";
1413 select = '#ifdef __i386__ || __vax__';
1414 sed = "s/\\#ifdef __i386__ || __vax__/\\#if __i386__ || __vax__/g";
1419 * Fix bogus #ifdef on SunOS 4.1.
1422 hackname = sun_bogus_ifdef_sun4c;
1423 files = "hsfs/hsnode.h";
1424 select = '#ifdef __i386__ || __sun4c__';
1425 sed = "s/\\#ifdef __i386__ || __sun4c__/\\#if __i386__ || __sun4c__/g";
1430 * Fix the CAT macro in SunOS memvar.h.
1433 hackname = sun_catmacro;
1434 files = pixrect/memvar.h;
1435 select = "^#define[ \t]+CAT\\(a,b\\)";
1436 sed = "/^#define[ \t]CAT(a,b)/ i\\\n"
1437 "#ifdef __STDC__ \\\n"
1438 "#define CAT(a,b) a##b\\\n"
1441 sed = "/^#define[ \t]CAT(a,b)/ a\\\n"
1447 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
1448 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
1451 hackname = sun_malloc;
1454 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
1455 sed = "s/int[ \t][ \t]*free/void\tfree/g";
1456 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
1457 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
1462 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1463 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1464 * many other systems have similar text but correct versions of the file.
1465 * To ensure only Sun's is fixed, we grep for a likely unique string.
1466 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1469 hackname = sun_memcpy;
1471 select = "/\\*\t@\\(#\\)"
1472 "(head/memory.h\t50.1\t "
1473 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
1475 sed = "1i\\\n/* This file was generated by fixincludes */\\\n"
1476 "#ifndef __memory_h__\\\n"
1477 "#define __memory_h__\\\n\\\n"
1478 "#ifdef __STDC__\\\n"
1479 "extern void *memccpy();\\\n"
1480 "extern void *memchr();\\\n"
1481 "extern void *memcpy();\\\n"
1482 "extern void *memset();\\\n"
1484 "extern char *memccpy();\\\n"
1485 "extern char *memchr();\\\n"
1486 "extern char *memcpy();\\\n"
1487 "extern char *memset();\\\n"
1488 "#endif /* __STDC__ */\\\n\\\n"
1489 "extern int memcmp();\\\n\\\n"
1490 "#endif /* __memory_h__ */\n";
1497 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
1500 hackname = sun_rusers_semi;
1501 files = rpcsvc/rusers.h;
1503 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
1508 * signal.h on SunOS defines signal using (),
1509 * which causes trouble when compiling with g++ -pedantic.
1512 hackname = sun_signal;
1513 files = sys/signal.h;
1515 select = "^void\t" '\(\*signal\(\)\)\(\);';
1517 sed = "/^void\t" '(\*signal())();$/i' "\\\n"
1518 "#ifdef __cplusplus" "\\\n"
1519 "void\t(*signal(...))(...);" "\\\n"
1522 sed = "/^void\t" '(\*signal())();$/a' "\\\n"
1528 * Apply fix this to all OSs since this problem seems to effect
1529 * more than just SunOS. In general, fixes which are triggered
1530 * by a specific target are bad.
1533 hackname = sun_auth_proto;
1539 * Select those files containing '(*name)()'.
1541 select = '\(\*[a-z][a-z_]*\)\(\)';
1543 '/^\(.*(\*[a-z][a-z_]*)(\)' '\();.*\)'
1545 "#ifdef __cplusplus\\\n"
1555 * math.h on SunOS 4 puts the declaration of matherr before the definition
1556 * of struct exception, so the prototype (added by fixproto) causes havoc.
1559 hackname = sunos_matherr_decl;
1562 * Once a declaration for 'struct exception' is found,
1563 * stop trying to insert a forward reference for it.
1565 sed = "/^struct exception/,$b";
1566 sed = "/matherr/i\\\nstruct exception;\n";
1571 * Correct the return type for strlen in strings.h in SunOS 4.
1574 hackname = sunos_strlen;
1576 sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/";
1581 * Solaris math.h and floatingpoint.h define __P without protection,
1582 * which conflicts with the fixproto definition. The fixproto
1583 * definition and the Solaris definition are used the same way.
1589 files = floatingpoint.h;
1590 select = "^#define[ \t]*__P";
1591 sed = "/^#define[ \t]*__P/i\\\n#ifndef __P\n";
1592 sed = "/^#define[ \t]*__P/a\\\n#endif\n";
1597 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
1598 * that is visible to any ANSI compiler using this include. Simply
1599 * delete the lines that #define some string functions to internal forms.
1603 hackname = svr4_disable_opt;
1605 select = '#define.*__std_hdr_';
1606 sed = '/#define.*__std_hdr_/d';
1611 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1615 hackname = svr4_endian;
1616 files = sys/endian.h;
1617 bypass = '__GNUC__';
1619 sed = "/#\tifdef\t__STDC__/i\\\n"
1620 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
1622 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
1624 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
1625 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
1630 * Remove useless extern keyword from struct forward declarations
1631 * in <sys/stream.h> and <sys/strsubr.h>
1635 hackname = svr4_extern_struct;
1636 files = sys/stream.h;
1637 files = sys/strsubr.h;
1638 select = 'extern struct [a-z_]*;';
1639 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
1644 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
1645 * systems the file <ftw.h> contains extern declarations of these
1646 * functions followed by explicitly `static' definitions of these
1647 * functions... and that's not allowed according to ANSI C. (Note
1648 * however that on Solaris, this header file glitch has been pre-fixed by
1649 * Sun. In the Solaris version of <ftw.h> there are no static
1650 * definitions of any function so we don't need to do any of this stuff
1656 hackname = svr4_ftw;
1658 select = '^extern int ftw\(const';
1660 sed = '/^extern int ftw(const/i' "\\\n"
1661 "#if !defined(_STYPES)\\\n"
1666 sed = 's/extern \(int ftw(const.*\)$/\1/';
1667 sed = "/^extern int nftw/i\\\n"
1668 "#if defined(_STYPES)\\\n"
1673 sed = 's/extern \(int nftw.*\)$/\1/';
1674 sed = "/^extern int ftw(),/c\\\n"
1675 "#if !defined(_STYPES)\\\n"
1681 "#if defined(_STYPES)\\\n"
1693 * Fix broken decl of getcwd present on some svr4 systems.
1697 hackname = svr4_getcwd;
1700 select = 'getcwd\(char \*, int\)';
1702 sed = 's/getcwd(char \*, int)/getcwd(char *, size_t)/';
1711 hackname = svr4_kernel;
1712 files = fs/rfs/rf_cache.h;
1716 files = sys/getpages.h;
1718 files = sys/cmn_err.h;
1719 files = sys/kdebugger.h;
1721 sed = "1i\\\n#ifdef _KERNEL";
1722 sed = "$a\\\n#endif /* _KERNEL */";
1727 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
1728 * tend to conflict with the compiler's own definition of this symbol. (We
1729 * will use the compiler's definition.)
1730 * Likewise __sparc, for Solaris, and __i860, and a few others
1731 * (guessing it is necessary for all of them).
1735 hackname = svr4_mach_defines;
1737 select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
1738 sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
1743 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
1747 hackname = svr4_mkdev;
1748 files = sys/mkdev.h;
1750 sed = "/^dev_t makedev(const/c\\\n"
1751 "static dev_t makedev(const major_t, const minor_t);";
1753 sed = "/^dev_t makedev()/c\\\n"
1754 "static dev_t makedev();";
1756 sed = "/^major_t major(const/c\\\n"
1757 "static major_t major(const dev_t);";
1759 sed = "/^major_t major()/c\\\n"
1760 "static major_t major();";
1762 sed = "/^minor_t minor(const/c\\\n"
1763 "static minor_t minor(const dev_t);";
1765 sed = "/^minor_t minor()/c\\\n"
1766 "static minor_t minor();";
1771 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
1772 * Also fix types of array initializers.
1776 hackname = svr4_netcspace;
1777 files = sys/netcspace.h;
1778 select = 'NC_NPI_RAW';
1779 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
1780 sed = 's/NC_/(unsigned long) NC_/';
1785 * Fix reference to NMSZ in <sys/adv.h>.
1789 hackname = svr4_nmsz;
1791 select = '\[NMSZ\]';
1792 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
1797 * Completely replace <sys/varargs.h> with a file that includes gcc's
1798 * stdarg.h or varargs.h files as appropriate.
1802 hackname = svr4_no_varargs;
1803 files = sys/varargs.h;
1804 shell = "cat > /dev/null\n"
1806 "/* This file was generated by fixincludes. */\n"
1807 "#ifndef _SYS_VARARGS_H\n"
1808 "#define _SYS_VARARGS_H\n\n"
1811 "#include <stdarg.h>\n"
1813 "#include <varargs.h>\n"
1816 "#endif /* _SYS_VARARGS_H */\n"
1822 * Fix broken decl of profil present on some svr4 systems.
1826 hackname = svr4_profil;
1830 sed = 's/profil(unsigned short \*, unsigned int, '
1831 'unsigned int, unsigned int)'
1832 '/profil(unsigned short *, size_t, int, unsigned)/';
1837 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1841 hackname = svr4_proto_form;
1843 select = 'const extern';
1845 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
1850 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
1855 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
1860 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
1865 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
1866 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
1867 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
1868 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
1869 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
1870 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
1875 * Add a prototyped declaration of mmap to <sys/mman.h>.
1879 hackname = svr4_proto_mmap;
1881 select = '^extern caddr_t mmap();$';
1882 sed = '/^extern caddr_t mmap();$/c' "\\\n"
1883 "#ifdef __STDC__\\\n"
1884 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
1885 "#else /* !defined(__STDC__) */\\\n"
1886 "extern caddr_t mmap ();\\\n"
1887 "#endif /* !defined(__STDC__) */\\\n";
1892 * Add a #define of _SIGACTION_ into <sys/signal.h>.
1896 hackname = svr4_sigaction;
1897 files = sys/signal.h;
1898 sed = "/^struct sigaction {/i\\\n"
1899 "#define _SIGACTION_";
1900 sed = 's/(void *(\*)())/(void (*)(int))/';
1905 * Put storage class at start of decl, to avoid warning.
1909 hackname = svr4_storage_class;
1910 files = rpc/types.h;
1911 select = 'const extern';
1912 sed = 's/const extern/extern const/g';
1917 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
1918 * in string.h on sysV68
1919 * Correct the return type for strlen in string.h on Lynx.
1920 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1921 * Add missing const for strdup on OSF/1 V3.0.
1922 * On sysV88 layout is slightly different.
1925 hackname = systypes;
1926 files = "sys/types.h";
1928 files = "sys/stdtypes.h";
1932 select = "typedef[ \t]+[a-z_][ \ta-z_]*[ \t]"
1933 "(size|ptrdiff|wchar)_t";
1935 sed = "/^[ \t]*\\*[ \t]*typedef unsigned int size_t;/N";
1937 sed = "s/^\\([ \t]*\\*[ \t]*typedef unsigned int size_t;\\n"
1938 "[ \t]*\\*\\/\\)/\\1\\\n"
1939 "#ifndef __SIZE_TYPE__\\\n"
1940 "#define __SIZE_TYPE__ long unsigned int\\\n"
1942 "typedef __SIZE_TYPE__ size_t;\\\n/";
1944 sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/i\\\n"
1945 "#ifndef __SIZE_TYPE__\\\n"
1946 "#define __SIZE_TYPE__ long unsigned int\\\n"
1949 sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/"
1950 "typedef __SIZE_TYPE__ size_t/";
1952 sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/i\\\n"
1953 "#ifndef __PTRDIFF_TYPE__\\\n"
1954 "#define __PTRDIFF_TYPE__ long int\\\n"
1957 sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/"
1958 "typedef __PTRDIFF_TYPE__ ptrdiff_t/";
1960 sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/i\\\n"
1961 "#ifndef __WCHAR_TYPE__\\\n"
1962 "#define __WCHAR_TYPE__ int\\\n"
1964 "#ifndef __cplusplus\n";
1966 sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/a\\\n"
1969 sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/"
1970 "typedef __WCHAR_TYPE__ wchar_t/";
1975 * Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
1976 * Also wrap protection around size_t for m88k-sysv3 systems.
1977 * We use a funny name to ensure it follows 'systypes' fix.
1980 hackname = systypes_for_aix;
1981 files = sys/types.h;
1982 select = "typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t";
1983 bypass = "_GCC_SIZE_T";
1985 sed = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/i\\\n"
1986 "#ifndef _GCC_SIZE_T\\\n"
1987 "#define _GCC_SIZE_T\n";
1989 sed = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/a\\\n"
1995 * if the #if says _cplusplus, not the double underscore __cplusplus
1999 hackname = sysv68_string;
2002 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2003 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2004 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2005 sed = "/^extern char$/N";
2006 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2007 sed = "/^\tstrncmp(),$/N";
2008 sed = "s/^\\(\tstrncmp()\\),\\n\\(\tstrlen(),\\)$/\\1;\\\n"
2009 "extern unsigned int\\\n\\2/";
2010 sed = "/^extern int$/N";
2011 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2016 * Fix return type of exit and abort in <stdlib.h>
2017 * Also wrap protection around size_t.
2020 hackname = sysz_stdlib_for_sun;
2023 sed = "s/int\tabort/void\tabort/g";
2024 sed = "s/int\tfree/void\tfree/g";
2025 sed = "s/char[ \t]*\\*[ \t]*calloc/void \\*\tcalloc/g";
2026 sed = "s/char[ \t]*\\*[ \t]*malloc/void \\*\tmalloc/g";
2027 sed = "s/char[ \t]*\\*[ \t]*realloc/void \\*\trealloc/g";
2028 sed = "s/int[ \t][ \t]*exit/void\texit/g";
2030 sed = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/i\\\n"
2031 "#ifndef _GCC_SIZE_T\\\n"
2032 "#define _GCC_SIZE_T\n";
2034 sed = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/a\\\n"
2040 * Fix this Sun file to avoid interfering with stddef.h.
2041 * We use a funny name to ensure it follows 'systypes' fix.
2044 hackname = sysz_stdtypes_for_sun;
2045 files = sys/stdtypes.h;
2046 sed = "/[\t ]size_t.*;/i\\\n"
2047 "#ifndef _GCC_SIZE_T\\\n"
2048 "#define _GCC_SIZE_T\n";
2050 sed = "/[\t ]size_t.*;/a\\\n"
2053 sed = "/[\t ]ptrdiff_t.*;/i\\\n"
2054 "#ifndef _GCC_PTRDIFF_T\\\n"
2055 "#define _GCC_PTRDIFF_T\n";
2057 sed = "/[\t ]ptrdiff_t.*;/a\\\n"
2060 sed = "/[\t ]wchar_t.*;/i\\\n"
2061 "#ifndef _GCC_WCHAR_T\\\n"
2062 "#define _GCC_WCHAR_T\n";
2064 sed = "/[\t ]wchar_t.*;/a\\\n"
2070 * Fix this file to avoid interfering with stddef.h,
2071 * but don't mistakenly match ssize_t present in AIX for the ps/2,
2072 * or typedefs which use (but do not set) size_t.
2075 hackname = tinfo_cplusplus;
2077 sed = "s/[ \t]_cplusplus/ __cplusplus/";
2082 * Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
2085 hackname = ultrix_ansi_compat;
2086 files = ansi_compat.h;
2088 sed = "1i\\\n/* This file intentionally left blank. */\n";
2094 * Ultrix V4.[35] puts the declaration of uname before the definition
2095 * of struct utsname, so the prototype (added by fixproto) causes havoc.
2098 hackname = ultrix_fix_fixproto;
2099 files = sys/utsname.h;
2101 sed = "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n"
2102 "struct utsname;\n";
2107 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2108 * also get rid of bogus inline definitions in HP-UX 8.0
2111 hackname = ultrix_atof_param;
2114 sed = "s@atof(\\([ \t]*char[ \t]*\\*[^)]*\\))@atof(const \\1)@";
2115 sed = "s@inline int abs(int [a-z][a-z]*) {.*}@extern \"C\" int abs(int);@";
2116 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2117 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2118 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2123 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2126 hackname = ultrix_const;
2129 sed = 's@perror( char \*__s );@perror( const char *__s );@';
2130 sed = 's@fputs( char \*__s,@fputs( const char *__s,@';
2131 sed = 's@fopen( char \*__filename, char \*__type );@'
2132 'fopen( const char *__filename, const char *__type );@';
2133 sed = 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@';
2134 sed = 's@fscanf( FILE \*__stream, char \*__format,@'
2135 'fscanf( FILE *__stream, const char *__format,@';
2136 sed = 's@scanf( char \*__format,@scanf( const char *__format,@';
2137 sed = 's@sscanf( char \*__s, char \*__format,@'
2138 'sscanf( const char *__s, const char *__format,@';
2139 sed = 's@popen(char \*, char \*);@popen(const char *, const char *);@';
2140 sed = 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@';
2145 * Check for bad #ifdef line (in Ultrix 4.1)
2148 hackname = ultrix_ifdef;
2149 select = "#ifdef KERNEL";
2151 sed = "s/#ifdef KERNEL/#if defined(KERNEL)/";
2156 * Avoid nested comments on Ultrix 4.3.
2159 hackname = ultrix_nested_cmnt;
2161 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
2166 * Check for superfluous `static' (in Ultrix 4.2)
2167 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2170 hackname = ultrix_static;
2171 files = machine/cpu.h;
2172 select = '#include "r[34]_cpu';
2173 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2174 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2175 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2180 * Fix multiple defines for NULL
2183 hackname = undefine_null;
2184 select = "^#[ \t]*define[ \t]*[ \t]NULL[ \t]";
2185 bypass = "#[ \t]*(ifn|un)def[ \t]*[ \t]NULL($|[ \t])";
2186 sed = "/^#[ \t]*define[ \t][ \t]*NULL[ \t]/i\\\n"
2192 * Fix definitions of macros used by va-i960.h in VxWorks header file.
2195 hackname = va_i960_macro;
2196 files = arch/i960/archI960.h;
2197 select = "__(vsiz|vali|vpad|alignof__)";
2198 sed = "s/__vsiz/__vxvsiz/";
2199 sed = "s/__vali/__vxvali/";
2200 sed = "s/__vpad/__vxvpad/";
2201 sed = "s/__alignof__/__vxalignof__/";
2206 * AIX headers define NULL to be cast to a void pointer,
2207 * which is illegal in ANSI C++.
2210 hackname = void_null;
2220 files = sys/param.h;
2221 files = sys/types.h;
2222 select = "#[ \t]*define[ \t][ \t]*NULL[ \t].*void";
2223 sed = "s/^#[ \t]*define[ \t]*NULL[ \t]*((void[ \t]*\\*)0)"
2229 * Make VxWorks header which is almost gcc ready fully gcc ready.
2232 hackname = vxworks_gcc_problem;
2233 files = types/vxTypesBase.h;
2234 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
2236 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
2239 sed = "/[ \t]size_t/i\\\n"
2240 "#ifndef _GCC_SIZE_T\\\n"
2241 "#define _GCC_SIZE_T\n";
2243 sed = "/[ \t]size_t/a\\\n"
2246 sed = "/[ \t]ptrdiff_t/i\\\n"
2247 "#ifndef _GCC_PTRDIFF_T\\\n"
2248 "#define _GCC_PTRDIFF_T\n";
2250 sed = "/[ \t]ptrdiff_t/a\\\n"
2253 sed = "/[ \t]wchar_t/i\\\n"
2254 "#ifndef _GCC_WCHAR_T\\\n"
2255 "#define _GCC_WCHAR_T\n";
2257 sed = "/[ \t]wchar_t/a\\\n"
2263 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
2266 hackname = vxworks_needs_vxtypes;
2268 select = "uint_t[ \t][ \t]*_clocks_per_sec";
2269 sed = "s/uint_t/unsigned int/";
2274 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2277 hackname = vxworks_needs_vxworks;
2279 test = " -r types/vxTypesOld.h";
2280 test = " -n \"`egrep '#include' $file`\"";
2281 test = " -n \"`egrep ULONG $file`\"";
2282 select = "#[ \t]define[ \t][ \t]*__INCstath";
2284 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
2285 "#include <types/vxTypesOld.h>\n";
2290 * Another bad dependency in VxWorks 5.2 <time.h>.
2293 hackname = vxworks_time;
2295 select = "VOIDFUNCPTR";
2296 test = " -r vxWorks.h";
2297 sed = "/VOIDFUNCPTR/i\\\n"
2298 "#ifndef __gcc_VOIDFUNCPTR_defined\\\n"
2299 "#ifdef __cplusplus\\\n"
2300 "typedef void (*__gcc_VOIDFUNCPTR) (...);\\\n"
2302 "typedef void (*__gcc_VOIDFUNCPTR) ();\\\n"
2304 "#define __gcc_VOIDFUNCPTR_defined\\\n"
2307 sed = "s/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g";
2312 * There are several name conflicts with C++ reserved words in X11 header
2313 * files. These are fixed in some versions, so don't do the fixes if
2314 * we find __cplusplus in the file. These were found on the RS/6000.
2317 hackname = x11_class;
2318 files = X11/ShellP.h;
2319 bypass = __cplusplus;
2320 sed = "/char \\*class;/i\\\n"
2321 "#ifdef __cplusplus\\\n"
2322 "\tchar *c_class;\\\n"
2324 sed = "/char \\*class;/a\\\n"
2330 * class in Xm/BaseClassI.h
2333 hackname = x11_class_usage;
2334 files = Xm/BaseClassI.h;
2335 bypass = "__cplusplus";
2336 sed = "s/ class[)]/ c_class)/g";
2341 * new in Xm/Traversal.h
2345 files = Xm/Traversal.h;
2346 bypass = __cplusplus;
2348 sed = "/Widget\told, new;/i\\\n"
2349 "#ifdef __cplusplus\\\n"
2350 "\tWidget\told, c_new;\\\n"
2353 sed = "/Widget\told, new;/a\\\n"
2356 sed = "s/Widget new,/Widget c_new,/g";
2361 * Incorrect sprintf declaration in X11/Xmu.h
2364 hackname = x11_sprintf;
2366 sed = "s,^extern char \\*\tsprintf();$,#ifndef __STDC__\\\n"
2367 "extern char *\tsprintf();\\\n"
2368 "#endif /* !defined __STDC__ */,";
2372 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2376 * We sure do hope that broken fixes and needed fixes are never
2377 * applied to the same file!! :-}
2381 * Purge some HP-UX 11 files that are only borken after they are "fixed".
2384 hackname = zzz_ki_iface;
2385 files = sys/ki_iface.h;
2386 select = 'These definitions are for HP Internal developers';
2388 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2389 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2395 * Purge some HP-UX 11 files that are only borken after they are "fixed".
2400 select = '11.00 HP-UX LP64';
2402 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2403 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2409 * Purge some HP-UX 11 files that are only borken after they are "fixed".
2412 hackname = zzz_ki_calls;
2413 files = sys/ki_calls.h;
2414 select = 'kthread_create_caller_t';
2416 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2417 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2423 * Purge some HP-UX 11 files that are only borken after they are "fixed".
2426 hackname = zzz_ki_defs;
2427 files = sys/ki_defs.h;
2428 select = 'Kernel Instrumentation Definitions';
2430 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2431 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2437 * This file on SunOS 4 has a very large macro. When the sed loop
2438 * tries pull it in, it overflows the pattern space size of the SunOS
2439 * sed (GNU sed does not have this problem). Since the file does not
2440 * require fixing, we remove it from the fixed directory.
2443 hackname = zzz_bad_fixes;
2444 files = sundev/ipi_error.h;
2445 /* shouldn't there be a select expression here??? */
2447 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2448 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"
2454 * Purge some HP-UX 11 files that are only borken after they are "fixed".
2457 hackname = zzz_time;
2459 select = '11.0 and later representation of ki time';
2461 "echo \"Removing incorrect fix to <$file>\" >&2\n"
2462 "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n"