4 autogen definitions fixincl;
6 /* Define all the fixes we know about for repairing damaged headers.
7 Please see the README before adding or changing entries in this file.
9 This is the sort command:
11 blocksort output=XXX \
13 start='== REPLACEMENT FIXES ==' \
14 trailer='^/\*EOF\*[/]' \
16 key='hackname[ ]*=[ ]*(.*);'
18 Set up a debug test so we can make the templates emit special
19 code while debugging these fixes: */
25 /* == REPLACEMENT FIXES == */
28 * Completely replace <_int_varargs.h> with a file that includes gcc's
29 * stdarg.h or varargs.h files as appropriate on DG/UX
32 hackname = AAB_dgux_int_varargs;
33 files = _int_varargs.h;
35 #ifndef __INT_VARARGS_H
36 #define __INT_VARARGS_H
38 /********************************************************/
39 /* Define the common stuff for varargs/stdarg/stdio. */
40 /********************************************************/
43 ** This file is a DG internal header. Never include this
47 #ifndef ___int_features_h
48 #include <sys/_int_features.h>
51 #if !(defined(_VA_LIST) || defined(_VA_LIST_))
58 typedef void * va_list;
60 typedef char * va_list;
74 #else /* ! defined(__DCC__) */
77 int __va_arg; /* argument number */
78 int *__va_stk; /* start of args passed on stack */
79 int *__va_reg; /* start of args passed in regs */
82 #endif /* ! defined(__DCC__) */
86 #if defined(__GNUC__) || defined(__STDC__)
87 typedef void * va_list;
89 typedef char * va_list;
92 #endif /* _IX86_ANY */
95 #endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
96 #endif /* #ifndef __INT_VARARGS_H */
102 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
105 hackname = AAB_fd_zero_asm_posix_types_h;
106 files = asm/posix_types.h;
107 mach = 'i[34567]86-*-linux*';
111 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
112 * the start, so that if #include_next gets another instance of
113 * the wrapper, this will follow the #include_next chain until
114 * we arrive at the real <asm/posix_types.h>.
117 /* This file fixes a bug in the __FD_ZERO macro
118 for older versions of the Linux kernel. */
119 #ifndef _POSIX_TYPES_H_WRAPPER
120 #include <features.h>
121 #include_next <asm/posix_types.h>
123 #if defined(__FD_ZERO) && !defined(__GLIBC__)
125 #define __FD_ZERO(fdsetp) \
128 __asm__ __volatile__("cld ; rep ; stosl" \
129 : "=&c" (__d0), "=&D" (__d1) \
130 : "a" (0), "0" (__FDSET_LONGS), \
131 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
135 #define _POSIX_TYPES_H_WRAPPER
136 #endif /* _POSIX_TYPES_H_WRAPPER */
142 * This fixes __FD_ZERO bug for glibc-1.x
145 hackname = AAB_fd_zero_gnu_types_h;
147 mach = 'i[34567]86-*-linux*';
150 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
151 * the start, so that if #include_next gets another instance of
152 * the wrapper, this will follow the #include_next chain until
153 * we arrive at the real <gnu/types.h>.
157 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
158 \#ifndef _TYPES_H_WRAPPER
159 \#include <features.h>
160 \#include_next <gnu/types.h>
162 \#if defined(__FD_ZERO) && !defined(__GLIBC__)
164 \# define __FD_ZERO(fdsetp) \\
167 __asm__ __volatile__("cld ; rep ; stosl" \\
168 : "=&c" (__d0), "=&D" (__d1) \\
169 : "a" (0), "0" (__FDSET_LONGS), \\
170 "1" ((__fd_set *) (fdsetp)) :"memory"); \\
174 \#define _TYPES_H_WRAPPER
175 \#endif /* _TYPES_H_WRAPPER */
181 * This fixes __FD_ZERO bug for glibc-2.0.x
184 hackname = AAB_fd_zero_selectbits_h;
185 files = selectbits.h;
186 mach = 'i[34567]86-*-linux*';
189 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
190 * the start, so that if #include_next gets another instance of
191 * the wrapper, this will follow the #include_next chain until
192 * we arrive at the real <selectbits.h>.
196 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
197 \#ifndef _SELECTBITS_H_WRAPPER
198 \#include <features.h>
199 \#include_next <selectbits.h>
201 \#if defined(__FD_ZERO) && defined(__GLIBC__) \\
202 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
203 && __GLIBC_MINOR__ == 0
205 \#define __FD_ZERO(fdsetp) \\
208 __asm__ __volatile__ ("cld; rep; stosl" \\
209 : "=&c" (__d0), "=&D" (__d1) \\
210 : "a" (0), "0" (sizeof (__fd_set) \\
211 / sizeof (__fd_mask)), \\
212 "1" ((__fd_mask *) (fdsetp)) \\
217 \#define _SELECTBITS_H_WRAPPER
218 \#endif /* _SELECTBITS_H_WRAPPER */
224 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
225 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
226 * many other systems have similar text but correct versions of the file.
227 * To ensure only Sun's is fixed, we grep for a likely unique string.
228 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
231 hackname = AAB_sun_memcpy;
233 select = "/\\*\t@\\(#\\)"
234 "(head/memory.h\t50.1\t "
235 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
238 '/* This file was generated by fixincludes */
239 \#ifndef __memory_h__
240 \#define __memory_h__
243 extern void *memccpy();
244 extern void *memchr();
245 extern void *memcpy();
246 extern void *memset();
248 extern char *memccpy();
249 extern char *memchr();
250 extern char *memcpy();
251 extern char *memset();
252 \#endif /* __STDC__ */
256 \#endif /* __memory_h__ */
263 * Completely replace <sys/varargs.h> with a file that includes gcc's
264 * stdarg.h or varargs.h files as appropriate.
268 hackname = AAB_svr4_no_varargs;
269 files = sys/varargs.h;
270 replace = "/* This file was generated by fixincludes. */\n"
271 "#ifndef _SYS_VARARGS_H\n"
272 "#define _SYS_VARARGS_H\n\n"
275 "#include <stdarg.h>\n"
277 "#include <varargs.h>\n"
280 "#endif /* _SYS_VARARGS_H */\n";
286 * Completely replace <sys/byteorder.h>; with a file that implements gcc's
287 * optimized byteswapping. Restricted to "SVR4" machines until either
288 * it is shown to be safe to replace this file always, or we get bolder ;-)
291 hackname = AAB_svr4_replace_byteorder;
294 mach = "i[34567]86-*-sysv5*";
295 mach = "i[34567]86-*-udk*";
296 mach = "i[34567]86-*-solaris2.[0-4]";
297 mach = "powerpcle-*-solaris2.[0-4]";
298 mach = "sparc-*-solaris2.[0-4]";
300 files = sys/byteorder.h;
301 replace = '#ifndef _SYS_BYTEORDER_H
302 \#define _SYS_BYTEORDER_H
304 /* Functions to convert `short\' and `long\' quantities from host byte order
305 to (internet) network byte order (i.e. big-endian).
307 Written by Ron Guilmette (rfg@ncd.com).
309 This isn\'t actually used by GCC. It is installed by fixinc.svr4.
311 For big-endian machines these functions are essentially no-ops.
313 For little-endian machines, we define the functions using specialized
314 asm sequences in cases where doing so yields better code (e.g. i386). */
316 \#if !defined (__GNUC__) && !defined (__GNUG__)
317 \#error You lose! This file is only useful with GNU compilers.
320 \#ifndef __BYTE_ORDER__
321 /* Byte order defines. These are as defined on UnixWare 1.1, but with
322 double underscores added at the front and back. */
323 \#define __LITTLE_ENDIAN__ 1234
324 \#define __BIG_ENDIAN__ 4321
325 \#define __PDP_ENDIAN__ 3412
329 static __inline__ unsigned long htonl (unsigned long);
330 static __inline__ unsigned short htons (unsigned int);
331 static __inline__ unsigned long ntohl (unsigned long);
332 static __inline__ unsigned short ntohs (unsigned int);
333 \#endif /* defined (__STDC__) */
335 \#if defined (__i386__)
337 \#ifndef __BYTE_ORDER__
338 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
341 /* Convert a host long to a network long. */
343 /* We must use a new-style function definition, so that this will also
345 static __inline__ unsigned long
346 htonl (unsigned long __arg)
348 register unsigned long __result;
350 __asm__ ("xchg%B0 %b0,%h0
352 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
356 /* Convert a host short to a network short. */
358 static __inline__ unsigned short
359 htons (unsigned int __arg)
361 register unsigned short __result;
363 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
367 \#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \\
368 || defined (__ns32k__) || defined (__vax__) \\
369 || defined (__spur__) || defined (__arm__))
371 \#ifndef __BYTE_ORDER__
372 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
375 /* For other little-endian machines, using C code is just as efficient as
376 using assembly code. */
378 /* Convert a host long to a network long. */
380 static __inline__ unsigned long
381 htonl (unsigned long __arg)
383 register unsigned long __result;
385 __result = (__arg >> 24) & 0x000000ff;
386 __result |= (__arg >> 8) & 0x0000ff00;
387 __result |= (__arg << 8) & 0x00ff0000;
388 __result |= (__arg << 24) & 0xff000000;
392 /* Convert a host short to a network short. */
394 static __inline__ unsigned short
395 htons (unsigned int __arg)
397 register unsigned short __result;
399 __result = (__arg << 8) & 0xff00;
400 __result |= (__arg >> 8) & 0x00ff;
404 \#else /* must be a big-endian machine */
406 \#ifndef __BYTE_ORDER__
407 \#define __BYTE_ORDER__ __BIG_ENDIAN__
410 /* Convert a host long to a network long. */
412 static __inline__ unsigned long
413 htonl (unsigned long __arg)
418 /* Convert a host short to a network short. */
420 static __inline__ unsigned short
421 htons (unsigned int __arg)
426 \#endif /* big-endian */
428 /* Convert a network long to a host long. */
430 static __inline__ unsigned long
431 ntohl (unsigned long __arg)
433 return htonl (__arg);
436 /* Convert a network short to a host short. */
438 static __inline__ unsigned short
439 ntohs (unsigned int __arg)
441 return htons (__arg);
449 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
452 hackname = AAB_ultrix_ansi_compat;
453 files = ansi_compat.h;
455 replace = "/* This file intentionally left blank. */\n";
460 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
461 * Replace limits.h with a file that includes sys/limits.h.
464 hackname = AAB_ultrix_limits;
466 mach = "*-*-ultrix4.3";
468 '#ifndef _LIMITS_INCLUDED
469 \#define _LIMITS_INCLUDED
470 \#include <sys/limits.h>
471 \#endif /* _LIMITS_INCLUDED */
477 * The ULTRIX 4.3 version of memory.h duplicates definitions
478 * present in strings.h. Replace memory.h with a file that includes
479 * strings.h to prevent problems from multiple inclusion.
482 hackname = AAB_ultrix_memory;
484 mach = "*-*-ultrix4.3";
486 '#ifndef _MEMORY_INCLUDED
487 \#define _MEMORY_INCLUDED
488 \#include <strings.h>
489 \#endif /* _MEMORY_INCLUDED */
495 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
496 * Replace string.h link with a file that includes strings.h to prevent
497 * problems from multiple inclusion.
500 hackname = AAB_ultrix_string;
502 mach = "*-*-ultrix4.3";
504 '#ifndef _STRING_INCLUDED
505 \#define _STRING_INCLUDED
506 \#include <strings.h>
507 \#endif /* _STRING_INCLUDED */
513 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
514 * which violates a requirement of ISO C.
517 hackname = aix_pthread;
519 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
522 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
523 "{...init stuff...}";
528 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
529 * in an otherwise harmless (and #ifed out) macro definition
532 hackname = aix_sysmachine;
533 files = sys/machine.h;
537 test_text = "#define FOO \\\n"
538 " bar \\ \n baz \\ \n bat";
543 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
544 * definition of struct rusage, so the prototype added by fixproto fails.
547 hackname = aix_syswait;
549 select = "^extern pid_t wait3\\(\\);\n";
552 c_fix_arg = "struct rusage;\n%0";
553 test_text = "/* bos325, */\n"
554 "extern pid_t wait3();\n"
555 "\t/* pid_t wait3(int *, int, struct rusage *); */";
560 * sys/signal.h on some versions of AIX uses volatile in the typedef of
561 * sig_atomic_t, which causes gcc to generate a warning about duplicate
562 * volatile when a sig_atomic_t variable is declared volatile, as
563 * required by ANSI C.
566 hackname = aix_volatile;
567 files = sys/signal.h;
568 select = "typedef volatile int sig_atomic_t";
570 c_fix_arg = "typedef int sig_atomic_t";
571 test_text = "typedef volatile int sig_atomic_t;";
576 * Fix __assert declaration in assert.h on Alpha OSF/1.
579 hackname = alpha___assert;
581 select = '__assert\(char \*, char \*, int\)';
583 c_fix_arg = "__assert(const char *, const char *, int)";
584 test_text = 'extern void __assert(char *, char *, int);';
589 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
592 hackname = alpha_getopt;
595 select = 'getopt\(int, char \*\[\], *char \*\)';
597 c_fix_arg = "getopt(int, char *const[], const char *)";
598 test_text = 'extern int getopt(int, char *[], char *);';
603 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
606 hackname = alpha_parens;
608 select = '#ifndef\(__mips64\)';
610 c_fix_arg = "#ifndef __mips64";
611 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
616 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
619 hackname = alpha_sbrk;
621 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
623 c_fix_arg = "void *sbrk(";
624 test_text = "extern char* sbrk(ptrdiff_t increment);";
629 * Fix this ARM/RISCiX file where ___type is a Compiler
630 * hint that is specific to the Norcroft compiler.
633 hackname = arm_norcroft_hint;
634 select = "___type p_type";
635 files = "X11/Intrinsic.h";
637 c_fix_arg = "p_type";
638 test_text = "___type p_type mumble;";
643 * Fix this ARM/RISCiX file to avoid interfering
644 * with the use of __wchar_t in cc1plus.
647 hackname = arm_wchar;
649 select = "#[ \t]*define[ \t]*__wchar_t";
652 c_fix_arg = "%1_GCC_WCHAR_T";
653 c_fix_arg = "(#[ \t]*(ifndef|define)[ \t]+)__wchar_t";
656 "# ifndef \t __wchar_t /* we don't have wchar_t yet, ... */\n"
657 "# define __wchar_t short\n"
658 "# endif /* __wchar_t */";
663 * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89;
664 * gcc doesn't understand it.
669 select = "#ifndef NOINLINE";
672 c_fix_arg = "#if !defined(NOINLINE) && !defined(__GNUC__)";
675 "#ifndef NOINLINE /* ain't got no inline, so we got it */\n"
676 "#endif /* NOINLINE */";
681 * For C++, avoid any typedef or macro definition of bool,
682 * and use the built in type instead.
683 * HP/UX 10.20 also has it in curses_colr/curses.h.
686 hackname = avoid_bool_define;
688 files = curses_colr/curses.h;
692 select = "#[ \t]*define[ \t]+bool[ \t]";
693 bypass = "we must use the C\\+\\+ compiler's type";
696 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
697 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
699 test_text = "# define bool\t char \n";
703 hackname = avoid_bool_type;
705 files = curses_colr/curses.h;
709 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
710 bypass = "we must use the C\\+\\+ compiler's type";
713 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
715 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
719 * For C++, avoid any typedef definition of wchar_t,
720 * and use the built in type instead.
724 hackname = avoid_wchar_t_type;
726 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
729 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
731 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
735 * Fix #defines under Alpha OSF/1:
736 * The following files contain '#pragma extern_prefix "_FOO"' followed by
737 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
738 * statements is to reduce namespace pollution. While these macros work
739 * properly in most cases, they don't allow you to take a pointer to the
740 * "something" being modified. To get around this limitation, change these
741 * statements to be of the form '#define something _FOOsomething'.
743 * sed ain't egrep, lesson 2463: sed can use self-referential
744 * regular expressions. In the substitute expression below,
745 * "\\1" and "\\2" refer to subexpressions found earlier in the
746 * same match. So, we continue to use sed. "extern_prefix" will
747 * be a rare match anyway...
752 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
770 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
771 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
773 test_text = '#pragma extern_prefix "_FOO"'"\n"
774 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
775 "#define mumble _FOOmumble";
780 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
783 hackname = bad_struct_term;
785 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
787 c_fix_arg = "struct term;";
789 test_text = 'typedef struct term;';
794 * Fix one other error in this file:
795 * a mismatched quote not inside a C comment.
799 files = sundev/vuid_event.h;
802 c_fix_arg = "does not";
804 test_text = "/* doesn't have matched single quotes */";
809 * check for broken assert.h that needs stdio.h
812 hackname = broken_assert_stdio;
815 bypass = "include.*stdio\\.h";
817 c_fix_arg = "#include <stdio.h>\n";
818 test_text = "extern FILE* stderr;";
823 * check for broken assert.h that needs stdlib.h
826 hackname = broken_assert_stdlib;
828 select = 'exit *\(|abort *\(';
829 bypass = "include.*stdlib\\.h";
831 c_fix_arg = "#ifdef __cplusplus\n"
832 "#include <stdlib.h>\n"
834 test_text = "extern void exit ( int );";
839 * Remove `extern double cabs' declarations from math.h.
840 * This conflicts with C99. Discovered on AIX.
841 * SunOS4 has its cabs() declaration followed by a comment which
842 * terminates on the following line.
845 hackname = broken_cabs;
847 select = '^extern[ \t]+double[ \t]+cabs';
851 c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
853 test_text = "#ifdef __STDC__\n"
854 "extern double cabs(struct dbl_hypot);\n"
856 "extern double cabs();\n"
858 "extern double cabs(); /* This is a comment\n"
859 " and it ends here. */";
864 * Fix various macros used to define ioctl numbers.
865 * The traditional syntax was:
867 * #define _CTRL(n, x) (('n'<<8)+x)
868 * #define TCTRLCFOO _CTRL(T, 1)
870 * but this does not work with the C standard, which disallows macro
871 * expansion inside strings. We have to rewrite it thus:
873 * #define _CTRL(n, x) ((n<<8)+x)
874 * #define TCTRLCFOO _CTRL('T', 1)
876 * The select expressions match too much, but the c_fix code is cautious.
878 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
881 hackname = ctrl_quotes_def;
882 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
883 c_fix = char_macro_def;
887 * This is two tests in order to ensure that the "CTRL(c)" can
888 * be selected in isolation from the multi-arg format
890 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
891 test_text = "#define _CTRL(c) ('c'&037)";
895 hackname = ctrl_quotes_use;
896 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
897 c_fix = char_macro_use;
899 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
904 * sys/mman.h on HP/UX is not C++ ready,
905 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
907 * rpc/types.h on OSF1/2.0 is not C++ ready,
908 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
910 * The problem is the declaration of malloc.
913 hackname = cxx_unready;
916 select = '[^#]+malloc.*;'; /* Catch any form of declaration
917 not within a macro. */
918 bypass = '"C"|__BEGIN_DECLS';
921 c_fix_arg = "#ifdef __cplusplus\n"
924 c_fix_arg = "#ifdef __cplusplus\n"
927 test_text = "extern void* malloc( size_t );";
932 * Fix <c_asm.h> on Digital UNIX V4.0:
933 * It contains a prototype for a DEC C internal asm() function,
934 * clashing with gcc's asm keyword. So protect this with __DECC.
937 hackname = dec_intern_asm;
939 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
940 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
944 " ... asm stuff ...\n"
945 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
950 * Fix typo in <wchar.h> on DJGPP 2.03.
953 hackname = djgpp_wchar_h;
955 select = "__DJ_wint_t";
956 bypass = "sys/djtypes.h";
958 c_fix_arg = "%0\n#include <sys/djtypes.h>";
959 c_fix_arg = "#include <stddef.h>";
960 test_text = "#include <stddef.h>\n"
961 "extern __DJ_wint_t x;\n";
965 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
968 hackname = ecd_cursor;
969 files = "sunwindow/win_lock.h";
970 files = "sunwindow/win_cursor.h";
971 select = 'ecd\.cursor';
973 c_fix_arg = 'ecd_cursor';
975 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
980 * fix-header doesn't fix fabs' prototype, and I have no idea why.
983 hackname = fix_header_breakage;
984 mach = "m88k-motorola-sysv3*";
987 select = 'extern double floor\(\), ceil\(\), fmod\(\), fabs\(\);';
990 'extern double floor(), ceil(), fmod(), fabs _PARAMS((double));';
991 test_text = 'extern double floor(), ceil(), fmod(), fabs();';
996 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
997 * neither the existence of GCC 3 nor its exact feature set yet break
998 * (by design?) when __GNUC__ is set beyond 2.
1001 hackname = freebsd_gcc3_breakage;
1002 mach = *-*-freebsd*;
1003 files = sys/cdefs.h;
1004 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1005 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1007 c_fix_arg = '%0 || __GNUC__ >= 3';
1008 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1013 * Fix these files to use the same types that we think they should.
1016 hackname = gnu_types;
1017 files = "sys/types.h";
1019 files = "sys/stdtypes.h";
1023 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1024 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1027 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1028 "typedef uint_t size_t; /* uint_t */\n"
1029 "typedef ushort_t wchar_t; /* ushort_t */";
1034 * Fix HP & Sony's use of "../machine/xxx.h"
1035 * to refer to: <machine/xxx.h>
1038 hackname = hp_inline;
1039 files = sys/spinlock.h;
1040 files = machine/machparam.h;
1041 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1044 c_fix_arg = "%1<machine/%2.h>";
1046 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1049 test_text = ' # include "../machine/mumble.h"';
1054 * Check for (...) in C++ code in HP/UX sys/file.h.
1057 hackname = hp_sysfile;
1059 select = "HPUX_SOURCE";
1062 c_fix_arg = "(struct file *, ...)";
1063 c_fix_arg = '\(\.\.\.\)';
1065 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1070 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1071 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1074 hackname = hpux10_cpp_pow_inline;
1075 files = fixinc-test-limits.h, math.h;
1076 select = <<- END_POW_INLINE
1077 ^# +ifdef +__cplusplus
1079 +inline +double +pow\(double +__d,int +__expon\) +{
1080 [ ]+return +pow\(__d,\(double\)__expon\);
1091 "# ifdef __cplusplus\n"
1093 " inline double pow(double __d,int __expon) {\n"
1094 "\t return pow(__d,(double)__expon);\n"
1096 ' extern "C"' " {\n"
1102 hackname = hpux11_cpp_pow_inline;
1104 select = " +inline double pow\\(double d,int expon\\) {\n"
1105 " +return pow\\(d, \\(double\\)expon\\);\n"
1111 " inline double pow(double d,int expon) {\n"
1112 " return pow(d, (double)expon);\n"
1118 * Keep HP-UX 11 from stomping on C++ math namespace
1119 * with defines for fabsf.
1122 hackname = hpux11_fabsf;
1124 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1125 bypass = "__cplusplus";
1128 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1132 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1138 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1139 * being defined by having it define _hpux_size_t instead.
1142 hackname = hpux11_size_t;
1143 mach = "*-hp-hpux11*";
1144 select = "__size_t";
1147 c_fix_arg = "_hpux_size_t";
1150 "#define __size_t size_t\n"
1151 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1156 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1157 * of UINT32_C has undefined behavior according to ISO/ANSI:
1158 * the arguments to __CONCAT__ are not macro expanded before the
1159 * concatination happens so the trailing ')' in the first argument
1160 * is concatinated with the 'l' in the second argument creating an
1161 * invalid pp token. The behavior of invalid pp tokens is undefined.
1162 * GCC does not handle these invalid tokens the way the HP compiler does.
1163 * This problem will potentially occur anytime macros are used in the
1164 * arguments to __CONCAT__. A general solution to this problem would be to
1165 * insert another layer of macro between __CONCAT__ and its use
1166 * in UINT32_C. An example of this solution can be found in the C standard.
1167 * A more specific solution, the one used here, is to change the UINT32_C
1168 * macro to not used macros in the arguments to __CONCAT__.
1171 hackname = hpux11_uint32_c;
1173 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1174 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1176 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1178 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1179 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1184 * Fix hpux 11.00 broken vsnprintf declaration
1187 hackname = hpux11_vsnprintf;
1189 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1190 'const char \*,) __va__list\);';
1192 c_fix_arg = "%1 __va_list);";
1194 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1200 * get rid of bogus inline definitions in HP-UX 8.0
1203 hackname = hpux8_bogus_inlines;
1206 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1207 "@extern \"C\" int abs(int);@";
1208 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1209 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1210 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1211 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1212 "inline double sqr(double v) { return v**0.5; }";
1217 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1220 hackname = hpux_maxint;
1221 files = sys/param.h;
1223 select = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1224 bypass = "^#[ \t]*ifndef[ \t]+MAXINT";
1226 "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1229 c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1230 c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1232 test_text = '#define MAXINT 0x7FFFFFFF';
1237 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1240 hackname = hpux_systime;
1242 select = "^extern struct sigevent;";
1245 c_fix_arg = "struct sigevent;";
1247 test_text = 'extern struct sigevent;';
1252 * Fix return type of abort and free
1255 hackname = int_abort_free_and_exit;
1257 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1260 c_fix_arg = "void\t%1(";
1262 test_text = "extern int abort(int);\n"
1263 "extern int free(void*);\n"
1264 "extern int exit(void*);";
1269 * Fix various macros used to define ioctl numbers.
1270 * The traditional syntax was:
1272 * #define _IO(n, x) (('n'<<8)+x)
1273 * #define TIOCFOO _IO(T, 1)
1275 * but this does not work with the C standard, which disallows macro
1276 * expansion inside strings. We have to rewrite it thus:
1278 * #define _IO(n, x) ((n<<8)+x)
1279 * #define TIOCFOO _IO('T', 1)
1281 * The select expressions match too much, but the c_fix code is cautious.
1283 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1286 hackname = io_quotes_def;
1287 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1288 c_fix = char_macro_def;
1291 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1292 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1293 "#define _IO(x,y) ('x'<<8|y)";
1295 "#define XX_IO(x) ('x'<<8|256)";
1299 hackname = io_quotes_use;
1300 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1302 c_fix = char_macro_use;
1304 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1305 "#define TIOCFOO \\\\\n"
1306 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1311 * Check for missing ';' in struct
1314 hackname = ip_missing_semi;
1315 files = netinet/ip.h;
1317 sed = "/^struct/,/^};/s/}$/};/";
1323 "}; /* mumbled struct */\n";
1328 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1329 * that causes the assembly preprocessor to complain about an
1330 * unterminated character constant.
1333 hackname = irix_asm_apostrophe;
1336 select = "^[ \t]*#.*[Ww]e're";
1338 c_fix_arg = "%1 are";
1339 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1340 test_text = "\t# and we're on vacation";
1345 * Non-traditional "const" declaration in Irix's limits.h.
1348 hackname = irix_limits_const;
1349 files = fixinc-test-limits.h, limits.h;
1350 select = "^extern const ";
1352 c_fix_arg = "extern __const ";
1353 test_text = "extern const char limit; /* test limits */";
1358 * IRIX 5.x's stdio.h declares some functions that take a va_list as
1359 * taking char *. However, GCC uses void * for va_list, so
1360 * calling vfprintf with a va_list fails in C++. */
1362 hackname = irix_stdio_va_list;
1365 select = '(printf\(.*), /\* va_list \*/ char \*';
1367 c_fix_arg = "%1, __gnuc_va_list";
1369 "extern int printf( const char *, /* va_list */ char * );";
1374 * Fixing ISC fmod declaration
1377 hackname = isc_fmod;
1379 select = 'fmod\(double\)';
1381 c_fix_arg = "fmod(double, double)";
1382 test_text = "extern double fmod(double);";
1387 * On Interactive Unix 2.2, certain traditional Unix definitions
1388 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
1389 * defined, not just if _POSIX_SOURCE is defined. This makes it
1390 * impossible to compile any nontrivial program except with -posix.
1393 hackname = isc_omits_with_stdc;
1398 files = "sys/limits.h";
1399 files = "sys/fcntl.h";
1400 files = "sys/dirent.h";
1402 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1404 c_fix_arg = '!defined(_POSIX_SOURCE)';
1405 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1406 "\nint foo;\n#endif";
1411 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1412 * use / * * / to concatenate tokens.
1415 hackname = kandr_concat;
1416 files = "sparc/asm_linkage.h";
1417 files = "sun3/asm_linkage.h";
1418 files = "sun3x/asm_linkage.h";
1419 files = "sun4/asm_linkage.h";
1420 files = "sun4c/asm_linkage.h";
1421 files = "sun4m/asm_linkage.h";
1422 files = "sun4c/debug/asm_linkage.h";
1423 files = "sun4m/debug/asm_linkage.h";
1424 files = "arm/as_support.h";
1425 files = "arm/mc_type.h";
1426 files = "arm/xcb.h";
1427 files = "dev/chardefmac.h";
1428 files = "dev/ps_irq.h";
1429 files = "dev/screen.h";
1430 files = "dev/scsi.h";
1431 files = "sys/tty.h";
1432 files = "Xm.acorn/XmP.h";
1433 files = bsd43/bsd43_.h;
1437 test_text = "#define __CONCAT__(a,b) a/**/b";
1442 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1443 * versions > 1. This fix will open up the declaration for all
1444 * versions of GCC and for g++.
1447 hackname = libc1_ifdefd_memx;
1449 /* The string.h result is overwritten by AAB_ultrix_string when doing
1450 "make check" and will fail. Therefore, we add the following kludgery
1451 to insert the test_text into the special testing header. :-} */
1456 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1457 bypass = __cplusplus;
1460 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1461 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1463 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1467 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1468 "#if defined(__STDC__) && __GNUC__ < 2\n"
1469 "/* Copy N bytes of SRC to DEST. */\n"
1470 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1477 * In limits.h, put #ifndefs around things that are supposed to be defined
1478 * in float.h to avoid redefinition errors if float.h is included first.
1479 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1480 * multi line comments and the inserted #endif winds up inside the
1481 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1482 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1483 * are there, and we do not add them ourselves.
1486 hackname = limits_ifndefs;
1487 files = "sys/limits.h";
1489 bypass = "ifndef[ \t]+FLT_MIN";
1492 c_fix_arg = "#ifndef %1\n%0\n#endif";
1493 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1494 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1495 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1500 * Delete the '#define void int' line from curses.h on Lynx
1503 hackname = lynx_void_int;
1505 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1508 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1513 * Fix fcntl prototype in fcntl.h on LynxOS.
1516 hackname = lynxos_fcntl_proto;
1518 select = "fcntl[ \t]*" '\(int, int, int\)';
1520 c_fix_arg = '%1...)';
1521 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1522 test_text = "extern int fcntl(int, int, int);";
1527 * libm.a on m88k-motorola-sysv3 contains a stupid optimization for
1528 * function hypot(), which returns the second argument without even
1529 * looking at its value, if the other is 0.0.
1532 hackname = m88k_bad_hypot_opt;
1533 mach = "m88k-motorola-sysv3*";
1535 select = "^extern double hypot\\(\\);\n";
1538 "/* Workaround a stupid Motorola optimization if one\n"
1539 " of x or y is 0.0 and the other is negative! */\n"
1541 "static __inline__ double fake_hypot (double x, double y)\n"
1543 "static __inline__ double fake_hypot (x, y)\n"
1547 "\treturn fabs (hypot (x, y));\n"
1549 "#define hypot\tfake_hypot\n";
1550 test_text = "extern double hypot();";
1555 * Fix incorrect S_IF* definitions on m88k-sysv3.
1558 hackname = m88k_bad_s_if;
1559 mach = "m88k-*-sysv3*";
1561 select = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&";
1564 c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)';
1565 c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+"
1567 "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)"
1569 test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */';
1574 * Put cpp wrappers around these include files to avoid redeclaration
1575 * errors during multiple inclusion on m88k-tektronix-sysv3.
1578 hackname = m88k_multi_incl;
1579 mach = "m88k-tektronix-sysv3*";
1588 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1590 * On NetBSD, machine is a symbolic link to an architecture specific
1591 * directory name, so we can't match a specific file name here.
1594 hackname = machine_ansi_h_va_list;
1595 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1596 bypass = '__builtin_va_list';
1599 c_fix_arg = "%1__builtin_va_list";
1600 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1602 test_text = " # define _BSD_VA_LIST_\tchar**";
1607 * Fix non-ansi machine name defines
1610 hackname = machine_name;
1611 c_test = machine_name;
1612 c_fix = machine_name;
1614 test_text = "/* MACH_DIFF: */\n"
1615 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1616 "\n/* no uniform test, so be careful :-) */";
1621 * Some math.h files define struct exception, which conflicts with
1622 * the class exception defined in the C++ file std/stdexcept.h. We
1623 * redefine it to __math_exception. This is not a great fix, but I
1624 * haven't been able to think of anything better.
1625 * Note that we have to put the #ifdef/#endif blocks at beginning
1626 * and end of file, because fixproto runs after us and may insert
1627 * additional references to struct exception.
1630 hackname = math_exception;
1632 select = "struct exception";
1633 bypass = 'We have a problem when using C\+\+';
1636 c_fix_arg = "#ifdef __cplusplus\n"
1637 "#define exception __math_exception\n"
1640 c_fix_arg = "#ifdef __cplusplus\n"
1641 "#undef exception\n"
1644 test_text = "typedef struct exception t_math_exception;";
1649 * This looks pretty broken to me. ``dbl_max_def'' will contain
1650 * "define DBL_MAX " at the start, when what we really want is just
1651 * the value portion. Can't figure out how to write a test case
1652 * for this either :-(
1655 hackname = math_huge_val_from_dbl_max;
1659 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1660 * in math.h, this fix applies.
1662 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1663 bypass = "define[ \t]+DBL_MAX";
1667 * See if we have a definition for DBL_MAX in float.h.
1668 * If we do, we will replace the one in math.h with that one.
1671 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1672 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1674 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1675 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1676 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1681 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1682 "#define HUGE_VAL DBL_MAX";
1687 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1690 hackname = math_huge_val_ifndef;
1692 files = math/math.h;
1693 select = "define[ \t]+HUGE_VAL";
1696 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1697 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1699 test_text = "# define\tHUGE_VAL 3.4e+40";
1707 hackname = nested_auth_des;
1709 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1711 c_fix_arg = "%1*/ /*";
1712 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1717 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1720 hackname = nested_motorola;
1721 mach = "m68k-motorola-sysv*";
1722 files = sys/limits.h;
1724 select = "max # bytes atomic in write|error value returned by Math lib";
1726 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1727 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1728 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1729 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1732 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1734 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1739 * Fixing nested comments in ISC <sys/limits.h>
1742 hackname = nested_sys_limits;
1743 files = sys/limits.h;
1745 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1746 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1747 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1748 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1752 * fix bogus recursive stdlib.h in NEWS-OS 4.0C
1755 hackname = news_os_recursion;
1757 select = "[ \t]*#include <stdlib\\.h>.*";
1760 c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif";
1761 test_text = "#include <stdlib.h>";
1766 * NeXT 3.2 adds const prefix to some math functions.
1767 * These conflict with the built-in functions.
1770 hackname = next_math_prefix;
1771 files = ansi/math.h;
1772 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1775 c_fix_arg = "extern double %1(";
1776 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1778 test_text = "extern\tdouble\t__const__\tmumble();";
1783 * NeXT 3.2 uses the word "template" as a parameter for some
1784 * functions. GCC reports an invalid use of a reserved key word
1785 * with the built-in functions.
1788 hackname = next_template;
1790 select = "[ \t]template\\)";
1794 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1795 test_text = "extern mumble( char * template); /* fix */";
1800 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1801 * function prototypes. That conflicts with the built-in functions.
1804 hackname = next_volitile;
1805 files = ansi/stdlib.h;
1806 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1809 c_fix_arg = "extern void %1(";
1810 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1812 test_text = "extern\tvolatile\tvoid\tabort();";
1817 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1818 * Note that version 3 of the NeXT system has wait.h in a different directory,
1819 * so that this code won't do anything. But wait.h in version 3 has a
1820 * conditional, so it doesn't need this fix. So everything is okay.
1823 hackname = next_wait_union;
1826 select = 'wait\(union wait';
1828 c_fix_arg = "wait(void";
1829 test_text = "extern pid_d wait(union wait*);";
1834 * a missing semi-colon at the end of the nodeent structure definition.
1837 hackname = nodeent_syntax;
1838 files = netdnet/dnetdb.h;
1839 select = "char[ \t]*\\*na_addr[ \t]*$";
1842 test_text = "char *na_addr\t";
1847 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1848 * defining regex.h related types. This causes libg++ build and usage
1849 * failures. Fixing this correctly requires checking and modifying 3 files.
1852 hackname = osf_namespace_a;
1853 files = reg_types.h;
1854 files = sys/lc_core.h;
1855 test = " -r reg_types.h";
1856 test = " -r sys/lc_core.h";
1857 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1858 test = " -z \"`grep __regex_t regex.h`\"";
1862 c_fix_arg = "reg(ex|off|match)_t";
1864 test_text = "`touch sys/lc_core.h`"
1865 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1866 "extern regex_t re;\n"
1867 "extern regoff_t ro;\n"
1868 "extern regmatch_t rm;\n";
1872 hackname = osf_namespace_c;
1874 test = " -r reg_types.h";
1875 test = " -r sys/lc_core.h";
1876 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1877 test = " -z \"`grep __regex_t regex.h`\"";
1879 select = "#include <reg_types\.h>.*";
1882 "typedef __regex_t\tregex_t;\n"
1883 "typedef __regoff_t\tregoff_t;\n"
1884 "typedef __regmatch_t\tregmatch_t;";
1886 test_text = "#include <reg_types.h>";
1891 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1892 * The original ones fail if uninitialized externs are not common.
1893 * This is the default for all ANSI standard C++ compilers.
1896 hackname = pthread_page_size;
1898 select = "^int __page_size";
1900 c_fix_arg = "extern %0";
1901 test_text = "int __page_size;";
1906 * Fix return type of fread and fwrite on sysV68
1909 hackname = read_ret_type;
1911 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1913 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1914 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1916 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1921 * function class(double x) conflicts with C++ keyword on rs/6000
1924 hackname = rs6000_double;
1926 select = '[^a-zA-Z_]class\(';
1929 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1930 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
1932 test_text = "extern int class();";
1937 * Wrong fchmod prototype on RS/6000.
1940 hackname = rs6000_fchmod;
1942 select = 'fchmod\(char \*';
1944 c_fix_arg = "fchmod(int";
1945 test_text = "extern int fchmod(char *, mode_t);";
1950 * parameters conflict with C++ new on rs/6000
1953 hackname = rs6000_param;
1957 select = 'rename\(const char \*old, const char \*new\)';
1959 c_fix_arg = 'rename(const char *_old, const char *_new)';
1961 test_text = 'extern int rename(const char *old, const char *new);';
1966 * The static functions lstat() and fchmod() in <sys/stat.h>
1967 * cause G++ grief since they're not wrapped in "if __cplusplus".
1969 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
1970 * tiny static wrappers that aren't C++ safe.
1973 hackname = sco_static_func;
1975 mach = "i?86-*-sco3.2*";
1976 select = "^static int";
1978 sed = "/^static int/i\\\n"
1979 "#if __cplusplus\\\n"
1980 "extern \"C\" {\\\n"
1981 "#endif /* __cplusplus */";
1984 "#if __cplusplus\\\n"
1986 "#endif /* __cplusplus */";
1990 "static int\tstat(const char *__f, struct stat *__p) {\n"
1991 "\treturn __stat32(__f, __p);\n"
1992 "}\n\n# else /* !__STDC__ */\n"
1994 "static int\tstat(__f, __p)\n"
1996 "\tstruct stat *__p;\n"
1998 "\treturn __stat32(__f, __p);\n"
2005 * Fix prototype declaration of utime in sys/times.h.
2006 * In 3.2v4.0 the const is missing.
2009 hackname = sco_utime;
2010 files = sys/times.h;
2011 mach = "i?86-*-sco3.2v4*";
2013 select = '\(const char \*, struct utimbuf \*\);';
2015 c_fix_arg = '(const char *, const struct utimbuf *);';
2017 test_text = "extern int utime(const char *, struct utimbuf *);";
2022 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2023 * "0" for the last field of the pthread_mutex_t structure, which is
2024 * of type upad64_t, which itself is typedef'd to int64_t, but with
2025 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2026 * initializer to "{0}" instead
2029 hackname = solaris_mutex_init;
2030 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2033 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2038 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+{.*)"
2039 ",[ \t]*0}" "(|[ \t].*)$";
2041 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
2042 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
2043 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
2044 "#define PTHREAD_RWLOCK_INITIALIZER\t"
2045 "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
2050 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2054 hackname = sony_ctype;
2056 test = " -x /bin/sony";
2057 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2058 sed = "s/__ctype/_ctype/g";
2064 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2068 hackname = sony_stdio;
2070 test = " -x /bin/sony";
2071 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2072 sed = "s/__filbuf/_filbuf/g\n"
2073 "s/__flsbuf/_flsbuf/g\n"
2080 * Add a `static' declaration of `getrnge' into <regexp.h>.
2082 * Don't do this if there is already a `static void getrnge' declaration
2083 * present, since this would cause a redeclaration error. Solaris 2.x has
2084 * such a declaration.
2088 hackname = static_getrnge;
2090 bypass = "static void getrnge";
2091 sed = "/^static int[ \t]*size;/c\\\n"
2092 "static int size ;\\\n\\\n"
2093 "static int getrnge ();";
2099 * a missing semi-colon at the end of the statsswtch structure definition.
2102 hackname = statsswtch;
2103 files = rpcsvc/rstat.h;
2104 select = "boottime$";
2106 c_fix_arg = "boottime;";
2107 test_text = "struct statswtch {\n int boottime\n};";
2112 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2113 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2117 hackname = stdio_stdarg_h;
2119 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2123 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2130 * Don't use or define the name va_list in stdio.h.
2131 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
2132 * Note _BSD_VA_LIST_ is dealt with elsewhere.
2135 hackname = stdio_va_list;
2137 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list';
2140 * Use __gnuc_va_list in arg types in place of va_list.
2141 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
2142 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
2143 * trailing parentheses and semicolon save all other systems from this.
2144 * Define __not_va_list__ (something harmless and unused)
2145 * instead of va_list.
2146 * Don't claim to have defined va_list.
2148 sed = "s@ va_list @ __gnuc_va_list @\n"
2149 "s@ va_list)@ __gnuc_va_list)@\n"
2150 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2151 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
2152 "s@ va_list@ __not_va_list__@\n"
2153 "s@\\*va_list@*__not_va_list__@\n"
2154 "s@ __va_list)@ __gnuc_va_list)@\n"
2155 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2156 "@typedef \\1 __not_va_list__;@\n"
2157 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2158 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2159 "s@VA_LIST@DUMMY_VA_LIST@\n"
2160 "s@_Va_LIST@_VA_LIST@";
2161 test_text = "extern void mumble( va_list);";
2166 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
2167 * is "!defined( __STRICT_ANSI__ )"
2170 hackname = strict_ansi_not;
2171 select = "^([ \t]*#[ \t]*if.*)"
2173 "|__STDC__[ \t]*==[ \t]*0"
2174 "|__STDC__[ \t]*!=[ \t]*1"
2175 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
2176 c_test = stdc_0_in_system_headers;
2179 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2181 test_text = "#if !__STDC__ \n"
2182 "#if __STDC__ == 0\n"
2183 "#if __STDC__ != 1\n"
2184 "#if __STDC__ - 0 == 0"
2185 "/* not std C */\nint foo;\n"
2186 "\n#end-end-end-end-if :-)";
2191 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
2194 hackname = strict_ansi_not_ctd;
2195 files = math.h, limits.h, stdio.h, signal.h,
2196 stdlib.h, sys/signal.h, time.h;
2198 * Starting at the beginning of a line, skip white space and
2199 * a leading "(" or "&&" or "||". One of those must be found.
2200 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
2201 * expression. If these are nested, then they must accumulate
2202 * because we won't match any closing parentheses. Finally,
2203 * after skipping over all that, we must then match our suspect
2204 * phrase: "__STDC__-0==0" with or without white space.
2206 select = "^([ \t]*" '(\(|&&|\|\|)'
2207 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
2209 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
2210 c_test = stdc_0_in_system_headers;
2213 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2215 test_text = "#if 1 && \\\\\n"
2216 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
2217 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
2218 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
2224 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2225 * is "defined( __STRICT_ANSI__ )"
2228 hackname = strict_ansi_only;
2229 select = "^([ \t]*#[ \t]*if.*)"
2230 "(__STDC__[ \t]*!=[ \t]*0"
2231 "|__STDC__[ \t]*==[ \t]*1"
2232 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2233 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
2234 c_test = stdc_0_in_system_headers;
2237 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
2239 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2244 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2245 * in prototype without previous definition.
2248 hackname = struct_file;
2250 select = '^.*xdrstdio_create.*struct __file_s';
2252 c_fix_arg = "struct __file_s;\n%0";
2253 test_text = "extern void xdrstdio_create( struct __file_s* );";
2258 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2259 * in prototype without previous definition.
2262 hackname = struct_sockaddr;
2264 select = "^.*authdes_create.*struct sockaddr";
2265 bypass = "<sys/socket\.h>";
2267 c_fix_arg = "struct sockaddr;\n%0";
2268 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2273 * Apply fix this to all OSs since this problem seems to effect
2274 * more than just SunOS.
2277 hackname = sun_auth_proto;
2283 * Select those files containing '(*name)()'.
2285 select = '\(\*[a-z][a-z_]*\)\(\)';
2288 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2289 "#else\n%1();%2\n#endif";
2290 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2294 " int (*name)(); /* C++ bad */\n"
2300 * Fix bogus #ifdef on SunOS 4.1.
2303 hackname = sun_bogus_ifdef;
2304 files = "hsfs/hsfs_spec.h";
2305 files = "hsfs/iso_spec.h";
2306 select = '#ifdef(.*\|\|.*)';
2308 c_fix_arg = "#if%1";
2310 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2315 * Fix the CAT macro in SunOS memvar.h.
2318 hackname = sun_catmacro;
2319 files = pixrect/memvar.h;
2320 select = "^#define[ \t]+CAT\\(a,b\\).*";
2325 "# define CAT(a,b) a##b\n"
2326 "#else\n%0\n#endif";
2329 "#define CAT(a,b)\ta/**/b";
2334 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2335 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2338 hackname = sun_malloc;
2341 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2342 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2343 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2344 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2345 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2348 "typedef char *\tmalloc_t;\n"
2350 "char*\tmalloc();\n"
2351 "char*\tcalloc();\n"
2352 "char*\trealloc();";
2357 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2360 hackname = sun_rusers_semi;
2361 files = rpcsvc/rusers.h;
2363 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2364 test_text = "struct mumble\n int _cnt\n};";
2369 * signal.h on SunOS defines signal using (),
2370 * which causes trouble when compiling with g++ -pedantic.
2373 hackname = sun_signal;
2374 files = sys/signal.h;
2376 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2380 "#ifdef __cplusplus\n"
2381 "void\t(*signal(...))(...);\n"
2382 "#else\n%0\n#endif";
2384 test_text = "void\t(*signal())();";
2389 * math.h on SunOS 4 puts the declaration of matherr before the definition
2390 * of struct exception, so the prototype (added by fixproto) causes havoc.
2393 hackname = sunos_matherr_decl;
2396 /* If matherr has a prototype already, the header needs no fix. */
2397 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2401 c_fix_arg = "struct exception;\n";
2403 test_text = "extern int matherr();";
2408 * Correct the return type for strlen in strings.h in SunOS 4.
2411 hackname = sunos_strlen;
2413 select = "int[ \t]*strlen\\(\\);(.*)";
2415 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2416 test_text = " int\tstrlen(); /* string length */";
2421 * Solaris math.h and floatingpoint.h define __P without protection,
2422 * which conflicts with the fixproto definition. The fixproto
2423 * definition and the Solaris definition are used the same way.
2428 files = floatingpoint.h;
2429 select = "^#define[ \t]+__P.*";
2431 c_fix_arg = "#ifndef __P\n%0\n#endif";
2433 test_text = "#define __P(a) a";
2438 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2439 * that is visible to any ANSI compiler using this include. Simply
2440 * delete the lines that #define some string functions to internal forms.
2444 hackname = svr4_disable_opt;
2446 select = '#define.*__std_hdr_';
2447 sed = '/#define.*__std_hdr_/d';
2453 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2454 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2455 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2459 hackname = svr4_endian;
2460 files = sys/endian.h;
2463 * since we emit our own sys/byteorder.h,
2464 * this fix can never be applied to that file.
2466 files = sys/byteorder.h;
2468 bypass = '__GNUC__';
2470 sed = "/#\tifdef\t__STDC__/i\\\n"
2471 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2473 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2475 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2476 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2482 * Remove useless extern keyword from struct forward declarations
2483 * in <sys/stream.h> and <sys/strsubr.h>
2487 hackname = svr4_extern_struct;
2488 files = sys/stream.h;
2489 files = sys/strsubr.h;
2490 select = 'extern struct [a-z_]*;';
2491 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2496 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2497 * systems the file <ftw.h> contains extern declarations of these
2498 * functions followed by explicitly `static' definitions of these
2499 * functions... and that's not allowed according to ANSI C. (Note
2500 * however that on Solaris, this header file glitch has been pre-fixed by
2501 * Sun. In the Solaris version of <ftw.h> there are no static
2502 * definitions of any function so we don't need to do any of this stuff
2508 hackname = svr4_ftw;
2510 select = '^extern int ftw\(const';
2512 sed = '/^extern int ftw(const/i' "\\\n"
2513 "#if !defined(_STYPES)\\\n"
2518 sed = 's/extern \(int ftw(const.*\)$/\1/';
2519 sed = "/^extern int nftw/i\\\n"
2520 "#if defined(_STYPES)\\\n"
2525 sed = 's/extern \(int nftw.*\)$/\1/';
2526 sed = "/^extern int ftw(),/c\\\n"
2527 "#if !defined(_STYPES)\\\n"
2533 "#if defined(_STYPES)\\\n"
2545 * Fix broken decl of getcwd present on some svr4 systems.
2548 hackname = svr4_getcwd;
2551 files = prototypes.h;
2552 select = 'getcwd\(char \*, int\)';
2555 c_fix_arg = "getcwd(char *, size_t)";
2557 test_text = "extern char* getcwd(char *, int);";
2566 hackname = svr4_kernel;
2567 files = fs/rfs/rf_cache.h;
2571 files = sys/getpages.h;
2573 files = sys/cmn_err.h;
2574 files = sys/kdebugger.h;
2578 c_fix_arg = "#ifdef _KERNEL\n";
2579 c_fix_arg = "#endif /* _KERNEL */\n";
2585 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2586 * tend to conflict with the compiler's own definition of this symbol. (We
2587 * will use the compiler's definition.)
2588 * Likewise __sparc, for Solaris, and __i860, and a few others
2589 * (guessing it is necessary for all of them).
2593 hackname = svr4_mach_defines;
2595 select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
2596 sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
2602 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2603 * They are declared as non-static then immediately redeclared as static.
2607 hackname = svr4_mkdev;
2608 files = sys/mkdev.h;
2611 sed = "/^dev_t makedev(/s/^/static /";
2612 sed = "/^major_t major(/s/^/static /";
2613 sed = "/^minor_t minor(/s/^/static /";
2619 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2620 * Also fix types of array initializers.
2624 hackname = svr4_netcspace;
2625 files = sys/netcspace.h;
2626 select = 'NC_NPI_RAW';
2627 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2628 sed = 's/NC_/(unsigned long) NC_/';
2633 * Fix reference to NMSZ in <sys/adv.h>.
2637 hackname = svr4_nmsz;
2639 select = '\[NMSZ\]';
2640 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2646 * Fix broken decl of profil present on some svr4 systems.
2649 hackname = svr4_profil;
2654 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2656 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2659 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2664 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2668 hackname = svr4_proto_form;
2670 select = 'const extern';
2672 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2677 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2682 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2687 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2692 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2693 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2694 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2695 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2696 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2697 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2702 * Add a prototyped declaration of mmap to <sys/mman.h>.
2706 hackname = svr4_proto_mmap;
2708 select = '^extern caddr_t mmap();$';
2709 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2710 "#ifdef __STDC__\\\n"
2711 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2712 "#else /* !defined(__STDC__) */\\\n"
2713 "extern caddr_t mmap ();\\\n"
2714 "#endif /* !defined(__STDC__) */\\\n";
2719 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2723 hackname = svr4_sigaction;
2724 files = sys/signal.h;
2725 sed = "/^struct sigaction {/i\\\n"
2726 "#define _SIGACTION_";
2727 sed = 's/(void *(\*)())/(void (*)(int))/';
2732 * Put storage class at start of decl, to avoid warning.
2736 hackname = svr4_storage_class;
2737 files = rpc/types.h;
2738 select = 'const extern';
2739 sed = 's/const extern/extern const/g';
2745 * Like svr4_mach_defines, but with newfangled syntax.
2746 * Source lines are of #define __i386 #machine(i386). Delete them.
2750 hackname = svr5_mach_defines;
2752 select = "#define[ \t]*__i386.*\(i386\)";
2753 sed = "/#define[ \t]*__i386.*/d";
2759 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2760 * in string.h on sysV68
2761 * Correct the return type for strlen in string.h on Lynx.
2762 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2763 * Add missing const for strdup on OSF/1 V3.0.
2764 * On sysV88 layout is slightly different.
2767 hackname = sysv68_string;
2771 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2772 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2773 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2775 sed = "/^extern char$/N";
2776 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2778 sed = "/^extern int$/N";
2779 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2781 sed = "/^\tstrncmp(),$/N";
2782 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
2783 '\1;' "\\\nextern unsigned int\\\n\\2/";
2786 "extern int strlen();\n"
2788 "extern int ffs(long);\n"
2801 "\tstrlen(), strspn();";
2806 * Fix return type of calloc, malloc, realloc, bsearch and exit
2809 hackname = sysz_stdlib_for_sun;
2812 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
2814 c_fix_arg = "void *\t%1(";
2817 "extern char*\tcalloc(size_t);\n"
2818 "extern char*\tmalloc(size_t);\n"
2819 "extern char*\trealloc(void*,size_t);\n"
2820 "extern char*\tbsearch(void*,size_t,size_t);\n";
2825 * if the #if says _cplusplus, not the double underscore __cplusplus
2829 hackname = tinfo_cplusplus;
2831 select = "[ \t]_cplusplus";
2834 c_fix_arg = " __cplusplus";
2835 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
2840 * function parameter to atexit is missing "void" on VAX Ultrix 4.3.
2843 hackname = ultrix_atexit_param;
2845 select = 'atexit\(.*\(\)';
2848 c_fix_arg = "atexit( void (*__func)( void )";
2850 test_text = "int atexit( void (*__func)() );\n";
2855 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2858 hackname = ultrix_atof_param;
2860 select = "atof\\([ \t]*char";
2863 c_fix_arg = "atof(const char";
2865 test_text = "extern double atof( char *__nptr);\n";
2870 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2873 hackname = ultrix_const;
2875 select = 'perror\( char \*';
2878 c_fix_arg = "%1 const %3 *__";
2879 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
2880 "[ \t]+(char|void) \\*__";
2883 "extern void perror( char *__s );\n"
2884 "extern int fputs( char *__s, FILE *);\n"
2885 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
2886 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
2887 "extern int scanf( char *__format, ...);\n";
2892 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2895 hackname = ultrix_const2;
2898 select = '\*fopen\( char \*';
2900 c_fix_arg = "%1( const char *%3, const char *";
2901 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
2902 "[ \t]*char[ \t]*\\*([^,]*),"
2903 "[ \t]*char[ \t]*\\*[ \t]*";
2906 "extern FILE *fopen( char *__filename, char *__type );\n"
2907 "extern int sscanf( char *__s, char *__format, ...);\n"
2908 "extern FILE *popen(char *, char *);\n"
2909 "extern char *tempnam(char*,char*);\n";
2914 * Ultrix V4.[35] puts the declaration of uname before the definition
2915 * of struct utsname, so the prototype (added by fixproto) causes havoc.
2918 hackname = ultrix_fix_fixproto;
2919 files = sys/utsname.h;
2923 c_fix_arg = "struct utsname;\n%0";
2924 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
2927 "/* ULTRIX's uname */\nextern\tint\tuname();";
2932 * Check for bad #ifdef line (in Ultrix 4.1)
2935 hackname = ultrix_ifdef;
2936 select = "^#ifdef KERNEL[ \t]+&&";
2940 c_fix_arg = "#if defined(KERNEL) &&";
2943 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
2948 * Strip "|| CC$gfloat" from Ultrix math headers.
2951 hackname = ultrix_math_ifdef;
2952 files = sys/limits.h;
2955 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
2959 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
2964 * Avoid nested comments on Ultrix 4.3.
2967 hackname = ultrix_nested_ioctl;
2968 files = sys/ioctl.h;
2969 select = "^/\\* #define SIOCSCREEN";
2970 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
2972 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
2973 "/* screend, net/gw_screen.h */\n";
2978 hackname = ultrix_nested_svc;
2980 select = "^ \\*[ \t]*int protocol; */\\*";
2981 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
2983 " *\tint protocol; /* like TCP or UDP\n";
2988 * Add missing prototype for lstat and define for S_ISLNK
2989 * in Ultrix V4.3 sys/stat.h.
2992 hackname = ultrix_stat;
2994 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
2995 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
2997 "/* macro to test for symbolic link */\\\n"
2998 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
3000 sed = "/^[ \t]*fstat(),$/a\\\n"
3003 "@(#)stat.h 6.1 (ULTRIX)\n"
3004 "#define S_IFPORT S_IFIFO\n"
3010 * Check for superfluous `static' (in Ultrix 4.2)
3011 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
3014 hackname = ultrix_static;
3015 files = machine/cpu.h;
3016 select = '#include "r[34]_cpu';
3017 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
3018 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
3019 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
3021 "static struct tlb_pid_state {\n"
3022 "#include \"r3_cpu.h\"\n";
3027 * Add once-only latch to Ultrix V4.3 strings.h.
3030 hackname = ultrix_strings;
3032 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
3035 "@(#)strings.h 6.1 (ULTRIX)\n";
3040 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
3041 * terminated lines, so accommodate these. Test both ways.
3044 hackname = undefine_null;
3045 select = "^#[ \t]*define[ \t]+NULL[ \t]";
3046 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
3049 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
3050 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
3052 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
3056 * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict"
3057 * which must be replaced by __restrict__ for GCC.
3060 hackname = unicosmk_restrict;
3064 mach = "*-*-unicosmk*";
3065 select = "(\\*[ \t]*)restrict([ \t]+)";
3068 c_fix_arg = "%1__restrict__%2";
3070 test_text = "void f (char * restrict x);";
3074 * If arpa/inet.h prototypes are incompatible with the ones we just
3075 * installed in <sys/byteorder.h>, just remove the protos.
3076 * Because of this close association, this patch must be applied only
3077 * on those systems where the replacement byteorder header is installed.
3080 hackname = uw7_byteorder_fix;
3081 files = arpa/inet.h;
3082 select = "in_port_t";
3083 test = "-f sys/byteorder.h";
3085 mach = "*-*-sysv4*";
3086 mach = "i?86-*-sysv5*";
3087 mach = "i?86-*-udk*";
3088 mach = "i?86-*-solaris2.[0-4]";
3089 mach = "powerpcle-*-solaris2.[0-4]";
3090 mach = "sparc-*-solaris2.[0-4]";
3095 c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
3097 test_text = "extern in_port_t\thtons __P((in_port_t));\n"
3098 "extern in_port_t\tntohs __P((in_port_t));"
3099 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3100 "echo '/* DUMMY */' >> sys/byteorder.h`";
3105 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3108 hackname = va_i960_macro;
3109 files = arch/i960/archI960.h;
3110 select = "__(vsiz|vali|vpad|alignof__)";
3113 c_fix_arg = "__vx%1";
3116 "extern int __vsiz vsiz;\n"
3117 "extern int __vali vali;\n"
3118 "extern int __vpad vpad;\n"
3119 "#define __alignof__(x) ...";
3124 * AIX headers define NULL to be cast to a void pointer,
3125 * which is illegal in ANSI C++.
3128 hackname = void_null;
3138 files = sys/param.h;
3139 files = sys/types.h;
3140 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3142 c_fix_arg = "#define NULL 0";
3143 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3148 * Make VxWorks header which is almost gcc ready fully gcc ready.
3151 hackname = vxworks_gcc_problem;
3152 files = types/vxTypesBase.h;
3153 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3155 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3158 sed = "/[ \t]size_t/i\\\n"
3159 "#ifndef _GCC_SIZE_T\\\n"
3160 "#define _GCC_SIZE_T\n";
3162 sed = "/[ \t]size_t/a\\\n"
3165 sed = "/[ \t]ptrdiff_t/i\\\n"
3166 "#ifndef _GCC_PTRDIFF_T\\\n"
3167 "#define _GCC_PTRDIFF_T\n";
3169 sed = "/[ \t]ptrdiff_t/a\\\n"
3172 sed = "/[ \t]wchar_t/i\\\n"
3173 "#ifndef _GCC_WCHAR_T\\\n"
3174 "#define _GCC_WCHAR_T\n";
3176 sed = "/[ \t]wchar_t/a\\\n"
3180 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3181 "typedef unsigned int size_t;\n"
3182 "typedef long ptrdiff_t;\n"
3183 "typedef unsigned short wchar_t;\n"
3184 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3189 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3192 hackname = vxworks_needs_vxtypes;
3194 select = "uint_t([ \t]+_clocks_per_sec)";
3196 c_fix_arg = "unsigned int%1";
3197 test_text = "uint_t\t_clocks_per_sec;";
3202 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3205 hackname = vxworks_needs_vxworks;
3207 test = " -r types/vxTypesOld.h";
3208 test = " -n \"`egrep '#include' $file`\"";
3209 test = " -n \"`egrep ULONG $file`\"";
3210 select = "#[ \t]define[ \t]+__INCstath";
3212 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3213 "#include <types/vxTypesOld.h>\n";
3215 test_text = "`touch types/vxTypesOld.h`"
3216 "#include </dev/null> /* ULONG */\n"
3217 "# define\t__INCstath <sys/stat.h>";
3222 * Another bad dependency in VxWorks 5.2 <time.h>.
3225 hackname = vxworks_time;
3227 test = " -r vxWorks.h";
3229 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3233 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3234 "#ifdef __cplusplus\n"
3235 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3237 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3239 "#define __gcc_VOIDFUNCPTR_defined\n"
3241 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3243 test_text = "`touch vxWorks.h`"
3244 "#define VOIDFUNCPTR (void(*)())";
3249 * There are several name conflicts with C++ reserved words in X11 header
3250 * files. These are fixed in some versions, so don't do the fixes if
3251 * we find __cplusplus in the file. These were found on the RS/6000.
3254 hackname = x11_class;
3255 files = X11/ShellP.h;
3256 bypass = __cplusplus;
3257 select = "^([ \t]*char \\*)class;(.*)";
3259 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3260 "#else\n%1class;%2\n#endif";
3269 * class in Xm/BaseClassI.h
3272 hackname = x11_class_usage;
3273 files = Xm/BaseClassI.h;
3274 bypass = "__cplusplus";
3276 select = " class\\)";
3278 c_fix_arg = " c_class)";
3280 test_text = "extern mumble (int class);\n";
3285 * new in Xm/Traversal.h
3289 files = Xm/Traversal.h;
3290 bypass = __cplusplus;
3292 sed = "/Widget\told, new;/i\\\n"
3293 "#ifdef __cplusplus\\\n"
3294 "\tWidget\told, c_new;\\\n"
3297 sed = "/Widget\told, new;/a\\\n"
3300 sed = "s/Widget new,/Widget c_new,/g";
3303 " Widget\told, new; /* fix the new */\n"
3304 "};\nextern Wedged( Widget new, Widget old );";
3309 * Incorrect sprintf declaration in X11/Xmu.h
3312 hackname = x11_sprintf;
3314 files = X11/Xmu/Xmu.h;
3315 select = "^extern char \\*\tsprintf\\(\\);$";
3318 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3320 test_text = "extern char *\tsprintf();";