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 Set up a debug test so we can make the templates emit special
10 code while debugging these fixes: */
16 /* DO NOT DO BROKEN FIXES (empty replacement fixes) */
19 * Purge some HP-UX 11 files that are only broken after they are "fixed".
22 hackname = AAA_ki_iface;
23 files = sys/ki_iface.h;
24 select = 'These definitions are for HP Internal developers';
25 replace; /* empty replacement -> no fixing the file */
30 * Purge some HP-UX 11 files that are only broken after they are "fixed".
35 select = '11.00 HP-UX LP64';
36 replace; /* empty replacement -> no fixing the file */
41 * Purge some HP-UX 11 files that are only broken after they are "fixed".
44 hackname = AAA_ki_calls;
45 files = sys/ki_calls.h;
46 select = 'kthread_create_caller_t';
47 replace; /* empty replacement -> no fixing the file */
52 * Purge some HP-UX 11 files that are only broken after they are "fixed".
55 hackname = AAA_ki_defs;
56 files = sys/ki_defs.h;
57 select = 'Kernel Instrumentation Definitions';
58 replace; /* empty replacement -> no fixing the file */
63 * Tru64 UNIX V4.0F/V5.1 <standards.h> defines _NO_PROTO and _NONSTD_TYPES
64 * correctly for GCC, but strict_ansi_not breaks it.
67 hackname = AAA_standards;
69 select = 'GNU and MIPS C compilers define __STDC__ differently';
70 replace; /* empty replacement -> no fixing the file */
75 * This file on SunOS 4 has a very large macro. When the sed loop
76 * tries pull it in, it overflows the pattern space size of the SunOS
77 * sed (GNU sed does not have this problem). Since the file does not
78 * require fixing, we remove it from the fixed directory.
81 hackname = AAA_bad_fixes;
82 files = sundev/ipi_error.h;
83 /* shouldn't there be a select expression here??? */
84 replace; /* empty replacement -> no fixing the file */
89 * Purge some HP-UX 11 files that are only broken after they are "fixed".
94 select = '11.0 and later representation of ki time';
95 replace; /* empty replacement -> no fixing the file */
98 /* And now, the real fixes, replacement text fixes first: */
101 * Completely replace <_int_varargs.h> with a file that includes gcc's
102 * stdarg.h or varargs.h files as appropriate on DG/UX
105 hackname = AAB_dgux_int_varargs;
106 files = _int_varargs.h;
108 "#ifndef __INT_VARARGS_H
109 \#define __INT_VARARGS_H
111 /************************************************************************/
112 /* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio. */
113 /************************************************************************/
116 ** This file is a DG internal header. Never include this
120 \#ifndef ___int_features_h
121 \#include <sys/_int_features.h>
124 \#if !(defined(_VA_LIST) || defined(_VA_LIST_))
131 typedef void * va_list;
133 typedef char * va_list;
139 \#if defined(__DCC__)
147 \#else /* ! defined(__DCC__) */
150 int __va_arg; /* argument number */
151 int *__va_stk; /* start of args passed on stack */
152 int *__va_reg; /* start of args passed in regs */
155 \#endif /* ! defined(__DCC__) */
159 \#if defined(__GNUC__) || defined(__STDC__)
160 typedef void * va_list;
162 typedef char * va_list;
165 \#endif /* _IX86_ANY */
167 \#endif /* __LINT__ */
168 \#endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
169 \#endif /* #ifndef __INT_VARARGS_H */\n";
174 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
177 hackname = AAB_fd_zero_asm_posix_types_h;
178 files = asm/posix_types.h;
179 mach = 'i[34567]86-*-linux*';
183 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
184 * the start, so that if #include_next gets another instance of
185 * the wrapper, this will follow the #include_next chain until
186 * we arrive at the real <asm/posix_types.h>.
190 '/* This file fixes a bug in the __FD_ZERO macro
191 for older versions of the Linux kernel. */
192 \#ifndef _POSIX_TYPES_H_WRAPPER
193 \#include <features.h>
194 \#include_next <asm/posix_types.h>
196 \#if defined(__FD_ZERO) && !defined(__GLIBC__)
198 \#define __FD_ZERO(fdsetp) \\
201 __asm__ __volatile__("cld ; rep ; stosl" \\
202 : "=&c" (__d0), "=&D" (__d1) \\
203 : "a" (0), "0" (__FDSET_LONGS), \\
204 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \\
208 \#define _POSIX_TYPES_H_WRAPPER
209 \#endif /* _POSIX_TYPES_H_WRAPPER */
215 * This fixes __FD_ZERO bug for glibc-1.x
218 hackname = AAB_fd_zero_gnu_types_h;
220 mach = 'i[34567]86-*-linux*';
223 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
224 * the start, so that if #include_next gets another instance of
225 * the wrapper, this will follow the #include_next chain until
226 * we arrive at the real <gnu/types.h>.
230 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
231 \#ifndef _TYPES_H_WRAPPER
232 \#include <features.h>
233 \#include_next <gnu/types.h>
235 \#if defined(__FD_ZERO) && !defined(__GLIBC__)
237 \# define __FD_ZERO(fdsetp) \\
240 __asm__ __volatile__("cld ; rep ; stosl" \\
241 : "=&c" (__d0), "=&D" (__d1) \\
242 : "a" (0), "0" (__FDSET_LONGS), \\
243 "1" ((__fd_set *) (fdsetp)) :"memory"); \\
247 \#define _TYPES_H_WRAPPER
248 \#endif /* _TYPES_H_WRAPPER */
254 * This fixes __FD_ZERO bug for glibc-2.0.x
257 hackname = AAB_fd_zero_selectbits_h;
258 files = selectbits.h;
259 mach = 'i[34567]86-*-linux*';
262 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
263 * the start, so that if #include_next gets another instance of
264 * the wrapper, this will follow the #include_next chain until
265 * we arrive at the real <selectbits.h>.
269 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
270 \#ifndef _SELECTBITS_H_WRAPPER
271 \#include <features.h>
272 \#include_next <selectbits.h>
274 \#if defined(__FD_ZERO) && defined(__GLIBC__) \\
275 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
276 && __GLIBC_MINOR__ == 0
278 \#define __FD_ZERO(fdsetp) \\
281 __asm__ __volatile__ ("cld; rep; stosl" \\
282 : "=&c" (__d0), "=&D" (__d1) \\
283 : "a" (0), "0" (sizeof (__fd_set) \\
284 / sizeof (__fd_mask)), \\
285 "1" ((__fd_mask *) (fdsetp)) \\
290 \#define _SELECTBITS_H_WRAPPER
291 \#endif /* _SELECTBITS_H_WRAPPER */
297 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
298 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
299 * many other systems have similar text but correct versions of the file.
300 * To ensure only Sun's is fixed, we grep for a likely unique string.
301 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
304 hackname = AAB_sun_memcpy;
306 select = "/\\*\t@\\(#\\)"
307 "(head/memory.h\t50.1\t "
308 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
311 '/* This file was generated by fixincludes */
312 \#ifndef __memory_h__
313 \#define __memory_h__
316 extern void *memccpy();
317 extern void *memchr();
318 extern void *memcpy();
319 extern void *memset();
321 extern char *memccpy();
322 extern char *memchr();
323 extern char *memcpy();
324 extern char *memset();
325 \#endif /* __STDC__ */
329 \#endif /* __memory_h__ */
336 * Completely replace <sys/byteorder.h>; with a file that implements gcc's
337 * optimized byteswapping. Restricted to "SVR4" machines until either
338 * it is shown to be safe to replace this file always, or we get bolder ;-)
341 hackname = AAB_svr4_replace_byteorder;
344 mach = "i[34567]86-*-sysv5*";
345 mach = "i[34567]86-*-udk*";
346 mach = "i[34567]86-*-solaris2.[0-4]";
347 mach = "powerpcle-*-solaris2.[0-4]";
348 mach = "sparc-*-solaris2.[0-4]";
350 files = sys/byteorder.h;
351 replace = '#ifndef _SYS_BYTEORDER_H
352 \#define _SYS_BYTEORDER_H
354 /* Functions to convert `short\' and `long\' quantities from host byte order
355 to (internet) network byte order (i.e. big-endian).
357 Written by Ron Guilmette (rfg@ncd.com).
359 This isn\'t actually used by GCC. It is installed by fixinc.svr4.
361 For big-endian machines these functions are essentially no-ops.
363 For little-endian machines, we define the functions using specialized
364 asm sequences in cases where doing so yields better code (e.g. i386). */
366 \#if !defined (__GNUC__) && !defined (__GNUG__)
367 \#error You lose! This file is only useful with GNU compilers.
370 \#ifndef __BYTE_ORDER__
371 /* Byte order defines. These are as defined on UnixWare 1.1, but with
372 double underscores added at the front and back. */
373 \#define __LITTLE_ENDIAN__ 1234
374 \#define __BIG_ENDIAN__ 4321
375 \#define __PDP_ENDIAN__ 3412
379 static __inline__ unsigned long htonl (unsigned long);
380 static __inline__ unsigned short htons (unsigned int);
381 static __inline__ unsigned long ntohl (unsigned long);
382 static __inline__ unsigned short ntohs (unsigned int);
383 \#endif /* defined (__STDC__) */
385 \#if defined (__i386__)
387 \#ifndef __BYTE_ORDER__
388 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
391 /* Convert a host long to a network long. */
393 /* We must use a new-style function definition, so that this will also
395 static __inline__ unsigned long
396 htonl (unsigned long __arg)
398 register unsigned long __result;
400 __asm__ ("xchg%B0 %b0,%h0
402 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
406 /* Convert a host short to a network short. */
408 static __inline__ unsigned short
409 htons (unsigned int __arg)
411 register unsigned short __result;
413 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
417 \#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \\
418 || defined (__ns32k__) || defined (__vax__) \\
419 || defined (__spur__) || defined (__arm__))
421 \#ifndef __BYTE_ORDER__
422 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
425 /* For other little-endian machines, using C code is just as efficient as
426 using assembly code. */
428 /* Convert a host long to a network long. */
430 static __inline__ unsigned long
431 htonl (unsigned long __arg)
433 register unsigned long __result;
435 __result = (__arg >> 24) & 0x000000ff;
436 __result |= (__arg >> 8) & 0x0000ff00;
437 __result |= (__arg << 8) & 0x00ff0000;
438 __result |= (__arg << 24) & 0xff000000;
442 /* Convert a host short to a network short. */
444 static __inline__ unsigned short
445 htons (unsigned int __arg)
447 register unsigned short __result;
449 __result = (__arg << 8) & 0xff00;
450 __result |= (__arg >> 8) & 0x00ff;
454 \#else /* must be a big-endian machine */
456 \#ifndef __BYTE_ORDER__
457 \#define __BYTE_ORDER__ __BIG_ENDIAN__
460 /* Convert a host long to a network long. */
462 static __inline__ unsigned long
463 htonl (unsigned long __arg)
468 /* Convert a host short to a network short. */
470 static __inline__ unsigned short
471 htons (unsigned int __arg)
476 \#endif /* big-endian */
478 /* Convert a network long to a host long. */
480 static __inline__ unsigned long
481 ntohl (unsigned long __arg)
483 return htonl (__arg);
486 /* Convert a network short to a host short. */
488 static __inline__ unsigned short
489 ntohs (unsigned int __arg)
491 return htons (__arg);
499 * Completely replace <sys/varargs.h> with a file that includes gcc's
500 * stdarg.h or varargs.h files as appropriate.
504 hackname = AAB_svr4_no_varargs;
505 files = sys/varargs.h;
506 replace = "/* This file was generated by fixincludes. */\n"
507 "#ifndef _SYS_VARARGS_H\n"
508 "#define _SYS_VARARGS_H\n\n"
511 "#include <stdarg.h>\n"
513 "#include <varargs.h>\n"
516 "#endif /* _SYS_VARARGS_H */\n";
522 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
525 hackname = AAB_ultrix_ansi_compat;
526 files = ansi_compat.h;
528 replace = "/* This file intentionally left blank. */\n";
533 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
534 * Replace limits.h with a file that includes sys/limits.h.
537 hackname = AAB_ultrix_limits;
539 mach = "*-*-ultrix4.3";
541 '#ifndef _LIMITS_INCLUDED
542 \#define _LIMITS_INCLUDED
543 \#include <sys/limits.h>
544 \#endif /* _LIMITS_INCLUDED */
550 * The ULTRIX 4.3 version of memory.h duplicates definitions
551 * present in strings.h. Replace memory.h with a file that includes
552 * strings.h to prevent problems from multiple inclusion.
555 hackname = AAB_ultrix_memory;
557 mach = "*-*-ultrix4.3";
559 '#ifndef _MEMORY_INCLUDED
560 \#define _MEMORY_INCLUDED
561 \#include <strings.h>
562 \#endif /* _MEMORY_INCLUDED */
568 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
569 * Replace string.h link with a file that includes strings.h to prevent
570 * problems from multiple inclusion.
573 hackname = AAB_ultrix_string;
575 mach = "*-*-ultrix4.3";
577 '#ifndef _STRING_INCLUDED
578 \#define _STRING_INCLUDED
579 \#include <strings.h>
580 \#endif /* _STRING_INCLUDED */
586 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
587 * which violates a requirement of ISO C.
590 hackname = aix_pthread;
592 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
595 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
596 "{...init stuff...}";
601 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
602 * in an otherwise harmless (and #ifed out) macro definition
605 hackname = aix_sysmachine;
606 files = sys/machine.h;
610 test_text = "#define FOO \\\n"
611 " bar \\ \n baz \\ \n bat";
616 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
617 * definition of struct rusage, so the prototype added by fixproto fails.
620 hackname = aix_syswait;
622 select = "^extern pid_t wait3\\(\\);\n";
625 c_fix_arg = "struct rusage;\n%0";
626 test_text = "/* bos325, */\n"
627 "extern pid_t wait3();\n"
628 "\t/* pid_t wait3(int *, int, struct rusage *); */";
633 * sys/signal.h on some versions of AIX uses volatile in the typedef of
634 * sig_atomic_t, which causes gcc to generate a warning about duplicate
635 * volatile when a sig_atomic_t variable is declared volatile, as
636 * required by ANSI C.
639 hackname = aix_volatile;
640 files = sys/signal.h;
641 select = "typedef volatile int sig_atomic_t";
643 c_fix_arg = "typedef int sig_atomic_t";
644 test_text = "typedef volatile int sig_atomic_t;";
649 * Fix __assert declaration in assert.h on Alpha OSF/1.
652 hackname = alpha___assert;
654 select = '__assert\(char \*, char \*, int\)';
656 c_fix_arg = "__assert(const char *, const char *, int)";
657 test_text = 'extern void __assert(char *, char *, int);';
662 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
665 hackname = alpha_getopt;
668 select = 'getopt\(int, char \*\[\], *char \*\)';
670 c_fix_arg = "getopt(int, char *const[], const char *)";
671 test_text = 'extern int getopt(int, char *[], char *);';
676 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
679 hackname = alpha_parens;
681 select = '#ifndef\(__mips64\)';
683 c_fix_arg = "#ifndef __mips64";
684 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
689 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
692 hackname = alpha_sbrk;
694 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
696 c_fix_arg = "void *sbrk(";
697 test_text = "extern char* sbrk(ptrdiff_t increment);";
702 * Fix this ARM/RISCiX file where ___type is a Compiler
703 * hint that is specific to the Norcroft compiler.
706 hackname = arm_norcroft_hint;
707 select = "___type p_type";
708 files = "X11/Intrinsic.h";
710 c_fix_arg = "p_type";
711 test_text = "___type p_type mumble;";
716 * Fix this ARM/RISCiX file to avoid interfering
717 * with the use of __wchar_t in cc1plus.
720 hackname = arm_wchar;
722 select = "#[ \t]*define[ \t]*__wchar_t";
725 c_fix_arg = "%1_GCC_WCHAR_T";
726 c_fix_arg = "(#[ \t]*(ifndef|define)[ \t]+)__wchar_t";
729 "# ifndef \t __wchar_t /* we don't have wchar_t yet, ... */\n"
730 "# define __wchar_t short\n"
731 "# endif /* __wchar_t */";
736 * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89;
737 * gcc doesn't understand it.
742 select = "#ifndef NOINLINE";
745 c_fix_arg = "#if !defined(NOINLINE) && !defined(__GNUC__)";
748 "#ifndef NOINLINE /* ain't got no inline, so we got it */\n"
749 "#endif /* NOINLINE */";
754 * For C++, avoid any typedef or macro definition of bool,
755 * and use the built in type instead.
756 * HP/UX 10.20 also has it in curses_colr/curses.h.
759 hackname = avoid_bool_define;
761 files = curses_colr/curses.h;
765 select = "#[ \t]*define[ \t]+bool[ \t]";
766 bypass = "we must use the C\\+\\+ compiler's type";
769 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
770 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
772 test_text = "# define bool\t char \n";
776 hackname = avoid_bool_type;
778 files = curses_colr/curses.h;
782 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
783 bypass = "we must use the C\\+\\+ compiler's type";
786 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
788 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
792 * For C++, avoid any typedef definition of wchar_t,
793 * and use the built in type instead.
797 hackname = avoid_wchar_t_type;
799 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
802 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
804 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
808 * Fix #defines under Alpha OSF/1:
809 * The following files contain '#pragma extern_prefix "_FOO"' followed by
810 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
811 * statements is to reduce namespace pollution. While these macros work
812 * properly in most cases, they don't allow you to take a pointer to the
813 * "something" being modified. To get around this limitation, change these
814 * statements to be of the form '#define something _FOOsomething'.
816 * sed ain't egrep, lesson 2463: sed can use self-referential
817 * regular expressions. In the substitute expression below,
818 * "\\1" and "\\2" refer to subexpressions found earlier in the
819 * same match. So, we continue to use sed. "extern_prefix" will
820 * be a rare match anyway...
825 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
843 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
844 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
846 test_text = '#pragma extern_prefix "_FOO"'"\n"
847 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
848 "#define mumble _FOOmumble";
853 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
856 hackname = bad_struct_term;
858 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
860 c_fix_arg = "struct term;";
862 test_text = 'typedef struct term;';
867 * Fix one other error in this file:
868 * a mismatched quote not inside a C comment.
872 files = sundev/vuid_event.h;
875 c_fix_arg = "does not";
877 test_text = "/* doesn't have matched single quotes */";
882 * check for broken assert.h that needs stdio.h
885 hackname = broken_assert_stdio;
888 bypass = "include.*stdio\\.h";
890 c_fix_arg = "#include <stdio.h>\n";
891 test_text = "extern FILE* stderr;";
896 * check for broken assert.h that needs stdlib.h
899 hackname = broken_assert_stdlib;
901 select = 'exit *\(|abort *\(';
902 bypass = "include.*stdlib\\.h";
904 c_fix_arg = "#ifdef __cplusplus\n"
905 "#include <stdlib.h>\n"
907 test_text = "extern void exit ( int );";
912 * Remove `extern double cabs' declarations from math.h.
913 * This conflicts with C99. Discovered on AIX.
914 * SunOS4 has its cabs() declaration followed by a comment which
915 * terminates on the following line.
918 hackname = broken_cabs;
920 select = '^extern[ \t]+double[ \t]+cabs';
924 c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
926 test_text = "#ifdef __STDC__\n"
927 "extern double cabs(struct dbl_hypot);\n"
929 "extern double cabs();\n"
931 "extern double cabs(); /* This is a comment\n"
932 " and it ends here. */";
937 * Fix various macros used to define ioctl numbers.
938 * The traditional syntax was:
940 * #define _CTRL(n, x) (('n'<<8)+x)
941 * #define TCTRLCFOO _CTRL(T, 1)
943 * but this does not work with the C standard, which disallows macro
944 * expansion inside strings. We have to rewrite it thus:
946 * #define _CTRL(n, x) ((n<<8)+x)
947 * #define TCTRLCFOO _CTRL('T', 1)
949 * The select expressions match too much, but the c_fix code is cautious.
951 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
954 hackname = ctrl_quotes_def;
955 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
956 c_fix = char_macro_def;
960 * This is two tests in order to ensure that the "CTRL(c)" can
961 * be selected in isolation from the multi-arg format
963 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
964 test_text = "#define _CTRL(c) ('c'&037)";
968 hackname = ctrl_quotes_use;
969 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
970 c_fix = char_macro_use;
972 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
977 * sys/mman.h on HP/UX is not C++ ready,
978 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
980 * rpc/types.h on OSF1/2.0 is not C++ ready,
981 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
983 * The problem is the declaration of malloc.
986 hackname = cxx_unready;
989 select = '[^#]+malloc.*;'; /* Catch any form of declaration
990 not within a macro. */
991 bypass = '"C"|__BEGIN_DECLS';
994 c_fix_arg = "#ifdef __cplusplus\n"
997 c_fix_arg = "#ifdef __cplusplus\n"
1000 test_text = "extern void* malloc( size_t );";
1005 * Fix <c_asm.h> on Digital UNIX V4.0:
1006 * It contains a prototype for a DEC C internal asm() function,
1007 * clashing with gcc's asm keyword. So protect this with __DECC.
1010 hackname = dec_intern_asm;
1012 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1013 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1017 " ... asm stuff ...\n"
1018 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1023 * Fix typo in <wchar.h> on DJGPP 2.03.
1026 hackname = djgpp_wchar_h;
1028 select = "__DJ_wint_t";
1029 bypass = "sys/djtypes.h";
1031 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1032 c_fix_arg = "#include <stddef.h>";
1033 test_text = "#include <stddef.h>\n"
1034 "extern __DJ_wint_t x;\n";
1038 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1041 hackname = ecd_cursor;
1042 files = "sunwindow/win_lock.h";
1043 files = "sunwindow/win_cursor.h";
1044 select = 'ecd\.cursor';
1046 c_fix_arg = 'ecd_cursor';
1048 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1053 * fix-header doesn't fix fabs' prototype, and I have no idea why.
1056 hackname = fix_header_breakage;
1057 mach = "m88k-motorola-sysv3*";
1060 select = 'extern double floor\(\), ceil\(\), fmod\(\), fabs\(\);';
1063 'extern double floor(), ceil(), fmod(), fabs _PARAMS((double));';
1064 test_text = 'extern double floor(), ceil(), fmod(), fabs();';
1069 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1070 * neither the existence of GCC 3 nor its exact feature set yet break
1071 * (by design?) when __GNUC__ is set beyond 2.
1074 hackname = freebsd_gcc3_breakage;
1075 mach = *-*-freebsd*;
1076 files = sys/cdefs.h;
1077 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1078 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1080 c_fix_arg = '%0 || __GNUC__ >= 3';
1081 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1086 * Fix HP & Sony's use of "../machine/xxx.h"
1087 * to refer to: <machine/xxx.h>
1090 hackname = hp_inline;
1091 files = sys/spinlock.h;
1092 files = machine/machparam.h;
1093 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1096 c_fix_arg = "%1<machine/%2.h>";
1098 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1101 test_text = ' # include "../machine/mumble.h"';
1106 * Check for (...) in C++ code in HP/UX sys/file.h.
1109 hackname = hp_sysfile;
1111 select = "HPUX_SOURCE";
1114 c_fix_arg = "(struct file *, ...)";
1115 c_fix_arg = '\(\.\.\.\)';
1117 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1122 * Keep HP-UX 11 from stomping on C++ math namespace
1123 * with defines for fabsf.
1126 hackname = hpux11_fabsf;
1128 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1129 bypass = "__cplusplus";
1132 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1136 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1142 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1143 * of UINT32_C has undefined behavior according to ISO/ANSI:
1144 * the arguments to __CONCAT__ are not macro expanded before the
1145 * concatination happens so the trailing ')' in the first argument
1146 * is concatinated with the 'l' in the second argument creating an
1147 * invalid pp token. The behavior of invalid pp tokens is undefined.
1148 * GCC does not handle these invalid tokens the way the HP compiler does.
1149 * This problem will potentially occur anytime macros are used in the
1150 * arguments to __CONCAT__. A general solution to this problem would be to
1151 * insert another layer of macro between __CONCAT__ and its use
1152 * in UINT32_C. An example of this solution can be found in the C standard.
1153 * A more specific solution, the one used here, is to change the UINT32_C
1154 * macro to not used macros in the arguments to __CONCAT__.
1157 hackname = hpux11_uint32_c;
1159 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1160 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1162 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1164 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1165 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1170 * get rid of bogus inline definitions in HP-UX 8.0
1173 hackname = hpux8_bogus_inlines;
1176 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1177 "@extern \"C\" int abs(int);@";
1178 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1179 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1180 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1181 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1182 "inline double sqr(double v) { return v**0.5; }";
1187 * Fix return type of abort and free
1190 hackname = int_abort_free_and_exit;
1192 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1195 c_fix_arg = "void\t%1(";
1197 test_text = "extern int abort(int);\n"
1198 "extern int free(void*);\n"
1199 "extern int exit(void*);";
1204 * On Interactive Unix 2.2, certain traditional Unix definitions
1205 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
1206 * defined, not just if _POSIX_SOURCE is defined. This makes it
1207 * impossible to compile any nontrivial program except with -posix.
1210 hackname = isc_omits_with_stdc;
1215 files = "sys/limits.h";
1216 files = "sys/fcntl.h";
1217 files = "sys/dirent.h";
1219 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1221 c_fix_arg = '!defined(_POSIX_SOURCE)';
1222 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1223 "\nint foo;\n#endif";
1228 * Fix various macros used to define ioctl numbers.
1229 * The traditional syntax was:
1231 * #define _IO(n, x) (('n'<<8)+x)
1232 * #define TIOCFOO _IO(T, 1)
1234 * but this does not work with the C standard, which disallows macro
1235 * expansion inside strings. We have to rewrite it thus:
1237 * #define _IO(n, x) ((n<<8)+x)
1238 * #define TIOCFOO _IO('T', 1)
1240 * The select expressions match too much, but the c_fix code is cautious.
1242 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1245 hackname = io_quotes_def;
1246 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1247 c_fix = char_macro_def;
1250 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1251 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1252 "#define _IO(x,y) ('x'<<8|y)";
1254 "#define XX_IO(x) ('x'<<8|256)";
1258 hackname = io_quotes_use;
1259 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1261 c_fix = char_macro_use;
1263 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1264 "#define TIOCFOO \\\\\n"
1265 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1270 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1273 hackname = hpux_maxint;
1274 files = sys/param.h;
1276 select = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1277 bypass = "^#[ \t]*ifndef[ \t]+MAXINT";
1279 "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1282 c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1283 c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1285 test_text = '#define MAXINT 0x7FFFFFFF';
1290 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1293 hackname = hpux_systime;
1295 select = "^extern struct sigevent;";
1298 c_fix_arg = "struct sigevent;";
1300 test_text = 'extern struct sigevent;';
1305 * Check for missing ';' in struct
1308 hackname = ip_missing_semi;
1309 files = netinet/ip.h;
1311 sed = "/^struct/,/^};/s/}$/};/";
1317 "}; /* mumbled struct */\n";
1322 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1323 * that causes the assembly preprocessor to complain about an
1324 * unterminated character constant.
1327 hackname = irix_asm_apostrophe;
1330 select = "^[ \t]*#.*[Ww]e're";
1332 c_fix_arg = "%1 are";
1333 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1334 test_text = "\t# and we're on vacation";
1339 * IRIX 5.x's stdio.h declares some functions that take a va_list as
1340 * taking char *. However, GCC uses void * for va_list, so
1341 * calling vfprintf with a va_list fails in C++. */
1343 hackname = irix_stdio_va_list;
1346 select = '(printf\(.*), /\* va_list \*/ char \*';
1348 c_fix_arg = "%1, __gnuc_va_list";
1350 "extern int printf( const char *, /* va_list */ char * );";
1355 * Non-traditional "const" declaration in Irix's limits.h.
1358 hackname = irix_limits_const;
1359 files = fixinc-test-limits.h, limits.h;
1360 select = "^extern const ";
1362 c_fix_arg = "extern __const ";
1363 test_text = "extern const char limit; /* test limits */";
1368 * Fixing ISC fmod declaration
1371 hackname = isc_fmod;
1373 select = 'fmod\(double\)';
1375 c_fix_arg = "fmod(double, double)";
1376 test_text = "extern double fmod(double);";
1381 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1382 * use / * * / to concatenate tokens.
1385 hackname = kandr_concat;
1386 files = "sparc/asm_linkage.h";
1387 files = "sun3/asm_linkage.h";
1388 files = "sun3x/asm_linkage.h";
1389 files = "sun4/asm_linkage.h";
1390 files = "sun4c/asm_linkage.h";
1391 files = "sun4m/asm_linkage.h";
1392 files = "sun4c/debug/asm_linkage.h";
1393 files = "sun4m/debug/asm_linkage.h";
1394 files = "arm/as_support.h";
1395 files = "arm/mc_type.h";
1396 files = "arm/xcb.h";
1397 files = "dev/chardefmac.h";
1398 files = "dev/ps_irq.h";
1399 files = "dev/screen.h";
1400 files = "dev/scsi.h";
1401 files = "sys/tty.h";
1402 files = "Xm.acorn/XmP.h";
1403 files = bsd43/bsd43_.h;
1407 test_text = "#define __CONCAT__(a,b) a/**/b";
1412 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1413 * versions > 1. This fix will open up the declaration for all
1414 * versions of GCC and for g++.
1417 hackname = libc1_ifdefd_memx;
1419 /* The string.h result is overwritten by AAB_ultrix_string when doing
1420 "make check" and will fail. Therefore, we add the following kludgery
1421 to insert the test_text into the special testing header. :-} */
1426 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1427 bypass = __cplusplus;
1430 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1431 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1433 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1437 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1438 "#if defined(__STDC__) && __GNUC__ < 2\n"
1439 "/* Copy N bytes of SRC to DEST. */\n"
1440 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1447 * In limits.h, put #ifndefs around things that are supposed to be defined
1448 * in float.h to avoid redefinition errors if float.h is included first.
1449 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1450 * multi line comments and the inserted #endif winds up inside the
1451 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1452 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1453 * are there, and we do not add them ourselves.
1456 hackname = limits_ifndefs;
1457 files = "sys/limits.h";
1459 bypass = "ifndef[ \t]+FLT_MIN";
1462 c_fix_arg = "#ifndef %1\n%0\n#endif";
1463 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1464 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1465 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1470 * Delete the '#define void int' line from curses.h on Lynx
1473 hackname = lynx_void_int;
1475 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1478 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1483 * Fix fcntl prototype in fcntl.h on LynxOS.
1486 hackname = lynxos_fcntl_proto;
1488 select = "fcntl[ \t]*" '\(int, int, int\)';
1490 c_fix_arg = '%1...)';
1491 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1492 test_text = "extern int fcntl(int, int, int);";
1497 * libm.a on m88k-motorola-sysv3 contains a stupid optimization for
1498 * function hypot(), which returns the second argument without even
1499 * looking at its value, if the other is 0.0.
1502 hackname = m88k_bad_hypot_opt;
1503 mach = "m88k-motorola-sysv3*";
1505 select = "^extern double hypot\\(\\);\n";
1508 "/* Workaround a stupid Motorola optimization if one\n"
1509 " of x or y is 0.0 and the other is negative! */\n"
1511 "static __inline__ double fake_hypot (double x, double y)\n"
1513 "static __inline__ double fake_hypot (x, y)\n"
1517 "\treturn fabs (hypot (x, y));\n"
1519 "#define hypot\tfake_hypot\n";
1520 test_text = "extern double hypot();";
1525 * Fix incorrect S_IF* definitions on m88k-sysv3.
1528 hackname = m88k_bad_s_if;
1529 mach = "m88k-*-sysv3*";
1531 select = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&";
1534 c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)';
1535 c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+"
1537 "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)"
1539 test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */';
1544 * Put cpp wrappers around these include files to avoid redeclaration
1545 * errors during multiple inclusion on m88k-tektronix-sysv3.
1548 hackname = m88k_multi_incl;
1549 mach = "m88k-tektronix-sysv3*";
1558 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1560 * On NetBSD, machine is a symbolic link to an architecture specific
1561 * directory name, so we can't match a specific file name here.
1564 hackname = machine_ansi_h_va_list;
1565 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1566 bypass = '__builtin_va_list';
1569 c_fix_arg = "%1__builtin_va_list";
1570 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1572 test_text = " # define _BSD_VA_LIST_\tchar**";
1577 * Fix non-ansi machine name defines
1580 hackname = machine_name;
1581 c_test = machine_name;
1582 c_fix = machine_name;
1584 test_text = "/* MACH_DIFF: */\n"
1585 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1586 "\n/* no uniform test, so be careful :-) */";
1591 * Some math.h files define struct exception, which conflicts with
1592 * the class exception defined in the C++ file std/stdexcept.h. We
1593 * redefine it to __math_exception. This is not a great fix, but I
1594 * haven't been able to think of anything better.
1595 * Note that we have to put the #ifdef/#endif blocks at beginning
1596 * and end of file, because fixproto runs after us and may insert
1597 * additional references to struct exception.
1600 hackname = math_exception;
1602 select = "struct exception";
1603 bypass = 'We have a problem when using C\+\+';
1606 c_fix_arg = "#ifdef __cplusplus\n"
1607 "#define exception __math_exception\n"
1610 c_fix_arg = "#ifdef __cplusplus\n"
1611 "#undef exception\n"
1614 test_text = "typedef struct exception t_math_exception;";
1619 * This looks pretty broken to me. ``dbl_max_def'' will contain
1620 * "define DBL_MAX " at the start, when what we really want is just
1621 * the value portion. Can't figure out how to write a test case
1622 * for this either :-(
1625 hackname = math_huge_val_from_dbl_max;
1629 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1630 * in math.h, this fix applies.
1632 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1633 bypass = "define[ \t]+DBL_MAX";
1637 * See if we have a definition for DBL_MAX in float.h.
1638 * If we do, we will replace the one in math.h with that one.
1641 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1642 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1644 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1645 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1646 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1651 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1652 "#define HUGE_VAL DBL_MAX";
1657 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1660 hackname = math_huge_val_ifndef;
1662 files = math/math.h;
1663 select = "define[ \t]+HUGE_VAL";
1666 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1667 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1669 test_text = "# define\tHUGE_VAL 3.4e+40";
1674 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1677 hackname = nested_motorola;
1678 mach = "m68k-motorola-sysv*";
1679 files = sys/limits.h;
1681 select = "max # bytes atomic in write|error value returned by Math lib";
1683 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1684 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1685 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1686 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1689 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1691 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1696 * Fixing nested comments in ISC <sys/limits.h>
1699 hackname = nested_sys_limits;
1700 files = sys/limits.h;
1702 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1703 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1704 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1705 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1712 hackname = nested_auth_des;
1714 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1716 c_fix_arg = "%1*/ /*";
1717 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1722 * fix bogus recursive stdlib.h in NEWS-OS 4.0C
1725 hackname = news_os_recursion;
1727 select = "[ \t]*#include <stdlib\\.h>.*";
1730 c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif";
1731 test_text = "#include <stdlib.h>";
1736 * NeXT 3.2 adds const prefix to some math functions.
1737 * These conflict with the built-in functions.
1740 hackname = next_math_prefix;
1741 files = ansi/math.h;
1742 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1745 c_fix_arg = "extern double %1(";
1746 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1748 test_text = "extern\tdouble\t__const__\tmumble();";
1753 * NeXT 3.2 uses the word "template" as a parameter for some
1754 * functions. GCC reports an invalid use of a reserved key word
1755 * with the built-in functions.
1758 hackname = next_template;
1760 select = "[ \t]template\\)";
1764 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1765 test_text = "extern mumble( char * template); /* fix */";
1770 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1771 * function prototypes. That conflicts with the built-in functions.
1774 hackname = next_volitile;
1775 files = ansi/stdlib.h;
1776 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1779 c_fix_arg = "extern void %1(";
1780 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1782 test_text = "extern\tvolatile\tvoid\tabort();";
1787 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1788 * Note that version 3 of the NeXT system has wait.h in a different directory,
1789 * so that this code won't do anything. But wait.h in version 3 has a
1790 * conditional, so it doesn't need this fix. So everything is okay.
1793 hackname = next_wait_union;
1796 select = 'wait\(union wait';
1798 c_fix_arg = "wait(void";
1799 test_text = "extern pid_d wait(union wait*);";
1804 * a missing semi-colon at the end of the nodeent structure definition.
1807 hackname = nodeent_syntax;
1808 files = netdnet/dnetdb.h;
1809 select = "char[ \t]*\\*na_addr[ \t]*$";
1812 test_text = "char *na_addr\t";
1817 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1818 * defining regex.h related types. This causes libg++ build and usage
1819 * failures. Fixing this correctly requires checking and modifying 3 files.
1822 hackname = osf_namespace_a;
1823 files = reg_types.h;
1824 files = sys/lc_core.h;
1825 test = " -r reg_types.h";
1826 test = " -r sys/lc_core.h";
1827 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1828 test = " -z \"`grep __regex_t regex.h`\"";
1832 c_fix_arg = "reg(ex|off|match)_t";
1834 test_text = "`touch sys/lc_core.h`"
1835 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1836 "extern regex_t re;\n"
1837 "extern regoff_t ro;\n"
1838 "extern regmatch_t rm;\n";
1842 hackname = osf_namespace_c;
1844 test = " -r reg_types.h";
1845 test = " -r sys/lc_core.h";
1846 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1847 test = " -z \"`grep __regex_t regex.h`\"";
1849 select = "#include <reg_types\.h>.*";
1852 "typedef __regex_t\tregex_t;\n"
1853 "typedef __regoff_t\tregoff_t;\n"
1854 "typedef __regmatch_t\tregmatch_t;";
1856 test_text = "#include <reg_types.h>";
1861 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1862 * The original ones fail if uninitialized externs are not common.
1863 * This is the default for all ANSI standard C++ compilers.
1866 hackname = pthread_page_size;
1868 select = "^int __page_size";
1870 c_fix_arg = "extern %0";
1871 test_text = "int __page_size;";
1876 * Fix return type of fread and fwrite on sysV68
1879 hackname = read_ret_type;
1881 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1883 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1884 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1886 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1891 * function class(double x) conflicts with C++ keyword on rs/6000
1894 hackname = rs6000_double;
1896 select = '[^a-zA-Z_]class\(';
1899 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1900 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
1902 test_text = "extern int class();";
1907 * Wrong fchmod prototype on RS/6000.
1910 hackname = rs6000_fchmod;
1912 select = 'fchmod\(char \*';
1914 c_fix_arg = "fchmod(int";
1915 test_text = "extern int fchmod(char *, mode_t);";
1920 * parameters conflict with C++ new on rs/6000
1923 hackname = rs6000_param;
1927 select = 'rename\(const char \*old, const char \*new\)';
1929 c_fix_arg = 'rename(const char *_old, const char *_new)';
1931 test_text = 'extern int rename(const char *old, const char *new);';
1936 * The static functions lstat() and fchmod() in <sys/stat.h>
1937 * cause G++ grief since they're not wrapped in "if __cplusplus".
1939 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
1940 * tiny static wrappers that aren't C++ safe.
1943 hackname = sco_static_func;
1945 mach = "i?86-*-sco3.2*";
1946 select = "^static int";
1948 sed = "/^static int/i\\\n"
1949 "#if __cplusplus\\\n"
1950 "extern \"C\" {\\\n"
1951 "#endif /* __cplusplus */";
1954 "#if __cplusplus\\\n"
1956 "#endif /* __cplusplus */";
1960 "static int\tstat(const char *__f, struct stat *__p) {\n"
1961 "\treturn __stat32(__f, __p);\n"
1962 "}\n\n# else /* !__STDC__ */\n"
1964 "static int\tstat(__f, __p)\n"
1966 "\tstruct stat *__p;\n"
1968 "\treturn __stat32(__f, __p);\n"
1975 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
1976 * is "!defined( __STRICT_ANSI__ )"
1979 hackname = strict_ansi_not;
1980 select = "^([ \t]*#[ \t]*if.*)"
1982 "|__STDC__[ \t]*==[ \t]*0"
1983 "|__STDC__[ \t]*!=[ \t]*1"
1984 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
1986 c_test = stdc_0_in_system_headers;
1989 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
1991 test_text = "#if !__STDC__ \n"
1992 "#if __STDC__ == 0\n"
1993 "#if __STDC__ != 1\n"
1994 "#if __STDC__ - 0 == 0"
1995 "/* not std C */\nint foo;\n"
1996 "\n#end-end-end-end-if :-)";
2001 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
2004 hackname = strict_ansi_not_ctd;
2005 files = math.h, limits.h, stdio.h, signal.h, stdlib.h, time.h;
2006 select = "^([ \t]*[|&][|&][ \t(]*)"
2007 "(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
2009 c_test = stdc_0_in_system_headers;
2012 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
2014 test_text = "#if 1\\\n"
2015 "|| __STDC__ - 0 == 0 /* not std C */\nint foo;\n#endif";
2019 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2020 * is "defined( __STRICT_ANSI__ )"
2023 hackname = strict_ansi_only;
2024 select = "^([ \t]*#[ \t]*if.*)"
2025 "(__STDC__[ \t]*!=[ \t]*0"
2026 "|__STDC__[ \t]*==[ \t]*1"
2027 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2028 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0"
2030 c_test = stdc_0_in_system_headers;
2033 c_fix_arg = "%1 defined(__STRICT_ANSI__)%3";
2035 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2040 * Fix prototype declaration of utime in sys/times.h.
2041 * In 3.2v4.0 the const is missing.
2044 hackname = sco_utime;
2045 files = sys/times.h;
2046 mach = "i?86-*-sco3.2v4*";
2048 select = '\(const char \*, struct utimbuf \*\);';
2050 c_fix_arg = '(const char *, const struct utimbuf *);';
2052 test_text = "extern int utime(const char *, struct utimbuf *);";
2057 * Sun Solaris 2.7 defines PTHREAD_MUTEX_INITIALIZER with a trailing
2058 * "0" for the last field of the pthread_mutex_t structure, which is
2059 * of type upad64_t, which itself is typedef'd to int64_t, but with
2060 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2061 * initializer to "{0}" instead
2064 hackname = solaris27_mutex_init;
2065 select = '@\(#\)pthread.h' "[ \t]+1.26[ \t]+98/04/12 SMI";
2068 c_fix_arg = "%1, {0}}";
2069 c_fix_arg = "(define[ \t]+PTHREAD_MUTEX_INITIALIZER.*),[ \t]*0}$";
2071 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
2072 "#define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}";
2077 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2081 hackname = sony_ctype;
2083 test = " -x /bin/sony";
2084 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2085 sed = "s/__ctype/_ctype/g";
2091 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2095 hackname = sony_stdio;
2097 test = " -x /bin/sony";
2098 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2099 sed = "s/__filbuf/_filbuf/g\n"
2100 "s/__flsbuf/_flsbuf/g\n"
2107 * Add a `static' declaration of `getrnge' into <regexp.h>.
2109 * Don't do this if there is already a `static void getrnge' declaration
2110 * present, since this would cause a redeclaration error. Solaris 2.x has
2111 * such a declaration.
2115 hackname = static_getrnge;
2117 bypass = "static void getrnge";
2118 sed = "/^static int[ \t]*size;/c\\\n"
2119 "static int size ;\\\n\\\n"
2120 "static int getrnge ();";
2126 * a missing semi-colon at the end of the statsswtch structure definition.
2129 hackname = statsswtch;
2130 files = rpcsvc/rstat.h;
2131 select = "boottime$";
2133 c_fix_arg = "boottime;";
2134 test_text = "struct statswtch {\n int boottime\n};";
2139 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2140 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2144 hackname = stdio_stdarg_h;
2146 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2150 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2157 * Don't use or define the name va_list in stdio.h.
2158 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
2159 * Note _BSD_VA_LIST_ is dealt with elsewhere.
2162 hackname = stdio_va_list;
2164 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list';
2167 * Use __gnuc_va_list in arg types in place of va_list.
2168 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
2169 * trailing parentheses and semicolon save all other systems from this.
2170 * Define __not_va_list__ (something harmless and unused)
2171 * instead of va_list.
2172 * Don't claim to have defined va_list.
2174 sed = "s@ va_list @ __gnuc_va_list @\n"
2175 "s@ va_list)@ __gnuc_va_list)@\n"
2176 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2177 "s@ va_list@ __not_va_list__@\n"
2178 "s@\\*va_list@*__not_va_list__@\n"
2179 "s@ __va_list)@ __gnuc_va_list)@\n"
2180 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2181 "@typedef \\1 __not_va_list__;@\n"
2182 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2183 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2184 "s@VA_LIST@DUMMY_VA_LIST@\n"
2185 "s@_Va_LIST@_VA_LIST@";
2186 test_text = "extern void mumble( va_list);";
2191 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2192 * in prototype without previous definition.
2195 hackname = struct_file;
2197 select = '^.*xdrstdio_create.*struct __file_s';
2199 c_fix_arg = "struct __file_s;\n%0";
2200 test_text = "extern void xdrstdio_create( struct __file_s* );";
2205 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2206 * in prototype without previous definition.
2209 hackname = struct_sockaddr;
2211 select = "^.*authdes_create.*struct sockaddr";
2212 bypass = "<sys/socket\.h>";
2214 c_fix_arg = "struct sockaddr;\n%0";
2215 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2220 * Apply fix this to all OSs since this problem seems to effect
2221 * more than just SunOS.
2224 hackname = sun_auth_proto;
2230 * Select those files containing '(*name)()'.
2232 select = '\(\*[a-z][a-z_]*\)\(\)';
2235 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2236 "#else\n%1();%2\n#endif";
2237 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2241 " int (*name)(); /* C++ bad */\n"
2247 * Fix bogus #ifdef on SunOS 4.1.
2250 hackname = sun_bogus_ifdef;
2251 files = "hsfs/hsfs_spec.h";
2252 files = "hsfs/iso_spec.h";
2253 select = '#ifdef(.*\|\|.*)';
2255 c_fix_arg = "#if%1";
2257 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2262 * Fix the CAT macro in SunOS memvar.h.
2265 hackname = sun_catmacro;
2266 files = pixrect/memvar.h;
2267 select = "^#define[ \t]+CAT\\(a,b\\).*";
2272 "# define CAT(a,b) a##b\n"
2273 "#else\n%0\n#endif";
2276 "#define CAT(a,b)\ta/**/b";
2281 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2282 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2285 hackname = sun_malloc;
2288 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2289 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2290 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2291 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2292 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2295 "typedef char *\tmalloc_t;\n"
2297 "char*\tmalloc();\n"
2298 "char*\tcalloc();\n"
2299 "char*\trealloc();";
2304 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2307 hackname = sun_rusers_semi;
2308 files = rpcsvc/rusers.h;
2310 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2311 test_text = "struct mumble\n int _cnt\n};";
2316 * signal.h on SunOS defines signal using (),
2317 * which causes trouble when compiling with g++ -pedantic.
2320 hackname = sun_signal;
2321 files = sys/signal.h;
2323 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2327 "#ifdef __cplusplus\n"
2328 "void\t(*signal(...))(...);\n"
2329 "#else\n%0\n#endif";
2331 test_text = "void\t(*signal())();";
2336 * math.h on SunOS 4 puts the declaration of matherr before the definition
2337 * of struct exception, so the prototype (added by fixproto) causes havoc.
2340 hackname = sunos_matherr_decl;
2343 /* If matherr has a prototype already, the header needs no fix. */
2344 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2348 c_fix_arg = "struct exception;\n";
2350 test_text = "extern int matherr();";
2355 * Correct the return type for strlen in strings.h in SunOS 4.
2358 hackname = sunos_strlen;
2360 select = "int[ \t]*strlen\\(\\);(.*)";
2362 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2363 test_text = " int\tstrlen(); /* string length */";
2368 * Solaris math.h and floatingpoint.h define __P without protection,
2369 * which conflicts with the fixproto definition. The fixproto
2370 * definition and the Solaris definition are used the same way.
2375 files = floatingpoint.h;
2376 select = "^#define[ \t]+__P.*";
2378 c_fix_arg = "#ifndef __P\n%0\n#endif";
2380 test_text = "#define __P(a) a";
2385 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2386 * that is visible to any ANSI compiler using this include. Simply
2387 * delete the lines that #define some string functions to internal forms.
2391 hackname = svr4_disable_opt;
2393 select = '#define.*__std_hdr_';
2394 sed = '/#define.*__std_hdr_/d';
2400 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2401 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2402 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2406 hackname = svr4_endian;
2407 files = sys/endian.h;
2410 * since we emit our own sys/byteorder.h,
2411 * this fix can never be applied to that file.
2413 files = sys/byteorder.h;
2415 bypass = '__GNUC__';
2417 sed = "/#\tifdef\t__STDC__/i\\\n"
2418 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2420 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2422 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2423 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2429 * Remove useless extern keyword from struct forward declarations
2430 * in <sys/stream.h> and <sys/strsubr.h>
2434 hackname = svr4_extern_struct;
2435 files = sys/stream.h;
2436 files = sys/strsubr.h;
2437 select = 'extern struct [a-z_]*;';
2438 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2443 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2444 * systems the file <ftw.h> contains extern declarations of these
2445 * functions followed by explicitly `static' definitions of these
2446 * functions... and that's not allowed according to ANSI C. (Note
2447 * however that on Solaris, this header file glitch has been pre-fixed by
2448 * Sun. In the Solaris version of <ftw.h> there are no static
2449 * definitions of any function so we don't need to do any of this stuff
2455 hackname = svr4_ftw;
2457 select = '^extern int ftw\(const';
2459 sed = '/^extern int ftw(const/i' "\\\n"
2460 "#if !defined(_STYPES)\\\n"
2465 sed = 's/extern \(int ftw(const.*\)$/\1/';
2466 sed = "/^extern int nftw/i\\\n"
2467 "#if defined(_STYPES)\\\n"
2472 sed = 's/extern \(int nftw.*\)$/\1/';
2473 sed = "/^extern int ftw(),/c\\\n"
2474 "#if !defined(_STYPES)\\\n"
2480 "#if defined(_STYPES)\\\n"
2492 * Fix broken decl of getcwd present on some svr4 systems.
2495 hackname = svr4_getcwd;
2498 files = prototypes.h;
2499 select = 'getcwd\(char \*, int\)';
2502 c_fix_arg = "getcwd(char *, size_t)";
2504 test_text = "extern char* getcwd(char *, int);";
2513 hackname = svr4_kernel;
2514 files = fs/rfs/rf_cache.h;
2518 files = sys/getpages.h;
2520 files = sys/cmn_err.h;
2521 files = sys/kdebugger.h;
2525 c_fix_arg = "#ifdef _KERNEL\n";
2526 c_fix_arg = "#endif /* _KERNEL */\n";
2532 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2533 * tend to conflict with the compiler's own definition of this symbol. (We
2534 * will use the compiler's definition.)
2535 * Likewise __sparc, for Solaris, and __i860, and a few others
2536 * (guessing it is necessary for all of them).
2540 hackname = svr4_mach_defines;
2542 select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
2543 sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
2549 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2550 * They are declared as non-static then immediately redeclared as static.
2554 hackname = svr4_mkdev;
2555 files = sys/mkdev.h;
2558 sed = "/^dev_t makedev(/s/^/static /";
2559 sed = "/^major_t major(/s/^/static /";
2560 sed = "/^minor_t minor(/s/^/static /";
2566 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2567 * Also fix types of array initializers.
2571 hackname = svr4_netcspace;
2572 files = sys/netcspace.h;
2573 select = 'NC_NPI_RAW';
2574 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2575 sed = 's/NC_/(unsigned long) NC_/';
2580 * Fix reference to NMSZ in <sys/adv.h>.
2584 hackname = svr4_nmsz;
2586 select = '\[NMSZ\]';
2587 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2593 * Fix broken decl of profil present on some svr4 systems.
2596 hackname = svr4_profil;
2601 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2603 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2606 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2611 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2615 hackname = svr4_proto_form;
2617 select = 'const extern';
2619 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2624 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2629 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2634 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2639 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2640 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2641 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2642 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2643 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2644 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2649 * Add a prototyped declaration of mmap to <sys/mman.h>.
2653 hackname = svr4_proto_mmap;
2655 select = '^extern caddr_t mmap();$';
2656 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2657 "#ifdef __STDC__\\\n"
2658 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2659 "#else /* !defined(__STDC__) */\\\n"
2660 "extern caddr_t mmap ();\\\n"
2661 "#endif /* !defined(__STDC__) */\\\n";
2666 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2670 hackname = svr4_sigaction;
2671 files = sys/signal.h;
2672 sed = "/^struct sigaction {/i\\\n"
2673 "#define _SIGACTION_";
2674 sed = 's/(void *(\*)())/(void (*)(int))/';
2679 * Put storage class at start of decl, to avoid warning.
2683 hackname = svr4_storage_class;
2684 files = rpc/types.h;
2685 select = 'const extern';
2686 sed = 's/const extern/extern const/g';
2692 * Like svr4_mach_defines, but with newfangled syntax.
2693 * Source lines are of #define __i386 #machine(i386). Delete them.
2697 hackname = svr5_mach_defines;
2699 select = "#define[ \t]*__i386.*\(i386\)";
2700 sed = "/#define[ \t]*__i386.*/d";
2706 * Fix these files to use the same types that we think they should.
2709 hackname = gnu_types;
2710 files = "sys/types.h";
2712 files = "sys/stdtypes.h";
2716 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2717 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2720 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2721 "typedef uint_t size_t; /* uint_t */\n"
2722 "typedef ushort_t wchar_t; /* ushort_t */";
2727 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2728 * in string.h on sysV68
2729 * Correct the return type for strlen in string.h on Lynx.
2730 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2731 * Add missing const for strdup on OSF/1 V3.0.
2732 * On sysV88 layout is slightly different.
2735 hackname = sysv68_string;
2739 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2740 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2741 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2743 sed = "/^extern char$/N";
2744 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2746 sed = "/^extern int$/N";
2747 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2749 sed = "/^\tstrncmp(),$/N";
2750 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
2751 '\1;' "\\\nextern unsigned int\\\n\\2/";
2754 "extern int strlen();\n"
2756 "extern int ffs(long);\n"
2769 "\tstrlen(), strspn();";
2774 * Fix return type of calloc, malloc, realloc, bsearch and exit
2777 hackname = sysz_stdlib_for_sun;
2780 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
2782 c_fix_arg = "void *\t%1(";
2785 "extern char*\tcalloc(size_t);\n"
2786 "extern char*\tmalloc(size_t);\n"
2787 "extern char*\trealloc(void*,size_t);\n"
2788 "extern char*\tbsearch(void*,size_t,size_t);\n";
2793 * if the #if says _cplusplus, not the double underscore __cplusplus
2797 hackname = tinfo_cplusplus;
2799 select = "[ \t]_cplusplus";
2802 c_fix_arg = " __cplusplus";
2803 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
2808 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2811 hackname = ultrix_atof_param;
2813 select = "atof\\([ \t]*char";
2816 c_fix_arg = "atof(const char";
2818 test_text = "extern double atof( char *__nptr);\n";
2823 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2826 hackname = ultrix_const;
2828 select = 'perror\( char \*';
2831 c_fix_arg = "%1 const %3 *__";
2832 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
2833 "[ \t]+(char|void) \\*__";
2836 "extern void perror( char *__s );\n"
2837 "extern int fputs( char *__s, FILE *);\n"
2838 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
2839 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
2840 "extern int scanf( char *__format, ...);\n";
2845 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2848 hackname = ultrix_const2;
2851 select = '\*fopen\( char \*';
2853 c_fix_arg = "%1( const char *%3, const char *";
2854 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
2855 "[ \t]*char[ \t]*\\*([^,]*),"
2856 "[ \t]*char[ \t]*\\*[ \t]*";
2859 "extern FILE *fopen( char *__filename, char *__type );\n"
2860 "extern int sscanf( char *__s, char *__format, ...);\n"
2861 "extern FILE *popen(char *, char *);\n"
2862 "extern char *tempnam(char*,char*);\n";
2867 * Ultrix V4.[35] puts the declaration of uname before the definition
2868 * of struct utsname, so the prototype (added by fixproto) causes havoc.
2871 hackname = ultrix_fix_fixproto;
2872 files = sys/utsname.h;
2876 c_fix_arg = "struct utsname;\n%0";
2877 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
2880 "/* ULTRIX's uname */\nextern\tint\tuname();";
2885 * Check for bad #ifdef line (in Ultrix 4.1)
2888 hackname = ultrix_ifdef;
2889 select = "^#ifdef KERNEL[ \t]+&&";
2893 c_fix_arg = "#if defined(KERNEL) &&";
2896 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
2901 * Strip "|| CC$gfloat" from Ultrix math headers.
2904 hackname = ultrix_math_ifdef;
2905 files = sys/limits.h;
2908 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
2912 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
2917 * Avoid nested comments on Ultrix 4.3.
2920 hackname = ultrix_nested_ioctl;
2921 files = sys/ioctl.h;
2922 select = "^/\\* #define SIOCSCREEN";
2923 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
2925 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
2926 "/* screend, net/gw_screen.h */\n";
2931 hackname = ultrix_nested_svc;
2933 select = "^ \\*[ \t]*int protocol; */\\*";
2934 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
2936 " *\tint protocol; /* like TCP or UDP\n";
2941 * Add missing prototype for lstat and define for S_ISLNK
2942 * in Ultrix V4.3 sys/stat.h.
2945 hackname = ultrix_stat;
2947 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
2948 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
2950 "/* macro to test for symbolic link */\\\n"
2951 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
2953 sed = "/^[ \t]*fstat(),$/a\\\n"
2956 "@(#)stat.h 6.1 (ULTRIX)\n"
2957 "#define S_IFPORT S_IFIFO\n"
2963 * Check for superfluous `static' (in Ultrix 4.2)
2964 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2967 hackname = ultrix_static;
2968 files = machine/cpu.h;
2969 select = '#include "r[34]_cpu';
2970 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2971 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2972 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2974 "static struct tlb_pid_state {\n"
2975 "#include \"r3_cpu.h\"\n";
2980 * Add once-only latch to Ultrix V4.3 strings.h.
2983 hackname = ultrix_strings;
2985 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
2988 "@(#)strings.h 6.1 (ULTRIX)\n";
2993 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
2994 * terminated lines, so accommodate these. Test both ways.
2997 hackname = undefine_null;
2998 select = "^#[ \t]*define[ \t]+NULL[ \t]";
2999 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
3002 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
3003 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
3005 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
3010 * If arpa/inet.h prototypes are incompatible with the ones we just
3011 * installed in <sys/byteorder.h>, just remove the protos.
3012 * Because of this close association, this patch must be applied only
3013 * on those systems where the replacement byteorder header is installed.
3016 hackname = uw7_byteorder_fix;
3017 files = arpa/inet.h;
3018 select = "in_port_t";
3019 test = "-f $DESTDIR/sys/byteorder.h";
3021 mach = "*-*-sysv4*";
3022 mach = "i?86-*-sysv5*";
3023 mach = "i?86-*-udk*";
3024 mach = "i?86-*-solaris2.[0-4]";
3025 mach = "powerpcle-*-solaris2.[0-4]";
3026 mach = "sparc-*-solaris2.[0-4]";
3031 c_fix_arg = "^extern.*(htons|ntohs).*\\(in_port_t\\).*\n";
3033 test_text = "extern htons(in_port_t);"
3034 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3035 "echo '/* DUMMY */' >> sys/byteorder.h\n"
3036 "touch $DESTDIR/sys/byteorder.h`";
3041 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3044 hackname = va_i960_macro;
3045 files = arch/i960/archI960.h;
3046 select = "__(vsiz|vali|vpad|alignof__)";
3049 c_fix_arg = "__vx%1";
3052 "extern int __vsiz vsiz;\n"
3053 "extern int __vali vali;\n"
3054 "extern int __vpad vpad;\n"
3055 "#define __alignof__(x) ...";
3060 * AIX headers define NULL to be cast to a void pointer,
3061 * which is illegal in ANSI C++.
3064 hackname = void_null;
3074 files = sys/param.h;
3075 files = sys/types.h;
3076 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3078 c_fix_arg = "#define NULL 0";
3079 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3084 * Make VxWorks header which is almost gcc ready fully gcc ready.
3087 hackname = vxworks_gcc_problem;
3088 files = types/vxTypesBase.h;
3089 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3091 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3094 sed = "/[ \t]size_t/i\\\n"
3095 "#ifndef _GCC_SIZE_T\\\n"
3096 "#define _GCC_SIZE_T\n";
3098 sed = "/[ \t]size_t/a\\\n"
3101 sed = "/[ \t]ptrdiff_t/i\\\n"
3102 "#ifndef _GCC_PTRDIFF_T\\\n"
3103 "#define _GCC_PTRDIFF_T\n";
3105 sed = "/[ \t]ptrdiff_t/a\\\n"
3108 sed = "/[ \t]wchar_t/i\\\n"
3109 "#ifndef _GCC_WCHAR_T\\\n"
3110 "#define _GCC_WCHAR_T\n";
3112 sed = "/[ \t]wchar_t/a\\\n"
3116 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3117 "typedef unsigned int size_t;\n"
3118 "typedef long ptrdiff_t;\n"
3119 "typedef unsigned short wchar_t;\n"
3120 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3125 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3128 hackname = vxworks_needs_vxtypes;
3130 select = "uint_t([ \t]+_clocks_per_sec)";
3132 c_fix_arg = "unsigned int%1";
3133 test_text = "uint_t\t_clocks_per_sec;";
3138 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3141 hackname = vxworks_needs_vxworks;
3143 test = " -r types/vxTypesOld.h";
3144 test = " -n \"`egrep '#include' $file`\"";
3145 test = " -n \"`egrep ULONG $file`\"";
3146 select = "#[ \t]define[ \t]+__INCstath";
3148 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3149 "#include <types/vxTypesOld.h>\n";
3151 test_text = "`touch types/vxTypesOld.h`"
3152 "#include </dev/null> /* ULONG */\n"
3153 "# define\t__INCstath <sys/stat.h>";
3158 * Another bad dependency in VxWorks 5.2 <time.h>.
3161 hackname = vxworks_time;
3163 test = " -r vxWorks.h";
3165 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3169 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3170 "#ifdef __cplusplus\n"
3171 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3173 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3175 "#define __gcc_VOIDFUNCPTR_defined\n"
3177 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3179 test_text = "`touch vxWorks.h`"
3180 "#define VOIDFUNCPTR (void(*)())";
3185 * There are several name conflicts with C++ reserved words in X11 header
3186 * files. These are fixed in some versions, so don't do the fixes if
3187 * we find __cplusplus in the file. These were found on the RS/6000.
3190 hackname = x11_class;
3191 files = X11/ShellP.h;
3192 bypass = __cplusplus;
3193 select = "^([ \t]*char \\*)class;(.*)";
3195 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3196 "#else\n%1class;%2\n#endif";
3205 * class in Xm/BaseClassI.h
3208 hackname = x11_class_usage;
3209 files = Xm/BaseClassI.h;
3210 bypass = "__cplusplus";
3212 select = " class\\)";
3214 c_fix_arg = " c_class)";
3216 test_text = "extern mumble (int class);\n";
3221 * new in Xm/Traversal.h
3225 files = Xm/Traversal.h;
3226 bypass = __cplusplus;
3228 sed = "/Widget\told, new;/i\\\n"
3229 "#ifdef __cplusplus\\\n"
3230 "\tWidget\told, c_new;\\\n"
3233 sed = "/Widget\told, new;/a\\\n"
3236 sed = "s/Widget new,/Widget c_new,/g";
3239 " Widget\told, new; /* fix the new */\n"
3240 "};\nextern Wedged( Widget new, Widget old );";
3245 * Incorrect sprintf declaration in X11/Xmu.h
3248 hackname = x11_sprintf;
3250 files = X11/Xmu/Xmu.h;
3251 select = "^extern char \\*\tsprintf\\(\\);$";
3254 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3256 test_text = "extern char *\tsprintf();";