3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
12 trailer='^/\*EOF\*[/]' \
14 key=$'hackname[ \t]*=[ \t]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
31 hackname = AAB_aix_stdio;
33 select = "define fopen fopen64";
35 test-text = ''; /* no way to test */
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
52 /* Alias the symbols using asm */
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
73 hackname = AAB_aix_fcntl;
75 select = "define open[ \t]open64";
77 test-text = ''; /* no way to test */
83 c_fix_arg = <<- _EOArg_
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
91 /* Alias the symbols using asm */
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
110 hackname = AAB_darwin7_9_long_double_funcs;
111 mach = "*-*-darwin7.9*";
112 files = architecture/ppc/math.h;
114 replace = <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
119 # define __APPLE_CC__ 1345
120 # include_next <architecture/ppc/math.h>
122 # define __APPLE_CC__ 1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
127 # define __LIBMLDBL_COMPAT(sym)
128 # endif /* __LONG_DOUBLE_128__ */
129 # endif /* __LIBMLDBL_COMPAT */
133 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
193 #endif /* __MATH__ */
198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
201 hackname = AAB_fd_zero_asm_posix_types_h;
202 files = asm/posix_types.h;
203 mach = 'i[34567]86-*-linux*';
206 bypass = 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
210 * the start, so that if #include_next gets another instance of
211 * the wrapper, this will follow the #include_next chain until
212 * we arrive at the real <asm/posix_types.h>.
214 replace = <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel. */
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include <features.h>
219 #include_next <asm/posix_types.h>
221 #if defined(__FD_ZERO) && !defined(__GLIBC__)
223 #define __FD_ZERO(fdsetp) \
226 __asm__ __volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0), "=&D" (__d1) \
228 : "a" (0), "0" (__FDSET_LONGS), \
229 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif /* _POSIX_TYPES_H_WRAPPER */
239 * This fixes __FD_ZERO bug for glibc-1.x
242 hackname = AAB_fd_zero_gnu_types_h;
244 mach = 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
248 * the start, so that if #include_next gets another instance of
249 * the wrapper, this will follow the #include_next chain until
250 * we arrive at the real <gnu/types.h>.
252 replace = <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
254 #ifndef _TYPES_H_WRAPPER
255 #include <features.h>
256 #include_next <gnu/types.h>
258 #if defined(__FD_ZERO) && !defined(__GLIBC__)
260 # define __FD_ZERO(fdsetp) \
263 __asm__ __volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0), "=&D" (__d1) \
265 : "a" (0), "0" (__FDSET_LONGS), \
266 "1" ((__fd_set *) (fdsetp)) :"memory"); \
270 #define _TYPES_H_WRAPPER
271 #endif /* _TYPES_H_WRAPPER */
276 * This fixes __FD_ZERO bug for glibc-2.0.x
279 hackname = AAB_fd_zero_selectbits_h;
280 files = selectbits.h;
281 mach = 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
285 * the start, so that if #include_next gets another instance of
286 * the wrapper, this will follow the #include_next chain until
287 * we arrive at the real <selectbits.h>.
289 replace = <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include <features.h>
293 #include_next <selectbits.h>
295 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
296 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
297 && __GLIBC_MINOR__ == 0
299 #define __FD_ZERO(fdsetp) \\
302 __asm__ __volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0), "=&D" (__d1) \\
304 : "a" (0), "0" (sizeof (__fd_set) \\
305 / sizeof (__fd_mask)), \\
306 "1" ((__fd_mask *) (fdsetp)) \\
311 #define _SELECTBITS_H_WRAPPER
312 #endif /* _SELECTBITS_H_WRAPPER */
317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
318 * the same interface as <stdarg.h>. No idea why they couldn't have just
319 * used the standard header.
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris*';
325 replace = <<- _EndOfHeader_
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
342 hackname = AAB_sun_memcpy;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
367 #endif /* __memory_h__ */
372 * Fix assert.h on VxWorks:
375 hackname = AAB_vxworks_assert;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
390 extern void __assert ();
394 #define assert(ign) ((void)0)
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
416 hackname = AAB_vxworks_regs_vxtypes;
418 mach = "*-*-vxworks*";
420 replace = <<- _EndOfHeader_
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
430 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
433 hackname = AAB_vxworks_unistd;
435 mach = "*-*-vxworks*";
437 replace = <<- _EndOfHeader_
440 #include_next <unistd.h>
443 #define STDIN_FILENO 0
445 #ifndef STDOUT_FILENO
446 #define STDOUT_FILENO 1
448 #ifndef STDERR_FILENO
449 #define STDERR_FILENO 2
451 #endif /* _UNISTD_H */
456 * assert.h on AIX 7 redefines static_assert as _Static_assert without
460 hackname = aix_assert;
463 select = "#define[ \t]static_assert[ \t]_Static_assert";
465 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
466 test_text = "#define static_assert _Static_assert";
470 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
471 * which only is provided by AIX xlc C99.
474 hackname = aix_complex;
477 select = "#define[ \t]_Complex_I[ \t]__I";
479 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
480 test_text = "#define _Complex_I __I\n";
484 * On AIX some headers are not properly guarded by 'extern "C"'.
487 hackname = aix_externc;
493 files = sys/localedef.h;
495 bypass = "extern \"C\"";
497 c_fix_arg = "#ifdef __cplusplus\n"
500 c_fix_arg = "#ifdef __cplusplus\n"
503 test_text = "extern int __n_pthreads;\n";
507 * On AIX sys/socket.h assumes C++.
510 hackname = aix_externcpp1;
512 files = "sys/socket.h";
513 select = "#ifdef __cplusplus";
515 c_fix_arg = "#ifdef __cplusplus\n"
517 test_text = "#ifdef __cplusplus";
522 hackname = aix_externcpp2;
524 files = "sys/socket.h";
525 select = "#else /\\* __cplusplus \\*/";
527 c_fix_arg = "} /* extern \"C++\" */\n"
528 "#else /* __cplusplus */";
529 test_text = "#else /* __cplusplus */";
534 * malloc.h on AIX6 uses XLC++ specific builtin syntax
537 hackname = aix_malloc;
540 select = "#ifdef __cplusplus";
542 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
543 test_text = "#ifdef __cplusplus";
547 * net/if_arp.h defines a variable fc_softc instead of adding a
548 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
551 hackname = aix_net_if_arp;
553 files = "net/if_arp.h";
554 select = "^struct fc_softc \\{";
556 c_fix_arg = "typedef struct _fc_softc {";
557 test_text = "struct fc_softc {\n int a;\n};";
561 * Fix AIX definition of NULL for G++.
566 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
567 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
569 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
571 c_fix_arg = <<- _EOFix_
576 #else /* ! __GNUG__ */
578 #endif /* __GNUG__ */
579 #else /* ! __cplusplus */
580 #define NULL ((void *)0)
581 #endif /* __cplusplus */
584 test_text = "# define\tNULL \t(0L) /* typed NULL */";
588 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
589 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
593 hackname = aix_once_init_1;
596 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
599 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
601 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
606 hackname = aix_once_init_2;
609 select = "[ \t]0 \\\\\n"
612 c_fix_arg = " 0 \\\n"
614 test_text = " 0 \\\\\n"
619 hackname = aix_mutex_initializer_1;
622 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
625 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
627 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
632 hackname = aix_cond_initializer_1;
635 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
638 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
640 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
645 hackname = aix_rwlock_initializer_1;
648 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
651 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
653 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
658 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
659 * which violates a requirement of ISO C.
662 hackname = aix_pthread;
664 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
667 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
668 "{...init stuff...}";
672 * AIX stdint.h fixes.
675 hackname = aix_stdint_1;
677 files = stdint-aix.h, stdint.h;
678 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
679 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
681 c_fix_arg = "#define UINT8_MAX (255)\n"
682 "#define UINT16_MAX (65535)";
683 test_text = "#define UINT8_MAX (255U)\n"
684 "#define UINT16_MAX (65535U)";
691 hackname = aix_stdint_2;
693 files = stdint-aix.h, stdint.h;
694 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
695 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
696 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
698 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
699 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
700 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
702 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
703 "#define INTPTR_MAX 9223372036854775807L\n"
704 "#define UINTPTR_MAX 18446744073709551615UL\n"
706 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
707 "#define INTPTR_MAX 2147483647L\n"
708 "#define UINTPTR_MAX 4294967295UL";
709 test_text = "#define INTPTR_MIN INT64_MIN\n"
710 "#define INTPTR_MAX INT64_MAX\n"
711 "#define UINTPTR_MAX UINT64_MAX\n"
713 "#define INTPTR_MIN INT32_MIN\n"
714 "#define INTPTR_MAX INT32_MAX\n"
715 "#define UINTPTR_MAX UINT32_MAX";
722 hackname = aix_stdint_3;
724 files = stdint-aix.h, stdint.h;
725 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
726 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
728 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
729 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
731 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
732 "#define PTRDIFF_MAX 9223372036854775807L\n"
734 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
735 "#define PTRDIFF_MAX 2147483647L";
736 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
737 "#define PTRDIFF_MAX INT64_MAX\n"
739 "#define PTRDIFF_MIN INT32_MIN\n"
740 "#define PTRDIFF_MAX INT32_MAX";
747 hackname = aix_stdint_4;
749 files = stdint-aix.h, stdint.h;
750 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
752 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
754 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
756 "#define SIZE_MAX 4294967295UL";
757 test_text = "#define SIZE_MAX UINT64_MAX\n"
759 "#define SIZE_MAX UINT32_MAX";
766 hackname = aix_stdint_5;
768 files = stdint-aix.h, stdint.h;
769 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
770 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
772 c_fix_arg = "#define UINT8_C(c) c\n"
773 "#define UINT16_C(c) c";
774 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
775 "#define UINT16_C(c) __CONCAT__(c,U)";
779 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
780 produces wrong code with G++.
783 hackname = aix_stdio_inline;
786 select = "#ifdef __cplusplus\\\n"
790 c_fix_arg = "#ifdef __cplusplus\n"
793 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
795 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
799 * stdlib.h on AIX uses #define on malloc and friends.
802 hackname = aix_stdlib_malloc;
805 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
807 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
808 test_text = "#define malloc __linux_malloc";
812 hackname = aix_stdlib_realloc;
815 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
817 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
818 test_text = "#define realloc __linux_realloc";
822 hackname = aix_stdlib_calloc;
825 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
827 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
828 test_text = "#define calloc __linux_calloc";
832 hackname = aix_stdlib_valloc;
835 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
837 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
838 test_text = "#define valloc __linux_valloc";
842 hackname = aix_stdlib_vec_malloc;
845 select = "#define[ \t]+malloc[ \t]+vec_malloc";
847 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
848 test_text = "#define malloc vec_malloc";
852 hackname = aix_stdlib_vec_calloc;
855 select = "#define[ \t]+calloc[ \t]+vec_calloc";
857 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
858 test_text = "#define calloc vec_calloc";
862 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
865 hackname = aix_strtof_const;
868 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
870 c_fix_arg = "%1(const char *, char **);";
871 test_text = "extern float strtof(char *, char **);";
875 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
876 * in an otherwise harmless (and #ifed out) macro definition
879 hackname = aix_sysmachine;
881 files = sys/machine.h;
885 test_text = "#define FOO \\\n"
886 " bar \\ \n baz \\ \n bat";
890 * sys/wait.h on AIX 5.2 defines macros that have both signed and
891 * unsigned types in conditional expressions.
894 hackname = aix_syswait_2;
897 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
899 c_fix_arg = "? (int)%1";
900 test_text = "#define WSTOPSIG(__x) "
901 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
905 * sys/signal.h on some versions of AIX uses volatile in the typedef of
906 * sig_atomic_t, which causes gcc to generate a warning about duplicate
907 * volatile when a sig_atomic_t variable is declared volatile, as
908 * required by ANSI C.
911 hackname = aix_volatile;
913 files = sys/signal.h;
914 select = "typedef volatile int sig_atomic_t";
916 c_fix_arg = "typedef int sig_atomic_t";
917 test_text = "typedef volatile int sig_atomic_t;";
921 * Fix __assert declaration in assert.h on Alpha OSF/1.
924 hackname = alpha___assert;
926 select = '__assert\(char \*, char \*, int\)';
928 c_fix_arg = "__assert(const char *, const char *, int)";
929 test_text = 'extern void __assert(char *, char *, int);';
933 * Fix assert macro in assert.h on Alpha OSF/1.
934 * The superfluous int cast breaks C++.
937 hackname = alpha_assert;
939 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
941 c_fix_arg = "%1(EX)";
942 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
943 ': __assert(#EX, __FILE__, __LINE__))';
947 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
950 hackname = alpha_getopt;
953 select = 'getopt\(int, char \*\[\], *char \*\)';
955 c_fix_arg = "getopt(int, char *const[], const char *)";
956 test_text = 'extern int getopt(int, char *[], char *);';
960 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
963 hackname = alpha_if_semicolon;
965 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
967 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
968 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
972 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
975 hackname = alpha_parens;
977 select = '#ifndef\(__mips64\)';
979 c_fix_arg = "#ifndef __mips64";
980 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
984 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
988 hackname = alpha_sbrk;
990 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
992 c_fix_arg = "void *sbrk(";
993 test_text = "extern char* sbrk(ptrdiff_t increment);";
997 * For C++, avoid any typedef or macro definition of bool,
998 * and use the built in type instead.
999 * HP/UX 10.20 also has it in curses_colr/curses.h.
1002 hackname = avoid_bool_define;
1004 files = curses_colr/curses.h;
1008 select = "#[ \t]*define[ \t]+bool[ \t]";
1009 bypass = "__cplusplus";
1012 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1013 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1015 test_text = "# define bool\t char \n";
1022 hackname = avoid_bool_type;
1024 files = curses_colr/curses.h;
1028 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1029 bypass = "__cplusplus";
1032 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1034 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1038 * For C++, avoid any typedef definition of wchar_t,
1039 * and use the built in type instead.
1040 * Don't do this for headers that are smart enough to do the right
1041 * thing (recent [n]curses.h and Xlib.h).
1042 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1043 * and will be broken by the edit.
1047 hackname = avoid_wchar_t_type;
1049 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1050 bypass = "__cplusplus";
1051 bypass = "_LINUX_NLS_H";
1052 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1055 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1057 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1061 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1064 hackname = bad_struct_term;
1066 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1068 c_fix_arg = "struct term;";
1070 test_text = 'typedef struct term;';
1074 * Fix one other error in this file:
1075 * a mismatched quote not inside a C comment.
1078 hackname = badquote;
1079 files = sundev/vuid_event.h;
1082 c_fix_arg = "does not";
1084 test_text = "/* doesn't have matched single quotes */";
1088 * check for broken assert.h that needs stdio.h
1091 hackname = broken_assert_stdio;
1094 bypass = "include.*stdio\\.h";
1096 c_fix_arg = "#include <stdio.h>\n";
1097 test_text = "extern FILE* stderr;";
1101 * check for broken assert.h that needs stdlib.h
1104 hackname = broken_assert_stdlib;
1106 select = 'exit *\(|abort *\(';
1107 bypass = "include.*stdlib\\.h";
1109 c_fix_arg = "#ifdef __cplusplus\n"
1110 "#include <stdlib.h>\n"
1112 test_text = "extern void exit ( int );";
1116 * Remove `extern double cabs' declarations from math.h.
1117 * This conflicts with C99. Discovered on AIX.
1118 * Darwin hides its broken cabs in architecture-specific subdirs.
1121 hackname = broken_cabs;
1122 files = math.h, "architecture/*/math.h";
1123 select = "^extern[ \t]+double[ \t]+cabs";
1125 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1126 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1128 test_text = "#ifdef __STDC__\n"
1129 "extern double cabs(struct dbl_hypot);\n"
1131 "extern double cabs();\n"
1133 "extern double cabs ( _Complex z );";
1137 * Fixup Darwin's broken check for __builtin_nanf.
1140 hackname = broken_nan;
1142 * It is tempting to omit the first "files" entry. Do not.
1143 * The testing machinery will take the first "files" entry as the name
1144 * of a test file to play with. It would be a nuisance to have a directory
1145 * with the name "*".
1147 files = "architecture/ppc/math.h";
1148 files = "architecture/*/math.h";
1149 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1152 c_fix_arg = "#if 1";
1153 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1157 * Various systems derived from BSD4.4 contain a macro definition
1158 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1159 * Known to be fixed in FreeBSD 5 system headers.
1162 hackname = bsd_stdio_attrs_conflict;
1164 mach = "*-*-*darwin*";
1166 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1168 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1169 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1170 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1171 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1172 test_text = '#define vfscanf __svfscanf';
1176 * Fix various macros used to define ioctl numbers.
1177 * The traditional syntax was:
1179 * #define _CTRL(n, x) (('n'<<8)+x)
1180 * #define TCTRLCFOO _CTRL(T, 1)
1182 * but this does not work with the C standard, which disallows macro
1183 * expansion inside strings. We have to rewrite it thus:
1185 * #define _CTRL(n, x) ((n<<8)+x)
1186 * #define TCTRLCFOO _CTRL('T', 1)
1188 * The select expressions match too much, but the c_fix code is cautious.
1190 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1193 hackname = ctrl_quotes_def;
1194 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1195 c_fix = char_macro_def;
1199 * This is two tests in order to ensure that the "CTRL(c)" can
1200 * be selected in isolation from the multi-arg format
1202 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1203 test_text = "#define _CTRL(c) ('c'&037)";
1207 * Fix various macros used to define ioctl numbers.
1210 hackname = ctrl_quotes_use;
1211 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1212 c_fix = char_macro_use;
1214 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1218 * sys/mman.h on HP/UX is not C++ ready,
1219 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1221 * rpc/types.h on OSF1/2.0 is not C++ ready,
1222 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1224 * The problem is the declaration of malloc.
1227 hackname = cxx_unready;
1229 files = rpc/types.h;
1230 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1231 not within a macro. */
1232 bypass = '"C"|__BEGIN_DECLS';
1235 c_fix_arg = "#ifdef __cplusplus\n"
1238 c_fix_arg = "#ifdef __cplusplus\n"
1241 test_text = "extern void* malloc( size_t );";
1245 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1249 hackname = darwin_availabilityinternal;
1250 mach = "*-*-darwin*";
1251 files = AvailabilityInternal.h;
1252 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1254 c_fix_arg = <<- _EOFix_
1255 #if defined(__has_attribute)
1256 #if __has_attribute(availability)
1266 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1267 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1271 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1272 * you have to not use "" includes.
1275 hackname = darwin_9_long_double_funcs_2;
1276 mach = "*-*-darwin7.9*";
1278 select = '#include[ \t]+\"';
1280 c_fix_arg = "%1<%2.h>";
1282 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1284 test_text = '#include "architecture/ppc/math.h"';
1288 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1289 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1292 hackname = darwin_externc;
1293 mach = "*-*-darwin*";
1294 files = mach-o/swap.h;
1295 files = mach/mach_time.h;
1296 files = mach/mach_traps.h;
1297 files = mach/message.h;
1299 files = mach/semaphore.h;
1300 bypass = "extern \"C\"";
1301 bypass = "__BEGIN_DECLS";
1303 c_fix_arg = "#ifdef __cplusplus\n"
1306 c_fix_arg = "#ifdef __cplusplus\n"
1309 test_text = "extern void swap_fat_header();\n";
1313 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1314 * bad __GNUC__ tests.
1317 hackname = darwin_gcc4_breakage;
1318 mach = "*-*-darwin*";
1319 files = AvailabilityMacros.h;
1320 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1322 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1323 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1324 "(__GNUC_MINOR__ >= 1)\n";
1328 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1331 hackname = darwin_longjmp_noreturn;
1332 mach = "*-*-darwin*";
1333 files = "i386/setjmp.h";
1335 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1337 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1339 test_text = "void siglongjmp(sigjmp_buf, int);";
1343 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1346 hackname = darwin_os_trace_1;
1347 mach = "*-*-darwin*";
1349 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1352 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1356 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1357 * extension without guard.
1360 hackname = darwin_os_trace_2;
1361 mach = "*-*-darwin*";
1363 select = "typedef.*\\^os_trace_payload_t.*";
1365 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1366 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1370 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1371 * os_trace_payload_t typedef, too.
1374 hackname = darwin_os_trace_3;
1375 mach = "*-*-darwin*";
1377 select = <<- _EOSelect_
1381 _os_trace.*os_trace_payload_t payload);
1384 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1385 test_text = <<- _EOText_
1386 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1387 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1389 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1391 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1392 OS_EXPORT OS_NOTHROW
1394 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1399 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1400 * why would you ever put it in a system header file?
1403 hackname = darwin_private_extern;
1404 mach = "*-*-darwin*";
1405 files = mach-o/dyld.h;
1406 select = "__private_extern__ [a-z_]+ _dyld_";
1408 c_fix_arg = "extern";
1409 c_fix_arg = "__private_extern__";
1410 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1411 "const char *dyld_func_name,\n"
1412 "unsigned long *address);\n";
1416 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1417 * unsigned constants.
1420 hackname = darwin_stdint_1;
1421 mach = "*-*-darwin*";
1422 files = stdint-darwin.h, stdint.h;
1424 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1425 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1426 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1427 test_text = "#define UINT8_C(v) (v ## U)\n"
1428 "#define UINT16_C(v) (v ## U)";
1432 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1436 hackname = darwin_stdint_2;
1437 mach = "*-*-darwin*";
1438 files = stdint-darwin.h, stdint.h;
1440 c_fix_arg = "#if __WORDSIZE == 64\n"
1441 "#define INTPTR_MAX 9223372036854775807L\n"
1442 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1444 "#define INTPTR_MAX 2147483647L\n"
1445 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1447 select = "#if __WORDSIZE == 64\n"
1448 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1449 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1451 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1452 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1454 test_text = "#if __WORDSIZE == 64\n"
1455 "#define INTPTR_MIN INT64_MIN\n"
1456 "#define INTPTR_MAX INT64_MAX\n"
1458 "#define INTPTR_MIN INT32_MIN\n"
1459 "#define INTPTR_MAX INT32_MAX\n"
1464 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1467 hackname = darwin_stdint_3;
1468 mach = "*-*-darwin*";
1469 files = stdint-darwin.h, stdint.h;
1471 c_fix_arg = "#if __WORDSIZE == 64\n"
1472 "#define UINTPTR_MAX 18446744073709551615UL\n"
1474 "#define UINTPTR_MAX 4294967295UL\n"
1476 select = "#if __WORDSIZE == 64\n"
1477 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1479 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1481 test_text = "#if __WORDSIZE == 64\n"
1482 "#define UINTPTR_MAX UINT64_MAX\n"
1484 "#define UINTPTR_MAX UINT32_MAX\n"
1489 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1492 hackname = darwin_stdint_4;
1493 mach = "*-*-darwin*";
1494 files = stdint-darwin.h, stdint.h;
1496 c_fix_arg = "#if __WORDSIZE == 64\n"
1497 "#define SIZE_MAX 18446744073709551615UL\n"
1499 "#define SIZE_MAX 4294967295UL\n"
1501 select = "#if __WORDSIZE == 64\n"
1502 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1504 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1506 test_text = "#if __WORDSIZE == 64\n"
1507 "#define SIZE_MAX UINT64_MAX\n"
1509 "#define SIZE_MAX UINT32_MAX\n"
1514 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1515 * with a wrong type.
1518 hackname = darwin_stdint_5;
1519 mach = "*-*-darwin*";
1520 files = stdint-darwin.h, stdint.h;
1522 c_fix_arg = "#if __WORDSIZE == 64\n"
1523 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1524 "#define INTMAX_MAX 9223372036854775807L\n"
1525 "#define UINTMAX_MAX 18446744073709551615UL\n"
1527 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1528 "#define INTMAX_MAX 9223372036854775807LL\n"
1529 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1531 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1532 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1534 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1535 test_text = "#define INTMAX_MIN INT64_MIN\n"
1536 "#define INTMAX_MAX INT64_MAX\n"
1538 "#define UINTMAX_MAX UINT64_MAX";
1542 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1543 * with a wrong type.
1546 hackname = darwin_stdint_6;
1547 mach = "*-*-darwin*";
1548 files = stdint-darwin.h, stdint.h;
1550 c_fix_arg = "#if __WORDSIZE == 64\n"
1551 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1552 "#define PTRDIFF_MAX 9223372036854775807L\n"
1554 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1555 "#define PTRDIFF_MAX 2147483647\n"
1557 select = "#if __WORDSIZE == 64\n"
1558 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1559 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1561 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1562 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1564 test_text = "#if __WORDSIZE == 64\n"
1565 "#define PTRDIFF_MIN INT64_MIN\n"
1566 "#define PTRDIFF_MAX INT64_MAX\n"
1568 "#define PTRDIFF_MIN INT32_MIN\n"
1569 "#define PTRDIFF_MAX INT32_MAX\n"
1574 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1575 * with a wrong type.
1578 hackname = darwin_stdint_7;
1579 mach = "*-*-darwin*";
1580 files = stdint-darwin.h, stdint.h;
1582 c_fix_arg = "#if __WORDSIZE == 64\n"
1583 "#define INTMAX_C(v) (v ## L)\n"
1584 "#define UINTMAX_C(v) (v ## UL)\n"
1586 "#define INTMAX_C(v) (v ## LL)\n"
1587 "#define UINTMAX_C(v) (v ## ULL)\n"
1589 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1590 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1591 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1592 "#define UINTMAX_C(v) (v ## ULL)";
1596 * Fix <c_asm.h> on Digital UNIX V4.0:
1597 * It contains a prototype for a DEC C internal asm() function,
1598 * clashing with gcc's asm keyword. So protect this with __DECC.
1601 hackname = dec_intern_asm;
1603 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1604 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1608 " ... asm stuff ...\n"
1609 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1613 * Fix typo in <wchar.h> on DJGPP 2.03.
1616 hackname = djgpp_wchar_h;
1618 select = "__DJ_wint_t";
1619 bypass = "sys/djtypes.h";
1621 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1622 c_fix_arg = "#include <stddef.h>";
1623 test_text = "#include <stddef.h>\n"
1624 "extern __DJ_wint_t x;\n";
1628 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1631 hackname = ecd_cursor;
1632 files = "sunwindow/win_lock.h";
1633 files = "sunwindow/win_cursor.h";
1634 select = 'ecd\.cursor';
1636 c_fix_arg = 'ecd_cursor';
1638 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1642 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1643 * that fails when compiling for SSE-less 32-bit x86.
1646 hackname = feraiseexcept_nosse_divbyzero;
1647 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1648 files = bits/fenv.h, '*/bits/fenv.h';
1649 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1650 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1651 bypass = "\"fdivp .*; fwait\"";
1654 c_fix_arg = <<- _EOText_
1655 # ifdef __SSE_MATH__
1658 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1659 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1663 test_text = <<- _EOText_
1664 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1669 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1670 * that fails when compiling for SSE-less 32-bit x86.
1673 hackname = feraiseexcept_nosse_invalid;
1674 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1675 files = bits/fenv.h, '*/bits/fenv.h';
1676 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1677 ": \"x\" \\(__f\\)\\);$";
1678 bypass = "\"fdiv .*; fwait\"";
1681 c_fix_arg = <<- _EOText_
1682 # ifdef __SSE_MATH__
1685 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1686 %1 : "=t" (__f) : "0" (__f));
1690 test_text = <<- _EOText_
1691 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1696 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1697 * neither the existence of GCC 3 nor its exact feature set yet break
1698 * (by design?) when __GNUC__ is set beyond 2.
1701 hackname = freebsd_gcc3_breakage;
1702 mach = "*-*-freebsd*";
1703 files = sys/cdefs.h;
1704 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1705 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1707 c_fix_arg = '%0 || __GNUC__ >= 3';
1708 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1712 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1713 * neither the existence of GCC 4 nor its exact feature set yet break
1714 * (by design?) when __GNUC__ is set beyond 3.
1717 hackname = freebsd_gcc4_breakage;
1718 mach = "*-*-freebsd*";
1719 files = sys/cdefs.h;
1720 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1722 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1723 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1727 * Some versions of glibc don't expect the C99 inline semantics.
1730 hackname = glibc_c99_inline_1;
1731 files = features.h, '*/features.h';
1732 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1734 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1736 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1737 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1738 # define __USE_EXTERN_INLINES 1
1744 * Similar, but a version that didn't have __NO_INLINE__
1747 hackname = glibc_c99_inline_1a;
1748 files = features.h, '*/features.h';
1749 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1750 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1752 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1754 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1755 # define __USE_EXTERN_INLINES 1
1761 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1762 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1763 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1766 hackname = glibc_c99_inline_2;
1767 files = sys/stat.h, '*/sys/stat.h';
1768 select = "extern __inline__ int";
1769 sed = "s/extern int \\(stat\\)/"
1770 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1771 "__inline__ int \\1/";
1772 sed = "s/extern int \\([lf]stat\\)/"
1773 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1774 "__inline__ int \\1/";
1775 sed = "s/extern int \\(mknod\\)/"
1776 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1777 "__inline__ int \\1/";
1778 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1779 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1780 "__inline__ int __REDIRECT\\1 (\\2/";
1781 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1782 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1783 "__inline__ int __REDIRECT\\1 (\\2/";
1784 sed = "s/^extern __inline__ int/"
1785 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1788 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1789 extern __inline__ int
1790 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1796 * glibc_c99_inline_3
1799 hackname = glibc_c99_inline_3;
1800 files = bits/string2.h, '*/bits/string2.h';
1801 select = "extern __inline";
1802 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1804 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1805 c_fix_arg = "^# ifdef __cplusplus$";
1808 # define __STRING_INLINE inline
1810 # define __STRING_INLINE extern __inline
1816 * glibc_c99_inline_4
1819 hackname = glibc_c99_inline_4;
1820 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1821 pthread.h, '*/pthread.h';
1822 bypass = "__extern_inline|__gnu_inline__";
1823 select = "(^| )extern __inline";
1825 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1827 __extension__ extern __inline unsigned int
1828 extern __inline unsigned int
1832 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1833 * so we replace them with versions that correspond to the
1837 hackname = glibc_mutex_init;
1839 select = '\{ *\{ *0, *\} *\}';
1840 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1841 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1842 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1843 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1844 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1845 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1846 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1847 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1848 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1849 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1850 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1851 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1852 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1853 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1854 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1855 "N;s/^[ \t]*#[ \t]*"
1856 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1857 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1859 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1862 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1864 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1865 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1866 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1867 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1869 test_text = <<- _EOText_
1870 #define PTHREAD_MUTEX_INITIALIZER \\
1873 # if __WORDSIZE == 64
1874 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1875 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1876 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1877 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1878 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1879 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1881 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1882 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1883 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1884 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1885 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1886 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1889 # define PTHREAD_RWLOCK_INITIALIZER \\
1892 # if __WORDSIZE == 64
1893 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1894 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1895 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1897 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1898 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1901 #define PTHREAD_COND_INITIALIZER { { 0, } }
1905 /* glibc versions before 2.5 have a version of stdint.h that defines
1906 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1907 versions with stdint.h based on those glibc versions. */
1909 hackname = glibc_stdint;
1911 select = "GNU C Library";
1913 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1914 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1915 test_text = "/* This file is part of the GNU C Library. */\n"
1916 "# define UINT8_C(c)\tc ## U\n"
1917 "# define UINT16_C(c)\tc ## U";
1920 /* Some versions of glibc have a version of bits/string2.h that
1921 produces "value computed is not used" warnings from strncpy; fix
1922 this definition by using __builtin_strncpy instead as in newer
1925 hackname = glibc_strncpy;
1926 files = bits/string2.h, '*/bits/string2.h';
1927 bypass = "__builtin_strncpy";
1929 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1930 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1932 # define strncpy(dest, src, n) \
1933 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1934 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1935 ? (char *) memcpy (dest, src, n) \\
1936 : strncpy (dest, src, n)) \\
1937 : strncpy (dest, src, n)))
1942 /* glibc's tgmath.h relies on an expression that is not an integer
1943 constant expression being treated as it was by GCC 4.4 and
1946 hackname = glibc_tgmath;
1948 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1949 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1951 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1952 "(__builtin_classify_type ((type) 0) == 9 && "
1953 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1954 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1958 * Fix these files to use the types we think they should for
1959 * ptrdiff_t, size_t, and wchar_t.
1961 * This defines the types in terms of macros predefined by our 'cpp'.
1962 * This is supposedly necessary for glibc's handling of these types.
1963 * It's probably not necessary for anyone else, but it doesn't hurt.
1966 hackname = gnu_types;
1967 files = "sys/types.h";
1969 files = "sys/stdtypes.h";
1973 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1974 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1976 /* The Solaris 10 headers already define these types correctly. */
1977 mach = '*-*-solaris2.1[0-9]*';
1980 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1981 "typedef uint_t size_t; /* uint_t */\n"
1982 "typedef ushort_t wchar_t; /* ushort_t */";
1986 * Fix HP & Sony's use of "../machine/xxx.h"
1987 * to refer to: <machine/xxx.h>
1990 hackname = hp_inline;
1991 files = sys/spinlock.h;
1992 files = machine/machparam.h;
1993 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1996 c_fix_arg = "%1<machine/%2.h>";
1998 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2001 test_text = ' # include "../machine/mumble.h"';
2005 * Check for (...) in C++ code in HP/UX sys/file.h.
2008 hackname = hp_sysfile;
2010 select = "HPUX_SOURCE";
2013 c_fix_arg = "(struct file *, ...)";
2014 c_fix_arg = '\(\.\.\.\)';
2016 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2020 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2021 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2024 hackname = hppa_hpux_fp_macros;
2025 mach = "hppa*-hp-hpux11*";
2027 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2028 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2029 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2030 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2031 "#[ \t]*define[ \t]*FP_NAN.*\n";
2033 c_fix_arg = <<- _EOFix_
2034 #endif /* _INCLUDE_HPUX_SOURCE */
2036 #if defined(_INCLUDE_HPUX_SOURCE) || \
2037 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2040 #ifdef _INCLUDE_HPUX_SOURCE
2045 "# define FP_NORMAL 0\n"
2046 "# define FP_ZERO 1\n"
2047 "# define FP_INFINITE 2\n"
2048 "# define FP_SUBNORMAL 3\n"
2049 "# define FP_NAN 4\n";
2053 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2054 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2057 hackname = hpux10_cpp_pow_inline;
2058 files = fixinc-test-limits.h, math.h;
2059 select = <<- END_POW_INLINE
2060 ^# +ifdef +__cplusplus
2062 +inline +double +pow\(double +__d,int +__expon\) +\{
2063 [ ]+return +pow\(__d,\(double\)__expon\);
2074 "# ifdef __cplusplus\n"
2076 " inline double pow(double __d,int __expon) {\n"
2077 "\t return pow(__d,(double)__expon);\n"
2079 ' extern "C"' " {\n"
2085 hackname = hpux11_cpp_pow_inline;
2087 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2088 " +return pow\\(d, \\(double\\)expon\\);\n"
2094 " inline double pow(double d,int expon) {\n"
2095 " return pow(d, (double)expon);\n"
2100 * Fix hpux 10.X missing ctype declarations 1
2103 hackname = hpux10_ctype_declarations1;
2105 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2106 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2108 c_fix_arg = "#ifdef _PROTOTYPES\n"
2109 "extern int __tolower(int);\n"
2110 "extern int __toupper(int);\n"
2111 "#else /* NOT _PROTOTYPES */\n"
2112 "extern int __tolower();\n"
2113 "extern int __toupper();\n"
2114 "#endif /* _PROTOTYPES */\n\n"
2117 test_text = "# define _toupper(__c) __toupper(__c)\n";
2121 * Fix hpux 10.X missing ctype declarations 2
2124 hackname = hpux10_ctype_declarations2;
2126 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2127 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2129 c_fix_arg = "%0\n\n"
2130 "#ifdef _PROTOTYPES\n"
2131 " extern int _isalnum(int);\n"
2132 " extern int _isalpha(int);\n"
2133 " extern int _iscntrl(int);\n"
2134 " extern int _isdigit(int);\n"
2135 " extern int _isgraph(int);\n"
2136 " extern int _islower(int);\n"
2137 " extern int _isprint(int);\n"
2138 " extern int _ispunct(int);\n"
2139 " extern int _isspace(int);\n"
2140 " extern int _isupper(int);\n"
2141 " extern int _isxdigit(int);\n"
2142 "# else /* not _PROTOTYPES */\n"
2143 " extern int _isalnum();\n"
2144 " extern int _isalpha();\n"
2145 " extern int _iscntrl();\n"
2146 " extern int _isdigit();\n"
2147 " extern int _isgraph();\n"
2148 " extern int _islower();\n"
2149 " extern int _isprint();\n"
2150 " extern int _ispunct();\n"
2151 " extern int _isspace();\n"
2152 " extern int _isupper();\n"
2153 " extern int _isxdigit();\n"
2154 "#endif /* _PROTOTYPES */\n";
2156 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2157 " extern unsigned int *__SB_masks;\n";
2161 * Fix hpux 10.X missing stdio declarations
2164 hackname = hpux10_stdio_declarations;
2166 select = "^#[ \t]*define _iob[ \t]*__iob";
2167 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2169 c_fix_arg = "%0\n\n"
2170 "# if defined(__STDC__) || defined(__cplusplus)\n"
2171 " extern int snprintf(char *, size_t, const char *, ...);\n"
2172 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2173 "# else /* not __STDC__) || __cplusplus */\n"
2174 " extern int snprintf();\n"
2175 " extern int vsnprintf();\n"
2176 "# endif /* __STDC__) || __cplusplus */\n";
2178 test_text = "# define _iob __iob\n";
2182 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2183 * As a result, we need to include sys/stdsyms.h in alloca.h.
2186 hackname = hppa_hpux11_alloca;
2187 mach = "hppa*-*-hpux11*";
2189 select = "#ifndef _STDDEF_INCLUDED";
2191 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2192 "# include <sys/stdsyms.h>\n"
2193 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2196 test_text = "#ifndef _STDDEF_INCLUDED";
2200 * Make sure hpux defines abs in header.
2203 hackname = hpux11_abs;
2204 mach = "*-hp-hpux11*";
2206 select = "ifndef _MATH_INCLUDED";
2208 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2209 test_text = "#ifndef _MATH_INCLUDED";
2213 * Fix hpux11 __LWP_RWLOCK_VALID define
2216 hackname = hpux11_lwp_rwlock_valid;
2217 mach = "*-hp-hpux11*";
2218 files = sys/pthread.h;
2219 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2221 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2222 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2229 hackname = hpux11_extern_sendfile;
2230 mach = "*-hp-hpux11.[12]*";
2231 files = sys/socket.h;
2232 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2234 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2235 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2236 " const struct iovec *, int));\n";
2243 hackname = hpux11_extern_sendpath;
2244 mach = "*-hp-hpux11.[12]*";
2245 files = sys/socket.h;
2246 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2248 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2249 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2250 " const struct iovec *, int));\n";
2254 * Keep HP-UX 11 from stomping on C++ math namespace
2255 * with defines for fabsf.
2258 hackname = hpux11_fabsf;
2259 mach = "*-hp-hpux11*";
2261 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2264 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2268 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2273 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2274 * in pthread.h need to be constant expressions to be standard complient.
2275 * As a result, we need to remove the void * casts in the initializers
2276 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2277 * to use the long type.
2280 hackname = hpux11_pthread_pointer;
2281 mach = "*-hp-hpux11.[0-3]*";
2282 files = sys/pthread.h;
2283 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2286 c_fix_arg = "long\t%2%3";
2287 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2291 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2294 hackname = hpux11_pthread_const;
2295 mach = "*-hp-hpux11.[0-3]*";
2296 files = sys/pthread.h;
2297 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2301 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2305 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2306 * being defined by having it define _hpux_size_t instead.
2309 hackname = hpux11_size_t;
2310 mach = "*-hp-hpux11*";
2311 select = "__size_t";
2314 c_fix_arg = "_hpux_size_t";
2317 "#define __size_t size_t\n"
2318 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2322 * Fix hpux 11.00 broken snprintf declaration
2323 * (third argument is char *, needs to be const char * to prevent
2324 * spurious warnings with -Wwrite-strings or in C++).
2327 hackname = hpux11_snprintf;
2329 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2330 ' *(char *\*, *\.\.\.\);)';
2332 c_fix_arg = '%1 const %3';
2334 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2335 "extern int snprintf(char *, __size_t, char *, ...);\n"
2336 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2340 * Fix hpux 11.00 broken vsnprintf declaration
2343 hackname = hpux11_vsnprintf;
2345 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2346 'const char \*,) __va__list\);';
2348 c_fix_arg = "%1 __va_list);";
2350 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2355 * Fix missing const in hpux vsscanf declaration
2358 hackname = hpux_vsscanf;
2361 select = '(extern int vsscanf\()char';
2363 c_fix_arg = "%1const char";
2365 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2369 * get rid of bogus inline definitions in HP-UX 8.0
2372 hackname = hpux8_bogus_inlines;
2375 bypass = "__GNUG__";
2376 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2377 "@extern \"C\" int abs(int);@";
2378 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2379 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2380 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2381 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2382 "inline double sqr(double v) { return v**0.5; }";
2389 hackname = hpux_c99_intptr;
2390 mach = "*-hp-hpux11.3*";
2391 files = stdint-hpux11.h, stdint.h;
2392 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2393 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2394 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2395 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2396 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2397 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2398 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2399 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2400 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2401 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2402 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2403 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2404 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2405 "#define PTRDIFF_MIN INT32_MIN\n"
2406 "#define INTPTR_MAX INT32_MAX\n"
2407 "#define INTPTR_MIN INT32_MIN\n"
2408 "#define UINTPTR_MAX UINT32_MAX\n"
2409 "#define SIZE_MAX UINT32_MAX\n";
2413 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2416 hackname = hpux_c99_inttypes;
2417 mach = "*-hp-hpux11.[23]*";
2419 files = stdint-hpux11.h, stdint.h;
2420 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2421 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2422 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2423 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2424 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2425 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2426 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2427 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2428 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2429 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2430 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2431 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2435 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2438 hackname = hpux_c99_inttypes2;
2439 mach = "*-hp-hpux11.2*";
2440 files = stdint-hpux11.h, stdint.h;
2441 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2442 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2443 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2444 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2445 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2446 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2447 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2448 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2449 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2450 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2451 "# define INT16_C(__c) ((short)(__c))\n"
2452 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2456 * Fix hpux broken ctype macros
2459 hackname = hpux_ctype_macros;
2461 select = '((: |\()__SB_masks \? )'
2462 '(__SB_masks\[__(alnum|c)\] & _IS)';
2464 c_fix_arg = "%1(int)%3";
2466 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2467 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2474 hackname = hpux_extern_errno;
2475 mach = "*-hp-hpux10.*";
2476 mach = "*-hp-hpux11.[0-2]*";
2478 select = "^[ \t]*extern int errno;$";
2480 c_fix_arg = "#ifdef __cplusplus\n"
2484 "#ifdef __cplusplus\n"
2487 test_text = " extern int errno;\n";
2491 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2494 hackname = hpux_htonl;
2495 files = netinet/in.h;
2496 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2498 " \\* Macros for number representation conversion\\.\n"
2502 c_fix_arg = "#if 1\n%1";
2504 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2506 " * Macros for number representation conversion.\n"
2509 "#define ntohl(x) (x)\n"
2510 "#define ntohs(x) (x)\n"
2511 "#define htonl(x) (x)\n"
2512 "#define htons(x) (x)\n"
2514 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2518 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2521 hackname = hpux_imaginary_i;
2522 mach = "ia64-hp-hpux11.*";
2524 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2526 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2527 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2531 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2534 hackname = hpux_inttype_int8_t;
2535 mach = "*-hp-hpux1[01].*";
2536 files = sys/_inttypes.h;
2537 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2539 c_fix_arg = "typedef signed char int%18_t;";
2540 test_text = "typedef char int_least8_t;\n"
2541 "typedef char int8_t;\n";
2548 hackname = hpux_long_double;
2549 mach = "*-*-hpux10*";
2550 mach = "*-*-hpux11.[012]*";
2552 select = "extern[ \t]long_double[ \t]strtold";
2553 bypass = "long_double_t";
2554 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2555 sed = "s/long_double/long double/g";
2557 test_text = "# ifndef _LONG_DOUBLE\n"
2558 "# define _LONG_DOUBLE\n"
2559 " typedef struct {\n"
2560 " unsigned int word1, word2, word3, word4;\n"
2562 "# endif /* _LONG_DOUBLE */\n"
2563 "extern long_double strtold(const char *, char **);\n";
2567 * We cannot use the above rule on 11.31 because it removes the strtold
2568 * definition. ia64 is OK with no hack, PA needs some help.
2571 hackname = hpux_long_double_2;
2572 mach = "hppa*-*-hpux11.3*";
2574 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2575 "defined\\(_PROTOTYPES\\) \\|\\| "
2576 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2578 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2580 test_text = "# if !defined(__ia64) || "
2581 "!defined(_PROTOTYPES) || "
2582 "defined(_LONG_DOUBLE_STRUCT)\n";
2586 * Add missing braces to pthread initializer defines.
2589 hackname = hpux_pthread_initializers;
2590 mach = "*-hp-hpux11.[0-3]*";
2591 files = sys/pthread.h;
2592 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2593 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2594 sed = "s@^[ \t]*1,[ \t]*\\\\"
2596 sed = "/^[ \t]*0$/d";
2597 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2598 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2599 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2600 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2601 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2602 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2603 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2604 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2605 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2606 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2607 sed = "s@__PTHREAD_COND_VALID, 0"
2608 "@{ __PTHREAD_COND_VALID, 0 }@";
2609 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2610 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2611 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2612 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2613 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2614 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2615 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2616 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2617 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2618 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2619 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2620 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2621 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2622 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2623 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2628 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2629 * type and mpinfou is only defined when _KERNEL is set.
2632 hackname = hpux_spu_info;
2633 mach = "*-hp-hpux*";
2635 * It is tempting to omit the first "files" entry. Do not.
2636 * The testing machinery will take the first "files" entry as the name
2637 * of a test file to play with. It would be a nuisance to have a directory
2638 * with the name "*".
2640 files = "ia64/sys/getppdp.h";
2641 files = "*/sys/getppdp.h";
2642 select = "^.*extern.*spu_info.*";
2645 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2647 test_text = "extern union mpinfou spu_info[];";
2651 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2654 hackname = hpux_stdint_least_fast;
2655 mach = "*-hp-hpux11.2*";
2656 files = stdint-hpux11.h, stdint.h;
2658 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2660 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2661 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2662 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2666 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2669 hackname = hpux_longjmp;
2670 mach = "*-hp-hpux*";
2672 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2675 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2677 test_text = 'extern void longjmp __((jmp_buf, int));';
2681 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2684 hackname = hpux_systime;
2686 select = "^extern struct sigevent;";
2689 c_fix_arg = "struct sigevent;";
2691 test_text = 'extern struct sigevent;';
2695 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2698 hackname = huge_val_hex;
2699 files = bits/huge_val.h, '*/bits/huge_val.h';
2700 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2701 bypass = "__builtin_huge_val";
2704 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2706 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2710 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2713 hackname = huge_valf_hex;
2714 files = bits/huge_val.h, '*/bits/huge_val.h';
2715 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2716 bypass = "__builtin_huge_valf";
2719 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2721 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2725 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2728 hackname = huge_vall_hex;
2729 files = bits/huge_val.h, '*/bits/huge_val.h';
2730 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2731 bypass = "__builtin_huge_vall";
2734 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2736 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2740 * Fix return type of abort and free
2743 hackname = int_abort_free_and_exit;
2745 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2746 bypass = "_CLASSIC_ANSI_TYPES";
2749 c_fix_arg = "void\t%1(";
2751 test_text = "extern int abort(int);\n"
2752 "extern int free(void*);\n"
2753 "extern int exit(void*);";
2757 * Fix various macros used to define ioctl numbers.
2758 * The traditional syntax was:
2760 * #define _IO(n, x) (('n'<<8)+x)
2761 * #define TIOCFOO _IO(T, 1)
2763 * but this does not work with the C standard, which disallows macro
2764 * expansion inside strings. We have to rewrite it thus:
2766 * #define _IO(n, x) ((n<<8)+x)
2767 * #define TIOCFOO _IO('T', 1)
2769 * The select expressions match too much, but the c_fix code is cautious.
2771 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2774 hackname = io_quotes_def;
2775 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2776 c_fix = char_macro_def;
2779 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2780 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2781 "#define _IO(x,y) ('x'<<8|y)";
2783 "#define XX_IO(x) ('x'<<8|256)";
2787 * Fix the usage of the ioctl macro numbers.
2790 hackname = io_quotes_use;
2791 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2793 c_fix = char_macro_use;
2795 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2796 "#define TIOCFOO \\\\\n"
2797 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2801 * Check for missing ';' in struct
2804 hackname = ip_missing_semi;
2805 files = netinet/ip.h;
2807 sed = "/^struct/,/^};/s/}$/};/";
2813 "}; /* mumbled struct */\n";
2817 * Non-traditional "const" declaration in Irix's limits.h.
2820 hackname = irix_limits_const;
2821 files = fixinc-test-limits.h, limits.h;
2822 select = "^extern const ";
2824 c_fix_arg = "extern __const ";
2825 test_text = "extern const char limit; /* test limits */";
2829 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2830 * taking char *. However, GCC uses void * for va_list, so
2831 * calling vfprintf with a va_list fails in C++. */
2833 hackname = irix_stdio_va_list;
2836 select = '/\* va_list \*/ char \*';
2838 c_fix_arg = "__gnuc_va_list";
2840 "extern int printf( const char *, /* va_list */ char * );";
2844 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2845 * use / * * / to concatenate tokens.
2848 hackname = kandr_concat;
2849 files = "sparc/asm_linkage.h";
2850 files = "sun*/asm_linkage.h";
2851 files = "arm/as_support.h";
2852 files = "arm/mc_type.h";
2853 files = "arm/xcb.h";
2854 files = "dev/chardefmac.h";
2855 files = "dev/ps_irq.h";
2856 files = "dev/screen.h";
2857 files = "dev/scsi.h";
2858 files = "sys/tty.h";
2859 files = "Xm.acorn/XmP.h";
2860 files = bsd43/bsd43_.h;
2864 test_text = "#define __CONCAT__(a,b) a/**/b";
2868 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2869 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2870 * constant on recent versions of g++.
2873 hackname = linux_ia64_ucontext;
2874 files = "sys/ucontext.h";
2875 mach = "ia64-*-linux*";
2876 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2877 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2879 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2880 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2881 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2885 * Remove header file warning from sys/time.h. Autoconf's
2886 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2887 * which causes warning on LynxOS. Remove the warning.
2890 hackname = lynxos_no_warning_in_sys_time_h;
2892 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2895 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2899 * Add missing declaration for putenv.
2902 hackname = lynxos_missing_putenv;
2903 mach = '*-*-lynxos*';
2905 bypass = 'putenv[ \t]*\\(';
2906 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2909 "extern int putenv _AP((char *));";
2910 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2911 test_text = "extern char *getenv _AP((const char *));";
2915 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2917 * On NetBSD, machine is a symbolic link to an architecture specific
2918 * directory name, so we can't match a specific file name here.
2921 hackname = machine_ansi_h_va_list;
2922 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2923 bypass = '__builtin_va_list';
2926 c_fix_arg = "%1__builtin_va_list";
2927 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2929 test_text = " # define _BSD_VA_LIST_\tchar**";
2933 * Fix non-ansi machine name defines
2936 hackname = machine_name;
2937 c_test = machine_name;
2938 c_fix = machine_name;
2940 test_text = "/* MACH_DIFF: */\n"
2941 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2942 "\n/* no uniform test, so be careful :-) */";
2946 * Some math.h files define struct exception (it's in the System V
2947 * Interface Definition), which conflicts with the class exception defined
2948 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2949 * This is not a great fix, but I haven't been able to think of anything
2953 hackname = math_exception;
2955 select = "struct exception";
2957 * This should be bypassed on __cplusplus, but some supposedly C++
2958 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2959 * exception either. So currently we bypass only for glibc, based on a
2960 * comment in the fixed glibc header. Ick.
2962 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2963 '_[a-z0-9A-Z_]+_exception; for C, exception';
2964 /* The Solaris 10 headers already get this right. */
2965 mach = '*-*-solaris2.1[0-9]*';
2969 c_fix_arg = "#ifdef __cplusplus\n"
2970 "#define exception __math_exception\n"
2973 c_fix_arg = "#ifdef __cplusplus\n"
2974 "#undef exception\n"
2977 test_text = "typedef struct exception t_math_exception;";
2981 * This looks pretty broken to me. ``dbl_max_def'' will contain
2982 * "define DBL_MAX " at the start, when what we really want is just
2983 * the value portion. Can't figure out how to write a test case
2984 * for this either :-(
2987 hackname = math_huge_val_from_dbl_max;
2991 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2992 * in math.h, this fix applies.
2994 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2995 bypass = "define[ \t]+DBL_MAX";
2999 * See if we have a definition for DBL_MAX in float.h.
3000 * If we do, we will replace the one in math.h with that one.
3003 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3004 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3006 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3007 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3008 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3013 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3014 "#define HUGE_VAL DBL_MAX";
3021 hackname = nested_auth_des;
3023 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3025 c_fix_arg = "%1*/ /*";
3026 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3030 * Some versions of NetBSD don't expect the C99 inline semantics.
3033 hackname = netbsd_c99_inline_1;
3034 mach = "*-*-netbsd*";
3036 select = "extern __inline int";
3039 c_fix_arg = "extern\n"
3040 "#ifdef __GNUC_STDC_INLINE__\n"
3041 "__attribute__((__gnu_inline__))\n"
3045 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3049 * netbsd_c99_inline_2
3052 hackname = netbsd_c99_inline_2;
3053 mach = "*-*-netbsd*";
3055 select = "#define _SIGINLINE extern __inline";
3058 c_fix_arg = <<- _EOArg_
3059 #ifdef __GNUC_STDC_INLINE__
3060 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3066 test_text = "#define _SIGINLINE extern __inline";
3070 * NetBSD has a semicolon after the ending '}' for some extern "C".
3073 hackname = netbsd_extra_semicolon;
3074 mach = "*-*-netbsd*";
3075 files = sys/cdefs.h;
3076 select = "#define[ \t]*__END_DECLS[ \t]*};";
3079 c_fix_arg = "#define __END_DECLS }";
3081 test_text = "#define __END_DECLS };";
3085 * newlib's stdint.h has several failures to conform to C99. The fix
3086 * for these removed a comment that can be matched to identify unfixed
3090 hackname = newlib_stdint_1;
3091 files = stdint-newlib.h, stdint.h;
3092 select = "@todo - Add support for wint_t types";
3093 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3094 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3095 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3096 sed = "s@#define INT_LEAST32_MIN.*@"
3097 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3098 sed = "s@#define INT_LEAST32_MAX.*@"
3099 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3100 sed = "s@#define UINT_LEAST32_MAX.*@"
3101 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3102 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3103 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3104 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3105 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3106 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3107 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3108 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3109 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3110 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3111 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3112 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3113 test_text = "/* @todo - Add support for wint_t types. */\n"
3114 "#define INT32_MIN (-2147483647-1)\n"
3115 "#define INT32_MAX 2147483647\n"
3116 "#define UINT32_MAX 4294967295U\n"
3117 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3118 "#define INT_LEAST32_MAX 2147483647\n"
3119 "#define UINT_LEAST32_MAX 4294967295U\n"
3120 "#define INT_FAST8_MIN INT8_MIN\n"
3121 "#define INT_FAST8_MAX INT8_MAX\n"
3122 "#define UINT_FAST8_MAX UINT8_MAX\n"
3123 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3124 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3125 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3126 "#define UINT8_C(x) x##U\n"
3127 "#define UINT16_C(x) x##U";
3134 hackname = newlib_stdint_2;
3135 files = stdint-newlib.h, stdint.h;
3136 select = "@todo - Add support for wint_t types";
3138 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3139 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3140 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3141 "#define WCHAR_MAX __WCHAR_MAX__\n"
3142 "#define WCHAR_MIN __WCHAR_MIN__\n"
3143 "#define WINT_MAX __WINT_MAX__\n"
3144 "#define WINT_MIN __WINT_MIN__\n\n"
3146 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3147 test_text = "/* @todo - Add support for wint_t types. */\n"
3148 "/** Macros for minimum-width integer constant expressions */";
3152 * NeXT 3.2 adds const prefix to some math functions.
3153 * These conflict with the built-in functions.
3156 hackname = next_math_prefix;
3157 files = ansi/math.h;
3158 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3161 c_fix_arg = "extern double %1(";
3162 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3164 test_text = "extern\tdouble\t__const__\tmumble();";
3168 * NeXT 3.2 uses the word "template" as a parameter for some
3169 * functions. GCC reports an invalid use of a reserved key word
3170 * with the built-in functions.
3173 hackname = next_template;
3175 select = "[ \t]template\\)";
3179 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3180 test_text = "extern mumble( char * template); /* fix */";
3184 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3185 * function prototypes. That conflicts with the built-in functions.
3188 hackname = next_volitile;
3189 files = ansi/stdlib.h;
3190 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3193 c_fix_arg = "extern void %1(";
3194 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3196 test_text = "extern\tvolatile\tvoid\tabort();";
3200 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3201 * Note that version 3 of the NeXT system has wait.h in a different directory,
3202 * so that this code won't do anything. But wait.h in version 3 has a
3203 * conditional, so it doesn't need this fix. So everything is okay.
3206 hackname = next_wait_union;
3209 select = 'wait\(union wait';
3211 c_fix_arg = "wait(void";
3212 test_text = "extern pid_d wait(union wait*);";
3216 * a missing semi-colon at the end of the nodeent structure definition.
3219 hackname = nodeent_syntax;
3220 files = netdnet/dnetdb.h;
3221 select = "char[ \t]*\\*na_addr[ \t]*$";
3224 test_text = "char *na_addr\t";
3228 * Fix OpenBSD's NULL definition.
3231 hackname = openbsd_null_definition;
3232 mach = "*-*-openbsd*";
3233 files = locale.h, stddef.h, stdio.h, string.h,
3234 time.h, unistd.h, wchar.h, sys/param.h;
3235 select = "__GNUG__";
3237 c_fix_arg = "#ifndef NULL\n"
3238 "#ifdef __cplusplus\n"
3240 "#define NULL\t__null\n"
3241 "#else\t /* ! __GNUG__ */\n"
3242 "#define NULL\t0L\n"
3243 "#endif\t /* __GNUG__ */\n"
3244 "#else\t /* ! __cplusplus */\n"
3245 "#define NULL\t((void *)0)\n"
3246 "#endif\t /* __cplusplus */\n"
3247 "#endif\t /* !NULL */";
3249 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3250 "^#ifdef[ \t]*__GNUG__\n"
3251 "^#define[ \t]*NULL[ \t]*__null\n"
3253 "^#define[ \t]*NULL[ \t]*0L\n"
3259 "#define NULL __null\n"
3267 * obstack.h used casts as lvalues.
3269 * We need to change postincrements of casted pointers (which are
3270 * then dereferenced and assigned into) of the form
3272 * *((TYPE*)PTRVAR)++ = (VALUE)
3274 * into expressions like
3276 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3278 * which is correct for the cases used in obstack.h since PTRVAR is
3279 * of type char * and the value of the expression is not used.
3282 hackname = obstack_lvalue_cast;
3284 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3286 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3287 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3291 * Fix OpenBSD's va_start define.
3294 hackname = openbsd_va_start;
3295 mach = "*-*-openbsd*";
3297 select = '__builtin_stdarg_start';
3299 c_fix_arg = __builtin_va_start;
3301 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3305 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3306 * defining regex.h related types. This causes libg++ build and usage
3307 * failures. Fixing this correctly requires checking and modifying 3 files.
3310 hackname = osf_namespace_a;
3311 files = reg_types.h;
3312 files = sys/lc_core.h;
3313 test = " -r reg_types.h";
3314 test = " -r sys/lc_core.h";
3315 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3316 test = " -z \"`grep __regex_t regex.h`\"";
3320 c_fix_arg = "reg(ex|off|match)_t";
3322 test_text = "`touch sys/lc_core.h`"
3323 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3324 "extern regex_t re;\n"
3325 "extern regoff_t ro;\n"
3326 "extern regmatch_t rm;\n";
3330 hackname = osf_namespace_c;
3332 test = " -r reg_types.h";
3333 test = " -r sys/lc_core.h";
3334 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3335 test = " -z \"`grep __regex_t regex.h`\"";
3337 select = "#include <reg_types\.h>.*";
3340 "typedef __regex_t\tregex_t;\n"
3341 "typedef __regoff_t\tregoff_t;\n"
3342 "typedef __regmatch_t\tregmatch_t;";
3344 test_text = "#include <reg_types.h>";
3348 * On broken glibc-2.3.3 systems an array of incomplete structures is
3349 * passed to __sigsetjmp. Fix that to take a pointer instead.
3352 hackname = pthread_incomplete_struct_argument;
3354 select = "struct __jmp_buf_tag";
3356 c_fix_arg = "%1 *%2%3";
3357 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3358 "(__env)\\[1\\](.*)$";
3359 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3364 * Fix return type of fread and fwrite on sysV68
3367 hackname = read_ret_type;
3369 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3371 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3372 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3374 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3378 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3381 hackname = rpc_xdr_lvalue_cast_a;
3383 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3385 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3386 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3387 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3391 * rpc_xdr_lvalue_cast_b
3394 hackname = rpc_xdr_lvalue_cast_b;
3396 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3398 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3399 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3400 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3404 * function class(double x) conflicts with C++ keyword on rs/6000
3407 hackname = rs6000_double;
3409 select = '[^a-zA-Z_]class\(';
3412 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3413 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3415 test_text = "extern int class();";
3419 * Wrong fchmod prototype on RS/6000.
3422 hackname = rs6000_fchmod;
3424 select = 'fchmod\(char \*';
3426 c_fix_arg = "fchmod(int";
3427 test_text = "extern int fchmod(char *, mode_t);";
3431 * parameters conflict with C++ new on rs/6000
3434 hackname = rs6000_param;
3438 select = 'rename\(const char \*old, const char \*new\)';
3440 c_fix_arg = 'rename(const char *_old, const char *_new)';
3442 test_text = 'extern int rename(const char *old, const char *new);';
3446 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3447 * for C99. This is wrong for C++, which needs many C99 features, but
3448 * only supports __restrict.
3451 hackname = solaris___restrict;
3452 files = sys/feature_tests.h;
3453 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3454 mach = "*-*-solaris2*";
3456 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3457 "#else\n%0\n#endif";
3458 test_text = "#define _RESTRICT_KYWD restrict";
3462 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3463 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3464 * and imaginary definitions which are not supported by GCC.
3467 hackname = solaris_complex;
3468 mach = "*-*-solaris2.*";
3470 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3471 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3472 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3473 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3474 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3475 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3476 test_text = "#define _Complex_I _Complex_I\n"
3477 "#define complex _Complex\n"
3478 "#define _Imaginary_I _Imaginary_I\n"
3479 "#define imaginary _Imaginary\n"
3481 "#define I _Imaginary_I";
3485 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3486 * extern "C" instead so libstdc++ can use it.
3489 hackname = solaris_complex_cxx;
3490 mach = "*-*-solaris2.*";
3492 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3493 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3494 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3495 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3496 test_text = "#if !defined(__cplusplus)\n"
3497 "#endif /* !defined(__cplusplus) */";
3501 * g++ rejects functions declared with both C and C++ linkage.
3504 hackname = solaris_cxx_linkage;
3505 mach = '*-*-solaris2*';
3506 files = "iso/stdlib_iso.h";
3507 select = "(#if __cplusplus >= 199711L)\n"
3508 "(extern \"C\\+\\+\" \\{\n)"
3509 "(.*(bsearch|qsort).*)";
3511 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3514 "#if __cplusplus >= 199711L\n"
3515 "extern \"C++\" {\n"
3516 " void *bsearch(const void *, const void *, size_t, size_t,";
3520 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3521 * _STRICT_STDC, but uses it.
3524 hackname = solaris_getc_strict_stdc;
3525 mach = "*-*-solaris2*";
3526 files = "iso/stdio_iso.h";
3527 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3529 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3532 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3536 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3539 hackname = solaris_gets_c11;
3540 mach = "*-*-solaris2*";
3541 files = "iso/stdio_iso.h";
3542 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3545 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3546 "%1 __attribute__((__deprecated__));\n"
3549 test_text = "extern char *gets(char *);";
3553 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3556 hackname = solaris_gets_cxx14;
3557 mach = "*-*-solaris2*";
3558 files = "iso/stdio_iso.h";
3559 select = <<- _EOSelect_
3560 (#if __STDC_VERSION__ < 201112L)
3561 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3564 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3566 test_text = <<- _EOText_
3567 #if __STDC_VERSION__ < 201112L
3568 extern char *gets(char *) __ATTR_DEPRECATED;
3573 * Sun Solaris 2 has a version of sys/int_const.h that defines
3574 * UINT8_C and UINT16_C to unsigned constants.
3577 hackname = solaris_int_const;
3578 files = sys/int_const.h;
3579 mach = '*-*-solaris2*';
3581 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3583 "#define\tUINT16_C(c)\t(c)";
3584 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3586 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3588 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3590 "#define UINT16_C(c) __CONCAT__(c,u)";
3594 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3595 * UINT8_MAX and UINT16_MAX to unsigned constants.
3598 hackname = solaris_int_limits_1;
3599 files = sys/int_limits.h;
3600 mach = '*-*-solaris2*';
3602 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3603 "#define\tUINT16_MAX\t(65535)";
3604 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3605 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3607 "#define UINT8_MAX (255U)\n"
3608 "#define UINT16_MAX (65535U)";
3612 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3613 * INT_FAST16 limits to wrong values for sys/int_types.h.
3616 hackname = solaris_int_limits_2;
3617 files = sys/int_limits.h;
3618 mach = '*-*-solaris2*';
3620 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3621 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3623 "#define INT_FAST16_MAX INT16_MAX\n"
3624 "#define UINT_FAST16_MAX UINT16_MAX\n"
3625 "#define INT_FAST16_MIN INT16_MIN";
3629 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3630 * SIZE_MAX as unsigned long.
3633 hackname = solaris_int_limits_3;
3634 files = sys/int_limits.h;
3635 mach = '*-*-solaris2*';
3637 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3638 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3640 "#define SIZE_MAX 4294967295UL";
3644 * Sun Solaris 10 defines several C99 math macros in terms of
3645 * builtins specific to the Studio compiler, in particular not
3646 * compatible with the GNU compiler.
3649 hackname = solaris_math_1;
3650 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3651 bypass = "__GNUC__";
3652 files = iso/math_c99.h;
3654 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3655 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3657 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3659 "#define HUGE_VAL __builtin_huge_val\n"
3660 "#undef HUGE_VALF\n"
3661 "#define HUGE_VALF __builtin_huge_valf\n"
3662 "#undef HUGE_VALL\n"
3663 "#define HUGE_VALL __builtin_huge_vall";
3667 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3668 * exception. Provide an alternative using GCC's builtin.
3671 hackname = solaris_math_10;
3672 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3673 files = iso/math_c99.h;
3675 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3676 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3677 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3679 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3680 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3681 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3682 "\\(-INFINITY\\);[ \t]*\\}\\)";
3684 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3686 "#define isinf(x) __extension__( \\\\\n"
3687 " { __typeof(x) __x_i = (x); \\\\\n"
3688 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3689 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3693 * Solaris math INFINITY
3696 hackname = solaris_math_2;
3697 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3698 bypass = "__GNUC__";
3699 files = iso/math_c99.h;
3701 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3702 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3704 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3706 "#define INFINITY __builtin_infinity";
3713 hackname = solaris_math_3;
3714 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3715 bypass = "__GNUC__";
3716 files = iso/math_c99.h;
3718 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3719 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3721 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3723 "#define NAN __builtin_nan";
3727 * Solaris math fpclassify
3730 hackname = solaris_math_4;
3731 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3732 bypass = "__GNUC__";
3733 files = iso/math_c99.h;
3735 c_fix_arg = "#define\tfpclassify(x) \\\n"
3736 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3737 "FP_SUBNORMAL, FP_ZERO, (x))";
3738 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3740 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3741 "#undef fpclassify\n"
3742 "#define fpclassify(x) __builtin_fpclassify(x)";
3746 * Solaris math signbit
3749 hackname = solaris_math_8;
3750 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3751 bypass = "__GNUC__";
3752 files = iso/math_c99.h;
3754 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3755 "\t\t\t ? __builtin_signbitf(x) \\\n"
3756 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3757 "\t\t\t ? __builtin_signbitl(x) \\\n"
3758 "\t\t\t : __builtin_signbit(x))";
3759 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3760 test_text = <<- _EOText_
3761 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3763 #define signbit(x) __builtin_signbit(x)
3768 * Solaris math comparison macros
3771 hackname = solaris_math_9;
3772 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3773 bypass = "__GNUC__";
3774 files = iso/math_c99.h;
3776 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3777 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3778 "__builtin_[a-z]+\\(y\\)\\)";
3780 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3781 "#undef isgreater\n"
3782 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3783 "#undef isgreaterequal\n"
3784 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3786 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3787 "#undef islessequal\n"
3788 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3789 "#undef islessgreater\n"
3790 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3791 "#undef isunordered\n"
3792 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3796 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3800 hackname = solaris_math_11;
3801 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3802 files = iso/math_c99.h;
3804 c_fix_arg = << _EOArg_
3806 #define signbit(x) (sizeof(x) == sizeof(float) \
3807 ? __builtin_signbitf(x) \
3808 : sizeof(x) == sizeof(long double) \
3809 ? __builtin_signbitl(x) \
3810 : __builtin_signbit(x))
3812 c_fix_arg = << _EOArg_
3814 #if defined\(__sparc\)
3815 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3816 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3817 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3818 #elif defined\(__i386\) \|\| defined\(__amd64\)
3819 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3820 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3821 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3822 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3823 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3824 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3825 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3828 test_text = << _EOText_
3829 /* @(#)math_c99.h 1.14 13/03/27 */
3831 #if defined(__sparc)
3832 #define signbit(x) __extension__( \\
3833 { __typeof(x) __x_s = (x); \\
3834 (int) (*(unsigned *) &__x_s >> 31); })
3835 #elif defined(__i386) || defined(__amd64)
3836 #define signbit(x) __extension__( \\
3837 { __typeof(x) __x_s = (x); \\
3838 (sizeof (__x_s) == sizeof (float) ? \\
3839 (int) (*(unsigned *) &__x_s >> 31) : \\
3840 sizeof (__x_s) == sizeof (double) ? \\
3841 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3842 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3848 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3851 hackname = solaris_math_12;
3853 mach = '*-*-solaris2*';
3854 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3855 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3856 test_text = << _EOText_
3857 #if __cplusplus >= 201103L
3858 #undef _GLIBCXX_USE_C99_MATH
3859 #undef _GLIBCXX_USE_C99_MATH_TR1
3865 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3866 * structure. As such, it need two levels of brackets, but only
3867 * contains one. Wrap the macro definition in an extra layer.
3870 hackname = solaris_once_init_1;
3871 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3873 mach = '*-*-solaris*';
3875 c_fix_arg = "%1{%2}%3";
3876 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3878 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3879 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3883 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3884 * posix_spawn declarations, which doesn't work with C++.
3887 hackname = solaris_posix_spawn_restrict;
3889 mach = '*-*-solaris2*';
3891 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3892 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3894 "char *const argv[_RESTRICT_KYWD],\n"
3895 "char *const envp[_RESTRICT_KYWD]);";
3899 * The pow overloads with int were removed in C++ 2011 DR 550.
3902 hackname = solaris_pow_int_overload;
3903 mach = '*-*-solaris2*';
3904 files = "iso/math_iso.h";
3905 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3906 " *\\{[^{}]*\n[^{}]*\\}";
3908 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3911 " inline long double pow(long double __X, int __Y) { return\n"
3912 " __powl(__X, (long double) (__Y)); }";
3916 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3917 * fields of the pthread_rwlock_t structure, which are of type
3918 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3919 * defined (e.g. by -ansi) it is a union. So change the initializer
3923 hackname = solaris_rwlock_init_1;
3924 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3926 mach = '*-*-solaris*';
3928 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3931 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3933 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3934 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3937 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3938 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3942 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3943 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3946 hackname = solaris_std___filbuf;
3948 mach = '*-*-solaris2*';
3949 bypass = "using std::__filbuf";
3950 select = "(using std::perror;\n)(#endif)";
3952 c_fix_arg = "%1#ifndef _LP64\n"
3953 "using std::__filbuf;\n"
3954 "using std::__flsbuf;\n"
3957 test_text = "using std::perror;\n"
3962 * Solaris <stdio.h> shouldn't use std::gets for C++14.
3965 hackname = solaris_std_gets_cxx14;
3966 mach = "*-*-solaris2*";
3968 select = "using std::gets;";
3971 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
3973 test_text = "using std::gets;";
3977 * Sun Solaris 8 has what appears to be some gross workaround for
3978 * some old version of their c++ compiler. G++ doesn't want it
3979 * either, but doesn't want to be tied to SunPRO version numbers.
3982 hackname = solaris_stdio_tag;
3983 files = stdio_tag.h;
3985 select = '__cplusplus < 54321L';
3986 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3987 "!defined(__GNUC__)" so we no longer need to fix it. */
3988 bypass = '__GNUC__';
3989 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3991 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3995 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
3998 hackname = solaris_stdlib_noreturn;
3999 mach = "*-*-solaris2*";
4000 files = "iso/stdlib_c99.h";
4001 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4004 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4006 test_text = "extern _Noreturn void quick_exit(int);";
4010 * a missing semi-colon at the end of the statsswtch structure definition.
4013 hackname = statsswtch;
4014 files = rpcsvc/rstat.h;
4015 select = "boottime$";
4017 c_fix_arg = "boottime;";
4018 test_text = "struct statswtch {\n int boottime\n};";
4022 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4023 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4027 hackname = stdio_stdarg_h;
4029 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4031 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4032 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4034 mach = '*-*-solaris2.1[0-9]*';
4039 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4045 * Don't use or define the name va_list in stdio.h. This is for
4046 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4047 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4048 * indicate that the header knows what it's doing -- under SUSv2,
4049 * stdio.h is required to define va_list, and we shouldn't break
4053 hackname = stdio_va_list;
4055 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4057 * On Solaris 10, the definition in
4058 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4059 * there is therefore no need for this fix there.
4061 mach = '*-*-solaris2.1[0-9]*';
4065 * Use __gnuc_va_list in arg types in place of va_list.
4066 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4067 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4068 * trailing parentheses and semicolon save all other systems from this.
4069 * Define __not_va_list__ (something harmless and unused)
4070 * instead of va_list.
4071 * Don't claim to have defined va_list.
4073 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4074 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4075 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4076 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4077 "s@ va_list@ __not_va_list__@\n"
4078 "s@\\*va_list@*__not_va_list__@\n"
4079 "s@ __va_list)@ __gnuc_va_list)@\n"
4080 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4081 "@typedef \\1 __not_va_list__;@\n"
4082 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4083 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4084 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4085 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4086 "s@VA_LIST@DUMMY_VA_LIST@\n"
4087 "s@_Va_LIST@_VA_LIST@";
4088 test_text = "extern void mumble( va_list);";
4092 * Fix headers that use va_list from stdio.h to use the updated
4093 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4094 * dealt with elsewhere. The presence of __gnuc_va_list,
4095 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4096 * knows what it's doing.
4099 hackname = stdio_va_list_clients;
4107 files = curses_colr/curses.h;
4108 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4109 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4110 otherwise protected. */
4111 bypass = 'include <stdarg\.h>|#ifdef va_start';
4114 * Use __gnuc_va_list in arg types in place of va_list.
4115 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4116 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4117 * trailing parentheses and semicolon save all other systems from this.
4118 * Define __not_va_list__ (something harmless and unused)
4119 * instead of va_list.
4120 * Don't claim to have defined va_list.
4122 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4123 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4124 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4125 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4126 "s@ va_list@ __not_va_list__@\n"
4127 "s@\\*va_list@*__not_va_list__@\n"
4128 "s@ __va_list)@ __gnuc_va_list)@\n"
4129 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4130 "@typedef \\1 __not_va_list__;@\n"
4131 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4132 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4133 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4134 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4135 "s@VA_LIST@DUMMY_VA_LIST@\n"
4136 "s@_Va_LIST@_VA_LIST@";
4137 test_text = "extern void mumble( va_list);";
4141 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4142 * is "!defined( __STRICT_ANSI__ )"
4145 hackname = strict_ansi_not;
4146 select = "^([ \t]*#[ \t]*if.*)"
4148 "|__STDC__[ \t]*==[ \t]*0"
4149 "|__STDC__[ \t]*!=[ \t]*1"
4150 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4151 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4152 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4153 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4154 is not defined by GCC, so it is safe. */
4155 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4156 c_test = stdc_0_in_system_headers;
4159 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4161 test_text = "#if !__STDC__ \n"
4162 "#if __STDC__ == 0\n"
4163 "#if __STDC__ != 1\n"
4164 "#if __STDC__ - 0 == 0"
4165 "/* not std C */\nint foo;\n"
4166 "\n#end-end-end-end-if :-)";
4171 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4174 hackname = strict_ansi_not_ctd;
4175 files = math.h, limits.h, stdio.h, signal.h,
4176 stdlib.h, sys/signal.h, time.h;
4178 * Starting at the beginning of a line, skip white space and
4179 * a leading "(" or "&&" or "||". One of those must be found.
4180 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4181 * expression. If these are nested, then they must accumulate
4182 * because we won't match any closing parentheses. Finally,
4183 * after skipping over all that, we must then match our suspect
4184 * phrase: "__STDC__-0==0" with or without white space.
4186 select = "^([ \t]*" '(\(|&&|\|\|)'
4187 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4189 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4190 c_test = stdc_0_in_system_headers;
4193 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4195 test_text = "#if 1 && \\\\\n"
4196 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4197 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4198 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4203 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4204 * is "defined( __STRICT_ANSI__ )"
4207 hackname = strict_ansi_only;
4208 select = "^([ \t]*#[ \t]*if.*)"
4209 "(__STDC__[ \t]*!=[ \t]*0"
4210 "|__STDC__[ \t]*==[ \t]*1"
4211 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4212 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4213 c_test = stdc_0_in_system_headers;
4216 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4218 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4222 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4223 * in prototype without previous definition.
4226 hackname = struct_file;
4228 select = '^.*xdrstdio_create.*struct __file_s';
4230 c_fix_arg = "struct __file_s;\n%0";
4231 test_text = "extern void xdrstdio_create( struct __file_s* );";
4235 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4236 * in prototype without previous definition.
4238 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4239 * function, and does define it.
4242 hackname = struct_sockaddr;
4244 select = "^.*authdes_create.*struct sockaddr[^_]";
4245 bypass = "<sys/socket\.h>";
4246 bypass = "struct sockaddr;\n";
4248 c_fix_arg = "struct sockaddr;\n%0";
4249 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4253 * Apply fix this to all OSs since this problem seems to effect
4254 * more than just SunOS.
4257 hackname = sun_auth_proto;
4262 bypass = "__cplusplus";
4264 * Select those files containing '(*name)()'.
4266 select = '\(\*[a-z][a-z_]*\)\(\)';
4269 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4270 "#else\n%1();%2\n#endif";
4271 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4275 " int (*name)(); /* C++ bad */\n"
4280 * Fix bogus #ifdef on SunOS 4.1.
4283 hackname = sun_bogus_ifdef;
4284 files = "hsfs/hsfs_spec.h";
4285 files = "hsfs/iso_spec.h";
4286 select = '#ifdef(.*\|\|.*)';
4288 c_fix_arg = "#if%1";
4290 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4294 * Fix the CAT macro in SunOS memvar.h.
4297 hackname = sun_catmacro;
4298 files = pixrect/memvar.h;
4299 select = "^#define[ \t]+CAT\\(a,b\\).*";
4304 "# define CAT(a,b) a##b\n"
4305 "#else\n%0\n#endif";
4308 "#define CAT(a,b)\ta/**/b";
4312 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4313 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4316 hackname = sun_malloc;
4318 bypass = "_CLASSIC_ANSI_TYPES";
4320 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4321 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4322 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4323 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4324 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4327 "typedef char *\tmalloc_t;\n"
4329 "char*\tmalloc();\n"
4330 "char*\tcalloc();\n"
4331 "char*\trealloc();";
4335 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4338 hackname = sun_rusers_semi;
4339 files = rpcsvc/rusers.h;
4341 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4342 test_text = "struct mumble\n int _cnt\n};";
4346 * signal.h on SunOS defines signal using (),
4347 * which causes trouble when compiling with g++ -pedantic.
4350 hackname = sun_signal;
4351 files = sys/signal.h;
4353 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4357 "#ifdef __cplusplus\n"
4358 "void\t(*signal(...))(...);\n"
4359 "#else\n%0\n#endif";
4361 test_text = "void\t(*signal())();";
4365 * Correct the return type for strlen in strings.h in SunOS 4.
4368 hackname = sunos_strlen;
4370 select = "int[ \t]*strlen\\(\\);(.*)";
4372 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4373 test_text = " int\tstrlen(); /* string length */";
4377 * Linux kernel's vt.h breaks C++
4380 hackname = suse_linux_vt_cxx;
4383 select = "^[ \t]*unsigned int new;";
4385 c_fix_arg = "unsigned int newev;";
4387 test_text = " unsigned int new; /* New console (if changing) */";
4391 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4392 * that is visible to any ANSI compiler using this include. Simply
4393 * delete the lines that #define some string functions to internal forms.
4396 hackname = svr4_disable_opt;
4398 select = '#define.*__std_hdr_';
4399 sed = '/#define.*__std_hdr_/d';
4400 test_text = "#define strlen __std_hdr_strlen\n";
4404 * Fix broken decl of getcwd present on some svr4 systems.
4407 hackname = svr4_getcwd;
4410 files = prototypes.h;
4411 select = 'getcwd\(char \*, int\)';
4414 c_fix_arg = "getcwd(char *, size_t)";
4416 test_text = "extern char* getcwd(char *, int);";
4420 * Fix broken decl of profil present on some svr4 systems.
4423 hackname = svr4_profil;
4428 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4430 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4433 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4437 * Correct types for signal handler constants like SIG_DFL; they might be
4438 * void (*) (), and should be void (*) (int). C++ doesn't like the
4442 hackname = svr4_sighandler_type;
4443 files = sys/signal.h;
4444 select = 'void *\(\*\)\(\)';
4446 c_fix_arg = "void (*)(int)";
4447 test_text = "#define SIG_DFL (void(*)())0\n"
4448 "#define SIG_IGN (void (*)())0\n";
4452 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4453 * function 'getrnge' in <regexp.h> before they declare it. For these
4454 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4457 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4458 * so put the declaration right after the declaration of 'size'.
4460 * Don't do this if there is already a `static void getrnge' declaration
4461 * present, since this would cause a redeclaration error. Solaris 2.x has
4462 * such a declaration.
4465 hackname = svr4_undeclared_getrnge;
4468 bypass = "static void getrnge";
4471 "static int getrnge ();";
4472 c_fix_arg = "^static int[ \t]+size;";
4473 test_text = "static int size;\n"
4474 "/* stuff which calls getrnge() */\n"
4475 "static getrnge()\n"
4480 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4481 * in string.h on sysV68
4482 * Correct the return type for strlen in string.h on Lynx.
4483 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4484 * Add missing const for strdup on OSF/1 V3.0.
4485 * On sysV88 layout is slightly different.
4488 hackname = sysv68_string;
4491 bypass = "_CLASSIC_ANSI_TYPES";
4493 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4494 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4495 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4497 sed = "/^extern char$/N";
4498 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4500 sed = "/^extern int$/N";
4501 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4503 sed = "/^\tstrncmp(),$/N";
4504 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4505 '\1;' "\\\nextern unsigned int\\\n\\2/";
4508 "extern int strlen();\n"
4510 "extern int ffs(long);\n"
4523 "\tstrlen(), strspn();";
4527 * Fix return type of calloc, malloc, realloc, bsearch and exit
4530 hackname = sysz_stdlib_for_sun;
4532 bypass = "_CLASSIC_ANSI_TYPES";
4534 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4536 c_fix_arg = "void *\t%1(";
4539 "extern char*\tcalloc(size_t);\n"
4540 "extern char*\tmalloc(size_t);\n"
4541 "extern char*\trealloc(void*,size_t);\n"
4542 "extern char*\tbsearch(void*,size_t,size_t);\n";
4546 * __thread is now a keyword.
4549 hackname = thread_keyword;
4550 files = "pthread.h";
4551 files = bits/sigthread.h, '*/bits/sigthread.h';
4552 select = "([* ])__thread([,)])";
4554 c_fix_arg = "%1__thr%2";
4557 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4558 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4559 "extern int pthread_cancel (pthread_t __thread);";
4563 * if the #if says _cplusplus, not the double underscore __cplusplus
4567 hackname = tinfo_cplusplus;
4569 select = "[ \t]_cplusplus";
4572 c_fix_arg = " __cplusplus";
4573 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4577 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4580 hackname = ultrix_const;
4582 select = 'perror\( char \*';
4585 c_fix_arg = "%1 const %3 *__";
4586 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4587 "[ \t]+(char|void) \\*__";
4590 "extern void perror( char *__s );\n"
4591 "extern int fputs( char *__s, FILE *);\n"
4592 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4593 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4594 "extern int scanf( char *__format, ...);\n";
4598 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4601 hackname = ultrix_const2;
4604 select = '\*fopen\( char \*';
4606 c_fix_arg = "%1( const char *%3, const char *";
4607 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4608 "[ \t]*char[ \t]*\\*([^,]*),"
4609 "[ \t]*char[ \t]*\\*[ \t]*";
4612 "extern FILE *fopen( char *__filename, char *__type );\n"
4613 "extern int sscanf( char *__s, char *__format, ...);\n"
4614 "extern FILE *popen(char *, char *);\n"
4615 "extern char *tempnam(char*,char*);\n";
4619 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4622 hackname = va_i960_macro;
4623 files = arch/i960/archI960.h;
4624 select = "__(vsiz|vali|vpad|alignof__)";
4627 c_fix_arg = "__vx%1";
4630 "extern int __vsiz vsiz;\n"
4631 "extern int __vali vali;\n"
4632 "extern int __vpad vpad;\n"
4633 "#define __alignof__(x) ...";
4637 * On VMS, add missing braces around sigset_t constants.
4640 hackname = vms_add_missing_braces;
4641 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4643 files = "rtldef/signal.h";
4646 c_fix_arg = '%1 {%2} ';
4648 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4649 "{0x00000000, 0x00000000},\n"
4650 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4654 * On VMS, some DEC-C builtins are directly used.
4657 hackname = vms_decc_builtin;
4658 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4660 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4662 sed = "s@__MEMSET@memset@";
4663 sed = "s@__MEMMOVE@memmove@";
4664 sed = "s@__MEMCPY@memcpy@";
4665 sed = "s@__STRLEN@strlen@";
4666 sed = "s@__STRCPY@strcpy@";
4668 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4672 * Define __CAN_USE_EXTERN_PREFIX on vms.
4675 hackname = vms_define_can_use_extern_prefix;
4676 files = "rtldef/decc$types.h";
4677 select = "#[ \t]*else\n"
4678 "#[ \t]*if defined\\(__DECCXX\\)\n"
4679 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4684 "# elif defined (__GNUC__)\n"
4685 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4687 test_text = "# else\n"
4688 "# if defined(__DECCXX)\n"
4689 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4695 * On VMS, disable the use of dec-c string builtins
4698 hackname = vms_disable_decc_string_builtins;
4699 select = "#if !defined\\(__VAX\\)\n";
4701 files = "rtldef/string.h";
4704 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4706 test_text = "#if !defined(__VAX)\n";
4710 * On VMS, fix incompatible redeclaration of hostalias.
4713 hackname = vms_do_not_redeclare_hostalias;
4714 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4715 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4717 files = "rtldef/resolv.h";
4723 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4724 "__char_ptr32 hostalias (const char *);\n";
4728 * On VMS, forward declare structure before referencing them in prototypes.
4731 hackname = vms_forward_declare_struct;
4732 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4733 "#ifdef __cplusplus\n";
4735 files = rtldef/if.h;
4739 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4741 test_text = "/* forward decls for C++ */\n"
4742 "#ifdef __cplusplus\n"
4748 * On VMS, do not declare getopt and al if pointers are 64 bit.
4751 hackname = vms_no_64bit_getopt;
4752 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4753 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4755 files = rtldef/stdio.h, rtldef/unistd.h;
4758 c_fix_arg = <<- _EOArg_
4759 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4764 test_text = "int getopt (int, char * const [], const char *);";
4768 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4769 * which is not yet fully supported by gcc.
4772 hackname = vms_use_fast_setjmp;
4773 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4775 files = rtldef/setjmp.h;
4778 c_fix_arg = "%0 defined (__GNUC__) ||";
4780 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4784 * On VMS, use pragma extern_model instead of VAX-C keywords.
4787 hackname = vms_use_pragma_extern_model;
4788 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4789 "# pragma extern_model __save\n";
4793 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4794 "# pragma extern_model __save\n";
4796 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4797 "# pragma extern_model __save\n"
4798 "# pragma extern_model strict_refdef\n"
4799 " extern struct x zz$yy;\n"
4800 "# pragma extern_model __restore\n"
4805 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4806 * conflict while building gcc. Likewise for <builtins.h>
4809 hackname = vms_use_quoted_include;
4810 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4812 files = rtldef/wait.h, starlet_c/pthread.h;
4815 c_fix_arg = '%1<sys/%2.h>';
4817 test_text = "# include <resource.h>";
4821 * AIX and Interix headers define NULL to be cast to a void pointer,
4822 * which is illegal in ANSI C++.
4825 hackname = void_null;
4826 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4827 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4828 /* avoid changing C++ friendly NULL */
4829 bypass = __cplusplus;
4831 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4833 c_fix_arg = <<- _EOFix_
4838 #else /* ! __GNUG__ */
4840 #endif /* __GNUG__ */
4841 #else /* ! __cplusplus */
4842 #define NULL ((void *)0)
4843 #endif /* __cplusplus */
4846 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4850 * Make VxWorks header which is almost gcc ready fully gcc ready.
4853 hackname = vxworks_gcc_problem;
4854 files = types/vxTypesBase.h;
4855 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4857 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4860 sed = "/[ \t]size_t/i\\\n"
4861 "#ifndef _GCC_SIZE_T\\\n"
4862 "#define _GCC_SIZE_T\n";
4864 sed = "/[ \t]size_t/a\\\n"
4867 sed = "/[ \t]ptrdiff_t/i\\\n"
4868 "#ifndef _GCC_PTRDIFF_T\\\n"
4869 "#define _GCC_PTRDIFF_T\n";
4871 sed = "/[ \t]ptrdiff_t/a\\\n"
4874 sed = "/[ \t]wchar_t/i\\\n"
4875 "#ifndef _GCC_WCHAR_T\\\n"
4876 "#define _GCC_WCHAR_T\n";
4878 sed = "/[ \t]wchar_t/a\\\n"
4882 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4883 "typedef unsigned int size_t;\n"
4884 "typedef long ptrdiff_t;\n"
4885 "typedef unsigned short wchar_t;\n"
4886 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4890 * Wrap VxWorks ioctl to keep everything pretty
4893 hackname = vxworks_ioctl_macro;
4895 mach = "*-*-vxworks*";
4899 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4900 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4902 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4906 * Wrap VxWorks mkdir to be posix compliant
4909 hackname = vxworks_mkdir_macro;
4911 mach = "*-*-vxworks*";
4915 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4916 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4917 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4918 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4921 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4925 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4928 hackname = vxworks_needs_vxtypes;
4930 select = "uint_t([ \t]+_clocks_per_sec)";
4932 c_fix_arg = "unsigned int%1";
4933 test_text = "uint_t\t_clocks_per_sec;";
4937 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4940 hackname = vxworks_needs_vxworks;
4942 test = " -r types/vxTypesOld.h";
4943 test = " -n \"`egrep '#include' $file`\"";
4944 test = " -n \"`egrep ULONG $file`\"";
4945 select = "#[ \t]define[ \t]+__INCstath";
4947 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4948 "#include <types/vxTypesOld.h>\n";
4950 test_text = "`touch types/vxTypesOld.h`"
4951 "#include </dev/null> /* ULONG */\n"
4952 "# define\t__INCstath <sys/stat.h>";
4956 * Make it so VxWorks does not include gcc/regs.h accidentally
4959 hackname = vxworks_regs;
4960 mach = "*-*-vxworks*";
4962 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4964 c_fix_arg = "#include <arch/../regs.h>";
4966 test_text = "#include <regs.h>\n";
4970 * Another bad dependency in VxWorks 5.2 <time.h>.
4973 hackname = vxworks_time;
4975 test = " -r vxWorks.h";
4977 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4981 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4982 "#ifdef __cplusplus\n"
4983 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4985 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4987 "#define __gcc_VOIDFUNCPTR_defined\n"
4989 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4991 test_text = "`touch vxWorks.h`"
4992 "#define VOIDFUNCPTR (void(*)())";
4996 * This hack makes write const-correct on VxWorks
4999 hackname = vxworks_write_const;
5001 mach = "*-*-vxworks*";
5004 c_fix_arg = "extern int write (int, const char*, size_t);";
5005 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5007 "[\t ]*char[\t ]*\\*[\t ]*,"
5008 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5010 test_text = "extern int write ( int , char * , size_t ) ;";
5014 * There are several name conflicts with C++ reserved words in X11 header
5015 * files. These are fixed in some versions, so don't do the fixes if
5016 * we find __cplusplus in the file. These were found on the RS/6000.
5019 hackname = x11_class;
5020 files = X11/ShellP.h;
5021 bypass = __cplusplus;
5022 select = "^([ \t]*char \\*)class;(.*)";
5024 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5025 "#else\n%1class;%2\n#endif";
5033 * class in Xm/BaseClassI.h
5036 hackname = x11_class_usage;
5037 files = Xm/BaseClassI.h;
5038 bypass = "__cplusplus";
5040 select = " class\\)";
5042 c_fix_arg = " c_class)";
5044 test_text = "extern mumble (int class);\n";
5048 * new in Xm/Traversal.h
5052 files = Xm/Traversal.h;
5053 bypass = __cplusplus;
5055 sed = "/Widget\told, new;/i\\\n"
5056 "#ifdef __cplusplus\\\n"
5057 "\\\tWidget\told, c_new;\\\n"
5060 sed = "/Widget\told, new;/a\\\n"
5063 sed = "s/Widget new,/Widget c_new,/g";
5066 " Widget\told, new;\n"
5067 "};\nextern Wedged( Widget new, Widget old );";
5071 * Incorrect sprintf declaration in X11/Xmu.h
5074 hackname = x11_sprintf;
5076 files = X11/Xmu/Xmu.h;
5077 select = "^extern char \\*\tsprintf\\(\\);$";
5080 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5082 test_text = "extern char *\tsprintf();";