3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
12 trailer='^/\*EOF\*[/]' \
14 key='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
24 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
27 hackname = AAB_fd_zero_asm_posix_types_h;
28 files = asm/posix_types.h;
29 mach = 'i[34567]86-*-linux*';
33 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
34 * the start, so that if #include_next gets another instance of
35 * the wrapper, this will follow the #include_next chain until
36 * we arrive at the real <asm/posix_types.h>.
38 replace = <<- _EndOfHeader_
39 /* This file fixes a bug in the __FD_ZERO macro
40 for older versions of the Linux kernel. */
41 #ifndef _POSIX_TYPES_H_WRAPPER
43 #include_next <asm/posix_types.h>
45 #if defined(__FD_ZERO) && !defined(__GLIBC__)
47 #define __FD_ZERO(fdsetp) \
50 __asm__ __volatile__("cld ; rep ; stosl" \
51 : "=&c" (__d0), "=&D" (__d1) \
52 : "a" (0), "0" (__FDSET_LONGS), \
53 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
57 #define _POSIX_TYPES_H_WRAPPER
58 #endif /* _POSIX_TYPES_H_WRAPPER */
64 * This fixes __FD_ZERO bug for glibc-1.x
67 hackname = AAB_fd_zero_gnu_types_h;
69 mach = 'i[34567]86-*-linux*';
72 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
73 * the start, so that if #include_next gets another instance of
74 * the wrapper, this will follow the #include_next chain until
75 * we arrive at the real <gnu/types.h>.
77 replace = <<- _EndOfHeader_
78 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
79 #ifndef _TYPES_H_WRAPPER
81 #include_next <gnu/types.h>
83 #if defined(__FD_ZERO) && !defined(__GLIBC__)
85 # define __FD_ZERO(fdsetp) \\
88 __asm__ __volatile__("cld ; rep ; stosl" \\
89 : "=&c" (__d0), "=&D" (__d1) \\
90 : "a" (0), "0" (__FDSET_LONGS), \\
91 "1" ((__fd_set *) (fdsetp)) :"memory"); \\
95 #define _TYPES_H_WRAPPER
96 #endif /* _TYPES_H_WRAPPER */
102 * This fixes __FD_ZERO bug for glibc-2.0.x
105 hackname = AAB_fd_zero_selectbits_h;
106 files = selectbits.h;
107 mach = 'i[34567]86-*-linux*';
110 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
111 * the start, so that if #include_next gets another instance of
112 * the wrapper, this will follow the #include_next chain until
113 * we arrive at the real <selectbits.h>.
115 replace = <<- _EndOfHeader_
116 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
117 #ifndef _SELECTBITS_H_WRAPPER
118 #include <features.h>
119 #include_next <selectbits.h>
121 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
122 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
123 && __GLIBC_MINOR__ == 0
125 #define __FD_ZERO(fdsetp) \\
128 __asm__ __volatile__ ("cld; rep; stosl" \\
129 : "=&c" (__d0), "=&D" (__d1) \\
130 : "a" (0), "0" (sizeof (__fd_set) \\
131 / sizeof (__fd_mask)), \\
132 "1" ((__fd_mask *) (fdsetp)) \\
137 #define _SELECTBITS_H_WRAPPER
138 #endif /* _SELECTBITS_H_WRAPPER */
144 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
145 * the same interface as <stdarg.h>. No idea why they couldn't have just
146 * used the standard header.
149 hackname = AAB_solaris_sys_varargs_h;
150 files = "sys/varargs.h";
151 mach = '*-*-solaris*';
152 replace = <<- _EndOfHeader_
163 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
164 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
165 * many other systems have similar text but correct versions of the file.
166 * To ensure only Sun's is fixed, we grep for a likely unique string.
167 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
170 hackname = AAB_sun_memcpy;
172 select = "/\\*\t@\\(#\\)"
173 "(head/memory.h\t50.1\t "
174 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
176 replace = <<- _EndOfHeader_
177 /* This file was generated by fixincludes */
182 extern void *memccpy();
183 extern void *memchr();
184 extern void *memcpy();
185 extern void *memset();
187 extern char *memccpy();
188 extern char *memchr();
189 extern char *memcpy();
190 extern char *memset();
191 #endif /* __STDC__ */
195 #endif /* __memory_h__ */
201 * Completely replace <sys/varargs.h> with a file that includes gcc's
202 * stdarg.h or varargs.h files as appropriate.
206 hackname = AAB_svr4_no_varargs;
207 files = sys/varargs.h;
208 replace = "/* This file was generated by fixincludes. */\n"
209 "#ifndef _SYS_VARARGS_H\n"
210 "#define _SYS_VARARGS_H\n\n"
213 "#include <stdarg.h>\n"
215 "#include <varargs.h>\n"
218 "#endif /* _SYS_VARARGS_H */\n";
224 * Completely replace <sys/byteorder.h>; with a file that implements gcc's
225 * optimized byteswapping.
228 hackname = AAB_svr4_replace_byteorder;
230 mach = "i[34567]86-*-sysv5*";
231 mach = "i[34567]86-*-sco3.2v5*";
232 mach = "i[34567]86-*-udk*";
233 mach = "i[34567]86-*-solaris2.[0-4]";
234 mach = "powerpcle-*-solaris2.[0-4]";
235 mach = "sparc-*-solaris2.[0-4]";
236 files = sys/byteorder.h;
237 replace = <<- _EndOfHeader_
238 #ifndef _SYS_BYTEORDER_H
239 #define _SYS_BYTEORDER_H
241 /* Functions to convert `short' and `long' quantities from host byte order
242 to (internet) network byte order (i.e. big-endian).
244 Written by Ron Guilmette (rfg@ncd.com).
246 This isn't actually used by GCC. It is installed by fixinc.svr4.
248 For big-endian machines these functions are essentially no-ops.
250 For little-endian machines, we define the functions using specialized
251 asm sequences in cases where doing so yields better code (e.g. i386). */
253 #if !defined (__GNUC__) && !defined (__GNUG__)
254 #error You lose! This file is only useful with GNU compilers.
257 #ifndef __BYTE_ORDER__
258 /* Byte order defines. These are as defined on UnixWare 1.1, but with
259 double underscores added at the front and back. */
260 #define __LITTLE_ENDIAN__ 1234
261 #define __BIG_ENDIAN__ 4321
262 #define __PDP_ENDIAN__ 3412
266 static __inline__ unsigned long htonl (unsigned long);
267 static __inline__ unsigned short htons (unsigned int);
268 static __inline__ unsigned long ntohl (unsigned long);
269 static __inline__ unsigned short ntohs (unsigned int);
270 #endif /* defined (__STDC__) */
272 #if defined (__i386__)
274 #ifndef __BYTE_ORDER__
275 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
278 /* Convert a host long to a network long. */
280 /* We must use a new-style function definition, so that this will also
282 static __inline__ unsigned long
283 htonl (unsigned long __arg)
285 register unsigned long __result;
287 __asm__ ("xchg%B0 %b0,%h0
289 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
293 /* Convert a host short to a network short. */
295 static __inline__ unsigned short
296 htons (unsigned int __arg)
298 register unsigned short __result;
300 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
304 #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
306 #ifndef __BYTE_ORDER__
307 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
310 /* For other little-endian machines, using C code is just as efficient as
311 using assembly code. */
313 /* Convert a host long to a network long. */
315 static __inline__ unsigned long
316 htonl (unsigned long __arg)
318 register unsigned long __result;
320 __result = (__arg >> 24) & 0x000000ff;
321 __result |= (__arg >> 8) & 0x0000ff00;
322 __result |= (__arg << 8) & 0x00ff0000;
323 __result |= (__arg << 24) & 0xff000000;
327 /* Convert a host short to a network short. */
329 static __inline__ unsigned short
330 htons (unsigned int __arg)
332 register unsigned short __result;
334 __result = (__arg << 8) & 0xff00;
335 __result |= (__arg >> 8) & 0x00ff;
339 #else /* must be a big-endian machine */
341 #ifndef __BYTE_ORDER__
342 #define __BYTE_ORDER__ __BIG_ENDIAN__
345 /* Convert a host long to a network long. */
347 static __inline__ unsigned long
348 htonl (unsigned long __arg)
353 /* Convert a host short to a network short. */
355 static __inline__ unsigned short
356 htons (unsigned int __arg)
361 #endif /* big-endian */
363 /* Convert a network long to a host long. */
365 static __inline__ unsigned long
366 ntohl (unsigned long __arg)
368 return htonl (__arg);
371 /* Convert a network short to a host short. */
373 static __inline__ unsigned short
374 ntohs (unsigned int __arg)
376 return htons (__arg);
384 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
387 hackname = AAB_ultrix_ansi_compat;
388 files = ansi_compat.h;
390 replace = "/* This file intentionally left blank. */\n";
395 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
396 * Replace limits.h with a file that includes sys/limits.h.
399 hackname = AAB_ultrix_limits;
401 mach = "*-*-ultrix4.3";
402 replace = <<- _EndOfHeader_
403 #ifndef _LIMITS_INCLUDED
404 #define _LIMITS_INCLUDED
405 #include <sys/limits.h>
406 #endif /* _LIMITS_INCLUDED */
412 * The ULTRIX 4.3 version of memory.h duplicates definitions
413 * present in strings.h. Replace memory.h with a file that includes
414 * strings.h to prevent problems from multiple inclusion.
417 hackname = AAB_ultrix_memory;
419 mach = "*-*-ultrix4.3";
420 replace = <<- _EndOfHeader_
421 #ifndef _MEMORY_INCLUDED
422 #define _MEMORY_INCLUDED
424 #endif /* _MEMORY_INCLUDED */
430 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
431 * Replace string.h link with a file that includes strings.h to prevent
432 * problems from multiple inclusion.
435 hackname = AAB_ultrix_string;
437 mach = "*-*-ultrix4.3";
438 replace = <<- _EndOfHeader_
439 #ifndef _STRING_INCLUDED
440 #define _STRING_INCLUDED
442 #endif /* _STRING_INCLUDED */
448 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
449 * which violates a requirement of ISO C.
452 hackname = aix_pthread;
454 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
457 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
458 "{...init stuff...}";
463 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
464 * in an otherwise harmless (and #ifed out) macro definition
467 hackname = aix_sysmachine;
468 files = sys/machine.h;
472 test_text = "#define FOO \\\n"
473 " bar \\ \n baz \\ \n bat";
478 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
479 * definition of struct rusage, so the prototype added by fixproto fails.
482 hackname = aix_syswait;
484 select = "^extern pid_t wait3\\(\\);\n";
487 c_fix_arg = "struct rusage;\n%0";
488 test_text = "/* bos325, */\n"
489 "extern pid_t wait3();\n"
490 "\t/* pid_t wait3(int *, int, struct rusage *); */";
495 * sys/signal.h on some versions of AIX uses volatile in the typedef of
496 * sig_atomic_t, which causes gcc to generate a warning about duplicate
497 * volatile when a sig_atomic_t variable is declared volatile, as
498 * required by ANSI C.
501 hackname = aix_volatile;
502 files = sys/signal.h;
503 select = "typedef volatile int sig_atomic_t";
505 c_fix_arg = "typedef int sig_atomic_t";
506 test_text = "typedef volatile int sig_atomic_t;";
511 * Fix __assert declaration in assert.h on Alpha OSF/1.
514 hackname = alpha___assert;
516 select = '__assert\(char \*, char \*, int\)';
518 c_fix_arg = "__assert(const char *, const char *, int)";
519 test_text = 'extern void __assert(char *, char *, int);';
524 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
527 hackname = alpha___extern_prefix;
529 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
531 mach = "alpha*-dec-osf5*";
533 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
535 test_text = "# if defined(__DECC)";
540 * Fix assert macro in assert.h on Alpha OSF/1.
541 * The superfluous int cast breaks C++.
544 hackname = alpha_assert;
546 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
548 c_fix_arg = "%1(EX)";
549 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 : __assert(#EX, __FILE__, __LINE__))';
554 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
557 hackname = alpha_getopt;
560 select = 'getopt\(int, char \*\[\], *char \*\)';
562 c_fix_arg = "getopt(int, char *const[], const char *)";
563 test_text = 'extern int getopt(int, char *[], char *);';
568 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
571 hackname = alpha_parens;
573 select = '#ifndef\(__mips64\)';
575 c_fix_arg = "#ifndef __mips64";
576 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
581 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
585 hackname = alpha_sbrk;
587 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
589 c_fix_arg = "void *sbrk(";
590 test_text = "extern char* sbrk(ptrdiff_t increment);";
595 * For C++, avoid any typedef or macro definition of bool,
596 * and use the built in type instead.
597 * HP/UX 10.20 also has it in curses_colr/curses.h.
600 hackname = avoid_bool_define;
602 files = curses_colr/curses.h;
606 select = "#[ \t]*define[ \t]+bool[ \t]";
607 bypass = "__cplusplus";
610 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
611 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
613 test_text = "# define bool\t char \n";
618 hackname = avoid_bool_type;
620 files = curses_colr/curses.h;
624 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
625 bypass = "__cplusplus";
628 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
630 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
635 * For C++, avoid any typedef definition of wchar_t,
636 * and use the built in type instead.
637 * Don't do this for headers that are smart enough to do the right
638 * thing (recent [n]curses.h and Xlib.h).
639 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
640 * and will be broken by the edit.
644 hackname = avoid_wchar_t_type;
646 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
647 bypass = "__cplusplus";
648 bypass = "_LINUX_NLS_H";
649 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
652 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
654 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
659 * Fix #defines under Alpha OSF/1:
660 * The following files contain '#pragma extern_prefix "_FOO"' followed by
661 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
662 * statements is to reduce namespace pollution. While these macros work
663 * properly in most cases, they don't allow you to take a pointer to the
664 * "something" being modified. To get around this limitation, change these
665 * statements to be of the form '#define something _FOOsomething'.
667 * sed ain't egrep, lesson 2463: sed can use self-referential
668 * regular expressions. In the substitute expression below,
669 * "\\1" and "\\2" refer to subexpressions found earlier in the
670 * same match. So, we continue to use sed. "extern_prefix" will
671 * be a rare match anyway...
676 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
694 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
695 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
697 test_text = '#pragma extern_prefix "_FOO"'"\n"
698 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
699 "#define mumble _FOOmumble";
704 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
707 hackname = bad_struct_term;
709 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
711 c_fix_arg = "struct term;";
713 test_text = 'typedef struct term;';
718 * Fix one other error in this file:
719 * a mismatched quote not inside a C comment.
723 files = sundev/vuid_event.h;
726 c_fix_arg = "does not";
728 test_text = "/* doesn't have matched single quotes */";
733 * check for broken assert.h that needs stdio.h
736 hackname = broken_assert_stdio;
739 bypass = "include.*stdio\\.h";
741 c_fix_arg = "#include <stdio.h>\n";
742 test_text = "extern FILE* stderr;";
747 * check for broken assert.h that needs stdlib.h
750 hackname = broken_assert_stdlib;
752 select = 'exit *\(|abort *\(';
753 bypass = "include.*stdlib\\.h";
755 c_fix_arg = "#ifdef __cplusplus\n"
756 "#include <stdlib.h>\n"
758 test_text = "extern void exit ( int );";
763 * Remove `extern double cabs' declarations from math.h.
764 * This conflicts with C99. Discovered on AIX.
765 * SunOS4 has its cabs() declaration followed by a comment which
766 * terminates on the following line.
769 hackname = broken_cabs;
771 select = '^extern[ \t]+double[ \t]+cabs';
775 c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
777 test_text = "#ifdef __STDC__\n"
778 "extern double cabs(struct dbl_hypot);\n"
780 "extern double cabs();\n"
782 "extern double cabs(); /* This is a comment\n"
783 " and it ends here. */";
788 * Various systems derived from BSD4.4 contain a macro definition
789 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
790 * Known to be fixed in FreeBSD 5 system headers.
793 hackname = bsd_stdio_attrs_conflict;
797 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
799 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
800 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
801 'int vfscanf(FILE *, const char *, __builtin_va_list) '
802 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
803 test_text = '#define vfscanf __svfscanf';
808 * Fix various macros used to define ioctl numbers.
809 * The traditional syntax was:
811 * #define _CTRL(n, x) (('n'<<8)+x)
812 * #define TCTRLCFOO _CTRL(T, 1)
814 * but this does not work with the C standard, which disallows macro
815 * expansion inside strings. We have to rewrite it thus:
817 * #define _CTRL(n, x) ((n<<8)+x)
818 * #define TCTRLCFOO _CTRL('T', 1)
820 * The select expressions match too much, but the c_fix code is cautious.
822 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
825 hackname = ctrl_quotes_def;
826 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
827 c_fix = char_macro_def;
831 * This is two tests in order to ensure that the "CTRL(c)" can
832 * be selected in isolation from the multi-arg format
834 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
835 test_text = "#define _CTRL(c) ('c'&037)";
839 hackname = ctrl_quotes_use;
840 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
841 c_fix = char_macro_use;
843 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
848 * sys/mman.h on HP/UX is not C++ ready,
849 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
851 * rpc/types.h on OSF1/2.0 is not C++ ready,
852 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
854 * The problem is the declaration of malloc.
857 hackname = cxx_unready;
860 select = '[^#]+malloc.*;'; /* Catch any form of declaration
861 not within a macro. */
862 bypass = '"C"|__BEGIN_DECLS';
865 c_fix_arg = "#ifdef __cplusplus\n"
868 c_fix_arg = "#ifdef __cplusplus\n"
871 test_text = "extern void* malloc( size_t );";
876 * Fix <c_asm.h> on Digital UNIX V4.0:
877 * It contains a prototype for a DEC C internal asm() function,
878 * clashing with gcc's asm keyword. So protect this with __DECC.
881 hackname = dec_intern_asm;
883 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
884 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
888 " ... asm stuff ...\n"
889 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
894 * Fix typo in <wchar.h> on DJGPP 2.03.
897 hackname = djgpp_wchar_h;
899 select = "__DJ_wint_t";
900 bypass = "sys/djtypes.h";
902 c_fix_arg = "%0\n#include <sys/djtypes.h>";
903 c_fix_arg = "#include <stddef.h>";
904 test_text = "#include <stddef.h>\n"
905 "extern __DJ_wint_t x;\n";
910 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
913 hackname = ecd_cursor;
914 files = "sunwindow/win_lock.h";
915 files = "sunwindow/win_cursor.h";
916 select = 'ecd\.cursor';
918 c_fix_arg = 'ecd_cursor';
920 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
925 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
926 * neither the existence of GCC 3 nor its exact feature set yet break
927 * (by design?) when __GNUC__ is set beyond 2.
930 hackname = freebsd_gcc3_breakage;
933 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
934 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
936 c_fix_arg = '%0 || __GNUC__ >= 3';
937 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
942 * Fix these files to use the types we think they should for
943 * ptrdiff_t, size_t, and wchar_t.
945 * This defines the types in terms of macros predefined by our 'cpp'.
946 * This is supposedly necessary for glibc's handling of these types.
947 * It's probably not necessary for anyone else, but it doesn't hurt.
950 hackname = gnu_types;
951 files = "sys/types.h";
953 files = "sys/stdtypes.h";
957 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
958 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
961 test_text = "typedef long int ptrdiff_t; /* long int */\n"
962 "typedef uint_t size_t; /* uint_t */\n"
963 "typedef ushort_t wchar_t; /* ushort_t */";
968 * Fix HP & Sony's use of "../machine/xxx.h"
969 * to refer to: <machine/xxx.h>
972 hackname = hp_inline;
973 files = sys/spinlock.h;
974 files = machine/machparam.h;
975 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
978 c_fix_arg = "%1<machine/%2.h>";
980 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
983 test_text = ' # include "../machine/mumble.h"';
988 * Check for (...) in C++ code in HP/UX sys/file.h.
991 hackname = hp_sysfile;
993 select = "HPUX_SOURCE";
996 c_fix_arg = "(struct file *, ...)";
997 c_fix_arg = '\(\.\.\.\)';
999 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1004 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1005 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1008 hackname = hpux10_cpp_pow_inline;
1009 files = fixinc-test-limits.h, math.h;
1010 select = <<- END_POW_INLINE
1011 ^# +ifdef +__cplusplus
1013 +inline +double +pow\(double +__d,int +__expon\) +\{
1014 [ ]+return +pow\(__d,\(double\)__expon\);
1025 "# ifdef __cplusplus\n"
1027 " inline double pow(double __d,int __expon) {\n"
1028 "\t return pow(__d,(double)__expon);\n"
1030 ' extern "C"' " {\n"
1036 hackname = hpux11_cpp_pow_inline;
1038 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1039 " +return pow\\(d, \\(double\\)expon\\);\n"
1045 " inline double pow(double d,int expon) {\n"
1046 " return pow(d, (double)expon);\n"
1052 * Fix hpux 10.X missing ctype declarations 1
1055 hackname = hpux10_ctype_declarations1;
1057 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1058 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1060 c_fix_arg = "#ifdef _PROTOTYPES\n"
1061 "extern int __tolower(int);\n"
1062 "extern int __toupper(int);\n"
1063 "#else /* NOT _PROTOTYPES */\n"
1064 "extern int __tolower();\n"
1065 "extern int __toupper();\n"
1066 "#endif /* _PROTOTYPES */\n\n"
1069 test_text = "# define _toupper(__c) __toupper(__c)\n";
1074 * Fix hpux 10.X missing ctype declarations 2
1077 hackname = hpux10_ctype_declarations2;
1079 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1080 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1082 c_fix_arg = "%0\n\n"
1083 "#ifdef _PROTOTYPES\n"
1084 " extern int _isalnum(int);\n"
1085 " extern int _isalpha(int);\n"
1086 " extern int _iscntrl(int);\n"
1087 " extern int _isdigit(int);\n"
1088 " extern int _isgraph(int);\n"
1089 " extern int _islower(int);\n"
1090 " extern int _isprint(int);\n"
1091 " extern int _ispunct(int);\n"
1092 " extern int _isspace(int);\n"
1093 " extern int _isupper(int);\n"
1094 " extern int _isxdigit(int);\n"
1095 "# else /* not _PROTOTYPES */\n"
1096 " extern int _isalnum();\n"
1097 " extern int _isalpha();\n"
1098 " extern int _iscntrl();\n"
1099 " extern int _isdigit();\n"
1100 " extern int _isgraph();\n"
1101 " extern int _islower();\n"
1102 " extern int _isprint();\n"
1103 " extern int _ispunct();\n"
1104 " extern int _isspace();\n"
1105 " extern int _isupper();\n"
1106 " extern int _isxdigit();\n"
1107 "#endif /* _PROTOTYPES */\n";
1109 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1110 " extern unsigned int *__SB_masks;\n";
1115 * Make sure hpux defines abs in header.
1118 hackname = hpux11_abs;
1119 mach = ia64-hp-hpux11*;
1121 select = "ifndef _MATH_INCLUDED";
1123 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1124 // sed = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1125 test_text = "#ifndef _MATH_INCLUDED";
1130 * Keep HP-UX 11 from stomping on C++ math namespace
1131 * with defines for fabsf.
1134 hackname = hpux11_fabsf;
1136 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1137 bypass = "__cplusplus";
1140 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1144 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1150 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1151 * being defined by having it define _hpux_size_t instead.
1154 hackname = hpux11_size_t;
1155 mach = "*-hp-hpux11*";
1156 select = "__size_t";
1159 c_fix_arg = "_hpux_size_t";
1162 "#define __size_t size_t\n"
1163 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1168 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1169 * of UINT32_C has undefined behavior according to ISO/ANSI:
1170 * the arguments to __CONCAT__ are not macro expanded before the
1171 * concatination happens so the trailing ')' in the first argument
1172 * is concatinated with the 'l' in the second argument creating an
1173 * invalid pp token. The behavior of invalid pp tokens is undefined.
1174 * GCC does not handle these invalid tokens the way the HP compiler does.
1175 * This problem will potentially occur anytime macros are used in the
1176 * arguments to __CONCAT__. A general solution to this problem would be to
1177 * insert another layer of macro between __CONCAT__ and its use
1178 * in UINT32_C. An example of this solution can be found in the C standard.
1179 * A more specific solution, the one used here, is to change the UINT32_C
1180 * macro to not used macros in the arguments to __CONCAT__.
1183 hackname = hpux11_uint32_c;
1185 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1186 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1188 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1190 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1191 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1196 * Fix hpux 11.00 broken vsnprintf declaration
1199 hackname = hpux11_vsnprintf;
1201 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1202 'const char \*,) __va__list\);';
1204 c_fix_arg = "%1 __va_list);";
1206 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1212 * get rid of bogus inline definitions in HP-UX 8.0
1215 hackname = hpux8_bogus_inlines;
1218 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1219 "@extern \"C\" int abs(int);@";
1220 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1221 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1222 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1223 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1224 "inline double sqr(double v) { return v**0.5; }";
1229 * Fix hpux broken ctype macros
1232 hackname = hpux_ctype_macros;
1234 select = '((: |\()__SB_masks \? )'
1235 '(__SB_masks\[__(alnum|c)\] & _IS)';
1237 c_fix_arg = "%1(int)%3";
1239 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1240 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1248 hackname = hpux_long_double;
1250 select = "extern[ \t]long_double[ \t]strtold";
1251 bypass = "long_double_t";
1252 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1253 sed = "s/long_double/long double/g";
1255 test_text = "# ifndef _LONG_DOUBLE\n"
1256 "# define _LONG_DOUBLE\n"
1257 " typedef struct {\n"
1258 " unsigned int word1, word2, word3, word4;\n"
1260 "# endif /* _LONG_DOUBLE */\n"
1261 "extern long_double strtold(const char *, char **);\n";
1266 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1269 hackname = hpux_maxint;
1270 files = sys/param.h;
1272 select = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1273 bypass = "^#[ \t]*ifndef[ \t]+MAXINT";
1275 "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1278 c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1279 c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1281 test_text = '#define MAXINT 0x7FFFFFFF';
1286 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1289 hackname = hpux_systime;
1291 select = "^extern struct sigevent;";
1294 c_fix_arg = "struct sigevent;";
1296 test_text = 'extern struct sigevent;';
1301 * Fix return type of abort and free
1304 hackname = int_abort_free_and_exit;
1306 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1309 c_fix_arg = "void\t%1(";
1311 test_text = "extern int abort(int);\n"
1312 "extern int free(void*);\n"
1313 "extern int exit(void*);";
1318 * Fix various macros used to define ioctl numbers.
1319 * The traditional syntax was:
1321 * #define _IO(n, x) (('n'<<8)+x)
1322 * #define TIOCFOO _IO(T, 1)
1324 * but this does not work with the C standard, which disallows macro
1325 * expansion inside strings. We have to rewrite it thus:
1327 * #define _IO(n, x) ((n<<8)+x)
1328 * #define TIOCFOO _IO('T', 1)
1330 * The select expressions match too much, but the c_fix code is cautious.
1332 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1335 hackname = io_quotes_def;
1336 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1337 c_fix = char_macro_def;
1340 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1341 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1342 "#define _IO(x,y) ('x'<<8|y)";
1344 "#define XX_IO(x) ('x'<<8|256)";
1348 hackname = io_quotes_use;
1349 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1351 c_fix = char_macro_use;
1353 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1354 "#define TIOCFOO \\\\\n"
1355 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1360 * Check for missing ';' in struct
1363 hackname = ip_missing_semi;
1364 files = netinet/ip.h;
1366 sed = "/^struct/,/^};/s/}$/};/";
1372 "}; /* mumbled struct */\n";
1377 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1378 * __restrict as restrict iff __c99. This is wrong for C++, which
1379 * needs many C99 features, but only supports __restrict.
1382 hackname = irix___restrict;
1383 files = internal/sgimacros.h;
1384 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1386 mach = "mips-sgi-irix6.5";
1389 "# ifndef __cplusplus\n%2\n# endif";
1391 test_text = "#ifdef __c99\n# define __restrict restrict";
1395 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1396 * that causes the assembly preprocessor to complain about an
1397 * unterminated character constant.
1400 hackname = irix_asm_apostrophe;
1403 select = "^[ \t]*#.*[Ww]e're";
1405 c_fix_arg = "%1 are";
1406 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1407 test_text = "\t# and we're on vacation";
1412 * Non-traditional "const" declaration in Irix's limits.h.
1415 hackname = irix_limits_const;
1416 files = fixinc-test-limits.h, limits.h;
1417 select = "^extern const ";
1419 c_fix_arg = "extern __const ";
1420 test_text = "extern const char limit; /* test limits */";
1425 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
1426 * Various socket function prototypes use different types instead,
1427 * depending on the API in use (BSD, XPG4/5), but the socklen_t
1428 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
1432 hackname = irix_socklen_t;
1433 files = sys/socket.h;
1434 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
1436 mach = "mips-sgi-irix6.5";
1439 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
1440 "typedef int socklen_t;\n"
1443 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
1445 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
1449 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
1450 * some functions that take a va_list as
1451 * taking char *. However, GCC uses void * for va_list, so
1452 * calling vfprintf with a va_list fails in C++. */
1454 hackname = irix_stdio_va_list;
1456 files = internal/stdio_core.h;
1458 select = '(printf\(.*), /\* va_list \*/ char \*';
1460 c_fix_arg = "%1, __gnuc_va_list";
1462 "extern int printf( const char *, /* va_list */ char * );";
1467 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
1468 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
1471 hackname = irix_wcsftime;
1472 files = internal/wchar_core.h;
1473 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
1475 mach = "mips-sgi-irix6.5";
1477 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
1479 test_text = "#if _NO_XOPEN5\n"
1480 "extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
1484 * Fixing ISC fmod declaration
1487 hackname = isc_fmod;
1489 select = 'fmod\(double\)';
1491 c_fix_arg = "fmod(double, double)";
1492 test_text = "extern double fmod(double);";
1497 * On Interactive Unix 2.2, certain traditional Unix definitions
1498 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
1499 * defined, not just if _POSIX_SOURCE is defined. This makes it
1500 * impossible to compile any nontrivial program except with -posix.
1503 hackname = isc_omits_with_stdc;
1508 files = "sys/limits.h";
1509 files = "sys/fcntl.h";
1510 files = "sys/dirent.h";
1512 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1514 c_fix_arg = '!defined(_POSIX_SOURCE)';
1515 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1516 "\nint foo;\n#endif";
1521 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1522 * use / * * / to concatenate tokens.
1525 hackname = kandr_concat;
1526 files = "sparc/asm_linkage.h";
1527 files = "sun3/asm_linkage.h";
1528 files = "sun3x/asm_linkage.h";
1529 files = "sun4/asm_linkage.h";
1530 files = "sun4c/asm_linkage.h";
1531 files = "sun4m/asm_linkage.h";
1532 files = "sun4c/debug/asm_linkage.h";
1533 files = "sun4m/debug/asm_linkage.h";
1534 files = "arm/as_support.h";
1535 files = "arm/mc_type.h";
1536 files = "arm/xcb.h";
1537 files = "dev/chardefmac.h";
1538 files = "dev/ps_irq.h";
1539 files = "dev/screen.h";
1540 files = "dev/scsi.h";
1541 files = "sys/tty.h";
1542 files = "Xm.acorn/XmP.h";
1543 files = bsd43/bsd43_.h;
1547 test_text = "#define __CONCAT__(a,b) a/**/b";
1552 * Fix libc1 _G_va_list definition, used in declarations of several
1553 * more-or-less standard functions, for example vasprintf.
1556 hackname = libc1_G_va_list;
1557 files = _G_config.h;
1558 mach = '*-*-linux*libc1';
1559 select = 'typedef void \* _G_va_list;';
1561 c_fix_arg = "typedef __builtin_va_list _G_va_list;";
1562 test_text = 'typedef void * _G_va_list;';
1567 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1568 * versions > 1. This fix will open up the declaration for all
1569 * versions of GCC and for g++.
1572 hackname = libc1_ifdefd_memx;
1574 /* The string.h result is overwritten by AAB_ultrix_string when doing
1575 "make check" and will fail. Therefore, we add the following kludgery
1576 to insert the test_text into the special testing header. :-} */
1581 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1582 bypass = __cplusplus;
1585 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1586 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1588 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1592 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1593 "#if defined(__STDC__) && __GNUC__ < 2\n"
1594 "/* Copy N bytes of SRC to DEST. */\n"
1595 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1602 * In limits.h, put #ifndefs around things that are supposed to be defined
1603 * in float.h to avoid redefinition errors if float.h is included first.
1604 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1605 * multi line comments and the inserted #endif winds up inside the
1606 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1607 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1608 * are there, and we do not add them ourselves.
1610 * QNX Software Systems also guards the defines, but doesn't define
1611 * FLT_MIN. Therefore, bypass the fix for *either* guarded FLT_MIN
1612 * or guarded FLT_MAX.
1615 hackname = limits_ifndefs;
1616 files = "sys/limits.h";
1618 select = "^[ \t]*#[ \t]*define[ \t]+"
1619 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1620 bypass = "ifndef[ \t]+FLT_(MIN|MAX)";
1623 c_fix_arg = "#ifndef %1\n%0\n#endif";
1624 /* Second arg is select expression */
1625 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1630 * Delete the '#define void int' line from curses.h on Lynx
1633 hackname = lynx_void_int;
1635 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1638 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1643 * Fix fcntl prototype in fcntl.h on LynxOS.
1646 hackname = lynxos_fcntl_proto;
1648 select = "fcntl[ \t]*" '\(int, int, int\)';
1650 c_fix_arg = '%1...)';
1651 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1652 test_text = "extern int fcntl(int, int, int);";
1657 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1659 * On NetBSD, machine is a symbolic link to an architecture specific
1660 * directory name, so we can't match a specific file name here.
1663 hackname = machine_ansi_h_va_list;
1664 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1665 bypass = '__builtin_va_list';
1668 c_fix_arg = "%1__builtin_va_list";
1669 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1671 test_text = " # define _BSD_VA_LIST_\tchar**";
1676 * Fix non-ansi machine name defines
1679 hackname = machine_name;
1680 c_test = machine_name;
1681 c_fix = machine_name;
1683 test_text = "/* MACH_DIFF: */\n"
1684 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1685 "\n/* no uniform test, so be careful :-) */";
1690 * Some math.h files define struct exception (it's in the System V
1691 * Interface Definition), which conflicts with
1692 * the class exception defined in the C++ file std/stdexcept.h. We
1693 * redefine it to __math_exception. This is not a great fix, but I
1694 * haven't been able to think of anything better.
1695 * Note that we have to put the #ifdef/#endif blocks at beginning
1696 * and end of file, because fixproto runs after us and may insert
1697 * additional references to struct exception.
1700 hackname = math_exception;
1702 select = "struct exception";
1703 bypass = '__cplusplus';
1706 c_fix_arg = "#ifdef __cplusplus\n"
1707 "#define exception __math_exception\n"
1710 c_fix_arg = "#ifdef __cplusplus\n"
1711 "#undef exception\n"
1714 test_text = "typedef struct exception t_math_exception;";
1719 * This looks pretty broken to me. ``dbl_max_def'' will contain
1720 * "define DBL_MAX " at the start, when what we really want is just
1721 * the value portion. Can't figure out how to write a test case
1722 * for this either :-(
1725 hackname = math_huge_val_from_dbl_max;
1729 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1730 * in math.h, this fix applies.
1732 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1733 bypass = "define[ \t]+DBL_MAX";
1737 * See if we have a definition for DBL_MAX in float.h.
1738 * If we do, we will replace the one in math.h with that one.
1741 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1742 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1744 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1745 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1746 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1751 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1752 "#define HUGE_VAL DBL_MAX";
1757 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1760 hackname = math_huge_val_ifndef;
1762 files = math/math.h;
1763 select = "define[ \t]+HUGE_VAL";
1766 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1767 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1769 test_text = "# define\tHUGE_VAL 3.4e+40";
1777 hackname = nested_auth_des;
1779 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1781 c_fix_arg = "%1*/ /*";
1782 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1787 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1790 hackname = nested_motorola;
1791 mach = "m68k-motorola-sysv*";
1792 files = sys/limits.h;
1794 select = "max # bytes atomic in write|error value returned by Math lib";
1796 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1797 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1798 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1799 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1802 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1804 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1809 * Fixing nested comments in ISC <sys/limits.h>
1812 hackname = nested_sys_limits;
1813 files = sys/limits.h;
1815 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1816 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1817 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1818 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1823 * NetBSD has a semicolon after the ending '}' for some extern "C".
1826 hackname = netbsd_extra_semicolon;
1828 files = sys/cdefs.h;
1829 select = "#define[ \t]*__END_DECLS[ \t]*};";
1832 c_fix_arg = "#define __END_DECLS }";
1834 test_text = "#define __END_DECLS };";
1839 * NeXT 3.2 adds const prefix to some math functions.
1840 * These conflict with the built-in functions.
1843 hackname = next_math_prefix;
1844 files = ansi/math.h;
1845 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1848 c_fix_arg = "extern double %1(";
1849 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1851 test_text = "extern\tdouble\t__const__\tmumble();";
1856 * NeXT 3.2 uses the word "template" as a parameter for some
1857 * functions. GCC reports an invalid use of a reserved key word
1858 * with the built-in functions.
1861 hackname = next_template;
1863 select = "[ \t]template\\)";
1867 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1868 test_text = "extern mumble( char * template); /* fix */";
1873 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1874 * function prototypes. That conflicts with the built-in functions.
1877 hackname = next_volitile;
1878 files = ansi/stdlib.h;
1879 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1882 c_fix_arg = "extern void %1(";
1883 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1885 test_text = "extern\tvolatile\tvoid\tabort();";
1890 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1891 * Note that version 3 of the NeXT system has wait.h in a different directory,
1892 * so that this code won't do anything. But wait.h in version 3 has a
1893 * conditional, so it doesn't need this fix. So everything is okay.
1896 hackname = next_wait_union;
1899 select = 'wait\(union wait';
1901 c_fix_arg = "wait(void";
1902 test_text = "extern pid_d wait(union wait*);";
1907 * a missing semi-colon at the end of the nodeent structure definition.
1910 hackname = nodeent_syntax;
1911 files = netdnet/dnetdb.h;
1912 select = "char[ \t]*\\*na_addr[ \t]*$";
1915 test_text = "char *na_addr\t";
1920 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1921 * defining regex.h related types. This causes libg++ build and usage
1922 * failures. Fixing this correctly requires checking and modifying 3 files.
1925 hackname = osf_namespace_a;
1926 files = reg_types.h;
1927 files = sys/lc_core.h;
1928 test = " -r reg_types.h";
1929 test = " -r sys/lc_core.h";
1930 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1931 test = " -z \"`grep __regex_t regex.h`\"";
1935 c_fix_arg = "reg(ex|off|match)_t";
1937 test_text = "`touch sys/lc_core.h`"
1938 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1939 "extern regex_t re;\n"
1940 "extern regoff_t ro;\n"
1941 "extern regmatch_t rm;\n";
1945 hackname = osf_namespace_c;
1947 test = " -r reg_types.h";
1948 test = " -r sys/lc_core.h";
1949 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1950 test = " -z \"`grep __regex_t regex.h`\"";
1952 select = "#include <reg_types\.h>.*";
1955 "typedef __regex_t\tregex_t;\n"
1956 "typedef __regoff_t\tregoff_t;\n"
1957 "typedef __regmatch_t\tregmatch_t;";
1959 test_text = "#include <reg_types.h>";
1964 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1965 * The original ones fail if uninitialized externs are not common.
1966 * This is the default for all ANSI standard C++ compilers.
1969 hackname = pthread_page_size;
1971 select = "^int __page_size";
1973 c_fix_arg = "extern %0";
1974 test_text = "int __page_size;";
1979 * Fix return type of fread and fwrite on sysV68
1982 hackname = read_ret_type;
1984 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1986 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1987 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1989 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1994 * function class(double x) conflicts with C++ keyword on rs/6000
1997 hackname = rs6000_double;
1999 select = '[^a-zA-Z_]class\(';
2002 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2003 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2005 test_text = "extern int class();";
2010 * Wrong fchmod prototype on RS/6000.
2013 hackname = rs6000_fchmod;
2015 select = 'fchmod\(char \*';
2017 c_fix_arg = "fchmod(int";
2018 test_text = "extern int fchmod(char *, mode_t);";
2023 * parameters conflict with C++ new on rs/6000
2026 hackname = rs6000_param;
2030 select = 'rename\(const char \*old, const char \*new\)';
2032 c_fix_arg = 'rename(const char *_old, const char *_new)';
2034 test_text = 'extern int rename(const char *old, const char *new);';
2039 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2040 * __builtin_generic. We fix that usage to use the GCC equivalent.
2041 * It also has a plethora of inline functions that conflict with libstdc++.
2044 hackname = sco_math;
2046 files = ansi/math.h;
2047 files = posix/math.h;
2048 files = xpg4/math.h;
2049 files = xpg4v2/math.h;
2050 files = xpg4plus/math.h;
2051 files = ods_30_compat/math.h;
2052 files = oldstyle/math.h;
2053 select = "inline double abs";
2054 sed = "/#define.*__fp_class(a) \\\\/i\\\n"
2055 "#ifndef __GNUC__\n";
2057 "/.*__builtin_generic/a\\\n"
2059 "#define __fp_class(a) \\\\\\\n"
2060 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
2061 " __fpclassifyl(a), \\\\\\\n"
2062 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
2063 " __fpclassifyf(a),__fpclassify(a)))\\\n"
2066 sed = "/extern \"C\\+\\+\"/N;"
2067 "/inline double abs/i\\\n"
2068 "#ifndef __GNUC__\n";
2069 sed = "/inline long double trunc/N;"
2070 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
2071 "#endif /* ! __GNUC__ */";
2074 "#define __fp_class(a) \\\\\n"
2075 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
2081 * On SCO OpenServer prior to 5.0.7UP1, <sys/regset.h> and <ieeefp.h>
2082 * have a clash on struct _fpstate and struct fpstate.
2085 hackname = sco_regset;
2086 files = sys/regset.h;
2087 mach = "*-*-sco3.2v5*";
2088 select = "(struct[ \t]+.*)fpstate";
2090 c_fix_arg = "%1rsfpstate";
2094 " struct\tfpstate\n"
2100 " struct _fpstate\n"
2109 * The static functions lstat() and fchmod() in <sys/stat.h>
2110 * cause G++ grief since they're not wrapped in "if __cplusplus".
2112 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
2113 * tiny static wrappers that aren't C++ safe.
2116 hackname = sco_static_func;
2118 mach = "i?86-*-sco3.2*";
2119 select = "^static int";
2121 sed = "/^static int/i\\\n"
2122 "#if __cplusplus\\\n"
2123 "extern \"C\" {\\\n"
2124 "#endif /* __cplusplus */";
2127 "#if __cplusplus\\\n"
2129 "#endif /* __cplusplus */";
2133 "static int\tstat(const char *__f, struct stat *__p) {\n"
2134 "\treturn __stat32(__f, __p);\n"
2135 "}\n\n# else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n"
2137 "static int\tstat(__f, __p)\n"
2139 "\tstruct stat *__p;\n"
2141 "\treturn __stat32(__f, __p);\n"
2148 * Fix prototype declaration of utime in sys/times.h.
2149 * In 3.2v4.0 the const is missing.
2152 hackname = sco_utime;
2153 files = sys/times.h;
2154 mach = "i?86-*-sco3.2v4*";
2156 select = '\(const char \*, struct utimbuf \*\);';
2158 c_fix_arg = '(const char *, const struct utimbuf *);';
2160 test_text = "extern int utime(const char *, struct utimbuf *);";
2165 * Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
2166 * incorrectly, so we replace them with versions that correspond to
2167 * the definition. We also explicitly name this fix "1" and the next
2168 * fix "2" because this one does not deal with the last field. This
2169 * fix needs to run before the next.
2172 hackname = solaris_mutex_init_1;
2173 select = '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI";
2175 sed = "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n"
2176 "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/";
2178 '#ident "@(#)pthread.h 1.16 97/05/05 SMI"'"\n"
2179 "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n"
2180 "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n";
2185 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2186 * "0" for the last field of the pthread_mutex_t structure, which is
2187 * of type upad64_t, which itself is typedef'd to int64_t, but with
2188 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2189 * initializer to "{0}" instead
2192 hackname = solaris_mutex_init_2;
2193 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2196 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2201 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+\\{.*)"
2202 ",[ \t]*0\\}" "(|[ \t].*)$";
2204 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
2205 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
2206 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
2207 "#define PTHREAD_RWLOCK_INITIALIZER\t"
2208 "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
2213 * Solaris 2.5.1 and 2.6 use an outdated prototype for send & recv
2214 * in sys/socket.h. This is corrected in Solaris 7 and up.
2217 hackname = solaris_socket;
2218 files = sys/socket.h;
2219 select = '@\(#\)socket.h' "[ \t]+1.[123][0-9][ \t]+9[567]/[0-9/]+ SMI";
2221 c_fix_arg = "extern int %1(int, %2void *, int, int);";
2222 c_fix_arg = '^extern int (recv|send)\(int,'
2226 test_text = '#ident "@(#)socket.h 1.30 97/01/20 SMI"'"\n"
2227 "extern int recv(int, char *, int, int);\n"
2228 "extern int send(int, const char *, int, int);";
2233 * Solaris 2.8 has what appears to be some gross workaround for
2234 * some old version of their c++ compiler. G++ doesn't want it
2235 * either, but doesn't want to be tied to SunPRO version numbers.
2238 hackname = solaris_stdio_tag;
2239 files = stdio_tag.h;
2241 select = '__cplusplus < 54321L';
2242 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
2244 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
2249 * Sun Solaris 2.5.1 doesn't define 'getpagesize' in <unistd.h>, as is done
2250 * on Solaris 2.6 and up.
2253 hackname = solaris_unistd;
2255 select = '@\(#\)unistd.h' "[ \t]+1.3[0-9][ \t]+9[567]/[0-9/]+ SMI";
2256 bypass = "getpagesize";
2258 c_fix_arg = "extern int getpagesize();\n%0";
2259 c_fix_arg = '^extern (pid_t|int) getpgid\(.*\);';
2260 test_text = '#ident "@(#)unistd.h 1.33 95/08/28 SMI"'"\n"
2261 "extern pid_t getpgid(pid_t);\n"
2262 "extern int getpgid();";
2267 * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h>
2268 * functions, breaking their prototypes if that file is included afterwards.
2269 * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6
2273 hackname = solaris_widec;
2275 mach = '*-*-solaris2.[0-5]*';
2276 bypass = "include.*wchar\\.h";
2277 select = "#include <euc.h>";
2279 c_fix_arg = "%0\n#include <wchar.h>";
2280 test_text = "#include <euc.h>";
2285 * Add a `static' declaration of `getrnge' into <regexp.h>.
2287 * Don't do this if there is already a `static void getrnge' declaration
2288 * present, since this would cause a redeclaration error. Solaris 2.x has
2289 * such a declaration.
2293 hackname = static_getrnge;
2295 bypass = "static void getrnge";
2296 sed = "/^static int[ \t]*size;/c\\\n"
2297 "static int size ;\\\n\\\n"
2298 "static int getrnge ();";
2304 * a missing semi-colon at the end of the statsswtch structure definition.
2307 hackname = statsswtch;
2308 files = rpcsvc/rstat.h;
2309 select = "boottime$";
2311 c_fix_arg = "boottime;";
2312 test_text = "struct statswtch {\n int boottime\n};";
2317 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2318 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2322 hackname = stdio_stdarg_h;
2324 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2328 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2335 * Don't use or define the name va_list in stdio.h.
2336 * This is for ANSI and also to interoperate properly with gcc's
2337 * varargs.h. Note _BSD_VA_LIST_ is dealt with elsewhere. The
2338 * presence of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken
2339 * to indicate that the header knows what it's doing -- under SUSv2,
2340 * stdio.h is required to define va_list, and we shouldn't break that.
2341 * On IRIX 6.5, internal/wchar_core.h used to get its definition of
2342 * va_list from stdio.h. Since this doesn't happen any longer, use
2343 * __gnuc_va_list there, too.
2346 hackname = stdio_va_list;
2348 files = internal/stdio_core.h;
2349 files = internal/wchar_core.h;
2350 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
2353 * Use __gnuc_va_list in arg types in place of va_list.
2354 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
2355 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
2356 * trailing parentheses and semicolon save all other systems from this.
2357 * Define __not_va_list__ (something harmless and unused)
2358 * instead of va_list.
2359 * Don't claim to have defined va_list.
2361 sed = "s@ va_list @ __gnuc_va_list @\n"
2362 "s@ va_list)@ __gnuc_va_list)@\n"
2363 "s@va_list _ap;@__gnuc_va_list _ap;@\n"
2364 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
2365 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2366 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
2367 "s@ va_list@ __not_va_list__@\n"
2368 "s@\\*va_list@*__not_va_list__@\n"
2369 "s@ __va_list)@ __gnuc_va_list)@\n"
2370 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2371 "@typedef \\1 __not_va_list__;@\n"
2372 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
2373 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2374 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2375 "s@VA_LIST@DUMMY_VA_LIST@\n"
2376 "s@_Va_LIST@_VA_LIST@";
2377 test_text = "extern void mumble( va_list);";
2382 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
2383 * is "!defined( __STRICT_ANSI__ )"
2386 hackname = strict_ansi_not;
2387 select = "^([ \t]*#[ \t]*if.*)"
2389 "|__STDC__[ \t]*==[ \t]*0"
2390 "|__STDC__[ \t]*!=[ \t]*1"
2391 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
2392 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
2393 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
2394 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
2395 is not defined by GCC, so it is safe. */
2396 bypass = '__SCO_VERSION__.*__STDC__ != 1';
2397 c_test = stdc_0_in_system_headers;
2400 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2402 test_text = "#if !__STDC__ \n"
2403 "#if __STDC__ == 0\n"
2404 "#if __STDC__ != 1\n"
2405 "#if __STDC__ - 0 == 0"
2406 "/* not std C */\nint foo;\n"
2407 "\n#end-end-end-end-if :-)";
2412 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
2415 hackname = strict_ansi_not_ctd;
2416 files = math.h, limits.h, stdio.h, signal.h,
2417 stdlib.h, sys/signal.h, time.h;
2419 * Starting at the beginning of a line, skip white space and
2420 * a leading "(" or "&&" or "||". One of those must be found.
2421 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
2422 * expression. If these are nested, then they must accumulate
2423 * because we won't match any closing parentheses. Finally,
2424 * after skipping over all that, we must then match our suspect
2425 * phrase: "__STDC__-0==0" with or without white space.
2427 select = "^([ \t]*" '(\(|&&|\|\|)'
2428 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
2430 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
2431 c_test = stdc_0_in_system_headers;
2434 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2436 test_text = "#if 1 && \\\\\n"
2437 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
2438 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
2439 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
2445 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2446 * is "defined( __STRICT_ANSI__ )"
2449 hackname = strict_ansi_only;
2450 select = "^([ \t]*#[ \t]*if.*)"
2451 "(__STDC__[ \t]*!=[ \t]*0"
2452 "|__STDC__[ \t]*==[ \t]*1"
2453 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2454 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
2455 c_test = stdc_0_in_system_headers;
2458 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
2460 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2465 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2466 * in prototype without previous definition.
2469 hackname = struct_file;
2471 select = '^.*xdrstdio_create.*struct __file_s';
2473 c_fix_arg = "struct __file_s;\n%0";
2474 test_text = "extern void xdrstdio_create( struct __file_s* );";
2479 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2480 * in prototype without previous definition.
2482 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
2483 * function, and does define it.
2486 hackname = struct_sockaddr;
2488 select = "^.*authdes_create.*struct sockaddr[^_]";
2489 bypass = "<sys/socket\.h>";
2490 bypass = "struct sockaddr;\n";
2492 c_fix_arg = "struct sockaddr;\n%0";
2493 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2498 * Apply fix this to all OSs since this problem seems to effect
2499 * more than just SunOS.
2502 hackname = sun_auth_proto;
2508 * Select those files containing '(*name)()'.
2510 select = '\(\*[a-z][a-z_]*\)\(\)';
2513 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2514 "#else\n%1();%2\n#endif";
2515 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2519 " int (*name)(); /* C++ bad */\n"
2525 * Fix bogus #ifdef on SunOS 4.1.
2528 hackname = sun_bogus_ifdef;
2529 files = "hsfs/hsfs_spec.h";
2530 files = "hsfs/iso_spec.h";
2531 select = '#ifdef(.*\|\|.*)';
2533 c_fix_arg = "#if%1";
2535 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2540 * Fix the CAT macro in SunOS memvar.h.
2543 hackname = sun_catmacro;
2544 files = pixrect/memvar.h;
2545 select = "^#define[ \t]+CAT\\(a,b\\).*";
2550 "# define CAT(a,b) a##b\n"
2551 "#else\n%0\n#endif";
2554 "#define CAT(a,b)\ta/**/b";
2559 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2560 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2563 hackname = sun_malloc;
2566 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2567 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2568 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2569 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2570 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2573 "typedef char *\tmalloc_t;\n"
2575 "char*\tmalloc();\n"
2576 "char*\tcalloc();\n"
2577 "char*\trealloc();";
2582 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2585 hackname = sun_rusers_semi;
2586 files = rpcsvc/rusers.h;
2588 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2589 test_text = "struct mumble\n int _cnt\n};";
2594 * signal.h on SunOS defines signal using (),
2595 * which causes trouble when compiling with g++ -pedantic.
2598 hackname = sun_signal;
2599 files = sys/signal.h;
2601 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2605 "#ifdef __cplusplus\n"
2606 "void\t(*signal(...))(...);\n"
2607 "#else\n%0\n#endif";
2609 test_text = "void\t(*signal())();";
2614 * math.h on SunOS 4 puts the declaration of matherr before the definition
2615 * of struct exception, so the prototype (added by fixproto) causes havoc.
2618 hackname = sunos_matherr_decl;
2621 /* If matherr has a prototype already, the header needs no fix. */
2622 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2626 c_fix_arg = "struct exception;\n";
2628 test_text = "extern int matherr();";
2633 * Correct the return type for strlen in strings.h in SunOS 4.
2636 hackname = sunos_strlen;
2638 select = "int[ \t]*strlen\\(\\);(.*)";
2640 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2641 test_text = " int\tstrlen(); /* string length */";
2646 * Solaris math.h and floatingpoint.h define __P without protection,
2647 * which conflicts with the fixproto definition. The fixproto
2648 * definition and the Solaris definition are used the same way.
2653 files = floatingpoint.h;
2654 select = "^#define[ \t]+__P.*";
2656 c_fix_arg = "#ifndef __P\n%0\n#endif";
2658 test_text = "#define __P(a) a";
2663 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2664 * that is visible to any ANSI compiler using this include. Simply
2665 * delete the lines that #define some string functions to internal forms.
2668 hackname = svr4_disable_opt;
2670 select = '#define.*__std_hdr_';
2671 sed = '/#define.*__std_hdr_/d';
2672 test_text = "#define strlen __std_hdr_strlen\n";
2677 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2678 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2679 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2683 hackname = svr4_endian;
2684 files = sys/endian.h;
2687 * since we emit our own sys/byteorder.h,
2688 * this fix can never be applied to that file.
2690 files = sys/byteorder.h;
2692 bypass = '__GNUC__';
2694 sed = "/#\tifdef\t__STDC__/i\\\n"
2695 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2697 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2699 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2700 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2706 * Remove useless extern keyword from struct forward declarations
2707 * in <sys/stream.h> and <sys/strsubr.h>
2711 hackname = svr4_extern_struct;
2712 files = sys/stream.h;
2713 files = sys/strsubr.h;
2714 select = 'extern struct [a-z_]*;';
2715 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2720 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2721 * systems the file <ftw.h> contains extern declarations of these
2722 * functions followed by explicitly `static' definitions of these
2723 * functions... and that's not allowed according to ANSI C. (Note
2724 * however that on Solaris, this header file glitch has been pre-fixed by
2725 * Sun. In the Solaris version of <ftw.h> there are no static
2726 * definitions of any function so we don't need to do any of this stuff
2732 hackname = svr4_ftw;
2734 select = '^extern int ftw\(const';
2736 sed = '/^extern int ftw(const/i' "\\\n"
2737 "#if !defined(_STYPES)\\\n"
2742 sed = 's/extern \(int ftw(const.*\)$/\1/';
2743 sed = "/^extern int nftw/i\\\n"
2744 "#if defined(_STYPES)\\\n"
2749 sed = 's/extern \(int nftw.*\)$/\1/';
2750 sed = "/^extern int ftw(),/c\\\n"
2751 "#if !defined(_STYPES)\\\n"
2757 "#if defined(_STYPES)\\\n"
2769 * Fix broken decl of getcwd present on some svr4 systems.
2772 hackname = svr4_getcwd;
2775 files = prototypes.h;
2776 select = 'getcwd\(char \*, int\)';
2779 c_fix_arg = "getcwd(char *, size_t)";
2781 test_text = "extern char* getcwd(char *, int);";
2790 hackname = svr4_kernel;
2791 files = fs/rfs/rf_cache.h;
2795 files = sys/getpages.h;
2797 files = sys/cmn_err.h;
2798 files = sys/kdebugger.h;
2802 c_fix_arg = "#ifdef _KERNEL\n";
2803 c_fix_arg = "#endif /* _KERNEL */\n";
2809 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2810 * tend to conflict with the compiler's own definition of this symbol. (We
2811 * will use the compiler's definition.)
2812 * Likewise __sparc, for Solaris, and __i860, and a few others
2813 * (guessing it is necessary for all of them).
2817 hackname = svr4_mach_defines;
2819 select = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
2820 sed = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
2826 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2827 * They are declared as non-static then immediately redeclared as static.
2831 hackname = svr4_mkdev;
2832 files = sys/mkdev.h;
2835 sed = "/^dev_t makedev(/s/^/static /";
2836 sed = "/^major_t major(/s/^/static /";
2837 sed = "/^minor_t minor(/s/^/static /";
2843 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2844 * Also fix types of array initializers.
2848 hackname = svr4_netcspace;
2849 files = sys/netcspace.h;
2850 select = 'NC_NPI_RAW';
2851 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2852 sed = 's/NC_/(unsigned long) NC_/';
2857 * Fix reference to NMSZ in <sys/adv.h>.
2861 hackname = svr4_nmsz;
2863 select = '\[NMSZ\]';
2864 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2870 * Fix broken decl of profil present on some svr4 systems.
2873 hackname = svr4_profil;
2878 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2880 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2883 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2888 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2892 hackname = svr4_proto_form;
2894 select = 'const extern';
2896 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2901 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2906 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2911 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2916 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2917 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2918 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2919 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2920 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2921 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2926 * Add a prototyped declaration of mmap to <sys/mman.h>.
2930 hackname = svr4_proto_mmap;
2932 select = '^extern caddr_t mmap();$';
2933 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2934 "#ifdef __STDC__\\\n"
2935 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2936 "#else /* !defined(__STDC__) */\\\n"
2937 "extern caddr_t mmap ();\\\n"
2938 "#endif /* !defined(__STDC__) */\\\n";
2943 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2947 hackname = svr4_sigaction;
2948 files = sys/signal.h;
2949 sed = "/^struct sigaction {/i\\\n"
2950 "#define _SIGACTION_";
2951 sed = 's/(void *(\*)())/(void (*)(int))/';
2956 * Put storage class at start of decl, to avoid warning.
2960 hackname = svr4_storage_class;
2961 files = rpc/types.h;
2962 select = 'const extern';
2963 sed = 's/const extern/extern const/g';
2969 * Like svr4_mach_defines, but with newfangled syntax.
2970 * Source lines are of #define __i386 #machine(i386). Delete them.
2974 hackname = svr5_mach_defines;
2976 select = "#define[ \t]*__i386.*\(i386\)";
2977 sed = "/#define[ \t]*__i386.*/d";
2983 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2984 * in string.h on sysV68
2985 * Correct the return type for strlen in string.h on Lynx.
2986 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2987 * Add missing const for strdup on OSF/1 V3.0.
2988 * On sysV88 layout is slightly different.
2991 hackname = sysv68_string;
2995 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2996 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2997 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2999 sed = "/^extern char$/N";
3000 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3002 sed = "/^extern int$/N";
3003 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3005 sed = "/^\tstrncmp(),$/N";
3006 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3007 '\1;' "\\\nextern unsigned int\\\n\\2/";
3010 "extern int strlen();\n"
3012 "extern int ffs(long);\n"
3025 "\tstrlen(), strspn();";
3030 * Fix return type of calloc, malloc, realloc, bsearch and exit
3033 hackname = sysz_stdlib_for_sun;
3036 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3038 c_fix_arg = "void *\t%1(";
3041 "extern char*\tcalloc(size_t);\n"
3042 "extern char*\tmalloc(size_t);\n"
3043 "extern char*\trealloc(void*,size_t);\n"
3044 "extern char*\tbsearch(void*,size_t,size_t);\n";
3049 * __thread is now a keyword.
3052 hackname = thread_keyword;
3053 files = "pthread.h";
3054 files = "bits/sigthread.h";
3055 select = "([* ])__thread([,)])";
3057 c_fix_arg = "%1__thr%2";
3060 "extern int pthread_create (pthread_t *__restrict __thread,\n"
3061 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
3062 "extern int pthread_cancel (pthread_t __thread);";
3066 * if the #if says _cplusplus, not the double underscore __cplusplus
3070 hackname = tinfo_cplusplus;
3072 select = "[ \t]_cplusplus";
3075 c_fix_arg = " __cplusplus";
3076 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
3081 * function parameter to atexit is missing "void" on VAX Ultrix 4.3.
3084 hackname = ultrix_atexit_param;
3086 select = 'atexit\(.*\(\)';
3089 c_fix_arg = "atexit( void (*__func)( void )";
3091 test_text = "int atexit( void (*__func)() );\n";
3096 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
3099 hackname = ultrix_atof_param;
3101 select = "atof\\([ \t]*char";
3104 c_fix_arg = "atof(const char";
3106 test_text = "extern double atof( char *__nptr);\n";
3111 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3114 hackname = ultrix_const;
3116 select = 'perror\( char \*';
3119 c_fix_arg = "%1 const %3 *__";
3120 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3121 "[ \t]+(char|void) \\*__";
3124 "extern void perror( char *__s );\n"
3125 "extern int fputs( char *__s, FILE *);\n"
3126 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3127 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3128 "extern int scanf( char *__format, ...);\n";
3133 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3136 hackname = ultrix_const2;
3139 select = '\*fopen\( char \*';
3141 c_fix_arg = "%1( const char *%3, const char *";
3142 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3143 "[ \t]*char[ \t]*\\*([^,]*),"
3144 "[ \t]*char[ \t]*\\*[ \t]*";
3147 "extern FILE *fopen( char *__filename, char *__type );\n"
3148 "extern int sscanf( char *__s, char *__format, ...);\n"
3149 "extern FILE *popen(char *, char *);\n"
3150 "extern char *tempnam(char*,char*);\n";
3155 * Ultrix V4.[35] puts the declaration of uname before the definition
3156 * of struct utsname, so the prototype (added by fixproto) causes havoc.
3159 hackname = ultrix_fix_fixproto;
3160 files = sys/utsname.h;
3164 c_fix_arg = "struct utsname;\n%0";
3165 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
3168 "/* ULTRIX's uname */\nextern\tint\tuname();";
3173 * Check for bad #ifdef line (in Ultrix 4.1)
3176 hackname = ultrix_ifdef;
3177 select = "^#ifdef KERNEL[ \t]+&&";
3181 c_fix_arg = "#if defined(KERNEL) &&";
3184 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
3189 * Strip "|| CC$gfloat" from Ultrix math headers.
3192 hackname = ultrix_math_ifdef;
3193 files = sys/limits.h;
3196 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
3200 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
3205 * Avoid nested comments on Ultrix 4.3.
3208 hackname = ultrix_nested_ioctl;
3209 files = sys/ioctl.h;
3210 select = "^/\\* #define SIOCSCREEN";
3211 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
3213 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
3214 "/* screend, net/gw_screen.h */\n";
3219 hackname = ultrix_nested_svc;
3221 select = "^ \\*[ \t]*int protocol; */\\*";
3222 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
3224 " *\tint protocol; /* like TCP or UDP\n";
3229 * Add missing prototype for lstat and define for S_ISLNK
3230 * in Ultrix V4.3 sys/stat.h.
3233 hackname = ultrix_stat;
3235 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
3236 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
3238 "/* macro to test for symbolic link */\\\n"
3239 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
3241 sed = "/^[ \t]*fstat(),$/a\\\n"
3244 "@(#)stat.h 6.1 (ULTRIX)\n"
3245 "#define S_IFPORT S_IFIFO\n"
3246 "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */";
3251 * Check for superfluous `static' (in Ultrix 4.2)
3252 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
3255 hackname = ultrix_static;
3256 files = machine/cpu.h;
3257 select = '#include "r[34]_cpu';
3258 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
3259 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
3260 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
3262 "static struct tlb_pid_state {\n"
3263 "#include \"r3_cpu.h\"\n";
3268 * Add once-only latch to Ultrix V4.3 strings.h.
3271 hackname = ultrix_strings;
3273 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
3276 "@(#)strings.h 6.1 (ULTRIX)\n";
3281 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
3282 * terminated lines, so accommodate these. Test both ways.
3285 hackname = undefine_null;
3286 select = "^#[ \t]*define[ \t]+NULL[ \t]";
3287 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
3290 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
3291 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
3293 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
3297 * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict"
3298 * which must be replaced by __restrict__ for GCC.
3301 hackname = unicosmk_restrict;
3305 mach = "*-*-unicosmk*";
3306 select = "(\\*[ \t]*)restrict([ \t]+)";
3309 c_fix_arg = "%1__restrict__%2";
3311 test_text = "void f (char * restrict x);";
3315 * If arpa/inet.h prototypes are incompatible with the ones we just
3316 * installed in <sys/byteorder.h>, just remove the protos.
3317 * Because of this close association, this patch must be applied only
3318 * on those systems where the replacement byteorder header is installed.
3321 hackname = uw7_byteorder_fix;
3322 files = arpa/inet.h;
3323 select = "in_port_t";
3324 test = "-f sys/byteorder.h";
3326 mach = "*-*-sysv4*";
3327 mach = "i?86-*-sysv5*";
3328 mach = "i?86-*-udk*";
3329 mach = "i?86-*-solaris2.[0-4]";
3330 mach = "powerpcle-*-solaris2.[0-4]";
3331 mach = "sparc-*-solaris2.[0-4]";
3336 c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
3338 test_text = "extern in_port_t\thtons __P((in_port_t));\n"
3339 "extern in_port_t\tntohs __P((in_port_t));"
3340 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3341 "echo '/* DUMMY */' >> sys/byteorder.h`";
3346 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3349 hackname = va_i960_macro;
3350 files = arch/i960/archI960.h;
3351 select = "__(vsiz|vali|vpad|alignof__)";
3354 c_fix_arg = "__vx%1";
3357 "extern int __vsiz vsiz;\n"
3358 "extern int __vali vali;\n"
3359 "extern int __vpad vpad;\n"
3360 "#define __alignof__(x) ...";
3365 * AIX and Interix headers define NULL to be cast to a void pointer,
3366 * which is illegal in ANSI C++.
3369 hackname = void_null;
3379 files = sys/param.h;
3380 files = sys/types.h;
3381 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3383 c_fix_arg = "#define NULL 0";
3384 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3389 * Make VxWorks header which is almost gcc ready fully gcc ready.
3392 hackname = vxworks_gcc_problem;
3393 files = types/vxTypesBase.h;
3394 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3396 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3399 sed = "/[ \t]size_t/i\\\n"
3400 "#ifndef _GCC_SIZE_T\\\n"
3401 "#define _GCC_SIZE_T\n";
3403 sed = "/[ \t]size_t/a\\\n"
3406 sed = "/[ \t]ptrdiff_t/i\\\n"
3407 "#ifndef _GCC_PTRDIFF_T\\\n"
3408 "#define _GCC_PTRDIFF_T\n";
3410 sed = "/[ \t]ptrdiff_t/a\\\n"
3413 sed = "/[ \t]wchar_t/i\\\n"
3414 "#ifndef _GCC_WCHAR_T\\\n"
3415 "#define _GCC_WCHAR_T\n";
3417 sed = "/[ \t]wchar_t/a\\\n"
3421 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3422 "typedef unsigned int size_t;\n"
3423 "typedef long ptrdiff_t;\n"
3424 "typedef unsigned short wchar_t;\n"
3425 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3430 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3433 hackname = vxworks_needs_vxtypes;
3435 select = "uint_t([ \t]+_clocks_per_sec)";
3437 c_fix_arg = "unsigned int%1";
3438 test_text = "uint_t\t_clocks_per_sec;";
3443 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3446 hackname = vxworks_needs_vxworks;
3448 test = " -r types/vxTypesOld.h";
3449 test = " -n \"`egrep '#include' $file`\"";
3450 test = " -n \"`egrep ULONG $file`\"";
3451 select = "#[ \t]define[ \t]+__INCstath";
3453 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3454 "#include <types/vxTypesOld.h>\n";
3456 test_text = "`touch types/vxTypesOld.h`"
3457 "#include </dev/null> /* ULONG */\n"
3458 "# define\t__INCstath <sys/stat.h>";
3463 * Another bad dependency in VxWorks 5.2 <time.h>.
3466 hackname = vxworks_time;
3468 test = " -r vxWorks.h";
3470 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3474 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3475 "#ifdef __cplusplus\n"
3476 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3478 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3480 "#define __gcc_VOIDFUNCPTR_defined\n"
3482 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3484 test_text = "`touch vxWorks.h`"
3485 "#define VOIDFUNCPTR (void(*)())";
3490 * WindISS math.h headers include bogus extern declarations of
3491 * numerous math functions that conflict with libstdc++-v3.
3494 hackname = windiss_math1;
3496 mach = "*-*-windiss";
3497 sed = "s|inline long double cosl.*|#ifndef __GNUC__|";
3499 test_text = "inline long double cosl(long double);";
3503 hackname = windiss_math2;
3505 mach = "*-*-windiss";
3506 sed = "s|/\\* long double declarations \\*/|"
3507 "#endif /* __GNUC__ */|";
3509 test_text = "/* long double declarations */";
3513 * WindISS headers include "diab/va_list.h" instead of "stdarg.h"
3516 select = '(#include.*)diab/va_list.h';
3517 hackname = windiss_valist;
3518 sed = "s|diab/va_list.h|stdarg.h|";
3519 mach = "*-*-windiss";
3521 test_text = "#include <diab/va_list.h>";
3525 * There are several name conflicts with C++ reserved words in X11 header
3526 * files. These are fixed in some versions, so don't do the fixes if
3527 * we find __cplusplus in the file. These were found on the RS/6000.
3530 hackname = x11_class;
3531 files = X11/ShellP.h;
3532 bypass = __cplusplus;
3533 select = "^([ \t]*char \\*)class;(.*)";
3535 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3536 "#else\n%1class;%2\n#endif";
3545 * class in Xm/BaseClassI.h
3548 hackname = x11_class_usage;
3549 files = Xm/BaseClassI.h;
3550 bypass = "__cplusplus";
3552 select = " class\\)";
3554 c_fix_arg = " c_class)";
3556 test_text = "extern mumble (int class);\n";
3561 * new in Xm/Traversal.h
3565 files = Xm/Traversal.h;
3566 bypass = __cplusplus;
3568 sed = "/Widget\told, new;/i\\\n"
3569 "#ifdef __cplusplus\\\n"
3570 "\tWidget\told, c_new;\\\n"
3573 sed = "/Widget\told, new;/a\\\n"
3576 sed = "s/Widget new,/Widget c_new,/g";
3579 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
3580 "};\nextern Wedged( Widget new, Widget old );";
3585 * Incorrect sprintf declaration in X11/Xmu.h
3588 hackname = x11_sprintf;
3590 files = X11/Xmu/Xmu.h;
3591 select = "^extern char \\*\tsprintf\\(\\);$";
3594 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3596 test_text = "extern char *\tsprintf();";