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 * Non-traditional "const" declaration in Irix's limits.h.
1333 hackname = irix_limits_const;
1335 select = "^extern const ";
1337 c_fix_arg = "extern __const ";
1338 test_text = "extern const char limit; /* test\n\tlimits */";
1343 * Fixing ISC fmod declaration
1346 hackname = isc_fmod;
1348 select = 'fmod\(double\)';
1350 c_fix_arg = "fmod(double, double)";
1351 test_text = "extern double fmod(double);";
1356 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1357 * use / * * / to concatenate tokens.
1360 hackname = kandr_concat;
1361 files = "sparc/asm_linkage.h";
1362 files = "sun3/asm_linkage.h";
1363 files = "sun3x/asm_linkage.h";
1364 files = "sun4/asm_linkage.h";
1365 files = "sun4c/asm_linkage.h";
1366 files = "sun4m/asm_linkage.h";
1367 files = "sun4c/debug/asm_linkage.h";
1368 files = "sun4m/debug/asm_linkage.h";
1369 files = "arm/as_support.h";
1370 files = "arm/mc_type.h";
1371 files = "arm/xcb.h";
1372 files = "dev/chardefmac.h";
1373 files = "dev/ps_irq.h";
1374 files = "dev/screen.h";
1375 files = "dev/scsi.h";
1376 files = "sys/tty.h";
1377 files = "Xm.acorn/XmP.h";
1378 files = bsd43/bsd43_.h;
1382 test_text = "#define __CONCAT__(a,b) a/**/b";
1387 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1388 * versions > 1. This fix will open up the declaration for all
1389 * versions of GCC and for g++.
1392 hackname = libc1_ifdefd_memx;
1394 /* The string.h result is overwritten by AAB_ultrix_string when doing
1395 "make check" and will fail. Therefore, we add the following kludgery
1396 to insert the test_text into the special testing header. :-} */
1401 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1402 bypass = __cplusplus;
1405 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1406 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1408 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1412 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1413 "#if defined(__STDC__) && __GNUC__ < 2\n"
1414 "/* Copy N bytes of SRC to DEST. */\n"
1415 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1422 * In limits.h, put #ifndefs around things that are supposed to be defined
1423 * in float.h to avoid redefinition errors if float.h is included first.
1424 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1425 * multi line comments and the inserted #endif winds up inside the
1426 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1427 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1428 * are there, and we do not add them ourselves.
1431 hackname = limits_ifndefs;
1432 files = "sys/limits.h";
1434 bypass = "ifndef[ \t]+FLT_MIN";
1437 c_fix_arg = "#ifndef %1\n%0\n#endif";
1438 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1439 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1440 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1445 * Delete the '#define void int' line from curses.h on Lynx
1448 hackname = lynx_void_int;
1450 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1453 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1458 * Fix fcntl prototype in fcntl.h on LynxOS.
1461 hackname = lynxos_fcntl_proto;
1463 select = "fcntl[ \t]*" '\(int, int, int\)';
1465 c_fix_arg = '%1...)';
1466 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1467 test_text = "extern int fcntl(int, int, int);";
1472 * libm.a on m88k-motorola-sysv3 contains a stupid optimization for
1473 * function hypot(), which returns the second argument without even
1474 * looking at its value, if the other is 0.0.
1477 hackname = m88k_bad_hypot_opt;
1478 mach = "m88k-motorola-sysv3*";
1480 select = "^extern double hypot\\(\\);\n";
1483 "/* Workaround a stupid Motorola optimization if one\n"
1484 " of x or y is 0.0 and the other is negative! */\n"
1486 "static __inline__ double fake_hypot (double x, double y)\n"
1488 "static __inline__ double fake_hypot (x, y)\n"
1492 "\treturn fabs (hypot (x, y));\n"
1494 "#define hypot\tfake_hypot\n";
1495 test_text = "extern double hypot();";
1500 * Fix incorrect S_IF* definitions on m88k-sysv3.
1503 hackname = m88k_bad_s_if;
1504 mach = "m88k-*-sysv3*";
1506 select = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&";
1509 c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)';
1510 c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+"
1512 "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)"
1514 test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */';
1519 * Put cpp wrappers around these include files to avoid redeclaration
1520 * errors during multiple inclusion on m88k-tektronix-sysv3.
1523 hackname = m88k_multi_incl;
1524 mach = "m88k-tektronix-sysv3*";
1533 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1535 * On NetBSD, machine is a symbolic link to an architecture specific
1536 * directory name, so we can't match a specific file name here.
1539 hackname = machine_ansi_h_va_list;
1540 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1541 bypass = '__builtin_va_list';
1544 c_fix_arg = "%1__builtin_va_list";
1545 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1547 test_text = " # define _BSD_VA_LIST_\tchar**";
1552 * Fix non-ansi machine name defines
1555 hackname = machine_name;
1556 c_test = machine_name;
1557 c_fix = machine_name;
1559 test_text = "/* MACH_DIFF: */\n"
1560 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1561 "\n/* no uniform test, so be careful :-) */";
1566 * Some math.h files define struct exception, which conflicts with
1567 * the class exception defined in the C++ file std/stdexcept.h. We
1568 * redefine it to __math_exception. This is not a great fix, but I
1569 * haven't been able to think of anything better.
1570 * Note that we have to put the #ifdef/#endif blocks at beginning
1571 * and end of file, because fixproto runs after us and may insert
1572 * additional references to struct exception.
1575 hackname = math_exception;
1577 select = "struct exception";
1578 bypass = 'We have a problem when using C\+\+';
1581 c_fix_arg = "#ifdef __cplusplus\n"
1582 "#define exception __math_exception\n"
1585 c_fix_arg = "#ifdef __cplusplus\n"
1586 "#undef exception\n"
1589 test_text = "typedef struct exception t_math_exception;";
1594 * This looks pretty broken to me. ``dbl_max_def'' will contain
1595 * "define DBL_MAX " at the start, when what we really want is just
1596 * the value portion. Can't figure out how to write a test case
1597 * for this either :-(
1600 hackname = math_huge_val_from_dbl_max;
1604 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1605 * in math.h, this fix applies.
1607 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1608 bypass = "define[ \t]+DBL_MAX";
1612 * See if we have a definition for DBL_MAX in float.h.
1613 * If we do, we will replace the one in math.h with that one.
1616 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1617 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1619 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1620 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1621 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1626 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1627 "#define HUGE_VAL DBL_MAX";
1632 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1635 hackname = math_huge_val_ifndef;
1637 files = math/math.h;
1638 select = "define[ \t]+HUGE_VAL";
1641 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1642 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1644 test_text = "# define\tHUGE_VAL 3.4e+40";
1649 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1652 hackname = nested_motorola;
1653 mach = "m68k-motorola-sysv*";
1654 files = sys/limits.h;
1656 select = "max # bytes atomic in write|error value returned by Math lib";
1658 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1659 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1660 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1661 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1664 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1666 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1671 * Fixing nested comments in ISC <sys/limits.h>
1674 hackname = nested_sys_limits;
1675 files = sys/limits.h;
1677 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1678 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1679 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1680 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1687 hackname = nested_auth_des;
1689 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1691 c_fix_arg = "%1*/ /*";
1692 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1697 * fix bogus recursive stdlib.h in NEWS-OS 4.0C
1700 hackname = news_os_recursion;
1702 select = "[ \t]*#include <stdlib\\.h>.*";
1705 c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif";
1706 test_text = "#include <stdlib.h>";
1711 * NeXT 3.2 adds const prefix to some math functions.
1712 * These conflict with the built-in functions.
1715 hackname = next_math_prefix;
1716 files = ansi/math.h;
1717 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1720 c_fix_arg = "extern double %1(";
1721 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1723 test_text = "extern\tdouble\t__const__\tmumble();";
1728 * NeXT 3.2 uses the word "template" as a parameter for some
1729 * functions. GCC reports an invalid use of a reserved key word
1730 * with the built-in functions.
1733 hackname = next_template;
1735 select = "[ \t]template\\)";
1739 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1740 test_text = "extern mumble( char * template); /* fix */";
1745 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1746 * function prototypes. That conflicts with the built-in functions.
1749 hackname = next_volitile;
1750 files = ansi/stdlib.h;
1751 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1754 c_fix_arg = "extern void %1(";
1755 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1757 test_text = "extern\tvolatile\tvoid\tabort();";
1762 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1763 * Note that version 3 of the NeXT system has wait.h in a different directory,
1764 * so that this code won't do anything. But wait.h in version 3 has a
1765 * conditional, so it doesn't need this fix. So everything is okay.
1768 hackname = next_wait_union;
1771 select = 'wait\(union wait';
1773 c_fix_arg = "wait(void";
1774 test_text = "extern pid_d wait(union wait*);";
1779 * a missing semi-colon at the end of the nodeent structure definition.
1782 hackname = nodeent_syntax;
1783 files = netdnet/dnetdb.h;
1784 select = "char[ \t]*\\*na_addr[ \t]*$";
1787 test_text = "char *na_addr\t";
1792 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1793 * defining regex.h related types. This causes libg++ build and usage
1794 * failures. Fixing this correctly requires checking and modifying 3 files.
1797 hackname = osf_namespace_a;
1798 files = reg_types.h;
1799 files = sys/lc_core.h;
1800 test = " -r reg_types.h";
1801 test = " -r sys/lc_core.h";
1802 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1803 test = " -z \"`grep __regex_t regex.h`\"";
1807 c_fix_arg = "reg(ex|off|match)_t";
1809 test_text = "`touch sys/lc_core.h`"
1810 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1811 "extern regex_t re;\n"
1812 "extern regoff_t ro;\n"
1813 "extern regmatch_t rm;\n";
1817 hackname = osf_namespace_c;
1819 test = " -r reg_types.h";
1820 test = " -r sys/lc_core.h";
1821 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1822 test = " -z \"`grep __regex_t regex.h`\"";
1824 select = "#include <reg_types\.h>.*";
1827 "typedef __regex_t\tregex_t;\n"
1828 "typedef __regoff_t\tregoff_t;\n"
1829 "typedef __regmatch_t\tregmatch_t;";
1831 test_text = "#include <reg_types.h>";
1836 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1837 * The original ones fail if uninitialized externs are not common.
1838 * This is the default for all ANSI standard C++ compilers.
1841 hackname = pthread_page_size;
1843 select = "^int __page_size";
1845 c_fix_arg = "extern %0";
1846 test_text = "int __page_size;";
1851 * Fix return type of fread and fwrite on sysV68
1854 hackname = read_ret_type;
1856 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1858 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1859 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1861 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1866 * function class(double x) conflicts with C++ keyword on rs/6000
1869 hackname = rs6000_double;
1871 select = '[^a-zA-Z_]class\(';
1874 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1875 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
1877 test_text = "extern int class();";
1882 * Wrong fchmod prototype on RS/6000.
1885 hackname = rs6000_fchmod;
1887 select = 'fchmod\(char \*';
1889 c_fix_arg = "fchmod(int";
1890 test_text = "extern int fchmod(char *, mode_t);";
1895 * parameters conflict with C++ new on rs/6000
1898 hackname = rs6000_param;
1902 select = 'rename\(const char \*old, const char \*new\)';
1904 c_fix_arg = 'rename(const char *_old, const char *_new)';
1906 test_text = 'extern int rename(const char *old, const char *new);';
1911 * The static functions lstat() and fchmod() in <sys/stat.h>
1912 * cause G++ grief since they're not wrapped in "if __cplusplus".
1914 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
1915 * tiny static wrappers that aren't C++ safe.
1918 hackname = sco_static_func;
1920 mach = "i?86-*-sco3.2*";
1921 select = "^static int";
1923 sed = "/^static int/i\\\n"
1924 "#if __cplusplus\\\n"
1925 "extern \"C\" {\\\n"
1926 "#endif /* __cplusplus */";
1929 "#if __cplusplus\\\n"
1931 "#endif /* __cplusplus */";
1935 "static int\tstat(const char *__f, struct stat *__p) {\n"
1936 "\treturn __stat32(__f, __p);\n"
1937 "}\n\n# else /* !__STDC__ */\n"
1939 "static int\tstat(__f, __p)\n"
1941 "\tstruct stat *__p;\n"
1943 "\treturn __stat32(__f, __p);\n"
1950 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
1951 * is "!defined( __STRICT_ANSI__ )"
1954 hackname = strict_ansi_not;
1955 select = "^([ \t]*#[ \t]*if.*)"
1957 "|__STDC__[ \t]*==[ \t]*0"
1958 "|__STDC__[ \t]*!=[ \t]*1"
1959 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
1963 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
1965 test_text = "#if !__STDC__ \n"
1966 "#if __STDC__ == 0\n"
1967 "#if __STDC__ != 1\n"
1968 "#if __STDC__ - 0 == 0"
1969 "/* not std C */\nint foo;\n#endif";
1974 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
1977 hackname = strict_ansi_not_ctd;
1984 select = "^([ \t]*[|&][|&][ \t(]*)"
1985 "(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
1989 c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
1991 test_text = "#if 1\\\n"
1992 "|| __STDC__ - 0 == 0 /* not std C */\nint foo;\n#endif";
1996 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
1997 * is "defined( __STRICT_ANSI__ )"
2000 hackname = strict_ansi_only;
2001 select = "^([ \t]*#[ \t]*if.*)"
2002 "(__STDC__[ \t]*!=[ \t]*0"
2003 "|__STDC__[ \t]*==[ \t]*1"
2004 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2005 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0"
2009 c_fix_arg = "%1 defined(__STRICT_ANSI__)%3";
2011 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2016 * Fix prototype declaration of utime in sys/times.h.
2017 * In 3.2v4.0 the const is missing.
2020 hackname = sco_utime;
2021 files = sys/times.h;
2022 mach = "i?86-*-sco3.2v4*";
2024 select = '\(const char \*, struct utimbuf \*\);';
2026 c_fix_arg = '(const char *, const struct utimbuf *);';
2028 test_text = "extern int utime(const char *, struct utimbuf *);";
2033 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2037 hackname = sony_ctype;
2039 test = " -x /bin/sony";
2040 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2041 sed = "s/__ctype/_ctype/g";
2047 * Sony NEWSOS 5.0 does not support the complete ANSI C standard.
2051 hackname = sony_stdio;
2053 test = " -x /bin/sony";
2054 test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
2055 sed = "s/__filbuf/_filbuf/g\n"
2056 "s/__flsbuf/_flsbuf/g\n"
2063 * Add a `static' declaration of `getrnge' into <regexp.h>.
2065 * Don't do this if there is already a `static void getrnge' declaration
2066 * present, since this would cause a redeclaration error. Solaris 2.x has
2067 * such a declaration.
2071 hackname = static_getrnge;
2073 bypass = "static void getrnge";
2074 sed = "/^static int[ \t]*size;/c\\\n"
2075 "static int size ;\\\n\\\n"
2076 "static int getrnge ();";
2082 * a missing semi-colon at the end of the statsswtch structure definition.
2085 hackname = statsswtch;
2086 files = rpcsvc/rstat.h;
2087 select = "boottime$";
2089 c_fix_arg = "boottime;";
2090 test_text = "struct statswtch {\n int boottime\n};";
2095 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2096 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2100 hackname = stdio_stdarg_h;
2102 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2106 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2113 * Don't use or define the name va_list in stdio.h.
2114 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
2115 * Note _BSD_VA_LIST_ is dealt with elsewhere.
2118 hackname = stdio_va_list;
2120 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list';
2123 * Use __gnuc_va_list in arg types in place of va_list.
2124 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
2125 * trailing parentheses and semicolon save all other systems from this.
2126 * Define __not_va_list__ (something harmless and unused)
2127 * instead of va_list.
2128 * Don't claim to have defined va_list.
2130 sed = "s@ va_list @ __gnuc_va_list @\n"
2131 "s@ va_list)@ __gnuc_va_list)@\n"
2132 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2133 "s@ va_list@ __not_va_list__@\n"
2134 "s@\\*va_list@*__not_va_list__@\n"
2135 "s@ __va_list)@ __gnuc_va_list)@\n"
2136 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2137 "@typedef \\1 __not_va_list__;@\n"
2138 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2139 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2140 "s@VA_LIST@DUMMY_VA_LIST@\n"
2141 "s@_Va_LIST@_VA_LIST@";
2142 test_text = "extern void mumble( va_list);";
2147 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2148 * in prototype without previous definition.
2151 hackname = struct_file;
2153 select = '^.*xdrstdio_create.*struct __file_s';
2155 c_fix_arg = "struct __file_s;\n%0";
2156 test_text = "extern void xdrstdio_create( struct __file_s* );";
2161 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2162 * in prototype without previous definition.
2165 hackname = struct_sockaddr;
2167 select = "^.*authdes_create.*struct sockaddr";
2168 bypass = "<sys/socket\.h>";
2170 c_fix_arg = "struct sockaddr;\n%0";
2171 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2176 * Apply fix this to all OSs since this problem seems to effect
2177 * more than just SunOS.
2180 hackname = sun_auth_proto;
2186 * Select those files containing '(*name)()'.
2188 select = '\(\*[a-z][a-z_]*\)\(\)';
2191 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2192 "#else\n%1();%2\n#endif";
2193 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2197 " int (*name)(); /* C++ bad */\n"
2203 * Fix bogus #ifdef on SunOS 4.1.
2206 hackname = sun_bogus_ifdef;
2207 files = "hsfs/hsfs_spec.h";
2208 files = "hsfs/iso_spec.h";
2209 select = '#ifdef(.*\|\|.*)';
2211 c_fix_arg = "#if%1";
2213 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2218 * Fix the CAT macro in SunOS memvar.h.
2221 hackname = sun_catmacro;
2222 files = pixrect/memvar.h;
2223 select = "^#define[ \t]+CAT\\(a,b\\).*";
2228 "# define CAT(a,b) a##b\n"
2229 "#else\n%0\n#endif";
2232 "#define CAT(a,b)\ta/**/b";
2237 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2238 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2241 hackname = sun_malloc;
2244 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2245 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2246 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2247 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2248 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2251 "typedef char *\tmalloc_t;\n"
2253 "char*\tmalloc();\n"
2254 "char*\tcalloc();\n"
2255 "char*\trealloc();";
2260 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2263 hackname = sun_rusers_semi;
2264 files = rpcsvc/rusers.h;
2266 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2267 test_text = "struct mumble\n int _cnt\n};";
2272 * signal.h on SunOS defines signal using (),
2273 * which causes trouble when compiling with g++ -pedantic.
2276 hackname = sun_signal;
2277 files = sys/signal.h;
2279 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2283 "#ifdef __cplusplus\n"
2284 "void\t(*signal(...))(...);\n"
2285 "#else\n%0\n#endif";
2287 test_text = "void\t(*signal())();";
2292 * math.h on SunOS 4 puts the declaration of matherr before the definition
2293 * of struct exception, so the prototype (added by fixproto) causes havoc.
2296 hackname = sunos_matherr_decl;
2299 /* If matherr has a prototype already, the header needs no fix. */
2300 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2304 c_fix_arg = "struct exception;\n";
2306 test_text = "extern int matherr();";
2311 * Correct the return type for strlen in strings.h in SunOS 4.
2314 hackname = sunos_strlen;
2316 select = "int[ \t]*strlen\\(\\);(.*)";
2318 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2319 test_text = " int\tstrlen(); /* string length */";
2324 * Solaris math.h and floatingpoint.h define __P without protection,
2325 * which conflicts with the fixproto definition. The fixproto
2326 * definition and the Solaris definition are used the same way.
2331 files = floatingpoint.h;
2332 select = "^#define[ \t]+__P.*";
2334 c_fix_arg = "#ifndef __P\n%0\n#endif";
2336 test_text = "#define __P(a) a";
2341 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2342 * that is visible to any ANSI compiler using this include. Simply
2343 * delete the lines that #define some string functions to internal forms.
2347 hackname = svr4_disable_opt;
2349 select = '#define.*__std_hdr_';
2350 sed = '/#define.*__std_hdr_/d';
2356 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2357 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2358 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2362 hackname = svr4_endian;
2363 files = sys/endian.h;
2366 * since we emit our own sys/byteorder.h,
2367 * this fix can never be applied to that file.
2369 files = sys/byteorder.h;
2371 bypass = '__GNUC__';
2373 sed = "/#\tifdef\t__STDC__/i\\\n"
2374 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2376 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2378 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2379 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2385 * Remove useless extern keyword from struct forward declarations
2386 * in <sys/stream.h> and <sys/strsubr.h>
2390 hackname = svr4_extern_struct;
2391 files = sys/stream.h;
2392 files = sys/strsubr.h;
2393 select = 'extern struct [a-z_]*;';
2394 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2399 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2400 * systems the file <ftw.h> contains extern declarations of these
2401 * functions followed by explicitly `static' definitions of these
2402 * functions... and that's not allowed according to ANSI C. (Note
2403 * however that on Solaris, this header file glitch has been pre-fixed by
2404 * Sun. In the Solaris version of <ftw.h> there are no static
2405 * definitions of any function so we don't need to do any of this stuff
2411 hackname = svr4_ftw;
2413 select = '^extern int ftw\(const';
2415 sed = '/^extern int ftw(const/i' "\\\n"
2416 "#if !defined(_STYPES)\\\n"
2421 sed = 's/extern \(int ftw(const.*\)$/\1/';
2422 sed = "/^extern int nftw/i\\\n"
2423 "#if defined(_STYPES)\\\n"
2428 sed = 's/extern \(int nftw.*\)$/\1/';
2429 sed = "/^extern int ftw(),/c\\\n"
2430 "#if !defined(_STYPES)\\\n"
2436 "#if defined(_STYPES)\\\n"
2448 * Fix broken decl of getcwd present on some svr4 systems.
2451 hackname = svr4_getcwd;
2454 files = prototypes.h;
2455 select = 'getcwd\(char \*, int\)';
2458 c_fix_arg = "getcwd(char *, size_t)";
2460 test_text = "extern char* getcwd(char *, int);";
2469 hackname = svr4_kernel;
2470 files = fs/rfs/rf_cache.h;
2474 files = sys/getpages.h;
2476 files = sys/cmn_err.h;
2477 files = sys/kdebugger.h;
2481 c_fix_arg = "#ifdef _KERNEL\n";
2482 c_fix_arg = "#endif /* _KERNEL */\n";
2488 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2489 * tend to conflict with the compiler's own definition of this symbol. (We
2490 * will use the compiler's definition.)
2491 * Likewise __sparc, for Solaris, and __i860, and a few others
2492 * (guessing it is necessary for all of them).
2496 hackname = svr4_mach_defines;
2498 select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]";
2499 sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d";
2505 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2506 * They are declared as non-static then immediately redeclared as static.
2510 hackname = svr4_mkdev;
2511 files = sys/mkdev.h;
2514 sed = "/^dev_t makedev(/s/^/static /";
2515 sed = "/^major_t major(/s/^/static /";
2516 sed = "/^minor_t minor(/s/^/static /";
2522 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2523 * Also fix types of array initializers.
2527 hackname = svr4_netcspace;
2528 files = sys/netcspace.h;
2529 select = 'NC_NPI_RAW';
2530 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2531 sed = 's/NC_/(unsigned long) NC_/';
2536 * Fix reference to NMSZ in <sys/adv.h>.
2540 hackname = svr4_nmsz;
2542 select = '\[NMSZ\]';
2543 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2549 * Fix broken decl of profil present on some svr4 systems.
2552 hackname = svr4_profil;
2557 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2559 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2562 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2567 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2571 hackname = svr4_proto_form;
2573 select = 'const extern';
2575 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2580 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2585 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2590 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2595 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2596 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2597 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2598 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2599 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2600 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2605 * Add a prototyped declaration of mmap to <sys/mman.h>.
2609 hackname = svr4_proto_mmap;
2611 select = '^extern caddr_t mmap();$';
2612 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2613 "#ifdef __STDC__\\\n"
2614 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2615 "#else /* !defined(__STDC__) */\\\n"
2616 "extern caddr_t mmap ();\\\n"
2617 "#endif /* !defined(__STDC__) */\\\n";
2622 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2626 hackname = svr4_sigaction;
2627 files = sys/signal.h;
2628 sed = "/^struct sigaction {/i\\\n"
2629 "#define _SIGACTION_";
2630 sed = 's/(void *(\*)())/(void (*)(int))/';
2635 * Put storage class at start of decl, to avoid warning.
2639 hackname = svr4_storage_class;
2640 files = rpc/types.h;
2641 select = 'const extern';
2642 sed = 's/const extern/extern const/g';
2648 * Like svr4_mach_defines, but with newfangled syntax.
2649 * Source lines are of #define __i386 #machine(i386). Delete them.
2653 hackname = svr5_mach_defines;
2655 select = "#define[ \t]*__i386.*\(i386\)";
2656 sed = "/#define[ \t]*__i386.*/d";
2662 * Fix these files to use the same types that we think they should.
2665 hackname = gnu_types;
2666 files = "sys/types.h";
2668 files = "sys/stdtypes.h";
2672 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2673 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2676 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2677 "typedef uint_t size_t; /* uint_t */\n"
2678 "typedef ushort_t wchar_t; /* ushort_t */";
2683 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2684 * in string.h on sysV68
2685 * Correct the return type for strlen in string.h on Lynx.
2686 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2687 * Add missing const for strdup on OSF/1 V3.0.
2688 * On sysV88 layout is slightly different.
2691 hackname = sysv68_string;
2695 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2696 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2697 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2699 sed = "/^extern char$/N";
2700 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2702 sed = "/^extern int$/N";
2703 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2705 sed = "/^\tstrncmp(),$/N";
2706 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
2707 '\1;' "\\\nextern unsigned int\\\n\\2/";
2710 "extern int strlen();\n"
2712 "extern int ffs(long);\n"
2725 "\tstrlen(), strspn();";
2730 * Fix return type of calloc, malloc, realloc, bsearch and exit
2733 hackname = sysz_stdlib_for_sun;
2736 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
2738 c_fix_arg = "void *\t%1(";
2741 "extern char*\tcalloc(size_t);\n"
2742 "extern char*\tmalloc(size_t);\n"
2743 "extern char*\trealloc(void*,size_t);\n"
2744 "extern char*\tbsearch(void*,size_t,size_t);\n";
2749 * if the #if says _cplusplus, not the double underscore __cplusplus
2753 hackname = tinfo_cplusplus;
2755 select = "[ \t]_cplusplus";
2758 c_fix_arg = " __cplusplus";
2759 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
2764 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
2767 hackname = ultrix_atof_param;
2769 select = "atof\\([ \t]*char";
2772 c_fix_arg = "atof(const char";
2774 test_text = "extern double atof( char *__nptr);\n";
2779 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2782 hackname = ultrix_const;
2784 select = 'perror\( char \*';
2787 c_fix_arg = "%1 const %3 *__";
2788 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
2789 "[ \t]+(char|void) \\*__";
2792 "extern void perror( char *__s );\n"
2793 "extern int fputs( char *__s, FILE *);\n"
2794 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
2795 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
2796 "extern int scanf( char *__format, ...);\n";
2801 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
2804 hackname = ultrix_const2;
2807 select = '\*fopen\( char \*';
2809 c_fix_arg = "%1( const char *%3, const char *";
2810 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
2811 "[ \t]*char[ \t]*\\*([^,]*),"
2812 "[ \t]*char[ \t]*\\*[ \t]*";
2815 "extern FILE *fopen( char *__filename, char *__type );\n"
2816 "extern int sscanf( char *__s, char *__format, ...);\n"
2817 "extern FILE *popen(char *, char *);\n"
2818 "extern char *tempnam(char*,char*);\n";
2823 * Ultrix V4.[35] puts the declaration of uname before the definition
2824 * of struct utsname, so the prototype (added by fixproto) causes havoc.
2827 hackname = ultrix_fix_fixproto;
2828 files = sys/utsname.h;
2832 c_fix_arg = "struct utsname;\n%0";
2833 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
2836 "/* ULTRIX's uname */\nextern\tint\tuname();";
2841 * Check for bad #ifdef line (in Ultrix 4.1)
2844 hackname = ultrix_ifdef;
2845 select = "^#ifdef KERNEL[ \t]+&&";
2849 c_fix_arg = "#if defined(KERNEL) &&";
2852 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
2857 * Strip "|| CC$gfloat" from Ultrix math headers.
2860 hackname = ultrix_math_ifdef;
2861 files = sys/limits.h;
2864 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
2868 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
2873 * Avoid nested comments on Ultrix 4.3.
2876 hackname = ultrix_nested_ioctl;
2877 files = sys/ioctl.h;
2878 select = "^/\\* #define SIOCSCREEN";
2879 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
2881 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
2882 "/* screend, net/gw_screen.h */\n";
2887 hackname = ultrix_nested_svc;
2889 select = "^ \\*[ \t]*int protocol; */\\*";
2890 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
2892 " *\tint protocol; /* like TCP or UDP\n";
2897 * Add missing prototype for lstat and define for S_ISLNK
2898 * in Ultrix V4.3 sys/stat.h.
2901 hackname = ultrix_stat;
2903 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
2904 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
2906 "/* macro to test for symbolic link */\\\n"
2907 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
2909 sed = "/^[ \t]*fstat(),$/a\\\n"
2912 "@(#)stat.h 6.1 (ULTRIX)\n"
2913 "#define S_IFPORT S_IFIFO\n"
2919 * Check for superfluous `static' (in Ultrix 4.2)
2920 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
2923 hackname = ultrix_static;
2924 files = machine/cpu.h;
2925 select = '#include "r[34]_cpu';
2926 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
2927 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
2928 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
2930 "static struct tlb_pid_state {\n"
2931 "#include \"r3_cpu.h\"\n";
2936 * Add once-only latch to Ultrix V4.3 strings.h.
2939 hackname = ultrix_strings;
2941 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
2944 "@(#)strings.h 6.1 (ULTRIX)\n";
2949 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
2950 * terminated lines, so accommodate these. Test both ways.
2953 hackname = undefine_null;
2954 select = "^#[ \t]*define[ \t]+NULL[ \t]";
2955 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
2958 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
2959 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
2961 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
2966 * If arpa/inet.h prototypes are incompatible with the ones we just
2967 * installed in <sys/byteorder.h>, just remove the protos.
2968 * Because of this close association, this patch must be applied only
2969 * on those systems where the replacement byteorder header is installed.
2972 hackname = uw7_byteorder_fix;
2973 files = arpa/inet.h;
2974 select = "in_port_t";
2975 test = "-f $DESTDIR/sys/byteorder.h";
2977 mach = "*-*-sysv4*";
2978 mach = "i?86-*-sysv5*";
2979 mach = "i?86-*-udk*";
2980 mach = "i?86-*-solaris2.[0-4]";
2981 mach = "powerpcle-*-solaris2.[0-4]";
2982 mach = "sparc-*-solaris2.[0-4]";
2987 c_fix_arg = "^extern.*(htons|ntohs).*\\(in_port_t\\).*\n";
2989 test_text = "extern htons(in_port_t);"
2990 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
2991 "echo '/* DUMMY */' >> sys/byteorder.h\n"
2992 "touch $DESTDIR/sys/byteorder.h`";
2997 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3000 hackname = va_i960_macro;
3001 files = arch/i960/archI960.h;
3002 select = "__(vsiz|vali|vpad|alignof__)";
3005 c_fix_arg = "__vx%1";
3008 "extern int __vsiz vsiz;\n"
3009 "extern int __vali vali;\n"
3010 "extern int __vpad vpad;\n"
3011 "#define __alignof__(x) ...";
3016 * AIX headers define NULL to be cast to a void pointer,
3017 * which is illegal in ANSI C++.
3020 hackname = void_null;
3030 files = sys/param.h;
3031 files = sys/types.h;
3032 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3034 c_fix_arg = "#define NULL 0";
3035 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3040 * Make VxWorks header which is almost gcc ready fully gcc ready.
3043 hackname = vxworks_gcc_problem;
3044 files = types/vxTypesBase.h;
3045 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3047 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3050 sed = "/[ \t]size_t/i\\\n"
3051 "#ifndef _GCC_SIZE_T\\\n"
3052 "#define _GCC_SIZE_T\n";
3054 sed = "/[ \t]size_t/a\\\n"
3057 sed = "/[ \t]ptrdiff_t/i\\\n"
3058 "#ifndef _GCC_PTRDIFF_T\\\n"
3059 "#define _GCC_PTRDIFF_T\n";
3061 sed = "/[ \t]ptrdiff_t/a\\\n"
3064 sed = "/[ \t]wchar_t/i\\\n"
3065 "#ifndef _GCC_WCHAR_T\\\n"
3066 "#define _GCC_WCHAR_T\n";
3068 sed = "/[ \t]wchar_t/a\\\n"
3072 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3073 "typedef unsigned int size_t;\n"
3074 "typedef long ptrdiff_t;\n"
3075 "typedef unsigned short wchar_t;\n"
3076 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3081 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3084 hackname = vxworks_needs_vxtypes;
3086 select = "uint_t([ \t]+_clocks_per_sec)";
3088 c_fix_arg = "unsigned int%1";
3089 test_text = "uint_t\t_clocks_per_sec;";
3094 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3097 hackname = vxworks_needs_vxworks;
3099 test = " -r types/vxTypesOld.h";
3100 test = " -n \"`egrep '#include' $file`\"";
3101 test = " -n \"`egrep ULONG $file`\"";
3102 select = "#[ \t]define[ \t]+__INCstath";
3104 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3105 "#include <types/vxTypesOld.h>\n";
3107 test_text = "`touch types/vxTypesOld.h`"
3108 "#include </dev/null> /* ULONG */\n"
3109 "# define\t__INCstath <sys/stat.h>";
3114 * Another bad dependency in VxWorks 5.2 <time.h>.
3117 hackname = vxworks_time;
3119 test = " -r vxWorks.h";
3121 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3125 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3126 "#ifdef __cplusplus\n"
3127 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3129 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3131 "#define __gcc_VOIDFUNCPTR_defined\n"
3133 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3135 test_text = "`touch vxWorks.h`"
3136 "#define VOIDFUNCPTR (void(*)())";
3141 * There are several name conflicts with C++ reserved words in X11 header
3142 * files. These are fixed in some versions, so don't do the fixes if
3143 * we find __cplusplus in the file. These were found on the RS/6000.
3146 hackname = x11_class;
3147 files = X11/ShellP.h;
3148 bypass = __cplusplus;
3149 select = "^([ \t]*char \\*)class;(.*)";
3151 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3152 "#else\n%1class;%2\n#endif";
3161 * class in Xm/BaseClassI.h
3164 hackname = x11_class_usage;
3165 files = Xm/BaseClassI.h;
3166 bypass = "__cplusplus";
3168 select = " class\\)";
3170 c_fix_arg = " c_class)";
3172 test_text = "extern mumble (int class);\n";
3177 * new in Xm/Traversal.h
3181 files = Xm/Traversal.h;
3182 bypass = __cplusplus;
3184 sed = "/Widget\told, new;/i\\\n"
3185 "#ifdef __cplusplus\\\n"
3186 "\tWidget\told, c_new;\\\n"
3189 sed = "/Widget\told, new;/a\\\n"
3192 sed = "s/Widget new,/Widget c_new,/g";
3195 " Widget\told, new; /* fix the new */\n"
3196 "};\nextern Wedged( Widget new, Widget old );";
3201 * Incorrect sprintf declaration in X11/Xmu.h
3204 hackname = x11_sprintf;
3206 files = X11/Xmu/Xmu.h;
3207 select = "^extern char \\*\tsprintf\\(\\);$";
3210 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3212 test_text = "extern char *\tsprintf();";