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;
107 replace = "#ifndef __INT_VARARGS_H
108 \#define __INT_VARARGS_H
110 /************************************************************************/
111 /* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio. */
112 /************************************************************************/
115 ** This file is a DG internal header. Never include this
119 \#ifndef ___int_features_h
120 \#include <sys/_int_features.h>
123 \#if !(defined(_VA_LIST) || defined(_VA_LIST_))
130 typedef void * va_list;
132 typedef char * va_list;
138 \#if defined(__DCC__)
146 \#else /* ! defined(__DCC__) */
149 int __va_arg; /* argument number */
150 int *__va_stk; /* start of args passed on stack */
151 int *__va_reg; /* start of args passed in regs */
154 \#endif /* ! defined(__DCC__) */
158 \#if defined(__GNUC__) || defined(__STDC__)
159 typedef void * va_list;
161 typedef char * va_list;
164 \#endif /* _IX86_ANY */
166 \#endif /* __LINT__ */
167 \#endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
168 \#endif /* #ifndef __INT_VARARGS_H */\n";
173 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
176 hackname = AAB_fd_zero_asm_posix_types_h;
177 files = asm/posix_types.h;
178 mach = 'i[34567]86-*-linux*';
182 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
183 * the start, so that if #include_next gets another instance of
184 * the wrapper, this will follow the #include_next chain until
185 * we arrive at the real <asm/posix_types.h>.
189 '/* This file fixes a bug in the __FD_ZERO macro
190 for older versions of the Linux kernel. */
191 \#ifndef _POSIX_TYPES_H_WRAPPER
192 \#include <features.h>
193 \#include_next <asm/posix_types.h>
195 \#if defined(__FD_ZERO) && !defined(__GLIBC__)
197 \#define __FD_ZERO(fdsetp) \\
200 __asm__ __volatile__("cld ; rep ; stosl" \\
201 : "=&c" (__d0), "=&D" (__d1) \\
202 : "a" (0), "0" (__FDSET_LONGS), \\
203 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \\
207 \#define _POSIX_TYPES_H_WRAPPER
208 \#endif /* _POSIX_TYPES_H_WRAPPER */
214 * This fixes __FD_ZERO bug for glibc-1.x
217 hackname = AAB_fd_zero_gnu_types_h;
219 mach = 'i[34567]86-*-linux*';
222 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
223 * the start, so that if #include_next gets another instance of
224 * the wrapper, this will follow the #include_next chain until
225 * we arrive at the real <gnu/types.h>.
229 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
230 \#ifndef _TYPES_H_WRAPPER
231 \#include <features.h>
232 \#include_next <gnu/types.h>
234 \#if defined(__FD_ZERO) && !defined(__GLIBC__)
236 \# define __FD_ZERO(fdsetp) \\
239 __asm__ __volatile__("cld ; rep ; stosl" \\
240 : "=&c" (__d0), "=&D" (__d1) \\
241 : "a" (0), "0" (__FDSET_LONGS), \\
242 "1" ((__fd_set *) (fdsetp)) :"memory"); \\
246 \#define _TYPES_H_WRAPPER
247 \#endif /* _TYPES_H_WRAPPER */
253 * This fixes __FD_ZERO bug for glibc-2.0.x
256 hackname = AAB_fd_zero_selectbits_h;
257 files = selectbits.h;
258 mach = 'i[34567]86-*-linux*';
261 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
262 * the start, so that if #include_next gets another instance of
263 * the wrapper, this will follow the #include_next chain until
264 * we arrive at the real <selectbits.h>.
268 '/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
269 \#ifndef _SELECTBITS_H_WRAPPER
270 \#include <features.h>
271 \#include_next <selectbits.h>
273 \#if defined(__FD_ZERO) && defined(__GLIBC__) \\
274 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
275 && __GLIBC_MINOR__ == 0
277 \#define __FD_ZERO(fdsetp) \\
280 __asm__ __volatile__ ("cld; rep; stosl" \\
281 : "=&c" (__d0), "=&D" (__d1) \\
282 : "a" (0), "0" (sizeof (__fd_set) \\
283 / sizeof (__fd_mask)), \\
284 "1" ((__fd_mask *) (fdsetp)) \\
289 \#define _SELECTBITS_H_WRAPPER
290 \#endif /* _SELECTBITS_H_WRAPPER */
296 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
297 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
298 * many other systems have similar text but correct versions of the file.
299 * To ensure only Sun's is fixed, we grep for a likely unique string.
300 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
303 hackname = AAB_sun_memcpy;
305 select = "/\\*\t@\\(#\\)"
306 "(head/memory.h\t50.1\t "
307 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
310 '/* This file was generated by fixincludes */
311 \#ifndef __memory_h__
312 \#define __memory_h__
315 extern void *memccpy();
316 extern void *memchr();
317 extern void *memcpy();
318 extern void *memset();
320 extern char *memccpy();
321 extern char *memchr();
322 extern char *memcpy();
323 extern char *memset();
324 \#endif /* __STDC__ */
328 \#endif /* __memory_h__ */
335 * Completely replace <sys/byteorder.h>; with a file that implements gcc's
336 * optimized byteswapping. Restricted to "SVR4" machines until either
337 * it is shown to be safe to replace this file always, or we get bolder ;-)
340 hackname = AAB_svr4_replace_byteorder;
343 mach = "i[34567]86-*-sysv5*";
344 mach = "i[34567]86-*-udk*";
345 mach = "i[34567]86-*-solaris2.[0-4]";
346 mach = "powerpcle-*-solaris2.[0-4]";
347 mach = "sparc-*-solaris2.[0-4]";
349 files = sys/byteorder.h;
350 replace = '#ifndef _SYS_BYTEORDER_H
351 \#define _SYS_BYTEORDER_H
353 /* Functions to convert `short\' and `long\' quantities from host byte order
354 to (internet) network byte order (i.e. big-endian).
356 Written by Ron Guilmette (rfg@ncd.com).
358 This isn\'t actually used by GCC. It is installed by fixinc.svr4.
360 For big-endian machines these functions are essentially no-ops.
362 For little-endian machines, we define the functions using specialized
363 asm sequences in cases where doing so yields better code (e.g. i386). */
365 \#if !defined (__GNUC__) && !defined (__GNUG__)
366 \#error You lose! This file is only useful with GNU compilers.
369 \#ifndef __BYTE_ORDER__
370 /* Byte order defines. These are as defined on UnixWare 1.1, but with
371 double underscores added at the front and back. */
372 \#define __LITTLE_ENDIAN__ 1234
373 \#define __BIG_ENDIAN__ 4321
374 \#define __PDP_ENDIAN__ 3412
378 static __inline__ unsigned long htonl (unsigned long);
379 static __inline__ unsigned short htons (unsigned int);
380 static __inline__ unsigned long ntohl (unsigned long);
381 static __inline__ unsigned short ntohs (unsigned int);
382 \#endif /* defined (__STDC__) */
384 \#if defined (__i386__)
386 \#ifndef __BYTE_ORDER__
387 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
390 /* Convert a host long to a network long. */
392 /* We must use a new-style function definition, so that this will also
394 static __inline__ unsigned long
395 htonl (unsigned long __arg)
397 register unsigned long __result;
399 __asm__ ("xchg%B0 %b0,%h0
401 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
405 /* Convert a host short to a network short. */
407 static __inline__ unsigned short
408 htons (unsigned int __arg)
410 register unsigned short __result;
412 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
416 \#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \\
417 || defined (__ns32k__) || defined (__vax__) \\
418 || defined (__spur__) || defined (__arm__))
420 \#ifndef __BYTE_ORDER__
421 \#define __BYTE_ORDER__ __LITTLE_ENDIAN__
424 /* For other little-endian machines, using C code is just as efficient as
425 using assembly code. */
427 /* Convert a host long to a network long. */
429 static __inline__ unsigned long
430 htonl (unsigned long __arg)
432 register unsigned long __result;
434 __result = (__arg >> 24) & 0x000000ff;
435 __result |= (__arg >> 8) & 0x0000ff00;
436 __result |= (__arg << 8) & 0x00ff0000;
437 __result |= (__arg << 24) & 0xff000000;
441 /* Convert a host short to a network short. */
443 static __inline__ unsigned short
444 htons (unsigned int __arg)
446 register unsigned short __result;
448 __result = (__arg << 8) & 0xff00;
449 __result |= (__arg >> 8) & 0x00ff;
453 \#else /* must be a big-endian machine */
455 \#ifndef __BYTE_ORDER__
456 \#define __BYTE_ORDER__ __BIG_ENDIAN__
459 /* Convert a host long to a network long. */
461 static __inline__ unsigned long
462 htonl (unsigned long __arg)
467 /* Convert a host short to a network short. */
469 static __inline__ unsigned short
470 htons (unsigned int __arg)
475 \#endif /* big-endian */
477 /* Convert a network long to a host long. */
479 static __inline__ unsigned long
480 ntohl (unsigned long __arg)
482 return htonl (__arg);
485 /* Convert a network short to a host short. */
487 static __inline__ unsigned short
488 ntohs (unsigned int __arg)
490 return htons (__arg);
498 * Completely replace <sys/varargs.h> with a file that includes gcc's
499 * stdarg.h or varargs.h files as appropriate.
503 hackname = AAB_svr4_no_varargs;
504 files = sys/varargs.h;
505 replace = "/* This file was generated by fixincludes. */\n"
506 "#ifndef _SYS_VARARGS_H\n"
507 "#define _SYS_VARARGS_H\n\n"
510 "#include <stdarg.h>\n"
512 "#include <varargs.h>\n"
515 "#endif /* _SYS_VARARGS_H */\n";
521 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
524 hackname = AAB_ultrix_ansi_compat;
525 files = ansi_compat.h;
527 replace = "/* This file intentionally left blank. */\n";
532 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
533 * Replace limits.h with a file that includes sys/limits.h.
536 hackname = AAB_ultrix_limits;
538 mach = "*-*-ultrix4.3";
541 /* This file was generated by fixincludes */
542 \#ifndef _LIMITS_INCLUDED
543 \#define _LIMITS_INCLUDED
544 \#include <sys/limits.h>
545 \#endif /* _LIMITS_INCLUDED */
551 * The ULTRIX 4.3 version of memory.h duplicates definitions
552 * present in strings.h. Replace memory.h with a file that includes
553 * strings.h to prevent problems from multiple inclusion.
556 hackname = AAB_ultrix_memory;
558 mach = "*-*-ultrix4.3";
561 /* This file was generated by fixincludes */
562 \#ifndef _MEMORY_INCLUDED
563 \#define _MEMORY_INCLUDED
564 \#include <strings.h>
565 \#endif /* _MEMORY_INCLUDED */
571 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
572 * Replace string.h link with a file that includes strings.h to prevent
573 * problems from multiple inclusion.
576 hackname = AAB_ultrix_string;
578 mach = "*-*-ultrix4.3";
581 /* This file was generated by fixincludes */
582 \#ifndef _STRING_INCLUDED
583 \#define _STRING_INCLUDED
584 \#include <strings.h>
585 \#endif /* _STRING_INCLUDED */
591 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
592 * which violates a requirement of ISO C.
595 hackname = aix_pthread;
597 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
600 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
601 "{...init stuff...}";
606 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
607 * in an otherwise harmless (and #ifed out) macro definition
610 hackname = aix_sysmachine;
611 files = sys/machine.h;
615 test_text = "#define FOO \\\n"
616 " bar \\ \n baz \\ \n bat";
621 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
622 * definition of struct rusage, so the prototype added by fixproto fails.
625 hackname = aix_syswait;
627 select = "^extern pid_t wait3\\(\\);\n";
630 c_fix_arg = "struct rusage;\n%0";
631 test_text = "/* bos325, */\n"
632 "extern pid_t wait3();\n"
633 "\t/* pid_t wait3(int *, int, struct rusage *); */";
638 * sys/signal.h on some versions of AIX uses volatile in the typedef of
639 * sig_atomic_t, which causes gcc to generate a warning about duplicate
640 * volatile when a sig_atomic_t variable is declared volatile, as
641 * required by ANSI C.
644 hackname = aix_volatile;
645 files = sys/signal.h;
646 select = "typedef volatile int sig_atomic_t";
648 c_fix_arg = "typedef int sig_atomic_t";
649 test_text = "typedef volatile int sig_atomic_t;";
654 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
657 hackname = alpha_getopt;
660 select = 'getopt\(int, char \*\[\], *char \*\)';
662 c_fix_arg = "getopt(int, char *const[], const char *)";
663 test_text = 'extern int getopt(int, char *[], char *);';
668 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
671 hackname = alpha_parens;
673 select = '#ifndef\(__mips64\)';
675 c_fix_arg = "#ifndef __mips64";
676 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
681 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
684 hackname = alpha_sbrk;
686 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
688 c_fix_arg = "void *sbrk(";
689 test_text = "extern char* sbrk(ptrdiff_t increment);";
694 * Fix this ARM/RISCiX file where ___type is a Compiler
695 * hint that is specific to the Norcroft compiler.
698 hackname = arm_norcroft_hint;
699 select = "___type p_type";
700 files = "X11/Intrinsic.h";
702 c_fix_arg = "p_type";
703 test_text = "___type p_type mumble;";
708 * Fix this ARM/RISCiX file to avoid interfering
709 * with the use of __wchar_t in cc1plus.
712 hackname = arm_wchar;
714 select = "#[ \t]*define[ \t]*__wchar_t";
717 c_fix_arg = "%1_GCC_WCHAR_T";
718 c_fix_arg = "(#[ \t]*(ifndef|define)[ \t]+)__wchar_t";
721 "# ifndef \t __wchar_t /* we don't have wchar_t yet, ... */\n"
722 "# define __wchar_t short\n"
723 "# endif /* __wchar_t */";
728 * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89;
729 * gcc doesn't understand it.
734 select = "#ifndef NOINLINE";
737 c_fix_arg = "#if !defined(NOINLINE) && !defined(__GNUC__)";
740 "#ifndef NOINLINE /* ain't got no inline, so we got it */\n"
741 "#endif /* NOINLINE */";
746 * For C++, avoid any typedef or macro definition of bool,
747 * and use the built in type instead.
748 * HP/UX 10.20 also has it in curses_colr/curses.h.
751 hackname = avoid_bool_define;
753 files = curses_colr/curses.h;
757 select = "#[ \t]*define[ \t]+bool[ \t]";
758 bypass = "we must use the C\\+\\+ compiler's type";
761 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
762 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
764 test_text = "# define bool\t char \n";
768 hackname = avoid_bool_type;
770 files = curses_colr/curses.h;
774 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
775 bypass = "we must use the C\\+\\+ compiler's type";
778 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
780 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
784 * For C++, avoid any typedef definition of wchar_t,
785 * and use the built in type instead.
789 hackname = avoid_wchar_t_type;
791 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
794 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
796 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
800 * Fix #defines under Alpha OSF/1:
801 * The following files contain '#pragma extern_prefix "_FOO"' followed by
802 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
803 * statements is to reduce namespace pollution. While these macros work
804 * properly in most cases, they don't allow you to take a pointer to the
805 * "something" being modified. To get around this limitation, change these
806 * statements to be of the form '#define something _FOOsomething'.
808 * sed ain't egrep, lesson 2463: sed can use self-referential
809 * regular expressions. In the substitute expression below,
810 * "\\1" and "\\2" refer to subexpressions found earlier in the
811 * same match. So, we continue to use sed. "extern_prefix" will
812 * be a rare match anyway...
817 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
835 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
836 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
838 test_text = '#pragma extern_prefix "_FOO"'"\n"
839 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
840 "#define mumble _FOOmumble";
845 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
848 hackname = bad_struct_term;
850 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
852 c_fix_arg = "struct term;";
854 test_text = 'typedef struct term;';
859 * Fix one other error in this file:
860 * a mismatched quote not inside a C comment.
864 files = sundev/vuid_event.h;
867 c_fix_arg = "does not";
869 test_text = "/* doesn't have matched single quotes */";
874 * check for broken assert.h that needs stdio.h
877 hackname = broken_assert_stdio;
880 bypass = "include.*stdio\\.h";
882 c_fix_arg = "#include <stdio.h>\n";
883 test_text = "extern FILE* stderr;";
888 * check for broken assert.h that needs stdlib.h
891 hackname = broken_assert_stdlib;
893 select = 'exit *\(|abort *\(';
894 bypass = "include.*stdlib\\.h";
896 c_fix_arg = "#ifdef __cplusplus\n"
897 "#include <stdlib.h>\n"
899 test_text = "extern void exit ( int );";
904 * Remove `extern double cabs' declarations from math.h.
905 * This conflicts with C99. Discovered on AIX.
906 * SunOS4 has its cabs() declaration followed by a comment which
907 * terminates on the following line.
910 hackname = broken_cabs;
912 select = '^extern[ \t]+double[ \t]+cabs';
916 c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
918 test_text = "#ifdef __STDC__\n"
919 "extern double cabs(struct dbl_hypot);\n"
921 "extern double cabs();\n"
923 "extern double cabs(); /* This is a comment\n"
924 " and it ends here. */";
929 * Fix various macros used to define ioctl numbers.
930 * The traditional syntax was:
932 * #define _CTRL(n, x) (('n'<<8)+x)
933 * #define TCTRLCFOO _CTRL(T, 1)
935 * but this does not work with the C standard, which disallows macro
936 * expansion inside strings. We have to rewrite it thus:
938 * #define _CTRL(n, x) ((n<<8)+x)
939 * #define TCTRLCFOO _CTRL('T', 1)
941 * The select expressions match too much, but the c_fix code is cautious.
943 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
946 hackname = ctrl_quotes_def;
947 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
948 c_fix = char_macro_def;
952 * This is two tests in order to ensure that the "CTRL(c)" can
953 * be selected in isolation from the multi-arg format
955 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
956 test_text = "#define _CTRL(c) ('c'&037)";
960 hackname = ctrl_quotes_use;
961 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
962 c_fix = char_macro_use;
964 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
969 * sys/mman.h on HP/UX is not C++ ready,
970 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
972 * rpc/types.h on OSF1/2.0 is not C++ ready,
973 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
975 * The problem is the declaration of malloc.
978 hackname = cxx_unready;
981 select = '[^#]+malloc.*;'; /* Catch any form of declaration
982 not within a macro. */
983 bypass = '"C"|__BEGIN_DECLS';
986 c_fix_arg = "#ifdef __cplusplus\n"
989 c_fix_arg = "#ifdef __cplusplus\n"
992 test_text = "extern void* malloc( size_t );";
997 * Fix <c_asm.h> on Digital UNIX V4.0:
998 * It contains a prototype for a DEC C internal asm() function,
999 * clashing with gcc's asm keyword. So protect this with __DECC.
1002 hackname = dec_intern_asm;
1004 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1005 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1009 " ... asm stuff ...\n"
1010 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1015 * Fix typo in <wchar.h> on DJGPP 2.03.
1018 hackname = djgpp_wchar_h;
1020 select = "__DJ_wint_t";
1021 bypass = "sys/djtypes.h";
1023 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1024 c_fix_arg = "#include <stddef.h>";
1025 test_text = "__DJ_wint_t\n#undef __DJ_wint_t\n#define __DJ_wint_t";
1029 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1032 hackname = ecd_cursor;
1033 files = "sunwindow/win_lock.h";
1034 files = "sunwindow/win_cursor.h";
1035 select = 'ecd\.cursor';
1037 c_fix_arg = 'ecd_cursor';
1039 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1044 * fix-header doesn't fix fabs' prototype, and I have no idea why.
1047 hackname = fix_header_breakage;
1048 mach = "m88k-motorola-sysv3*";
1051 select = 'extern double floor\(\), ceil\(\), fmod\(\), fabs\(\);';
1054 'extern double floor(), ceil(), fmod(), fabs _PARAMS((double));';
1055 test_text = 'extern double floor(), ceil(), fmod(), fabs();';
1060 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1061 * neither the existence of GCC 3 nor its exact feature set yet break
1062 * (by design?) when __GNUC__ is set beyond 2.
1065 hackname = freebsd_gcc3_breakage;
1066 mach = *-*-freebsd*;
1067 files = sys/cdefs.h;
1068 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1069 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1071 c_fix_arg = '%0 || __GNUC__ >= 3';
1072 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1077 * Fix HP & Sony's use of "../machine/xxx.h"
1078 * to refer to: <machine/xxx.h>
1081 hackname = hp_inline;
1082 files = sys/spinlock.h;
1083 files = machine/machparam.h;
1084 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1087 c_fix_arg = "%1<machine/%2.h>";
1089 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1092 test_text = ' # include "../machine/mumble.h"';
1097 * Check for (...) in C++ code in HP/UX sys/file.h.
1100 hackname = hp_sysfile;
1102 select = "HPUX_SOURCE";
1105 c_fix_arg = "(struct file *, ...)";
1106 c_fix_arg = '\(\.\.\.\)';
1108 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1113 * Keep HP-UX 11 from stomping on C++ math namespace
1114 * with defines for fabsf.
1117 hackname = hpux11_fabsf;
1119 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1120 bypass = "__cplusplus";
1123 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1127 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1133 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1134 * of UINT32_C has undefined behavior according to ISO/ANSI:
1135 * the arguments to __CONCAT__ are not macro expanded before the
1136 * concatination happens so the trailing ')' in the first argument
1137 * is concatinated with the 'l' in the second argument creating an
1138 * invalid pp token. The behavior of invalid pp tokens is undefined.
1139 * GCC does not handle these invalid tokens the way the HP compiler does.
1140 * This problem will potentially occur anytime macros are used in the
1141 * arguments to __CONCAT__. A general solution to this problem would be to
1142 * insert another layer of macro between __CONCAT__ and its use
1143 * in UINT32_C. An example of this solution can be found in the C standard.
1144 * A more specific solution, the one used here, is to change the UINT32_C
1145 * macro to not used macros in the arguments to __CONCAT__.
1148 hackname = hpux11_uint32_c;
1150 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1151 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1153 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1155 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1156 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1161 * get rid of bogus inline definitions in HP-UX 8.0
1164 hackname = hpux8_bogus_inlines;
1167 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1168 "@extern \"C\" int abs(int);@";
1169 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1170 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1171 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1172 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1173 "inline double sqr(double v) { return v**0.5; }";
1178 * Fix return type of abort and free
1181 hackname = int_abort_free_and_exit;
1183 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1186 c_fix_arg = "void\t%1(";
1188 test_text = "extern int abort(int);\n"
1189 "extern int free(void*);\n"
1190 "extern int exit(void*);";
1195 * On Interactive Unix 2.2, certain traditional Unix definitions
1196 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
1197 * defined, not just if _POSIX_SOURCE is defined. This makes it
1198 * impossible to compile any nontrivial program except with -posix.
1201 hackname = isc_omits_with_stdc;
1206 files = "sys/limits.h";
1207 files = "sys/fcntl.h";
1208 files = "sys/dirent.h";
1210 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1212 c_fix_arg = '!defined(_POSIX_SOURCE)';
1213 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1214 "\nint foo;\n#endif";
1219 * Fix various macros used to define ioctl numbers.
1220 * The traditional syntax was:
1222 * #define _IO(n, x) (('n'<<8)+x)
1223 * #define TIOCFOO _IO(T, 1)
1225 * but this does not work with the C standard, which disallows macro
1226 * expansion inside strings. We have to rewrite it thus:
1228 * #define _IO(n, x) ((n<<8)+x)
1229 * #define TIOCFOO _IO('T', 1)
1231 * The select expressions match too much, but the c_fix code is cautious.
1233 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1236 hackname = io_quotes_def;
1237 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1238 c_fix = char_macro_def;
1241 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1242 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1243 "#define _IO(x,y) ('x'<<8|y)";
1245 "#define XX_IO(x) ('x'<<8|256)";
1249 hackname = io_quotes_use;
1250 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1252 c_fix = char_macro_use;
1254 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1255 "#define TIOCFOO \\\\\n"
1256 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1261 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1264 hackname = hpux_maxint;
1265 files = sys/param.h;
1267 select = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1268 bypass = "^#[ \t]*ifndef[ \t]+MAXINT";
1270 "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1273 c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1274 c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1276 test_text = '#define MAXINT 0x7FFFFFFF';
1281 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1284 hackname = hpux_systime;
1286 select = "^extern struct sigevent;";
1289 c_fix_arg = "struct sigevent;";
1291 test_text = 'extern struct sigevent;';
1296 * Check for missing ';' in struct
1299 hackname = ip_missing_semi;
1300 files = netinet/ip.h;
1302 sed = "/^struct/,/^};/s/}$/};/";
1308 "}; /* mumbled struct */\n";
1313 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1314 * that causes the assembly preprocessor to complain about an
1315 * unterminated character constant.
1318 hackname = irix_asm_apostrophe;
1321 select = "^[ \t]*#.*[Ww]e're";
1323 c_fix_arg = "%1 are";
1324 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1325 test_text = "\t# and we're on vacation";
1330 * IRIX 5.x's stdio.h declares some functions that take a va_list as
1331 * taking char *. However, GCC uses void * for va_list, so
1332 * calling vfprintf with a va_list fails in C++. */
1334 hackname = irix_stdio_va_list;
1337 select = '(printf\(.*), /\* va_list \*/ char \*';
1339 c_fix_arg = "%1, __gnuc_va_list";
1344 * Non-traditional "const" declaration in Irix's limits.h.
1347 hackname = irix_limits_const;
1349 select = "^extern const ";
1351 c_fix_arg = "extern __const ";
1352 test_text = "extern const char limit; /* test\n\tlimits */";
1357 * Fixing ISC fmod declaration
1360 hackname = isc_fmod;
1362 select = 'fmod\(double\)';
1364 c_fix_arg = "fmod(double, double)";
1365 test_text = "extern double fmod(double);";
1370 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1371 * use / * * / to concatenate tokens.
1374 hackname = kandr_concat;
1375 files = "sparc/asm_linkage.h";
1376 files = "sun3/asm_linkage.h";
1377 files = "sun3x/asm_linkage.h";
1378 files = "sun4/asm_linkage.h";
1379 files = "sun4c/asm_linkage.h";
1380 files = "sun4m/asm_linkage.h";
1381 files = "sun4c/debug/asm_linkage.h";
1382 files = "sun4m/debug/asm_linkage.h";
1383 files = "arm/as_support.h";
1384 files = "arm/mc_type.h";
1385 files = "arm/xcb.h";
1386 files = "dev/chardefmac.h";
1387 files = "dev/ps_irq.h";
1388 files = "dev/screen.h";
1389 files = "dev/scsi.h";
1390 files = "sys/tty.h";
1391 files = "Xm.acorn/XmP.h";
1392 files = bsd43/bsd43_.h;
1396 test_text = "#define __CONCAT__(a,b) a/**/b";
1401 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1402 * versions > 1. This fix will open up the declaration for all
1403 * versions of GCC and for g++.
1406 hackname = libc1_ifdefd_memx;
1408 /* The string.h result is overwritten by AAB_ultrix_string when doing
1409 "make check" and will fail. Therefore, we add the following kludgery
1410 to insert the test_text into the special testing header. :-} */
1415 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1416 bypass = __cplusplus;
1419 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1420 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1422 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1426 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1427 "#if defined(__STDC__) && __GNUC__ < 2\n"
1428 "/* Copy N bytes of SRC to DEST. */\n"
1429 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1436 * In limits.h, put #ifndefs around things that are supposed to be defined
1437 * in float.h to avoid redefinition errors if float.h is included first.
1438 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1439 * multi line comments and the inserted #endif winds up inside the
1440 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1441 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1442 * are there, and we do not add them ourselves.
1445 hackname = limits_ifndefs;
1446 files = "sys/limits.h";
1448 bypass = "ifndef[ \t]+FLT_MIN";
1451 c_fix_arg = "#ifndef %1\n%0\n#endif";
1452 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1453 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1454 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1459 * Delete the '#define void int' line from curses.h on Lynx
1462 hackname = lynx_void_int;
1464 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1467 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1472 * Fix fcntl prototype in fcntl.h on LynxOS.
1475 hackname = lynxos_fcntl_proto;
1477 select = "fcntl[ \t]*" '\(int, int, int\)';
1479 c_fix_arg = '%1...)';
1480 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1481 test_text = "extern int fcntl(int, int, int);";
1486 * libm.a on m88k-motorola-sysv3 contains a stupid optimization for
1487 * function hypot(), which returns the second argument without even
1488 * looking at its value, if the other is 0.0.
1491 hackname = m88k_bad_hypot_opt;
1492 mach = "m88k-motorola-sysv3*";
1494 select = "^extern double hypot\\(\\);\n";
1497 "/* Workaround a stupid Motorola optimization if one\n"
1498 " of x or y is 0.0 and the other is negative! */\n"
1500 "static __inline__ double fake_hypot (double x, double y)\n"
1502 "static __inline__ double fake_hypot (x, y)\n"
1506 "\treturn fabs (hypot (x, y));\n"
1508 "#define hypot\tfake_hypot\n";
1509 test_text = "extern double hypot();";
1514 * Fix incorrect S_IF* definitions on m88k-sysv3.
1517 hackname = m88k_bad_s_if;
1518 mach = "m88k-*-sysv3*";
1520 select = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&";
1523 c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)';
1524 c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+"
1526 "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)"
1528 test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */';
1533 * Put cpp wrappers around these include files to avoid redeclaration
1534 * errors during multiple inclusion on m88k-tektronix-sysv3.
1537 hackname = m88k_multi_incl;
1538 mach = "m88k-tektronix-sysv3*";
1547 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1549 * On NetBSD, machine is a symbolic link to an architecture specific
1550 * directory name, so we can't match a specific file name here.
1553 hackname = machine_ansi_h_va_list;
1554 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1555 bypass = '__builtin_va_list';
1558 c_fix_arg = "%1__builtin_va_list";
1559 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1561 test_text = " # define _BSD_VA_LIST_\tchar**";
1566 * Fix non-ansi machine name defines
1569 hackname = machine_name;
1570 c_test = machine_name;
1571 c_fix = machine_name;
1573 test_text = "/* MACH_DIFF: */\n"
1574 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1575 "\n/* no uniform test, so be careful :-) */";
1580 * Some math.h files define struct exception, which conflicts with
1581 * the class exception defined in the C++ file std/stdexcept.h. We
1582 * redefine it to __math_exception. This is not a great fix, but I
1583 * haven't been able to think of anything better.
1584 * Note that we have to put the #ifdef/#endif blocks at beginning
1585 * and end of file, because fixproto runs after us and may insert
1586 * additional references to struct exception.
1589 hackname = math_exception;
1591 select = "struct exception";
1592 bypass = 'We have a problem when using C\+\+';
1595 c_fix_arg = "#ifdef __cplusplus\n"
1596 "#define exception __math_exception\n"
1599 c_fix_arg = "#ifdef __cplusplus\n"
1600 "#undef exception\n"
1603 test_text = "typedef struct exception t_math_exception;";
1608 * This looks pretty broken to me. ``dbl_max_def'' will contain
1609 * "define DBL_MAX " at the start, when what we really want is just
1610 * the value portion. Can't figure out how to write a test case
1611 * for this either :-(
1614 hackname = math_huge_val_from_dbl_max;
1618 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1619 * in math.h, this fix applies.
1621 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1622 bypass = "define[ \t]+DBL_MAX";
1626 * See if we have a definition for DBL_MAX in float.h.
1627 * If we do, we will replace the one in math.h with that one.
1630 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1631 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1633 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1634 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1635 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1640 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1641 "#define HUGE_VAL DBL_MAX";
1646 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1649 hackname = math_huge_val_ifndef;
1651 files = math/math.h;
1652 select = "define[ \t]+HUGE_VAL";
1655 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1656 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1658 test_text = "# define\tHUGE_VAL 3.4e+40";
1663 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1666 hackname = nested_motorola;
1667 mach = "m68k-motorola-sysv*";
1668 files = sys/limits.h;
1670 select = "max # bytes atomic in write|error value returned by Math lib";
1672 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1673 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1674 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1675 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1678 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1680 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1685 * Fixing nested comments in ISC <sys/limits.h>
1688 hackname = nested_sys_limits;
1689 files = sys/limits.h;
1691 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1692 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1693 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1694 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1701 hackname = nested_auth_des;
1703 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1705 c_fix_arg = "%1*/ /*";
1706 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1711 * fix bogus recursive stdlib.h in NEWS-OS 4.0C
1714 hackname = news_os_recursion;
1716 select = "[ \t]*#include <stdlib\\.h>.*";
1719 c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif";
1720 test_text = "#include <stdlib.h>";
1725 * NeXT 3.2 adds const prefix to some math functions.
1726 * These conflict with the built-in functions.
1729 hackname = next_math_prefix;
1730 files = ansi/math.h;
1731 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1734 c_fix_arg = "extern double %1(";
1735 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1737 test_text = "extern\tdouble\t__const__\tmumble();";
1742 * NeXT 3.2 uses the word "template" as a parameter for some
1743 * functions. GCC reports an invalid use of a reserved key word
1744 * with the built-in functions.
1747 hackname = next_template;
1749 select = "[ \t]template\\)";
1753 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1754 test_text = "extern mumble( char * template); /* fix */";
1759 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1760 * function prototypes. That conflicts with the built-in functions.
1763 hackname = next_volitile;
1764 files = ansi/stdlib.h;
1765 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1768 c_fix_arg = "extern void %1(";
1769 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1771 test_text = "extern\tvolatile\tvoid\tabort();";
1776 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1777 * Note that version 3 of the NeXT system has wait.h in a different directory,
1778 * so that this code won't do anything. But wait.h in version 3 has a
1779 * conditional, so it doesn't need this fix. So everything is okay.
1782 hackname = next_wait_union;
1785 select = 'wait\(union wait';
1787 c_fix_arg = "wait(void";
1788 test_text = "extern pid_d wait(union wait*);";
1793 * a missing semi-colon at the end of the nodeent structure definition.
1796 hackname = nodeent_syntax;
1797 files = netdnet/dnetdb.h;
1798 select = "char[ \t]*\\*na_addr[ \t]*$";
1801 test_text = "char *na_addr\t";
1806 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1807 * defining regex.h related types. This causes libg++ build and usage
1808 * failures. Fixing this correctly requires checking and modifying 3 files.
1811 hackname = osf_namespace_a;
1812 files = reg_types.h;
1813 files = sys/lc_core.h;
1814 test = " -r reg_types.h";
1815 test = " -r sys/lc_core.h";
1816 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1817 test = " -z \"`grep __regex_t regex.h`\"";
1821 c_fix_arg = "reg(ex|off|match)_t";
1823 test_text = "`touch sys/lc_core.h`"
1824 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1825 "extern regex_t re;\n"
1826 "extern regoff_t ro;\n"
1827 "extern regmatch_t rm;\n";
1831 hackname = osf_namespace_c;
1833 test = " -r reg_types.h";
1834 test = " -r sys/lc_core.h";
1835 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1836 test = " -z \"`grep __regex_t regex.h`\"";
1838 select = "#include <reg_types\.h>.*";
1841 "typedef __regex_t\tregex_t;\n"
1842 "typedef __regoff_t\tregoff_t;\n"
1843 "typedef __regmatch_t\tregmatch_t;";
1845 test_text = "#include <reg_types.h>";
1850 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1851 * The original ones fail if uninitialized externs are not common.
1852 * This is the default for all ANSI standard C++ compilers.
1855 hackname = pthread_page_size;
1857 select = "^int __page_size";
1859 c_fix_arg = "extern %0";
1860 test_text = "int __page_size;";
1865 * Fix return type of fread and fwrite on sysV68
1868 hackname = read_ret_type;
1870 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1872 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1873 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1875 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1880 * function class(double x) conflicts with C++ keyword on rs/6000
1883 hackname = rs6000_double;
1885 select = '[^a-zA-Z_]class\(';
1888 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1889 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
1891 test_text = "extern int class();";
1896 * Wrong fchmod prototype on RS/6000.
1899 hackname = rs6000_fchmod;
1901 select = 'fchmod\(char \*';
1903 c_fix_arg = "fchmod(int";
1904 test_text = "extern int fchmod(char *, mode_t);";
1909 * parameters conflict with C++ new on rs/6000
1912 hackname = rs6000_param;
1916 select = 'rename\(const char \*old, const char \*new\)';
1918 c_fix_arg = 'rename(const char *_old, const char *_new)';
1920 test_text = 'extern int rename(const char *old, const char *new);';
1925 * The static functions lstat() and fchmod() in <sys/stat.h>
1926 * cause G++ grief since they're not wrapped in "if __cplusplus".
1928 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
1929 * tiny static wrappers that aren't C++ safe.
1932 hackname = sco_static_func;
1934 mach = "i?86-*-sco3.2*";
1935 select = "^static int";
1937 sed = "/^static int/i\\\n"
1938 "#if __cplusplus\\\n"
1939 "extern \"C\" {\\\n"
1940 "#endif /* __cplusplus */";
1943 "#if __cplusplus\\\n"
1945 "#endif /* __cplusplus */";
1949 "static int\tstat(const char *__f, struct stat *__p) {\n"
1950 "\treturn __stat32(__f, __p);\n"
1951 "}\n\n# else /* !__STDC__ */\n"
1953 "static int\tstat(__f, __p)\n"
1955 "\tstruct stat *__p;\n"
1957 "\treturn __stat32(__f, __p);\n"
1964 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
1965 * is "!defined( __STRICT_ANSI__ )"
1968 hackname = strict_ansi_not;
1969 select = "^([ \t]*#[ \t]*if.*)"
1971 "|__STDC__[ \t]*==[ \t]*0"
1972 "|__STDC__[ \t]*!=[ \t]*1"
1973 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
1977 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
1979 test_text = "#if !__STDC__ \n"
1980 "#if __STDC__ == 0\n"
1981 "#if __STDC__ != 1\n"
1982 "#if __STDC__ - 0 == 0"
1983 "/* not std C */\nint foo;\n#endif";
1988 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
1991 hackname = strict_ansi_not_ctd;
1998 select = "^([ \t]*[|&][|&][ \t(]*)"
1999 "(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
2003 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
2005 test_text = "#if 1\\\n"
2006 "|| __STDC__ - 0 == 0 /* not std C */\nint foo;\n#endif";
2010 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2011 * is "defined( __STRICT_ANSI__ )"
2014 hackname = strict_ansi_only;
2015 select = "^([ \t]*#[ \t]*if.*)"
2016 "(__STDC__[ \t]*!=[ \t]*0"
2017 "|__STDC__[ \t]*==[ \t]*1"
2018 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2019 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0"
2023 c_fix_arg = "%1 defined(__STRICT_ANSI__)%3";
2025 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2030 * Fix prototype declaration of utime in sys/times.h.
2031 * In 3.2v4.0 the const is missing.
2034 hackname = sco_utime;
2035 files = sys/times.h;
2036 mach = "i?86-*-sco3.2v4*";
2038 select = '\(const char \*, struct utimbuf \*\);';
2040 c_fix_arg = '(const char *, const struct utimbuf *);';
2042 test_text = "extern int utime(const char *, struct utimbuf *);";
2047 * Sun Solaris 2.7 defines PTHREAD_MUTEX_INITIALIZER with a trailing
2048 * "0" for the last field of the pthread_mutex_t structure, which is
2049 * of type upad64_t, which itself is typedef'd to int64_t, but with
2050 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2051 * initializer to "{0}" instead
2054 hackname = solaris27_mutex_init;
2055 select = '@\(#\)pthread.h' "[ \t]+1.26[ \t]+98/04/12 SMI";
2058 c_fix_arg = "%1, {0}}";
2059 c_fix_arg = "(define[ \t]+PTHREAD_MUTEX_INITIALIZER.*),[ \t]*0}$";
2060 test_text = "#define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}";
2065 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2069 hackname = sony_ctype;
2071 test = " -x /bin/sony";
2072 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2073 sed = "s/__ctype/_ctype/g";
2079 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2083 hackname = sony_stdio;
2085 test = " -x /bin/sony";
2086 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2087 sed = "s/__filbuf/_filbuf/g\n"
2088 "s/__flsbuf/_flsbuf/g\n"
2095 * Add a `static' declaration of `getrnge' into <regexp.h>.
2097 * Don't do this if there is already a `static void getrnge' declaration
2098 * present, since this would cause a redeclaration error. Solaris 2.x has
2099 * such a declaration.
2103 hackname = static_getrnge;
2105 bypass = "static void getrnge";
2106 sed = "/^static int[ \t]*size;/c\\\n"
2107 "static int size ;\\\n\\\n"
2108 "static int getrnge ();";
2114 * a missing semi-colon at the end of the statsswtch structure definition.
2117 hackname = statsswtch;
2118 files = rpcsvc/rstat.h;
2119 select = "boottime$";
2121 c_fix_arg = "boottime;";
2122 test_text = "struct statswtch {\n int boottime\n};";
2127 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2128 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2132 hackname = stdio_stdarg_h;
2134 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2138 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2145 * Don't use or define the name va_list in stdio.h.
2146 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
2147 * Note _BSD_VA_LIST_ is dealt with elsewhere.
2150 hackname = stdio_va_list;
2152 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list';
2155 * Use __gnuc_va_list in arg types in place of va_list.
2156 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
2157 * trailing parentheses and semicolon save all other systems from this.
2158 * Define __not_va_list__ (something harmless and unused)
2159 * instead of va_list.
2160 * Don't claim to have defined va_list.
2162 sed = "s@ va_list @ __gnuc_va_list @\n"
2163 "s@ va_list)@ __gnuc_va_list)@\n"
2164 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2165 "s@ va_list@ __not_va_list__@\n"
2166 "s@\\*va_list@*__not_va_list__@\n"
2167 "s@ __va_list)@ __gnuc_va_list)@\n"
2168 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2169 "@typedef \\1 __not_va_list__;@\n"
2170 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2171 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2172 "s@VA_LIST@DUMMY_VA_LIST@\n"
2173 "s@_Va_LIST@_VA_LIST@";
2174 test_text = "extern void mumble( va_list);";
2179 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2180 * in prototype without previous definition.
2183 hackname = struct_file;
2185 select = '^.*xdrstdio_create.*struct __file_s';
2187 c_fix_arg = "struct __file_s;\n%0";
2188 test_text = "extern void xdrstdio_create( struct __file_s* );";
2193 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2194 * in prototype without previous definition.
2197 hackname = struct_sockaddr;
2199 select = "^.*authdes_create.*struct sockaddr";
2200 bypass = "<sys/socket\.h>";
2202 c_fix_arg = "struct sockaddr;\n%0";
2203 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2208 * Apply fix this to all OSs since this problem seems to effect
2209 * more than just SunOS.
2212 hackname = sun_auth_proto;
2218 * Select those files containing '(*name)()'.
2220 select = '\(\*[a-z][a-z_]*\)\(\)';
2223 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2224 "#else\n%1();%2\n#endif";
2225 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2229 " int (*name)(); /* C++ bad */\n"
2235 * Fix bogus #ifdef on SunOS 4.1.
2238 hackname = sun_bogus_ifdef;
2239 files = "hsfs/hsfs_spec.h";
2240 files = "hsfs/iso_spec.h";
2241 select = '#ifdef(.*\|\|.*)';
2243 c_fix_arg = "#if%1";
2245 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2250 * Fix the CAT macro in SunOS memvar.h.
2253 hackname = sun_catmacro;
2254 files = pixrect/memvar.h;
2255 select = "^#define[ \t]+CAT\\(a,b\\).*";
2260 "# define CAT(a,b) a##b\n"
2261 "#else\n%0\n#endif";
2264 "#define CAT(a,b)\ta/**/b";
2269 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2270 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2273 hackname = sun_malloc;
2276 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2277 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2278 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2279 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2280 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2283 "typedef char *\tmalloc_t;\n"
2285 "char*\tmalloc();\n"
2286 "char*\tcalloc();\n"
2287 "char*\trealloc();";
2292 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2295 hackname = sun_rusers_semi;
2296 files = rpcsvc/rusers.h;
2298 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2299 test_text = "struct mumble\n int _cnt\n};";
2304 * signal.h on SunOS defines signal using (),
2305 * which causes trouble when compiling with g++ -pedantic.
2308 hackname = sun_signal;
2309 files = sys/signal.h;
2311 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2315 "#ifdef __cplusplus\n"
2316 "void\t(*signal(...))(...);\n"
2317 "#else\n%0\n#endif";
2319 test_text = "void\t(*signal())();";
2324 * math.h on SunOS 4 puts the declaration of matherr before the definition
2325 * of struct exception, so the prototype (added by fixproto) causes havoc.
2328 hackname = sunos_matherr_decl;
2331 /* If matherr has a prototype already, the header needs no fix. */
2332 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2336 c_fix_arg = "struct exception;\n";
2338 test_text = "extern int matherr();";
2343 * Correct the return type for strlen in strings.h in SunOS 4.
2346 hackname = sunos_strlen;
2348 select = "int[ \t]*strlen\\(\\);(.*)";
2350 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2351 test_text = " int\tstrlen(); /* string length */";
2356 * Solaris math.h and floatingpoint.h define __P without protection,
2357 * which conflicts with the fixproto definition. The fixproto
2358 * definition and the Solaris definition are used the same way.
2363 files = floatingpoint.h;
2364 select = "^#define[ \t]+__P.*";
2366 c_fix_arg = "#ifndef __P\n%0\n#endif";
2368 test_text = "#define __P(a) a";
2373 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2374 * that is visible to any ANSI compiler using this include. Simply
2375 * delete the lines that #define some string functions to internal forms.
2379 hackname = svr4_disable_opt;
2381 select = '#define.*__std_hdr_';
2382 sed = '/#define.*__std_hdr_/d';
2388 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2389 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2390 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2394 hackname = svr4_endian;
2395 files = sys/endian.h;
2398 * since we emit our own sys/byteorder.h,
2399 * this fix can never be applied to that file.
2401 files = sys/byteorder.h;
2403 bypass = '__GNUC__';
2405 sed = "/#\tifdef\t__STDC__/i\\\n"
2406 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2408 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2410 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2411 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2417 * Remove useless extern keyword from struct forward declarations
2418 * in <sys/stream.h> and <sys/strsubr.h>
2422 hackname = svr4_extern_struct;
2423 files = sys/stream.h;
2424 files = sys/strsubr.h;
2425 select = 'extern struct [a-z_]*;';
2426 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2431 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2432 * systems the file <ftw.h> contains extern declarations of these
2433 * functions followed by explicitly `static' definitions of these
2434 * functions... and that's not allowed according to ANSI C. (Note
2435 * however that on Solaris, this header file glitch has been pre-fixed by
2436 * Sun. In the Solaris version of <ftw.h> there are no static
2437 * definitions of any function so we don't need to do any of this stuff
2443 hackname = svr4_ftw;
2445 select = '^extern int ftw\(const';
2447 sed = '/^extern int ftw(const/i' "\\\n"
2448 "#if !defined(_STYPES)\\\n"
2453 sed = 's/extern \(int ftw(const.*\)$/\1/';
2454 sed = "/^extern int nftw/i\\\n"
2455 "#if defined(_STYPES)\\\n"
2460 sed = 's/extern \(int nftw.*\)$/\1/';
2461 sed = "/^extern int ftw(),/c\\\n"
2462 "#if !defined(_STYPES)\\\n"
2468 "#if defined(_STYPES)\\\n"
2480 * Fix broken decl of getcwd present on some svr4 systems.
2483 hackname = svr4_getcwd;
2486 files = prototypes.h;
2487 select = 'getcwd\(char \*, int\)';
2490 c_fix_arg = "getcwd(char *, size_t)";
2492 test_text = "extern char* getcwd(char *, int);";
2501 hackname = svr4_kernel;
2502 files = fs/rfs/rf_cache.h;
2506 files = sys/getpages.h;
2508 files = sys/cmn_err.h;
2509 files = sys/kdebugger.h;
2513 c_fix_arg = "#ifdef _KERNEL\n";
2514 c_fix_arg = "#endif /* _KERNEL */\n";
2520 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2521 * tend to conflict with the compiler's own definition of this symbol. (We
2522 * will use the compiler's definition.)
2523 * Likewise __sparc, for Solaris, and __i860, and a few others
2524 * (guessing it is necessary for all of them).
2528 hackname = svr4_mach_defines;
2530 select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
2531 sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
2537 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2538 * They are declared as non-static then immediately redeclared as static.
2542 hackname = svr4_mkdev;
2543 files = sys/mkdev.h;
2546 sed = "/^dev_t makedev(/s/^/static /";
2547 sed = "/^major_t major(/s/^/static /";
2548 sed = "/^minor_t minor(/s/^/static /";
2554 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2555 * Also fix types of array initializers.
2559 hackname = svr4_netcspace;
2560 files = sys/netcspace.h;
2561 select = 'NC_NPI_RAW';
2562 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2563 sed = 's/NC_/(unsigned long) NC_/';
2568 * Fix reference to NMSZ in <sys/adv.h>.
2572 hackname = svr4_nmsz;
2574 select = '\[NMSZ\]';
2575 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2581 * Fix broken decl of profil present on some svr4 systems.
2584 hackname = svr4_profil;
2589 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2591 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2594 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2599 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2603 hackname = svr4_proto_form;
2605 select = 'const extern';
2607 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2612 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2617 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2622 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2627 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2628 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2629 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2630 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2631 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2632 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2637 * Add a prototyped declaration of mmap to <sys/mman.h>.
2641 hackname = svr4_proto_mmap;
2643 select = '^extern caddr_t mmap();$';
2644 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2645 "#ifdef __STDC__\\\n"
2646 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2647 "#else /* !defined(__STDC__) */\\\n"
2648 "extern caddr_t mmap ();\\\n"
2649 "#endif /* !defined(__STDC__) */\\\n";
2654 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2658 hackname = svr4_sigaction;
2659 files = sys/signal.h;
2660 sed = "/^struct sigaction {/i\\\n"
2661 "#define _SIGACTION_";
2662 sed = 's/(void *(\*)())/(void (*)(int))/';
2667 * Put storage class at start of decl, to avoid warning.
2671 hackname = svr4_storage_class;
2672 files = rpc/types.h;
2673 select = 'const extern';
2674 sed = 's/const extern/extern const/g';
2680 * Like svr4_mach_defines, but with newfangled syntax.
2681 * Source lines are of #define __i386 #machine(i386). Delete them.
2685 hackname = svr5_mach_defines;
2687 select = "#define[ \t]*__i386.*\(i386\)";
2688 sed = "/#define[ \t]*__i386.*/d";
2694 * Fix these files to use the same types that we think they should.
2697 hackname = gnu_types;
2698 files = "sys/types.h";
2700 files = "sys/stdtypes.h";
2704 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2705 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2708 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2709 "typedef uint_t size_t; /* uint_t */\n"
2710 "typedef ushort_t wchar_t; /* ushort_t */";
2715 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2716 * in string.h on sysV68
2717 * Correct the return type for strlen in string.h on Lynx.
2718 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2719 * Add missing const for strdup on OSF/1 V3.0.
2720 * On sysV88 layout is slightly different.
2723 hackname = sysv68_string;
2727 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2728 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2729 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2731 sed = "/^extern char$/N";
2732 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2734 sed = "/^extern int$/N";
2735 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2737 sed = "/^\tstrncmp(),$/N";
2738 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
2739 '\1;' "\\\nextern unsigned int\\\n\\2/";
2742 "extern int strlen();\n"
2744 "extern int ffs(long);\n"
2757 "\tstrlen(), strspn();";
2762 * Fix return type of calloc, malloc, realloc, bsearch and exit
2765 hackname = sysz_stdlib_for_sun;
2768 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
2770 c_fix_arg = "void *\t%1(";
2773 "extern char*\tcalloc(size_t);\n"
2774 "extern char*\tmalloc(size_t);\n"
2775 "extern char*\trealloc(void*,size_t);\n"
2776 "extern char*\tbsearch(void*,size_t,size_t);\n";
2781 * if the #if says _cplusplus, not the double underscore __cplusplus
2785 hackname = tinfo_cplusplus;
2787 select = "[ \t]_cplusplus";
2790 c_fix_arg = " __cplusplus";
2791 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
2796 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2799 hackname = ultrix_atof_param;
2801 select = "atof\\([ \t]*char";
2804 c_fix_arg = "atof(const char";
2806 test_text = "extern double atof( char *__nptr);\n";
2811 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2814 hackname = ultrix_const;
2816 select = 'perror\( char \*';
2819 c_fix_arg = "%1 const %3 *__";
2820 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
2821 "[ \t]+(char|void) \\*__";
2824 "extern void perror( char *__s );\n"
2825 "extern int fputs( char *__s, FILE *);\n"
2826 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
2827 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
2828 "extern int scanf( char *__format, ...);\n";
2833 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2836 hackname = ultrix_const2;
2839 select = '\*fopen\( char \*';
2841 c_fix_arg = "%1( const char *%3, const char *";
2842 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
2843 "[ \t]*char[ \t]*\\*([^,]*),"
2844 "[ \t]*char[ \t]*\\*[ \t]*";
2847 "extern FILE *fopen( char *__filename, char *__type );\n"
2848 "extern int sscanf( char *__s, char *__format, ...);\n"
2849 "extern FILE *popen(char *, char *);\n"
2850 "extern char *tempnam(char*,char*);\n";
2855 * Ultrix V4.[35] puts the declaration of uname before the definition
2856 * of struct utsname, so the prototype (added by fixproto) causes havoc.
2859 hackname = ultrix_fix_fixproto;
2860 files = sys/utsname.h;
2864 c_fix_arg = "struct utsname;\n%0";
2865 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
2868 "/* ULTRIX's uname */\nextern\tint\tuname();";
2873 * Check for bad #ifdef line (in Ultrix 4.1)
2876 hackname = ultrix_ifdef;
2877 select = "^#ifdef KERNEL[ \t]+&&";
2881 c_fix_arg = "#if defined(KERNEL) &&";
2884 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
2889 * Strip "|| CC$gfloat" from Ultrix math headers.
2892 hackname = ultrix_math_ifdef;
2893 files = sys/limits.h;
2896 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
2900 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
2905 * Avoid nested comments on Ultrix 4.3.
2908 hackname = ultrix_nested_ioctl;
2909 files = sys/ioctl.h;
2910 select = "^/\\* #define SIOCSCREEN";
2911 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
2913 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
2914 "/* screend, net/gw_screen.h */\n";
2919 hackname = ultrix_nested_svc;
2921 select = "^ \\*[ \t]*int protocol; */\\*";
2922 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
2924 " *\tint protocol; /* like TCP or UDP\n";
2929 * Add missing prototype for lstat and define for S_ISLNK
2930 * in Ultrix V4.3 sys/stat.h.
2933 hackname = ultrix_stat;
2935 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
2936 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
2938 "/* macro to test for symbolic link */\\\n"
2939 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
2941 sed = "/^[ \t]*fstat(),$/a\\\n"
2944 "@(#)stat.h 6.1 (ULTRIX)\n"
2945 "#define S_IFPORT S_IFIFO\n"
2951 * Check for superfluous `static' (in Ultrix 4.2)
2952 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2955 hackname = ultrix_static;
2956 files = machine/cpu.h;
2957 select = '#include "r[34]_cpu';
2958 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2959 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2960 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2962 "static struct tlb_pid_state {\n"
2963 "#include \"r3_cpu.h\"\n";
2968 * Add once-only latch to Ultrix V4.3 strings.h.
2971 hackname = ultrix_strings;
2973 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
2976 "@(#)strings.h 6.1 (ULTRIX)\n";
2981 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
2982 * terminated lines, so accommodate these. Test both ways.
2985 hackname = undefine_null;
2986 select = "^#[ \t]*define[ \t]+NULL[ \t]";
2987 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
2990 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
2991 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
2993 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
2998 * If arpa/inet.h prototypes are incompatible with the ones we just
2999 * installed in <sys/byteorder.h>, just remove the protos.
3000 * Because of this close association, this patch must be applied only
3001 * on those systems where the replacement byteorder header is installed.
3004 hackname = uw7_byteorder_fix;
3005 files = arpa/inet.h;
3006 select = "in_port_t";
3007 test = "-f $DESTDIR/sys/byteorder.h";
3009 mach = "*-*-sysv4*";
3010 mach = "i?86-*-sysv5*";
3011 mach = "i?86-*-udk*";
3012 mach = "i?86-*-solaris2.[0-4]";
3013 mach = "powerpcle-*-solaris2.[0-4]";
3014 mach = "sparc-*-solaris2.[0-4]";
3019 c_fix_arg = "^extern.*(htons|ntohs).*\\(in_port_t\\).*\n";
3021 test_text = "extern htons(in_port_t);"
3022 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3023 "echo '/* DUMMY */' >> sys/byteorder.h\n"
3024 "touch $DESTDIR/sys/byteorder.h`";
3029 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3032 hackname = va_i960_macro;
3033 files = arch/i960/archI960.h;
3034 select = "__(vsiz|vali|vpad|alignof__)";
3037 c_fix_arg = "__vx%1";
3040 "extern int __vsiz vsiz;\n"
3041 "extern int __vali vali;\n"
3042 "extern int __vpad vpad;\n"
3043 "#define __alignof__(x) ...";
3048 * AIX headers define NULL to be cast to a void pointer,
3049 * which is illegal in ANSI C++.
3052 hackname = void_null;
3062 files = sys/param.h;
3063 files = sys/types.h;
3064 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3066 c_fix_arg = "#define NULL 0";
3067 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3072 * Make VxWorks header which is almost gcc ready fully gcc ready.
3075 hackname = vxworks_gcc_problem;
3076 files = types/vxTypesBase.h;
3077 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3079 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3082 sed = "/[ \t]size_t/i\\\n"
3083 "#ifndef _GCC_SIZE_T\\\n"
3084 "#define _GCC_SIZE_T\n";
3086 sed = "/[ \t]size_t/a\\\n"
3089 sed = "/[ \t]ptrdiff_t/i\\\n"
3090 "#ifndef _GCC_PTRDIFF_T\\\n"
3091 "#define _GCC_PTRDIFF_T\n";
3093 sed = "/[ \t]ptrdiff_t/a\\\n"
3096 sed = "/[ \t]wchar_t/i\\\n"
3097 "#ifndef _GCC_WCHAR_T\\\n"
3098 "#define _GCC_WCHAR_T\n";
3100 sed = "/[ \t]wchar_t/a\\\n"
3104 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3105 "typedef unsigned int size_t;\n"
3106 "typedef long ptrdiff_t;\n"
3107 "typedef unsigned short wchar_t;\n"
3108 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3113 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3116 hackname = vxworks_needs_vxtypes;
3118 select = "uint_t([ \t]+_clocks_per_sec)";
3120 c_fix_arg = "unsigned int%1";
3121 test_text = "uint_t\t_clocks_per_sec;";
3126 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3129 hackname = vxworks_needs_vxworks;
3131 test = " -r types/vxTypesOld.h";
3132 test = " -n \"`egrep '#include' $file`\"";
3133 test = " -n \"`egrep ULONG $file`\"";
3134 select = "#[ \t]define[ \t]+__INCstath";
3136 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3137 "#include <types/vxTypesOld.h>\n";
3139 test_text = "`touch types/vxTypesOld.h`"
3140 "#include </dev/null> /* ULONG */\n"
3141 "# define\t__INCstath <sys/stat.h>";
3146 * Another bad dependency in VxWorks 5.2 <time.h>.
3149 hackname = vxworks_time;
3151 test = " -r vxWorks.h";
3153 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3157 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3158 "#ifdef __cplusplus\n"
3159 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3161 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3163 "#define __gcc_VOIDFUNCPTR_defined\n"
3165 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3167 test_text = "`touch vxWorks.h`"
3168 "#define VOIDFUNCPTR (void(*)())";
3173 * There are several name conflicts with C++ reserved words in X11 header
3174 * files. These are fixed in some versions, so don't do the fixes if
3175 * we find __cplusplus in the file. These were found on the RS/6000.
3178 hackname = x11_class;
3179 files = X11/ShellP.h;
3180 bypass = __cplusplus;
3181 select = "^([ \t]*char \\*)class;(.*)";
3183 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3184 "#else\n%1class;%2\n#endif";
3193 * class in Xm/BaseClassI.h
3196 hackname = x11_class_usage;
3197 files = Xm/BaseClassI.h;
3198 bypass = "__cplusplus";
3200 select = " class\\)";
3202 c_fix_arg = " c_class)";
3204 test_text = "extern mumble (int class);\n";
3209 * new in Xm/Traversal.h
3213 files = Xm/Traversal.h;
3214 bypass = __cplusplus;
3216 sed = "/Widget\told, new;/i\\\n"
3217 "#ifdef __cplusplus\\\n"
3218 "\tWidget\told, c_new;\\\n"
3221 sed = "/Widget\told, new;/a\\\n"
3224 sed = "s/Widget new,/Widget c_new,/g";
3227 " Widget\told, new; /* fix the new */\n"
3228 "};\nextern Wedged( Widget new, Widget old );";
3233 * Incorrect sprintf declaration in X11/Xmu.h
3236 hackname = x11_sprintf;
3238 files = X11/Xmu/Xmu.h;
3239 select = "^extern char \\*\tsprintf\\(\\);$";
3242 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3244 test_text = "extern char *\tsprintf();";