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[ ]*=[ ]*(.*);'
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");
68 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
69 * open64 and creat to creat64. This fixes fcntl.h to
70 * undef those defines and use __asm__ to alias the symbols if
71 * building with g++ and -D_LARGE_FILES
74 hackname = AAB_aix_fcntl;
76 select = "define open[ \t]open64";
78 test-text = ''; /* no way to test */
84 c_fix_arg = <<- _EOArg_
86 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
87 #define __need__aix_fcntl_h_fix
88 #ifdef __need__aix_fcntl_h_fix
92 /* Alias the symbols using asm */
94 extern int open(const char *, int, ...) __asm__("open64");
95 extern int creat(const char *, mode_t) __asm__("creat64");
96 #if (_XOPEN_SOURCE >= 700)
97 extern int openat(int, const char *, int, ...) __asm__("open64at");
108 * On Mac OS 10.3.9, the 'long double' functions are available in
109 * libSystem, but are not prototyped in math.h.
112 hackname = AAB_darwin7_9_long_double_funcs;
113 mach = "*-*-darwin7.9*";
114 files = architecture/ppc/math.h;
116 replace = <<- _EndOfHeader_
117 /* This file prototypes the long double functions available on Mac OS
121 # define __APPLE_CC__ 1345
122 # include_next <architecture/ppc/math.h>
124 # define __APPLE_CC__ 1
125 # ifndef __LIBMLDBL_COMPAT
126 # ifdef __LONG_DOUBLE_128__
127 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
129 # define __LIBMLDBL_COMPAT(sym)
130 # endif /* __LONG_DOUBLE_128__ */
131 # endif /* __LIBMLDBL_COMPAT */
135 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
136 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
137 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
138 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
139 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
140 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
141 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
142 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
143 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
144 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
145 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
146 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
147 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
148 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
149 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
150 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
151 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
152 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
153 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
154 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
155 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
156 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
157 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
158 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
159 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
160 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
161 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
162 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
163 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
164 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
165 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
166 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
167 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
168 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
169 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
170 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
171 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
172 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
173 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
174 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
175 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
176 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
177 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
178 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
179 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
180 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
181 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
182 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
183 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
184 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
185 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
186 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
187 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
188 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
189 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
190 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
191 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
195 #endif /* __MATH__ */
201 * ... and for the previous fix to be useful, you have to not use ""
205 hackname = AAB_darwin7_9_long_double_funcs_2;
206 mach = "*-*-darwin7.9*";
208 select = '#include[ \t]+\"';
210 c_fix_arg = "%1<%2.h>";
212 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
214 test_text = '#include "architecture/ppc/math.h"';
219 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
222 hackname = AAB_fd_zero_asm_posix_types_h;
223 files = asm/posix_types.h;
224 mach = 'i[34567]86-*-linux*';
227 bypass = 'posix_types_64';
230 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
231 * the start, so that if #include_next gets another instance of
232 * the wrapper, this will follow the #include_next chain until
233 * we arrive at the real <asm/posix_types.h>.
235 replace = <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro
237 for older versions of the Linux kernel. */
238 #ifndef _POSIX_TYPES_H_WRAPPER
239 #include <features.h>
240 #include_next <asm/posix_types.h>
242 #if defined(__FD_ZERO) && !defined(__GLIBC__)
244 #define __FD_ZERO(fdsetp) \
247 __asm__ __volatile__("cld ; rep ; stosl" \
248 : "=&c" (__d0), "=&D" (__d1) \
249 : "a" (0), "0" (__FDSET_LONGS), \
250 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
254 #define _POSIX_TYPES_H_WRAPPER
255 #endif /* _POSIX_TYPES_H_WRAPPER */
261 * This fixes __FD_ZERO bug for glibc-1.x
264 hackname = AAB_fd_zero_gnu_types_h;
266 mach = 'i[34567]86-*-linux*';
269 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
270 * the start, so that if #include_next gets another instance of
271 * the wrapper, this will follow the #include_next chain until
272 * we arrive at the real <gnu/types.h>.
274 replace = <<- _EndOfHeader_
275 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
276 #ifndef _TYPES_H_WRAPPER
277 #include <features.h>
278 #include_next <gnu/types.h>
280 #if defined(__FD_ZERO) && !defined(__GLIBC__)
282 # define __FD_ZERO(fdsetp) \
285 __asm__ __volatile__("cld ; rep ; stosl" \
286 : "=&c" (__d0), "=&D" (__d1) \
287 : "a" (0), "0" (__FDSET_LONGS), \
288 "1" ((__fd_set *) (fdsetp)) :"memory"); \
292 #define _TYPES_H_WRAPPER
293 #endif /* _TYPES_H_WRAPPER */
299 * This fixes __FD_ZERO bug for glibc-2.0.x
302 hackname = AAB_fd_zero_selectbits_h;
303 files = selectbits.h;
304 mach = 'i[34567]86-*-linux*';
307 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
308 * the start, so that if #include_next gets another instance of
309 * the wrapper, this will follow the #include_next chain until
310 * we arrive at the real <selectbits.h>.
312 replace = <<- _EndOfHeader_
313 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
314 #ifndef _SELECTBITS_H_WRAPPER
315 #include <features.h>
316 #include_next <selectbits.h>
318 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
319 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
320 && __GLIBC_MINOR__ == 0
322 #define __FD_ZERO(fdsetp) \\
325 __asm__ __volatile__ ("cld; rep; stosl" \\
326 : "=&c" (__d0), "=&D" (__d1) \\
327 : "a" (0), "0" (sizeof (__fd_set) \\
328 / sizeof (__fd_mask)), \\
329 "1" ((__fd_mask *) (fdsetp)) \\
334 #define _SELECTBITS_H_WRAPPER
335 #endif /* _SELECTBITS_H_WRAPPER */
341 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
342 * the same interface as <stdarg.h>. No idea why they couldn't have just
343 * used the standard header.
346 hackname = AAB_solaris_sys_varargs_h;
347 files = "sys/varargs.h";
348 mach = '*-*-solaris*';
349 replace = <<- _EndOfHeader_
360 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
361 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
362 * many other systems have similar text but correct versions of the file.
363 * To ensure only Sun's is fixed, we grep for a likely unique string.
364 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
367 hackname = AAB_sun_memcpy;
369 select = "/\\*\t@\\(#\\)"
370 "(head/memory.h\t50.1\t "
371 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
373 replace = <<- _EndOfHeader_
374 /* This file was generated by fixincludes */
379 extern void *memccpy();
380 extern void *memchr();
381 extern void *memcpy();
382 extern void *memset();
384 extern char *memccpy();
385 extern char *memchr();
386 extern char *memcpy();
387 extern char *memset();
388 #endif /* __STDC__ */
392 #endif /* __memory_h__ */
397 * Fix assert.h on VxWorks:
400 hackname = AAB_vxworks_assert;
402 mach = "*-*-vxworks*";
404 replace = <<- _EndOfHeader_
412 #if defined(__STDC__) || defined(__cplusplus)
413 extern void __assert (const char*);
415 extern void __assert ();
419 #define assert(ign) ((void)0)
422 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
423 #define ASSERT_STRINGIFY_HELPER(str) #str
425 #define assert(test) ((void) \
426 ((test) ? ((void)0) : \
427 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
428 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
437 * Add needed include to regs.h (NOT the gcc header) on VxWorks
441 hackname = AAB_vxworks_regs_vxtypes;
443 mach = "*-*-vxworks*";
445 replace = <<- _EndOfHeader_
448 #include <types/vxTypesOld.h>
449 #include_next <arch/../regs.h>
455 * Make VxWorks stdint.h a bit more compliant - add typedefs
458 hackname = AAB_vxworks_stdint;
460 mach = "*-*-vxworks*";
462 replace = <<- _EndOfHeader_
465 /* get int*_t, uint*_t */
466 #include <types/vxTypes.h>
468 /* get legacy vxworks types for compatibility */
469 #include <types/vxTypesOld.h>
471 typedef long intptr_t;
472 typedef unsigned long uintptr_t;
474 typedef int64_t intmax_t;
475 typedef uint64_t uintmax_t;
477 typedef int8_t int_least8_t;
478 typedef int16_t int_least16_t;
479 typedef int32_t int_least32_t;
480 typedef int64_t int_least64_t;
482 typedef uint8_t uint_least8_t;
483 typedef uint16_t uint_least16_t;
484 typedef uint32_t uint_least32_t;
485 typedef uint64_t uint_least64_t;
487 typedef int8_t int_fast8_t;
488 typedef int int_fast16_t;
489 typedef int32_t int_fast32_t;
490 typedef int64_t int_fast64_t;
492 typedef uint8_t uint_fast8_t;
493 typedef unsigned int uint_fast16_t;
494 typedef uint32_t uint_fast32_t;
495 typedef uint64_t uint_fast64_t;
498 #define UINT8_MAX (~(uint8_t)0)
500 #define UINT16_MAX (~(uint16_t)0)
502 #define UINT32_MAX (~(uint32_t)0)
504 #define UINT64_MAX (~(uint64_t)0)
507 #define UINTPTR_MAX (~(uintptr_t)0)
508 #define UINTPTR_MIN 0
510 /* Need to do int_fast16_t as well, as type
511 size may be architecture dependent */
512 #define UINT_FAST16_MAX (~(uint_fast16_t)0)
513 #define UINT_FAST16_MAX 0
515 #define INT8_MAX (UINT8_MAX>>1)
516 #define INT8_MIN (INT8_MAX+1)
517 #define INT16_MAX (UINT16_MAX>>1)
518 #define INT16_MIN (INT16_MAX+1)
519 #define INT32_MAX (UINT32_MAX>>1)
520 #define INT32_MIN (INT32_MAX+1)
521 #define INT64_MAX (UINT64_MAX>>1)
522 #define INT64_MIN (INT64_MAX+1)
524 #define INTPTR_MAX (UINTPTR_MAX>>1)
525 #define INTPTR_MIN (INTPTR_MAX+1)
527 #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
528 #define INT_FAST16_MIN (INT_FAST16_MAX+1)
530 /* now define equiv. constants */
531 #define UINT_FAST8_MAX UINT8_MAX
532 #define UINT_FAST8_MIN UINT_FAST8_MIN
533 #define INT_FAST8_MAX INT8_MAX
534 #define INT_FAST8_MIN INT8_MIN
535 #define UINT_FAST32_MAX UINT32_MAX
536 #define UINT_FAST32_MIN UINT32_MIN
537 #define INT_FAST32_MAX INT32_MAX
538 #define INT_FAST32_MIN INT32_MIN
539 #define UINT_FAST64_MAX UINT64_MAX
540 #define UINT_FAST64_MIN UINT64_MIN
541 #define INT_FAST64_MAX INT64_MAX
542 #define INT_FAST64_MIN INT64_MIN
544 #define UINT_LEAST8_MAX UINT8_MAX
545 #define UINT_LEAST8_MIN UINT8_MIN
546 #define INT_LEAST8_MAX INT8_MAX
547 #define INT_LEAST8_MIN INT8_MIN
548 #define UINT_LEAST16_MAX UINT16_MAX
549 #define UINT_LEAST16_MIN UINT16_MIN
550 #define INT_LEAST16_MAX INT16_MAX
551 #define INT_LEAST16_MIN INT16_MIN
552 #define UINT_LEAST32_MAX UINT32_MAX
553 #define UINT_LEAST32_MIN UINT32_MIN
554 #define INT_LEAST32_MAX INT32_MAX
555 #define INT_LEAST32_MIN INT32_MIN
556 #define UINT_LEAST64_MAX UINT64_MAX
557 #define UINT_LEAST64_MIN UINT64_MIN
558 #define INT_LEAST64_MAX INT64_MAX
559 #define INT_LEAST64_MIN INT64_MIN
561 #define UINTMAX_MAX UINT64_MAX
562 #define UINTMAX_MIN UINT64_MIN
563 #define INTMAX_MAX INT64_MAX
564 #define INTMAX_MIN INT64_MIN
571 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
574 hackname = AAB_vxworks_unistd;
576 mach = "*-*-vxworks*";
578 replace = <<- _EndOfHeader_
581 #include_next <unistd.h>
584 #define STDIN_FILENO 0
586 #ifndef STDOUT_FILENO
587 #define STDOUT_FILENO 1
589 #ifndef STDERR_FILENO
590 #define STDERR_FILENO 2
592 #endif /* _UNISTD_H */
598 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
599 * which only is provided by AIX xlc C99.
602 hackname = aix_complex;
605 select = "#define[ \t]_Complex_I[ \t]__I";
607 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
608 test_text = "#define _Complex_I __I\n";
612 * malloc.h on AIX6 uses XLC++ specific builtin syntax
615 hackname = aix_malloc;
618 select = "#ifdef __cplusplus";
620 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
621 test_text = "#ifdef __cplusplus";
625 * net/if_arp.h defines a variable fc_softc instead of adding a
626 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
629 hackname = aix_net_if_arp;
631 files = "net/if_arp.h";
632 select = "^struct fc_softc \\{";
634 c_fix_arg = "typedef struct _fc_softc {";
635 test_text = "struct fc_softc {\n int a;\n};";
639 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
640 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
644 hackname = aix_once_init_1;
647 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
650 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
652 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
657 hackname = aix_once_init_2;
660 select = "[ \t]0 \\\\\n"
663 c_fix_arg = " 0 \\\n"
665 test_text = " 0 \\\\\n"
670 hackname = aix_mutex_initializer_1;
673 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
676 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
678 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
683 hackname = aix_cond_initializer_1;
686 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
689 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
691 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
696 hackname = aix_rwlock_initializer_1;
699 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
702 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
704 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
709 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
710 * which violates a requirement of ISO C.
713 hackname = aix_pthread;
715 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
718 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
719 "{...init stuff...}";
724 * AIX stdint.h fixes.
727 hackname = aix_stdint_1;
729 files = stdint-aix.h, stdint.h;
730 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
731 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
733 c_fix_arg = "#define UINT8_MAX (255)\n"
734 "#define UINT16_MAX (65535)";
735 test_text = "#define UINT8_MAX (255U)\n"
736 "#define UINT16_MAX (65535U)";
741 hackname = aix_stdint_2;
743 files = stdint-aix.h, stdint.h;
744 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
745 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
746 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
748 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
749 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
750 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
752 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
753 "#define INTPTR_MAX 9223372036854775807L\n"
754 "#define UINTPTR_MAX 18446744073709551615UL\n"
756 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
757 "#define INTPTR_MAX 2147483647L\n"
758 "#define UINTPTR_MAX 4294967295UL";
759 test_text = "#define INTPTR_MIN INT64_MIN\n"
760 "#define INTPTR_MAX INT64_MAX\n"
761 "#define UINTPTR_MAX UINT64_MAX\n"
763 "#define INTPTR_MIN INT32_MIN\n"
764 "#define INTPTR_MAX INT32_MAX\n"
765 "#define UINTPTR_MAX UINT32_MAX";
770 hackname = aix_stdint_3;
772 files = stdint-aix.h, stdint.h;
773 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
774 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
776 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
777 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
779 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
780 "#define PTRDIFF_MAX 9223372036854775807L\n"
782 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
783 "#define PTRDIFF_MAX 2147483647L";
784 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
785 "#define PTRDIFF_MAX INT64_MAX\n"
787 "#define PTRDIFF_MIN INT32_MIN\n"
788 "#define PTRDIFF_MAX INT32_MAX";
793 hackname = aix_stdint_4;
795 files = stdint-aix.h, stdint.h;
796 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
798 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
800 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
802 "#define SIZE_MAX 4294967295UL";
803 test_text = "#define SIZE_MAX UINT64_MAX\n"
805 "#define SIZE_MAX UINT32_MAX";
810 hackname = aix_stdint_5;
812 files = stdint-aix.h, stdint.h;
813 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
814 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
816 c_fix_arg = "#define UINT8_C(c) c\n"
817 "#define UINT16_C(c) c";
818 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
819 "#define UINT16_C(c) __CONCAT__(c,U)";
824 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
825 * in an otherwise harmless (and #ifed out) macro definition
828 hackname = aix_sysmachine;
829 files = sys/machine.h;
833 test_text = "#define FOO \\\n"
834 " bar \\ \n baz \\ \n bat";
839 * sys/wait.h on AIX 5.2 defines macros that have both signed and
840 * unsigned types in conditional expressions.
843 hackname = aix_syswait_2;
845 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
847 c_fix_arg = "? (int)%1";
848 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
853 * sys/signal.h on some versions of AIX uses volatile in the typedef of
854 * sig_atomic_t, which causes gcc to generate a warning about duplicate
855 * volatile when a sig_atomic_t variable is declared volatile, as
856 * required by ANSI C.
859 hackname = aix_volatile;
860 files = sys/signal.h;
861 select = "typedef volatile int sig_atomic_t";
863 c_fix_arg = "typedef int sig_atomic_t";
864 test_text = "typedef volatile int sig_atomic_t;";
869 * Fix __assert declaration in assert.h on Alpha OSF/1.
872 hackname = alpha___assert;
874 select = '__assert\(char \*, char \*, int\)';
876 c_fix_arg = "__assert(const char *, const char *, int)";
877 test_text = 'extern void __assert(char *, char *, int);';
882 * Fix assert macro in assert.h on Alpha OSF/1.
883 * The superfluous int cast breaks C++.
886 hackname = alpha_assert;
888 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
890 c_fix_arg = "%1(EX)";
891 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
892 ': __assert(#EX, __FILE__, __LINE__))';
897 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
900 hackname = alpha_getopt;
903 select = 'getopt\(int, char \*\[\], *char \*\)';
905 c_fix_arg = "getopt(int, char *const[], const char *)";
906 test_text = 'extern int getopt(int, char *[], char *);';
911 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
914 hackname = alpha_if_semicolon;
916 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
918 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
919 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
924 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
927 hackname = alpha_parens;
929 select = '#ifndef\(__mips64\)';
931 c_fix_arg = "#ifndef __mips64";
932 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
937 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
941 hackname = alpha_sbrk;
943 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
945 c_fix_arg = "void *sbrk(";
946 test_text = "extern char* sbrk(ptrdiff_t increment);";
951 * For C++, avoid any typedef or macro definition of bool,
952 * and use the built in type instead.
953 * HP/UX 10.20 also has it in curses_colr/curses.h.
956 hackname = avoid_bool_define;
958 files = curses_colr/curses.h;
962 select = "#[ \t]*define[ \t]+bool[ \t]";
963 bypass = "__cplusplus";
966 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
967 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
969 test_text = "# define bool\t char \n";
974 hackname = avoid_bool_type;
976 files = curses_colr/curses.h;
980 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
981 bypass = "__cplusplus";
984 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
986 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
991 * For C++, avoid any typedef definition of wchar_t,
992 * and use the built in type instead.
993 * Don't do this for headers that are smart enough to do the right
994 * thing (recent [n]curses.h and Xlib.h).
995 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
996 * and will be broken by the edit.
1000 hackname = avoid_wchar_t_type;
1002 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1003 bypass = "__cplusplus";
1004 bypass = "_LINUX_NLS_H";
1005 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1008 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1010 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1015 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1018 hackname = bad_struct_term;
1020 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1022 c_fix_arg = "struct term;";
1024 test_text = 'typedef struct term;';
1029 * Fix one other error in this file:
1030 * a mismatched quote not inside a C comment.
1033 hackname = badquote;
1034 files = sundev/vuid_event.h;
1037 c_fix_arg = "does not";
1039 test_text = "/* doesn't have matched single quotes */";
1044 * check for broken assert.h that needs stdio.h
1047 hackname = broken_assert_stdio;
1050 bypass = "include.*stdio\\.h";
1052 c_fix_arg = "#include <stdio.h>\n";
1053 test_text = "extern FILE* stderr;";
1058 * check for broken assert.h that needs stdlib.h
1061 hackname = broken_assert_stdlib;
1063 select = 'exit *\(|abort *\(';
1064 bypass = "include.*stdlib\\.h";
1066 c_fix_arg = "#ifdef __cplusplus\n"
1067 "#include <stdlib.h>\n"
1069 test_text = "extern void exit ( int );";
1074 * Remove `extern double cabs' declarations from math.h.
1075 * This conflicts with C99. Discovered on AIX.
1076 * Darwin hides its broken cabs in architecture-specific subdirs.
1079 hackname = broken_cabs;
1080 files = math.h, "architecture/*/math.h";
1081 select = "^extern[ \t]+double[ \t]+cabs";
1083 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1084 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1086 test_text = "#ifdef __STDC__\n"
1087 "extern double cabs(struct dbl_hypot);\n"
1089 "extern double cabs();\n"
1091 "extern double cabs ( _Complex z );";
1096 * Fixup Darwin's broken check for __builtin_nanf.
1099 hackname = broken_nan;
1101 * It is tempting to omit the first "files" entry. Do not.
1102 * The testing machinery will take the first "files" entry as the name
1103 * of a test file to play with. It would be a nuisance to have a directory
1104 * with the name "*".
1106 files = "architecture/ppc/math.h";
1107 files = "architecture/*/math.h";
1108 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1111 c_fix_arg = "#if 1";
1112 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1117 * Various systems derived from BSD4.4 contain a macro definition
1118 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1119 * Known to be fixed in FreeBSD 5 system headers.
1122 hackname = bsd_stdio_attrs_conflict;
1124 mach = "*-*-*darwin*";
1126 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1128 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1129 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1130 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1131 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1132 test_text = '#define vfscanf __svfscanf';
1136 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
1137 * that it conforms to ISO/IEC 14882:2011. It currently does
1138 * not support the [[noreturn]] procedure attribute.
1139 * When it does, this hack should be removed.
1140 * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
1143 hackname = cdef_cplusplus;
1144 files = sys/cdefs.h;
1145 select = '\[\[noreturn\]\]';
1147 c_fix_arg = '__attribute__((__noreturn__))';
1148 test_text = "#define _Noreturn [[noreturn]]";
1152 * Fix various macros used to define ioctl numbers.
1153 * The traditional syntax was:
1155 * #define _CTRL(n, x) (('n'<<8)+x)
1156 * #define TCTRLCFOO _CTRL(T, 1)
1158 * but this does not work with the C standard, which disallows macro
1159 * expansion inside strings. We have to rewrite it thus:
1161 * #define _CTRL(n, x) ((n<<8)+x)
1162 * #define TCTRLCFOO _CTRL('T', 1)
1164 * The select expressions match too much, but the c_fix code is cautious.
1166 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1169 hackname = ctrl_quotes_def;
1170 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1171 c_fix = char_macro_def;
1175 * This is two tests in order to ensure that the "CTRL(c)" can
1176 * be selected in isolation from the multi-arg format
1178 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1179 test_text = "#define _CTRL(c) ('c'&037)";
1183 hackname = ctrl_quotes_use;
1184 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1185 c_fix = char_macro_use;
1187 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1192 * sys/mman.h on HP/UX is not C++ ready,
1193 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1195 * rpc/types.h on OSF1/2.0 is not C++ ready,
1196 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1198 * The problem is the declaration of malloc.
1201 hackname = cxx_unready;
1203 files = rpc/types.h;
1204 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1205 not within a macro. */
1206 bypass = '"C"|__BEGIN_DECLS';
1209 c_fix_arg = "#ifdef __cplusplus\n"
1212 c_fix_arg = "#ifdef __cplusplus\n"
1215 test_text = "extern void* malloc( size_t );";
1220 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1221 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1224 hackname = darwin_externc;
1225 mach = "*-*-darwin*";
1226 files = mach-o/swap.h;
1227 files = mach/mach_time.h;
1228 files = mach/mach_traps.h;
1229 files = mach/message.h;
1231 files = mach/semaphore.h;
1232 bypass = "extern \"C\"";
1233 bypass = "__BEGIN_DECLS";
1235 c_fix_arg = "#ifdef __cplusplus\n"
1238 c_fix_arg = "#ifdef __cplusplus\n"
1241 test_text = "extern void swap_fat_header();\n";
1246 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1247 * bad __GNUC__ tests.
1251 hackname = darwin_gcc4_breakage;
1252 mach = "*-*-darwin*";
1253 files = AvailabilityMacros.h;
1254 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1256 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1257 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1258 "(__GNUC_MINOR__ >= 1)\n";
1263 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1264 * why would you ever put it in a system header file?
1267 hackname = darwin_private_extern;
1268 mach = "*-*-darwin*";
1269 files = mach-o/dyld.h;
1270 select = "__private_extern__ [a-z_]+ _dyld_";
1272 c_fix_arg = "extern";
1273 c_fix_arg = "__private_extern__";
1274 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1275 "const char *dyld_func_name,\n"
1276 "unsigned long *address);\n";
1281 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1282 * unsigned constants.
1285 hackname = darwin_stdint_1;
1286 mach = "*-*-darwin*";
1287 files = stdint-darwin.h, stdint.h;
1289 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1290 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1291 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1292 test_text = "#define UINT8_C(v) (v ## U)\n"
1293 "#define UINT16_C(v) (v ## U)";
1298 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1302 hackname = darwin_stdint_2;
1303 mach = "*-*-darwin*";
1304 files = stdint-darwin.h, stdint.h;
1306 c_fix_arg = "#if __WORDSIZE == 64\n"
1307 "#define INTPTR_MAX 9223372036854775807L\n"
1308 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1310 "#define INTPTR_MAX 2147483647L\n"
1311 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1313 select = "#if __WORDSIZE == 64\n"
1314 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1315 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1317 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1318 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1320 test_text = "#if __WORDSIZE == 64\n"
1321 "#define INTPTR_MIN INT64_MIN\n"
1322 "#define INTPTR_MAX INT64_MAX\n"
1324 "#define INTPTR_MIN INT32_MIN\n"
1325 "#define INTPTR_MAX INT32_MAX\n"
1331 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1334 hackname = darwin_stdint_3;
1335 mach = "*-*-darwin*";
1336 files = stdint-darwin.h, stdint.h;
1338 c_fix_arg = "#if __WORDSIZE == 64\n"
1339 "#define UINTPTR_MAX 18446744073709551615UL\n"
1341 "#define UINTPTR_MAX 4294967295UL\n"
1343 select = "#if __WORDSIZE == 64\n"
1344 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1346 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1348 test_text = "#if __WORDSIZE == 64\n"
1349 "#define UINTPTR_MAX UINT64_MAX\n"
1351 "#define UINTPTR_MAX UINT32_MAX\n"
1357 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1360 hackname = darwin_stdint_4;
1361 mach = "*-*-darwin*";
1362 files = stdint-darwin.h, stdint.h;
1364 c_fix_arg = "#if __WORDSIZE == 64\n"
1365 "#define SIZE_MAX 18446744073709551615UL\n"
1367 "#define SIZE_MAX 4294967295UL\n"
1369 select = "#if __WORDSIZE == 64\n"
1370 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1372 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1374 test_text = "#if __WORDSIZE == 64\n"
1375 "#define SIZE_MAX UINT64_MAX\n"
1377 "#define SIZE_MAX UINT32_MAX\n"
1383 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1384 * with a wrong type.
1387 hackname = darwin_stdint_5;
1388 mach = "*-*-darwin*";
1389 files = stdint-darwin.h, stdint.h;
1391 c_fix_arg = "#if __WORDSIZE == 64\n"
1392 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1393 "#define INTMAX_MAX 9223372036854775807L\n"
1394 "#define UINTMAX_MAX 18446744073709551615UL\n"
1396 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1397 "#define INTMAX_MAX 9223372036854775807LL\n"
1398 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1400 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1401 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1403 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1404 test_text = "#define INTMAX_MIN INT64_MIN\n"
1405 "#define INTMAX_MAX INT64_MAX\n"
1407 "#define UINTMAX_MAX UINT64_MAX";
1412 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1413 * with a wrong type.
1416 hackname = darwin_stdint_6;
1417 mach = "*-*-darwin*";
1418 files = stdint-darwin.h, stdint.h;
1420 c_fix_arg = "#if __WORDSIZE == 64\n"
1421 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1422 "#define PTRDIFF_MAX 9223372036854775807L\n"
1424 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1425 "#define PTRDIFF_MAX 2147483647\n"
1427 select = "#if __WORDSIZE == 64\n"
1428 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1429 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1431 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1432 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1434 test_text = "#if __WORDSIZE == 64\n"
1435 "#define PTRDIFF_MIN INT64_MIN\n"
1436 "#define PTRDIFF_MAX INT64_MAX\n"
1438 "#define PTRDIFF_MIN INT32_MIN\n"
1439 "#define PTRDIFF_MAX INT32_MAX\n"
1445 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1446 * with a wrong type.
1449 hackname = darwin_stdint_7;
1450 mach = "*-*-darwin*";
1451 files = stdint-darwin.h, stdint.h;
1453 c_fix_arg = "#if __WORDSIZE == 64\n"
1454 "#define INTMAX_C(v) (v ## L)\n"
1455 "#define UINTMAX_C(v) (v ## UL)\n"
1457 "#define INTMAX_C(v) (v ## LL)\n"
1458 "#define UINTMAX_C(v) (v ## ULL)\n"
1460 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1461 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1462 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1463 "#define UINTMAX_C(v) (v ## ULL)";
1468 * Fix <c_asm.h> on Digital UNIX V4.0:
1469 * It contains a prototype for a DEC C internal asm() function,
1470 * clashing with gcc's asm keyword. So protect this with __DECC.
1473 hackname = dec_intern_asm;
1475 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1476 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1480 " ... asm stuff ...\n"
1481 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1486 * Fix typo in <wchar.h> on DJGPP 2.03.
1489 hackname = djgpp_wchar_h;
1491 select = "__DJ_wint_t";
1492 bypass = "sys/djtypes.h";
1494 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1495 c_fix_arg = "#include <stddef.h>";
1496 test_text = "#include <stddef.h>\n"
1497 "extern __DJ_wint_t x;\n";
1502 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1505 hackname = ecd_cursor;
1506 files = "sunwindow/win_lock.h";
1507 files = "sunwindow/win_cursor.h";
1508 select = 'ecd\.cursor';
1510 c_fix_arg = 'ecd_cursor';
1512 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1517 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1518 * neither the existence of GCC 3 nor its exact feature set yet break
1519 * (by design?) when __GNUC__ is set beyond 2.
1522 hackname = freebsd_gcc3_breakage;
1523 mach = "*-*-freebsd*";
1524 files = sys/cdefs.h;
1525 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1526 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1528 c_fix_arg = '%0 || __GNUC__ >= 3';
1529 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1534 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1535 * neither the existence of GCC 4 nor its exact feature set yet break
1536 * (by design?) when __GNUC__ is set beyond 3.
1539 hackname = freebsd_gcc4_breakage;
1540 mach = "*-*-freebsd*";
1541 files = sys/cdefs.h;
1542 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1544 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1545 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1550 * Some versions of glibc don't expect the C99 inline semantics.
1553 hackname = glibc_c99_inline_1;
1554 files = features.h, '*/features.h';
1555 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1557 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1559 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1560 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1561 # define __USE_EXTERN_INLINES 1
1568 * Similar, but a version that didn't have __NO_INLINE__
1571 hackname = glibc_c99_inline_1a;
1572 files = features.h, '*/features.h';
1573 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1574 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1576 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1578 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1579 # define __USE_EXTERN_INLINES 1
1586 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1587 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1588 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1591 hackname = glibc_c99_inline_2;
1592 files = sys/stat.h, '*/sys/stat.h';
1593 select = "extern __inline__ int";
1594 sed = "s/extern int \\(stat\\)/"
1595 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1596 "__inline__ int \\1/";
1597 sed = "s/extern int \\([lf]stat\\)/"
1598 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1599 "__inline__ int \\1/";
1600 sed = "s/extern int \\(mknod\\)/"
1601 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1602 "__inline__ int \\1/";
1603 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1604 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1605 "__inline__ int __REDIRECT\\1 (\\2/";
1606 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1607 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1608 "__inline__ int __REDIRECT\\1 (\\2/";
1609 sed = "s/^extern __inline__ int/"
1610 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1613 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1614 extern __inline__ int
1615 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1622 hackname = glibc_c99_inline_3;
1623 files = bits/string2.h, '*/bits/string2.h';
1624 select = "extern __inline";
1625 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1627 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1628 c_fix_arg = "^# ifdef __cplusplus$";
1631 # define __STRING_INLINE inline
1633 # define __STRING_INLINE extern __inline
1640 hackname = glibc_c99_inline_4;
1641 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1642 bypass = "__extern_inline|__gnu_inline__";
1643 select = "(^| )extern __inline";
1645 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1647 __extension__ extern __inline unsigned int
1648 extern __inline unsigned int
1653 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1654 * so we replace them with versions that correspond to the
1658 hackname = glibc_mutex_init;
1660 select = '\{ *\{ *0, *\} *\}';
1661 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1662 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1663 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1664 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1665 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1666 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1667 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1668 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1669 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1670 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1671 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1672 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1673 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1674 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1675 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1676 "N;s/^[ \t]*#[ \t]*"
1677 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1678 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1680 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1683 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1685 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1686 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1687 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1688 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1690 test_text = <<- _EOText_
1691 #define PTHREAD_MUTEX_INITIALIZER \\
1694 # if __WORDSIZE == 64
1695 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1696 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1697 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1698 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1699 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1700 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1702 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1703 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1704 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1705 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1706 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1707 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1710 # define PTHREAD_RWLOCK_INITIALIZER \\
1713 # if __WORDSIZE == 64
1714 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1715 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1716 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1718 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1719 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1722 #define PTHREAD_COND_INITIALIZER { { 0, } }
1727 /* glibc versions before 2.5 have a version of stdint.h that defines
1728 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1729 versions with stdint.h based on those glibc versions. */
1731 hackname = glibc_stdint;
1733 select = "GNU C Library";
1735 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1736 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1737 test_text = "/* This file is part of the GNU C Library. */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U";
1741 /* Some versions of glibc have a version of bits/string2.h that
1742 produces "value computed is not used" warnings from strncpy; fix
1743 this definition by using __builtin_strncpy instead as in newer
1746 hackname = glibc_strncpy;
1747 files = bits/string2.h;
1748 bypass = "__builtin_strncpy";
1750 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1751 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1753 # define strncpy(dest, src, n) \
1754 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1755 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1756 ? (char *) memcpy (dest, src, n) \\
1757 : strncpy (dest, src, n)) \\
1758 : strncpy (dest, src, n)))
1763 /* glibc's tgmath.h relies on an expression that is not an integer
1764 constant expression being treated as it was by GCC 4.4 and
1767 hackname = glibc_tgmath;
1769 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1770 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1772 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1773 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1777 * Fix these files to use the types we think they should for
1778 * ptrdiff_t, size_t, and wchar_t.
1780 * This defines the types in terms of macros predefined by our 'cpp'.
1781 * This is supposedly necessary for glibc's handling of these types.
1782 * It's probably not necessary for anyone else, but it doesn't hurt.
1785 hackname = gnu_types;
1786 files = "sys/types.h";
1788 files = "sys/stdtypes.h";
1792 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1793 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1795 /* The Solaris 10 headers already define these types correctly. */
1796 mach = '*-*-solaris2.1[0-9]*';
1799 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1800 "typedef uint_t size_t; /* uint_t */\n"
1801 "typedef ushort_t wchar_t; /* ushort_t */";
1806 * Fix HP & Sony's use of "../machine/xxx.h"
1807 * to refer to: <machine/xxx.h>
1810 hackname = hp_inline;
1811 files = sys/spinlock.h;
1812 files = machine/machparam.h;
1813 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1816 c_fix_arg = "%1<machine/%2.h>";
1818 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1821 test_text = ' # include "../machine/mumble.h"';
1826 * Check for (...) in C++ code in HP/UX sys/file.h.
1829 hackname = hp_sysfile;
1831 select = "HPUX_SOURCE";
1834 c_fix_arg = "(struct file *, ...)";
1835 c_fix_arg = '\(\.\.\.\)';
1837 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1842 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1843 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1846 hackname = hppa_hpux_fp_macros;
1847 mach = "hppa*-hp-hpux11*";
1849 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1850 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1851 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1852 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1853 "#[ \t]*define[ \t]*FP_NAN.*\n";
1855 c_fix_arg = <<- _EOFix_
1856 #endif /* _INCLUDE_HPUX_SOURCE */
1858 #if defined(_INCLUDE_HPUX_SOURCE) || \
1859 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1862 #ifdef _INCLUDE_HPUX_SOURCE
1867 "# define FP_NORMAL 0\n"
1868 "# define FP_ZERO 1\n"
1869 "# define FP_INFINITE 2\n"
1870 "# define FP_SUBNORMAL 3\n"
1871 "# define FP_NAN 4\n";
1876 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1877 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1880 hackname = hpux10_cpp_pow_inline;
1881 files = fixinc-test-limits.h, math.h;
1882 select = <<- END_POW_INLINE
1883 ^# +ifdef +__cplusplus
1885 +inline +double +pow\(double +__d,int +__expon\) +\{
1886 [ ]+return +pow\(__d,\(double\)__expon\);
1897 "# ifdef __cplusplus\n"
1899 " inline double pow(double __d,int __expon) {\n"
1900 "\t return pow(__d,(double)__expon);\n"
1902 ' extern "C"' " {\n"
1908 hackname = hpux11_cpp_pow_inline;
1910 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1911 " +return pow\\(d, \\(double\\)expon\\);\n"
1917 " inline double pow(double d,int expon) {\n"
1918 " return pow(d, (double)expon);\n"
1924 * Fix hpux 10.X missing ctype declarations 1
1927 hackname = hpux10_ctype_declarations1;
1929 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1930 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1932 c_fix_arg = "#ifdef _PROTOTYPES\n"
1933 "extern int __tolower(int);\n"
1934 "extern int __toupper(int);\n"
1935 "#else /* NOT _PROTOTYPES */\n"
1936 "extern int __tolower();\n"
1937 "extern int __toupper();\n"
1938 "#endif /* _PROTOTYPES */\n\n"
1941 test_text = "# define _toupper(__c) __toupper(__c)\n";
1946 * Fix hpux 10.X missing ctype declarations 2
1949 hackname = hpux10_ctype_declarations2;
1951 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1952 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1954 c_fix_arg = "%0\n\n"
1955 "#ifdef _PROTOTYPES\n"
1956 " extern int _isalnum(int);\n"
1957 " extern int _isalpha(int);\n"
1958 " extern int _iscntrl(int);\n"
1959 " extern int _isdigit(int);\n"
1960 " extern int _isgraph(int);\n"
1961 " extern int _islower(int);\n"
1962 " extern int _isprint(int);\n"
1963 " extern int _ispunct(int);\n"
1964 " extern int _isspace(int);\n"
1965 " extern int _isupper(int);\n"
1966 " extern int _isxdigit(int);\n"
1967 "# else /* not _PROTOTYPES */\n"
1968 " extern int _isalnum();\n"
1969 " extern int _isalpha();\n"
1970 " extern int _iscntrl();\n"
1971 " extern int _isdigit();\n"
1972 " extern int _isgraph();\n"
1973 " extern int _islower();\n"
1974 " extern int _isprint();\n"
1975 " extern int _ispunct();\n"
1976 " extern int _isspace();\n"
1977 " extern int _isupper();\n"
1978 " extern int _isxdigit();\n"
1979 "#endif /* _PROTOTYPES */\n";
1981 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1982 " extern unsigned int *__SB_masks;\n";
1987 * Fix hpux 10.X missing stdio declarations
1990 hackname = hpux10_stdio_declarations;
1992 select = "^#[ \t]*define _iob[ \t]*__iob";
1993 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1995 c_fix_arg = "%0\n\n"
1996 "# if defined(__STDC__) || defined(__cplusplus)\n"
1997 " extern int snprintf(char *, size_t, const char *, ...);\n"
1998 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1999 "# else /* not __STDC__) || __cplusplus */\n"
2000 " extern int snprintf();\n"
2001 " extern int vsnprintf();\n"
2002 "# endif /* __STDC__) || __cplusplus */\n";
2004 test_text = "# define _iob __iob\n";
2009 * Make sure hpux defines abs in header.
2012 hackname = hpux11_abs;
2013 mach = "*-hp-hpux11*";
2015 select = "ifndef _MATH_INCLUDED";
2017 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2018 test_text = "#ifndef _MATH_INCLUDED";
2023 * Keep HP-UX 11 from stomping on C++ math namespace
2024 * with defines for fabsf.
2027 hackname = hpux11_fabsf;
2029 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2030 bypass = "__cplusplus";
2033 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2037 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2043 * Fix C99 constant in __POINTER_SET define.
2046 hackname = hpux11_pthread_const;
2047 mach = "*-hp-hpux11.[0-3]*";
2048 files = sys/pthread.h;
2049 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2052 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2053 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2058 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2059 * being defined by having it define _hpux_size_t instead.
2062 hackname = hpux11_size_t;
2063 mach = "*-hp-hpux11*";
2064 select = "__size_t";
2067 c_fix_arg = "_hpux_size_t";
2070 "#define __size_t size_t\n"
2071 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2076 * Fix hpux 11.00 broken snprintf declaration
2077 * (third argument is char *, needs to be const char * to prevent
2078 * spurious warnings with -Wwrite-strings or in C++).
2081 hackname = hpux11_snprintf;
2083 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2084 ' *(char *\*, *\.\.\.\);)';
2086 c_fix_arg = '%1 const %3';
2088 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2089 "extern int snprintf(char *, __size_t, char *, ...);\n"
2090 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2094 * Fix hpux 11.00 broken vsnprintf declaration
2097 hackname = hpux11_vsnprintf;
2099 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2100 'const char \*,) __va__list\);';
2102 c_fix_arg = "%1 __va_list);";
2104 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2110 * get rid of bogus inline definitions in HP-UX 8.0
2113 hackname = hpux8_bogus_inlines;
2116 bypass = "__GNUG__";
2117 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2118 "@extern \"C\" int abs(int);@";
2119 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2120 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2121 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2122 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2123 "inline double sqr(double v) { return v**0.5; }";
2128 * Fix hpux broken ctype macros
2131 hackname = hpux_ctype_macros;
2133 select = '((: |\()__SB_masks \? )'
2134 '(__SB_masks\[__(alnum|c)\] & _IS)';
2136 c_fix_arg = "%1(int)%3";
2138 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2139 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2144 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2147 hackname = hpux_htonl;
2148 files = netinet/in.h;
2149 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2151 " \\* Macros for number representation conversion\\.\n"
2155 c_fix_arg = "#if 1\n%1";
2157 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2159 " * Macros for number representation conversion.\n"
2162 "#define ntohl(x) (x)\n"
2163 "#define ntohs(x) (x)\n"
2164 "#define htonl(x) (x)\n"
2165 "#define htons(x) (x)\n"
2167 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2175 hackname = hpux_long_double;
2176 mach = "*-*-hpux10*";
2177 mach = "*-*-hpux11.[012]*";
2179 select = "extern[ \t]long_double[ \t]strtold";
2180 bypass = "long_double_t";
2181 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2182 sed = "s/long_double/long double/g";
2184 test_text = "# ifndef _LONG_DOUBLE\n"
2185 "# define _LONG_DOUBLE\n"
2186 " typedef struct {\n"
2187 " unsigned int word1, word2, word3, word4;\n"
2189 "# endif /* _LONG_DOUBLE */\n"
2190 "extern long_double strtold(const char *, char **);\n";
2194 * We cannot use the above rule on 11.31 because it removes the strtold
2195 * definition. ia64 is OK with no hack, PA needs some help.
2198 hackname = hpux_long_double_2;
2199 mach = "hppa*-*-hpux11.3*";
2201 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
2203 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2205 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
2209 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2212 hackname = hpux_systime;
2214 select = "^extern struct sigevent;";
2217 c_fix_arg = "struct sigevent;";
2219 test_text = 'extern struct sigevent;';
2224 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2225 * type and mpinfou is only defined when _KERNEL is set.
2228 hackname = hpux_spu_info;
2229 mach = "*-hp-hpux*";
2231 * It is tempting to omit the first "files" entry. Do not.
2232 * The testing machinery will take the first "files" entry as the name
2233 * of a test file to play with. It would be a nuisance to have a directory
2234 * with the name "*".
2236 files = "ia64/sys/getppdp.h";
2237 files = "*/sys/getppdp.h";
2238 select = "^.*extern.*spu_info.*";
2241 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2243 test_text = "extern union mpinfou spu_info[];";
2247 hackname = hpux11_extern_sendfile;
2248 mach = "*-hp-hpux11.[12]*";
2249 files = sys/socket.h;
2250 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2252 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2253 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2257 hackname = hpux11_extern_sendpath;
2258 mach = "*-hp-hpux11.[12]*";
2259 files = sys/socket.h;
2260 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2262 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2263 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2267 hackname = hpux_extern_errno;
2268 mach = "*-hp-hpux10.*";
2269 mach = "*-hp-hpux11.[0-2]*";
2271 select = "^[ \t]*extern int errno;$";
2273 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2274 test_text = " extern int errno;\n";
2279 * Add missing braces to pthread initializer defines.
2282 hackname = hpux_pthread_initializers;
2283 mach = "*-hp-hpux11.[0-3]*";
2284 files = sys/pthread.h;
2285 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2286 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2287 sed = "s@^[ \t]*1,[ \t]*\\\\"
2289 sed = "/^[ \t]*0$/d";
2290 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2291 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2292 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2293 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2294 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2295 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2296 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2297 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2298 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2299 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2300 sed = "s@__PTHREAD_COND_VALID, 0"
2301 "@{ __PTHREAD_COND_VALID, 0 }@";
2302 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2303 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2304 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2305 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2306 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2307 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2308 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2309 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2310 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2311 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2312 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2313 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2314 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2315 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2316 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2321 hackname = hpux_c99_intptr;
2322 mach = "*-hp-hpux11.3*";
2323 files = stdint-hpux11.h, stdint.h;
2324 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2325 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2326 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2327 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2328 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2329 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2330 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2331 "#define PTRDIFF_MIN INT32_MIN\n"
2332 "#define INTPTR_MAX INT32_MAX\n"
2333 "#define INTPTR_MIN INT32_MIN\n"
2334 "#define UINTPTR_MAX UINT32_MAX\n"
2335 "#define SIZE_MAX UINT32_MAX\n";
2339 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2343 hackname = hpux_c99_inttypes;
2344 mach = "*-hp-hpux11.[23]*";
2346 files = stdint-hpux11.h, stdint.h;
2347 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2348 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2349 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2350 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2351 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2352 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2353 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2354 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2358 hackname = hpux_c99_inttypes2;
2359 mach = "*-hp-hpux11.2*";
2360 files = stdint-hpux11.h, stdint.h;
2361 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2362 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2363 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2364 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2365 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2366 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2367 "# define INT16_C(__c) ((short)(__c))\n"
2368 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2372 hackname = hpux_stdint_least_fast;
2373 mach = "*-hp-hpux11.2*";
2374 files = stdint-hpux11.h, stdint.h;
2376 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2378 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2379 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2380 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2385 hackname = hpux_inttype_int8_t;
2386 mach = "*-hp-hpux1[01].*";
2387 files = sys/_inttypes.h;
2388 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2390 c_fix_arg = "typedef signed char int%18_t;";
2391 test_text = "typedef char int_least8_t;\n"
2392 "typedef char int8_t;\n";
2396 hackname = hpux_imaginary_i;
2397 mach = "ia64-hp-hpux11.*";
2399 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2401 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2402 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2406 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2409 hackname = huge_val_hex;
2410 files = bits/huge_val.h;
2411 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2412 bypass = "__builtin_huge_val";
2415 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2417 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2422 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2425 hackname = huge_valf_hex;
2426 files = bits/huge_val.h;
2427 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2428 bypass = "__builtin_huge_valf";
2431 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2433 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2438 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2441 hackname = huge_vall_hex;
2442 files = bits/huge_val.h;
2443 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2444 bypass = "__builtin_huge_vall";
2447 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2449 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2454 * Fix return type of abort and free
2457 hackname = int_abort_free_and_exit;
2459 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2460 bypass = "_CLASSIC_ANSI_TYPES";
2463 c_fix_arg = "void\t%1(";
2465 test_text = "extern int abort(int);\n"
2466 "extern int free(void*);\n"
2467 "extern int exit(void*);";
2472 * Fix various macros used to define ioctl numbers.
2473 * The traditional syntax was:
2475 * #define _IO(n, x) (('n'<<8)+x)
2476 * #define TIOCFOO _IO(T, 1)
2478 * but this does not work with the C standard, which disallows macro
2479 * expansion inside strings. We have to rewrite it thus:
2481 * #define _IO(n, x) ((n<<8)+x)
2482 * #define TIOCFOO _IO('T', 1)
2484 * The select expressions match too much, but the c_fix code is cautious.
2486 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2489 hackname = io_quotes_def;
2490 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2491 c_fix = char_macro_def;
2494 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2495 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2496 "#define _IO(x,y) ('x'<<8|y)";
2498 "#define XX_IO(x) ('x'<<8|256)";
2502 hackname = io_quotes_use;
2503 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2505 c_fix = char_macro_use;
2507 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2508 "#define TIOCFOO \\\\\n"
2509 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2514 * Check for missing ';' in struct
2517 hackname = ip_missing_semi;
2518 files = netinet/ip.h;
2520 sed = "/^struct/,/^};/s/}$/};/";
2526 "}; /* mumbled struct */\n";
2531 * Non-traditional "const" declaration in Irix's limits.h.
2534 hackname = irix_limits_const;
2535 files = fixinc-test-limits.h, limits.h;
2536 select = "^extern const ";
2538 c_fix_arg = "extern __const ";
2539 test_text = "extern const char limit; /* test limits */";
2544 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2545 * taking char *. However, GCC uses void * for va_list, so
2546 * calling vfprintf with a va_list fails in C++. */
2548 hackname = irix_stdio_va_list;
2551 select = '/\* va_list \*/ char \*';
2553 c_fix_arg = "__gnuc_va_list";
2555 "extern int printf( const char *, /* va_list */ char * );";
2560 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2561 * use / * * / to concatenate tokens.
2564 hackname = kandr_concat;
2565 files = "sparc/asm_linkage.h";
2566 files = "sun*/asm_linkage.h";
2567 files = "arm/as_support.h";
2568 files = "arm/mc_type.h";
2569 files = "arm/xcb.h";
2570 files = "dev/chardefmac.h";
2571 files = "dev/ps_irq.h";
2572 files = "dev/screen.h";
2573 files = "dev/scsi.h";
2574 files = "sys/tty.h";
2575 files = "Xm.acorn/XmP.h";
2576 files = bsd43/bsd43_.h;
2580 test_text = "#define __CONCAT__(a,b) a/**/b";
2584 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2585 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2586 * constant on recent versions of g++.
2589 hackname = linux_ia64_ucontext;
2590 files = "sys/ucontext.h";
2591 mach = "ia64-*-linux*";
2592 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2593 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2595 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2596 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2597 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2602 * Remove header file warning from sys/time.h. Autoconf's
2603 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2604 * which causes warning on LynxOS. Remove the warning.
2607 hackname = lynxos_no_warning_in_sys_time_h;
2609 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2612 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2617 * Add missing declaration for putenv.
2620 hackname = lynxos_missing_putenv;
2621 mach = '*-*-lynxos*';
2623 bypass = 'putenv[ \t]*\\(';
2624 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2627 "extern int putenv _AP((char *));";
2628 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2629 test_text = "extern char *getenv _AP((const char *));";
2634 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2636 * On NetBSD, machine is a symbolic link to an architecture specific
2637 * directory name, so we can't match a specific file name here.
2640 hackname = machine_ansi_h_va_list;
2641 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2642 bypass = '__builtin_va_list';
2645 c_fix_arg = "%1__builtin_va_list";
2646 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2648 test_text = " # define _BSD_VA_LIST_\tchar**";
2653 * Fix non-ansi machine name defines
2656 hackname = machine_name;
2657 c_test = machine_name;
2658 c_fix = machine_name;
2660 test_text = "/* MACH_DIFF: */\n"
2661 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2662 "\n/* no uniform test, so be careful :-) */";
2667 * Some math.h files define struct exception (it's in the System V
2668 * Interface Definition), which conflicts with the class exception defined
2669 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2670 * This is not a great fix, but I haven't been able to think of anything
2674 hackname = math_exception;
2676 select = "struct exception";
2678 * This should be bypassed on __cplusplus, but some supposedly C++
2679 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2680 * exception either. So currently we bypass only for glibc, based on a
2681 * comment in the fixed glibc header. Ick.
2683 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2684 '_[a-z0-9A-Z_]+_exception; for C, exception';
2687 c_fix_arg = "#ifdef __cplusplus\n"
2688 "#define exception __math_exception\n"
2691 c_fix_arg = "#ifdef __cplusplus\n"
2692 "#undef exception\n"
2695 test_text = "typedef struct exception t_math_exception;";
2700 * This looks pretty broken to me. ``dbl_max_def'' will contain
2701 * "define DBL_MAX " at the start, when what we really want is just
2702 * the value portion. Can't figure out how to write a test case
2703 * for this either :-(
2706 hackname = math_huge_val_from_dbl_max;
2710 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2711 * in math.h, this fix applies.
2713 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2714 bypass = "define[ \t]+DBL_MAX";
2718 * See if we have a definition for DBL_MAX in float.h.
2719 * If we do, we will replace the one in math.h with that one.
2722 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2723 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2725 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2726 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2727 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2732 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2733 "#define HUGE_VAL DBL_MAX";
2741 hackname = nested_auth_des;
2743 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2745 c_fix_arg = "%1*/ /*";
2746 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2751 * Some versions of NetBSD don't expect the C99 inline semantics.
2754 hackname = netbsd_c99_inline_1;
2755 mach = "*-*-netbsd*";
2757 select = "extern __inline int";
2760 c_fix_arg = "extern\n"
2761 "#ifdef __GNUC_STDC_INLINE__\n"
2762 "__attribute__((__gnu_inline__))\n"
2766 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2771 hackname = netbsd_c99_inline_2;
2772 mach = "*-*-netbsd*";
2774 select = "#define _SIGINLINE extern __inline";
2777 c_fix_arg = <<- _EOArg_
2778 #ifdef __GNUC_STDC_INLINE__
2779 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2785 test_text = "#define _SIGINLINE extern __inline";
2790 * NetBSD has a semicolon after the ending '}' for some extern "C".
2793 hackname = netbsd_extra_semicolon;
2794 mach = "*-*-netbsd*";
2795 files = sys/cdefs.h;
2796 select = "#define[ \t]*__END_DECLS[ \t]*};";
2799 c_fix_arg = "#define __END_DECLS }";
2801 test_text = "#define __END_DECLS };";
2805 /* newlib's stdint.h has several failures to conform to C99. The fix
2806 for these removed a comment that can be matched to identify unfixed
2809 hackname = newlib_stdint_1;
2810 files = stdint-newlib.h, stdint.h;
2811 select = "@todo - Add support for wint_t types";
2812 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2813 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2814 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2815 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2816 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2817 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2818 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2819 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2820 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2821 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2822 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2823 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2824 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2825 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2826 test_text = "/* @todo - Add support for wint_t types. */\n"
2827 "#define INT32_MIN (-2147483647-1)\n"
2828 "#define INT32_MAX 2147483647\n"
2829 "#define UINT32_MAX 4294967295U\n"
2830 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2831 "#define INT_LEAST32_MAX 2147483647\n"
2832 "#define UINT_LEAST32_MAX 4294967295U\n"
2833 "#define INT_FAST8_MIN INT8_MIN\n"
2834 "#define INT_FAST8_MAX INT8_MAX\n"
2835 "#define UINT_FAST8_MAX UINT8_MAX\n"
2836 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2837 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2838 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2839 "#define UINT8_C(x) x##U\n"
2840 "#define UINT16_C(x) x##U";
2845 hackname = newlib_stdint_2;
2846 files = stdint-newlib.h, stdint.h;
2847 select = "@todo - Add support for wint_t types";
2849 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2850 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2851 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2852 "#define WCHAR_MAX __WCHAR_MAX__\n"
2853 "#define WCHAR_MIN __WCHAR_MIN__\n"
2854 "#define WINT_MAX __WINT_MAX__\n"
2855 "#define WINT_MIN __WINT_MIN__\n\n"
2857 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2858 test_text = "/* @todo - Add support for wint_t types. */\n"
2859 "/** Macros for minimum-width integer constant expressions */";
2864 * NeXT 3.2 adds const prefix to some math functions.
2865 * These conflict with the built-in functions.
2868 hackname = next_math_prefix;
2869 files = ansi/math.h;
2870 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2873 c_fix_arg = "extern double %1(";
2874 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2876 test_text = "extern\tdouble\t__const__\tmumble();";
2881 * NeXT 3.2 uses the word "template" as a parameter for some
2882 * functions. GCC reports an invalid use of a reserved key word
2883 * with the built-in functions.
2886 hackname = next_template;
2888 select = "[ \t]template\\)";
2892 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2893 test_text = "extern mumble( char * template); /* fix */";
2898 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2899 * function prototypes. That conflicts with the built-in functions.
2902 hackname = next_volitile;
2903 files = ansi/stdlib.h;
2904 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2907 c_fix_arg = "extern void %1(";
2908 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2910 test_text = "extern\tvolatile\tvoid\tabort();";
2915 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2916 * Note that version 3 of the NeXT system has wait.h in a different directory,
2917 * so that this code won't do anything. But wait.h in version 3 has a
2918 * conditional, so it doesn't need this fix. So everything is okay.
2921 hackname = next_wait_union;
2924 select = 'wait\(union wait';
2926 c_fix_arg = "wait(void";
2927 test_text = "extern pid_d wait(union wait*);";
2932 * a missing semi-colon at the end of the nodeent structure definition.
2935 hackname = nodeent_syntax;
2936 files = netdnet/dnetdb.h;
2937 select = "char[ \t]*\\*na_addr[ \t]*$";
2940 test_text = "char *na_addr\t";
2944 * Fix OpenBSD's NULL definition.
2947 hackname = openbsd_null_definition;
2948 mach = "*-*-openbsd*";
2949 files = locale.h, stddef.h, stdio.h, string.h,
2950 time.h, unistd.h, wchar.h, sys/param.h;
2951 select = "__GNUG__";
2953 c_fix_arg = "#ifndef NULL\n"
2954 "#ifdef __cplusplus\n"
2956 "#define NULL\t__null\n"
2957 "#else\t /* ! __GNUG__ */\n"
2958 "#define NULL\t0L\n"
2959 "#endif\t /* __GNUG__ */\n"
2960 "#else\t /* ! __cplusplus */\n"
2961 "#define NULL\t((void *)0)\n"
2962 "#endif\t /* __cplusplus */\n"
2963 "#endif\t /* !NULL */";
2965 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2966 "^#ifdef[ \t]*__GNUG__\n"
2967 "^#define[ \t]*NULL[ \t]*__null\n"
2969 "^#define[ \t]*NULL[ \t]*0L\n"
2975 "#define NULL __null\n"
2983 * obstack.h used casts as lvalues.
2985 * We need to change postincrements of casted pointers (which are
2986 * then dereferenced and assigned into) of the form
2988 * *((TYPE*)PTRVAR)++ = (VALUE)
2990 * into expressions like
2992 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2994 * which is correct for the cases used in obstack.h since PTRVAR is
2995 * of type char * and the value of the expression is not used.
2998 hackname = obstack_lvalue_cast;
3000 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3002 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3003 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3007 * Fix OpenBSD's va_start define.
3010 hackname = openbsd_va_start;
3011 mach = "*-*-openbsd*";
3013 select = '__builtin_stdarg_start';
3015 c_fix_arg = __builtin_va_start;
3017 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3021 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3022 * defining regex.h related types. This causes libg++ build and usage
3023 * failures. Fixing this correctly requires checking and modifying 3 files.
3026 hackname = osf_namespace_a;
3027 files = reg_types.h;
3028 files = sys/lc_core.h;
3029 test = " -r reg_types.h";
3030 test = " -r sys/lc_core.h";
3031 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3032 test = " -z \"`grep __regex_t regex.h`\"";
3036 c_fix_arg = "reg(ex|off|match)_t";
3038 test_text = "`touch sys/lc_core.h`"
3039 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3040 "extern regex_t re;\n"
3041 "extern regoff_t ro;\n"
3042 "extern regmatch_t rm;\n";
3046 hackname = osf_namespace_c;
3048 test = " -r reg_types.h";
3049 test = " -r sys/lc_core.h";
3050 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3051 test = " -z \"`grep __regex_t regex.h`\"";
3053 select = "#include <reg_types\.h>.*";
3056 "typedef __regex_t\tregex_t;\n"
3057 "typedef __regoff_t\tregoff_t;\n"
3058 "typedef __regmatch_t\tregmatch_t;";
3060 test_text = "#include <reg_types.h>";
3065 * On broken glibc-2.3.3 systems an array of incomplete structures is
3066 * passed to __sigsetjmp. Fix that to take a pointer instead.
3069 hackname = pthread_incomplete_struct_argument;
3071 select = "struct __jmp_buf_tag";
3073 c_fix_arg = "%1 *%2%3";
3074 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
3075 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
3079 * Fix return type of fread and fwrite on sysV68
3082 hackname = read_ret_type;
3084 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3086 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3087 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3089 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3094 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3097 hackname = rpc_xdr_lvalue_cast_a;
3099 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3101 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3102 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3103 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3108 hackname = rpc_xdr_lvalue_cast_b;
3110 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3112 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3113 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3114 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3119 * function class(double x) conflicts with C++ keyword on rs/6000
3122 hackname = rs6000_double;
3124 select = '[^a-zA-Z_]class\(';
3127 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3128 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3130 test_text = "extern int class();";
3135 * Wrong fchmod prototype on RS/6000.
3138 hackname = rs6000_fchmod;
3140 select = 'fchmod\(char \*';
3142 c_fix_arg = "fchmod(int";
3143 test_text = "extern int fchmod(char *, mode_t);";
3148 * parameters conflict with C++ new on rs/6000
3151 hackname = rs6000_param;
3155 select = 'rename\(const char \*old, const char \*new\)';
3157 c_fix_arg = 'rename(const char *_old, const char *_new)';
3159 test_text = 'extern int rename(const char *old, const char *new);';
3164 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3165 * for C99. This is wrong for C++, which needs many C99 features, but
3166 * only supports __restrict.
3169 hackname = solaris___restrict;
3170 files = sys/feature_tests.h;
3171 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3172 mach = "*-*-solaris2*";
3174 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3175 "#else\n%0\n#endif";
3176 test_text = "#define _RESTRICT_KYWD restrict";
3181 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3182 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3183 * and imaginary definitions which are not supported by GCC.
3186 hackname = solaris_complex;
3187 mach = "*-*-solaris2.*";
3189 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3190 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3191 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3192 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3193 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3194 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3195 test_text = "#define _Complex_I _Complex_I\n"
3196 "#define complex _Complex\n"
3197 "#define _Imaginary_I _Imaginary_I\n"
3198 "#define imaginary _Imaginary\n"
3200 "#define I _Imaginary_I";
3205 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3206 * extern "C" instead so libstdc++ can use it.
3209 hackname = solaris_complex_cxx;
3210 mach = "*-*-solaris2.*";
3212 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3213 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3214 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3215 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3216 test_text = "#if !defined(__cplusplus)\n"
3217 "#endif /* !defined(__cplusplus) */";
3222 * g++ rejects functions declared with both C and C++ linkage.
3225 hackname = solaris_cxx_linkage;
3226 mach = '*-*-solaris2*';
3227 files = "iso/stdlib_iso.h";
3228 select = "(#if __cplusplus >= 199711L)\n"
3229 "(extern \"C\\+\\+\" \\{\n)"
3230 "(.*(bsearch|qsort).*)";
3232 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3235 "#if __cplusplus >= 199711L\n"
3236 "extern \"C++\" {\n"
3237 " void *bsearch(const void *, const void *, size_t, size_t,";
3242 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3243 * _STRICT_STDC, but uses it.
3246 hackname = solaris_getc_strict_stdc;
3247 mach = "*-*-solaris2*";
3248 files = "iso/stdio_iso.h";
3249 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3251 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3254 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3259 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
3262 hackname = solaris_longjmp_noreturn;
3263 mach = "*-*-solaris2*";
3264 files = "iso/setjmp_iso.h";
3265 bypass = "__NORETURN";
3266 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
3268 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
3270 test_text = "extern void longjmp(jmp_buf, int);";
3275 * Sun Solaris 10 defines several C99 math macros in terms of
3276 * builtins specific to the Studio compiler, in particular not
3277 * compatible with the GNU compiler.
3280 hackname = solaris_math_1;
3281 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3282 bypass = "__GNUC__";
3283 files = iso/math_c99.h;
3285 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3286 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3288 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3290 "#define HUGE_VAL __builtin_huge_val\n"
3291 "#undef HUGE_VALF\n"
3292 "#define HUGE_VALF __builtin_huge_valf\n"
3293 "#undef HUGE_VALL\n"
3294 "#define HUGE_VALL __builtin_huge_vall";
3298 hackname = solaris_math_2;
3299 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3300 bypass = "__GNUC__";
3301 files = iso/math_c99.h;
3303 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3304 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3306 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3308 "#define INFINITY __builtin_infinity";
3312 hackname = solaris_math_3;
3313 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3314 bypass = "__GNUC__";
3315 files = iso/math_c99.h;
3317 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3318 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3320 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3322 "#define NAN __builtin_nan";
3326 hackname = solaris_math_4;
3327 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3328 bypass = "__GNUC__";
3329 files = iso/math_c99.h;
3331 c_fix_arg = "#define\tfpclassify(x) \\\n"
3332 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3333 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3335 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3336 "#undef fpclassify\n"
3337 "#define fpclassify(x) __builtin_fpclassify(x)";
3341 hackname = solaris_math_8;
3342 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3343 bypass = "__GNUC__";
3344 files = iso/math_c99.h;
3346 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3347 "\t\t\t ? __builtin_signbitf(x) \\\n"
3348 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3349 "\t\t\t ? __builtin_signbitl(x) \\\n"
3350 "\t\t\t : __builtin_signbit(x))";
3351 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3352 test_text = <<- _EOText_
3353 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3355 #define signbit(x) __builtin_signbit(x)
3360 hackname = solaris_math_9;
3361 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3362 bypass = "__GNUC__";
3363 files = iso/math_c99.h;
3365 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3366 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3368 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3369 "#undef isgreater\n"
3370 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3371 "#undef isgreaterequal\n"
3372 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3374 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3375 "#undef islessequal\n"
3376 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3377 "#undef islessgreater\n"
3378 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3379 "#undef isunordered\n"
3380 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3384 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3385 * exception. Provide an alternative using GCC's builtin.
3389 hackname = solaris_math_10;
3390 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3391 files = iso/math_c99.h;
3393 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3394 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3395 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3396 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3397 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3399 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3401 "#define isinf(x) __extension__( \\\\\n"
3402 " { __typeof(x) __x_i = (x); \\\\\n"
3403 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3404 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3408 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3409 * "0" for the last field of the pthread_mutex_t structure, which is
3410 * of type upad64_t, which itself is typedef'd to int64_t, but with
3411 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3412 * initializer to "{0}" instead
3415 hackname = solaris_mutex_init_2;
3416 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3419 * On Solaris 10, this fix is unnecessary because upad64_t is
3420 * always defined correctly regardless of the definition of the
3421 * __STDC__ macro. The first "mach" pattern matches up to
3422 * solaris9. The second "mach" pattern will not match any two (or
3423 * more) digit solaris version, but it will match e.g. 2.5.1.
3425 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3427 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3432 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3433 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3434 ",[ \t]*0\\}" "(|[ \t].*)$";
3436 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3437 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3438 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3439 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3440 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3441 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3442 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3447 * The pow overloads with int were removed in C++ 2011.
3450 hackname = solaris_pow_int_overload;
3451 mach = '*-*-solaris2*';
3452 files = "iso/math_iso.h";
3453 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3454 " *\\{[^{}]*\n[^{}]*\\}";
3456 c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif";
3459 " inline long double pow(long double __X, int __Y) { return\n"
3460 " __powl(__X, (long double) (__Y)); }";
3465 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3466 * fields of the pthread_rwlock_t structure, which are of type
3467 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3468 * defined (e.g. by -ansi) it is a union. So change the initializer
3472 hackname = solaris_rwlock_init_1;
3473 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3475 mach = '*-*-solaris*';
3477 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3480 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3482 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3483 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3486 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3487 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3492 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3493 * structure. As such, it need two levels of brackets, but only
3494 * contains one. Wrap the macro definition in an extra layer.
3497 hackname = solaris_once_init_1;
3498 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3500 mach = '*-*-solaris*';
3502 c_fix_arg = "%1{%2}%3";
3503 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3505 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3506 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3511 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3512 * fields of the pthread_once_t structure, which are of type
3513 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3514 * defined (e.g. by -ansi) it is a union. So change the initializer
3515 * to "{0}" instead. This test relies on solaris_once_init_1.
3518 hackname = solaris_once_init_2;
3519 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3522 * On Solaris 10, this fix is unnecessary because upad64_t is
3523 * always defined correctly regardless of the definition of the
3524 * __STDC__ macro. The first "mach" pattern matches up to
3525 * solaris9. The second "mach" pattern will not match any two (or
3526 * more) digit solaris version, but it will match e.g. 2.5.1.
3528 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3530 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3533 "%1{0}, {0}, {0}, {%3}%4\n"
3535 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3536 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3538 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3539 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3544 * Sun Solaris 2 has a version of sys/int_const.h that defines
3545 * UINT8_C and UINT16_C to unsigned constants.
3548 hackname = solaris_int_const;
3549 files = sys/int_const.h;
3550 mach = '*-*-solaris2*';
3552 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3554 "#define\tUINT16_C(c)\t(c)";
3555 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3557 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3559 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3561 "#define UINT16_C(c) __CONCAT__(c,u)";
3566 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3567 * UINT8_MAX and UINT16_MAX to unsigned constants.
3570 hackname = solaris_int_limits_1;
3571 files = sys/int_limits.h;
3572 mach = '*-*-solaris2*';
3574 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3575 "#define\tUINT16_MAX\t(65535)";
3576 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3577 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3579 "#define UINT8_MAX (255U)\n"
3580 "#define UINT16_MAX (65535U)";
3585 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3586 * INT_FAST16 limits to wrong values for sys/int_types.h.
3589 hackname = solaris_int_limits_2;
3590 files = sys/int_limits.h;
3591 mach = '*-*-solaris2*';
3593 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3594 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3596 "#define INT_FAST16_MAX INT16_MAX\n"
3597 "#define UINT_FAST16_MAX UINT16_MAX\n"
3598 "#define INT_FAST16_MIN INT16_MIN";
3603 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3604 * SIZE_MAX as unsigned long.
3607 hackname = solaris_int_limits_3;
3608 files = sys/int_limits.h;
3609 mach = '*-*-solaris2*';
3611 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3612 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3614 "#define SIZE_MAX 4294967295UL";
3619 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3620 * of Standard C99 64-bit types in 32-bit mode.
3623 hackname = solaris_int_types;
3624 select = "__STDC__ - 0 == 0";
3625 bypass = "_LONGLONG_TYPE";
3626 files = sys/int_types.h;
3629 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3631 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3632 "typedef long long int64_t;\n"
3634 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3635 "typedef int64_t intmax_t;\n"
3641 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3642 * posix_spawn declarations, which doesn't work with C++.
3645 hackname = solaris_posix_spawn_restrict;
3647 mach = '*-*-solaris2*';
3649 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3650 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3652 "char *const argv[_RESTRICT_KYWD],\n"
3653 "char *const envp[_RESTRICT_KYWD]);";
3658 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3659 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3662 hackname = solaris_std___filbuf;
3664 mach = '*-*-solaris2*';
3665 bypass = "using std::__filbuf";
3666 select = "(using std::perror;\n)(#endif)";
3668 c_fix_arg = "%1#ifndef _LP64\n"
3669 "using std::__filbuf;\n"
3670 "using std::__flsbuf;\n"
3673 test_text = "using std::perror;\n"
3679 * Sun Solaris 8 has what appears to be some gross workaround for
3680 * some old version of their c++ compiler. G++ doesn't want it
3681 * either, but doesn't want to be tied to SunPRO version numbers.
3684 hackname = solaris_stdio_tag;
3685 files = stdio_tag.h;
3687 select = '__cplusplus < 54321L';
3688 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3689 "!defined(__GNUC__)" so we no longer need to fix it. */
3690 bypass = '__GNUC__';
3691 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3693 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3698 * On Solaris 9, __va_list needs to become a typedef for
3699 * __builtin_va_list to make -Wmissing-format-attribute work.
3702 hackname = solaris_sys_va_list;
3703 files = sys/va_list.h;
3704 mach = '*-*-solaris2.9';
3705 select = "#if.*__STDC__.*\n"
3706 "typedef void \\*__va_list;\n"
3708 "typedef char \\*__va_list;\n"
3712 c_fix_arg = "#ifdef __GNUC__\n"
3713 "typedef __builtin_va_list __va_list;\n"
3717 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3718 "typedef void *__va_list;\n"
3720 "typedef char *__va_list;\n"
3726 * a missing semi-colon at the end of the statsswtch structure definition.
3729 hackname = statsswtch;
3730 files = rpcsvc/rstat.h;
3731 select = "boottime$";
3733 c_fix_arg = "boottime;";
3734 test_text = "struct statswtch {\n int boottime\n};";
3739 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3740 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3744 hackname = stdio_stdarg_h;
3746 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3748 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3749 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3751 mach = '*-*-solaris2.1[0-9]*';
3756 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3763 * Don't use or define the name va_list in stdio.h. This is for
3764 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3765 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3766 * indicate that the header knows what it's doing -- under SUSv2,
3767 * stdio.h is required to define va_list, and we shouldn't break
3771 hackname = stdio_va_list;
3773 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3775 * On Solaris 10, the definition in
3776 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3777 * there is therefore no need for this fix there.
3779 mach = '*-*-solaris2.1[0-9]*';
3783 * Use __gnuc_va_list in arg types in place of va_list.
3784 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3785 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3786 * trailing parentheses and semicolon save all other systems from this.
3787 * Define __not_va_list__ (something harmless and unused)
3788 * instead of va_list.
3789 * Don't claim to have defined va_list.
3791 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3792 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3793 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3794 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3795 "s@ va_list@ __not_va_list__@\n"
3796 "s@\\*va_list@*__not_va_list__@\n"
3797 "s@ __va_list)@ __gnuc_va_list)@\n"
3798 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3799 "@typedef \\1 __not_va_list__;@\n"
3800 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3801 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3802 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3803 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3804 "s@VA_LIST@DUMMY_VA_LIST@\n"
3805 "s@_Va_LIST@_VA_LIST@";
3806 test_text = "extern void mumble( va_list);";
3811 * Fix headers that use va_list from stdio.h to use the updated
3812 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3813 * dealt with elsewhere. The presence of __gnuc_va_list,
3814 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3815 * knows what it's doing.
3818 hackname = stdio_va_list_clients;
3826 files = curses_colr/curses.h;
3827 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3828 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3829 otherwise protected. */
3830 bypass = 'include <stdarg\.h>|#ifdef va_start';
3833 * Use __gnuc_va_list in arg types in place of va_list.
3834 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3835 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3836 * trailing parentheses and semicolon save all other systems from this.
3837 * Define __not_va_list__ (something harmless and unused)
3838 * instead of va_list.
3839 * Don't claim to have defined va_list.
3841 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3842 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3843 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3844 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3845 "s@ va_list@ __not_va_list__@\n"
3846 "s@\\*va_list@*__not_va_list__@\n"
3847 "s@ __va_list)@ __gnuc_va_list)@\n"
3848 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3849 "@typedef \\1 __not_va_list__;@\n"
3850 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3851 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3852 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3853 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3854 "s@VA_LIST@DUMMY_VA_LIST@\n"
3855 "s@_Va_LIST@_VA_LIST@";
3856 test_text = "extern void mumble( va_list);";
3861 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3862 * is "!defined( __STRICT_ANSI__ )"
3865 hackname = strict_ansi_not;
3866 select = "^([ \t]*#[ \t]*if.*)"
3868 "|__STDC__[ \t]*==[ \t]*0"
3869 "|__STDC__[ \t]*!=[ \t]*1"
3870 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3871 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3872 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3873 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3874 is not defined by GCC, so it is safe. */
3875 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3876 c_test = stdc_0_in_system_headers;
3879 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3881 test_text = "#if !__STDC__ \n"
3882 "#if __STDC__ == 0\n"
3883 "#if __STDC__ != 1\n"
3884 "#if __STDC__ - 0 == 0"
3885 "/* not std C */\nint foo;\n"
3886 "\n#end-end-end-end-if :-)";
3891 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3894 hackname = strict_ansi_not_ctd;
3895 files = math.h, limits.h, stdio.h, signal.h,
3896 stdlib.h, sys/signal.h, time.h;
3898 * Starting at the beginning of a line, skip white space and
3899 * a leading "(" or "&&" or "||". One of those must be found.
3900 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3901 * expression. If these are nested, then they must accumulate
3902 * because we won't match any closing parentheses. Finally,
3903 * after skipping over all that, we must then match our suspect
3904 * phrase: "__STDC__-0==0" with or without white space.
3906 select = "^([ \t]*" '(\(|&&|\|\|)'
3907 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3909 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3910 c_test = stdc_0_in_system_headers;
3913 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3915 test_text = "#if 1 && \\\\\n"
3916 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3917 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3918 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3924 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3925 * is "defined( __STRICT_ANSI__ )"
3928 hackname = strict_ansi_only;
3929 select = "^([ \t]*#[ \t]*if.*)"
3930 "(__STDC__[ \t]*!=[ \t]*0"
3931 "|__STDC__[ \t]*==[ \t]*1"
3932 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3933 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3934 c_test = stdc_0_in_system_headers;
3937 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3939 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3944 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3945 * in prototype without previous definition.
3948 hackname = struct_file;
3950 select = '^.*xdrstdio_create.*struct __file_s';
3952 c_fix_arg = "struct __file_s;\n%0";
3953 test_text = "extern void xdrstdio_create( struct __file_s* );";
3958 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3959 * in prototype without previous definition.
3961 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3962 * function, and does define it.
3965 hackname = struct_sockaddr;
3967 select = "^.*authdes_create.*struct sockaddr[^_]";
3968 bypass = "<sys/socket\.h>";
3969 bypass = "struct sockaddr;\n";
3971 c_fix_arg = "struct sockaddr;\n%0";
3972 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3977 * Apply fix this to all OSs since this problem seems to effect
3978 * more than just SunOS.
3981 hackname = sun_auth_proto;
3986 bypass = "__cplusplus";
3988 * Select those files containing '(*name)()'.
3990 select = '\(\*[a-z][a-z_]*\)\(\)';
3993 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3994 "#else\n%1();%2\n#endif";
3995 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3999 " int (*name)(); /* C++ bad */\n"
4005 * Fix bogus #ifdef on SunOS 4.1.
4008 hackname = sun_bogus_ifdef;
4009 files = "hsfs/hsfs_spec.h";
4010 files = "hsfs/iso_spec.h";
4011 select = '#ifdef(.*\|\|.*)';
4013 c_fix_arg = "#if%1";
4015 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4020 * Fix the CAT macro in SunOS memvar.h.
4023 hackname = sun_catmacro;
4024 files = pixrect/memvar.h;
4025 select = "^#define[ \t]+CAT\\(a,b\\).*";
4030 "# define CAT(a,b) a##b\n"
4031 "#else\n%0\n#endif";
4034 "#define CAT(a,b)\ta/**/b";
4039 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4040 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4043 hackname = sun_malloc;
4045 bypass = "_CLASSIC_ANSI_TYPES";
4047 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4048 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4049 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4050 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4051 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4054 "typedef char *\tmalloc_t;\n"
4056 "char*\tmalloc();\n"
4057 "char*\tcalloc();\n"
4058 "char*\trealloc();";
4063 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4066 hackname = sun_rusers_semi;
4067 files = rpcsvc/rusers.h;
4069 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4070 test_text = "struct mumble\n int _cnt\n};";
4075 * signal.h on SunOS defines signal using (),
4076 * which causes trouble when compiling with g++ -pedantic.
4079 hackname = sun_signal;
4080 files = sys/signal.h;
4082 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4086 "#ifdef __cplusplus\n"
4087 "void\t(*signal(...))(...);\n"
4088 "#else\n%0\n#endif";
4090 test_text = "void\t(*signal())();";
4095 * Correct the return type for strlen in strings.h in SunOS 4.
4098 hackname = sunos_strlen;
4100 select = "int[ \t]*strlen\\(\\);(.*)";
4102 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4103 test_text = " int\tstrlen(); /* string length */";
4108 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4109 * that is visible to any ANSI compiler using this include. Simply
4110 * delete the lines that #define some string functions to internal forms.
4113 hackname = svr4_disable_opt;
4115 select = '#define.*__std_hdr_';
4116 sed = '/#define.*__std_hdr_/d';
4117 test_text = "#define strlen __std_hdr_strlen\n";
4122 * Fix broken decl of getcwd present on some svr4 systems.
4125 hackname = svr4_getcwd;
4128 files = prototypes.h;
4129 select = 'getcwd\(char \*, int\)';
4132 c_fix_arg = "getcwd(char *, size_t)";
4134 test_text = "extern char* getcwd(char *, int);";
4139 * Fix broken decl of profil present on some svr4 systems.
4142 hackname = svr4_profil;
4147 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4149 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4152 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4157 * Correct types for signal handler constants like SIG_DFL; they might be
4158 * void (*) (), and should be void (*) (int). C++ doesn't like the
4162 hackname = svr4_sighandler_type;
4163 files = sys/signal.h;
4164 select = 'void *\(\*\)\(\)';
4166 c_fix_arg = "void (*)(int)";
4167 test_text = "#define SIG_DFL (void(*)())0\n"
4168 "#define SIG_IGN (void (*)())0\n";
4173 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4174 * function 'getrnge' in <regexp.h> before they declare it. For these
4175 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4178 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4179 * so put the declaration right after the declaration of 'size'.
4181 * Don't do this if there is already a `static void getrnge' declaration
4182 * present, since this would cause a redeclaration error. Solaris 2.x has
4183 * such a declaration.
4186 hackname = svr4_undeclared_getrnge;
4189 bypass = "static void getrnge";
4192 "static int getrnge ();";
4193 c_fix_arg = "^static int[ \t]+size;";
4194 test_text = "static int size;\n"
4195 "/* stuff which calls getrnge() */\n"
4196 "static getrnge()\n"
4202 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4203 * in string.h on sysV68
4204 * Correct the return type for strlen in string.h on Lynx.
4205 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4206 * Add missing const for strdup on OSF/1 V3.0.
4207 * On sysV88 layout is slightly different.
4210 hackname = sysv68_string;
4213 bypass = "_CLASSIC_ANSI_TYPES";
4215 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4216 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4217 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4219 sed = "/^extern char$/N";
4220 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4222 sed = "/^extern int$/N";
4223 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4225 sed = "/^\tstrncmp(),$/N";
4226 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4227 '\1;' "\\\nextern unsigned int\\\n\\2/";
4230 "extern int strlen();\n"
4232 "extern int ffs(long);\n"
4245 "\tstrlen(), strspn();";
4250 * Fix return type of calloc, malloc, realloc, bsearch and exit
4253 hackname = sysz_stdlib_for_sun;
4255 bypass = "_CLASSIC_ANSI_TYPES";
4257 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4259 c_fix_arg = "void *\t%1(";
4262 "extern char*\tcalloc(size_t);\n"
4263 "extern char*\tmalloc(size_t);\n"
4264 "extern char*\trealloc(void*,size_t);\n"
4265 "extern char*\tbsearch(void*,size_t,size_t);\n";
4270 * __thread is now a keyword.
4273 hackname = thread_keyword;
4274 files = "pthread.h";
4275 files = "bits/sigthread.h";
4276 select = "([* ])__thread([,)])";
4278 c_fix_arg = "%1__thr%2";
4281 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4282 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4283 "extern int pthread_cancel (pthread_t __thread);";
4287 * if the #if says _cplusplus, not the double underscore __cplusplus
4291 hackname = tinfo_cplusplus;
4293 select = "[ \t]_cplusplus";
4296 c_fix_arg = " __cplusplus";
4297 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4302 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4305 hackname = ultrix_const;
4307 select = 'perror\( char \*';
4310 c_fix_arg = "%1 const %3 *__";
4311 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4312 "[ \t]+(char|void) \\*__";
4315 "extern void perror( char *__s );\n"
4316 "extern int fputs( char *__s, FILE *);\n"
4317 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4318 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4319 "extern int scanf( char *__format, ...);\n";
4324 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4327 hackname = ultrix_const2;
4330 select = '\*fopen\( char \*';
4332 c_fix_arg = "%1( const char *%3, const char *";
4333 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4334 "[ \t]*char[ \t]*\\*([^,]*),"
4335 "[ \t]*char[ \t]*\\*[ \t]*";
4338 "extern FILE *fopen( char *__filename, char *__type );\n"
4339 "extern int sscanf( char *__s, char *__format, ...);\n"
4340 "extern FILE *popen(char *, char *);\n"
4341 "extern char *tempnam(char*,char*);\n";
4346 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4349 hackname = va_i960_macro;
4350 files = arch/i960/archI960.h;
4351 select = "__(vsiz|vali|vpad|alignof__)";
4354 c_fix_arg = "__vx%1";
4357 "extern int __vsiz vsiz;\n"
4358 "extern int __vali vali;\n"
4359 "extern int __vpad vpad;\n"
4360 "#define __alignof__(x) ...";
4365 * Define __CAN_USE_EXTERN_PREFIX on vms.
4368 hackname = vms_define_can_use_extern_prefix;
4369 files = "rtldef/decc$types.h";
4370 select = "#[ \t]*else\n"
4371 "#[ \t]*if defined\\(__DECCXX\\)\n"
4372 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4377 "# elif defined (__GNUC__)\n"
4378 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4380 test_text = "# else\n"
4381 "# if defined(__DECCXX)\n"
4382 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4388 * On VMS, use pragma extern_model instead of VAX-C keywords.
4391 hackname = vms_use_pragma_extern_model;
4392 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4393 "# pragma extern_model __save\n";
4397 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4398 "# pragma extern_model __save\n";
4400 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4401 "# pragma extern_model __save\n"
4402 "# pragma extern_model strict_refdef\n"
4403 " extern struct x zz$yy;\n"
4404 "# pragma extern_model __restore\n"
4409 * On VMS, disable the use of dec-c string builtins
4412 hackname = vms_disable_decc_string_builtins;
4413 select = "#if !defined\\(__VAX\\)\n";
4415 files = "rtldef/string.h";
4418 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4420 test_text = "#if !defined(__VAX)\n";
4424 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4425 * conflict while building gcc. Likewise for <builtins.h>
4428 hackname = vms_use_quoted_include;
4429 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4431 files = rtldef/wait.h, starlet_c/pthread.h;
4434 c_fix_arg = '%1<sys/%2.h>';
4436 test_text = "# include <resource.h>";
4440 * On VMS, add missing braces around sigset_t constants.
4443 hackname = vms_add_missing_braces;
4444 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4446 files = "rtldef/signal.h";
4449 c_fix_arg = '%1 {%2} ';
4451 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4452 "{0x00000000, 0x00000000},\n"
4453 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4457 * On VMS, fix incompatible redeclaration of hostalias.
4460 hackname = vms_do_not_redeclare_hostalias;
4461 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4462 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4464 files = "rtldef/resolv.h";
4470 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4471 "__char_ptr32 hostalias (const char *);\n";
4475 * On VMS, some DEC-C builtins are directly used.
4478 hackname = vms_decc_builtin;
4479 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4481 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4483 sed = "s@__MEMSET@memset@";
4484 sed = "s@__MEMMOVE@memmove@";
4485 sed = "s@__MEMCPY@memcpy@";
4486 sed = "s@__STRLEN@strlen@";
4487 sed = "s@__STRCPY@strcpy@";
4489 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4493 * On VMS, do not declare getopt and al if pointers are 64 bit.
4496 hackname = vms_no_64bit_getopt;
4497 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4498 /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
4500 files = rtldef/stdio.h, rtldef/unistd.h;
4503 c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n"
4507 test_text = "int getopt (int, char * const [], const char *);";
4511 * On VMS, forward declare structure before referencing them in prototypes.
4514 hackname = vms_forward_declare_struct;
4515 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4516 "#ifdef __cplusplus\n";
4518 files = rtldef/if.h;
4522 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4524 test_text = "/* forward decls for C++ */\n"
4525 "#ifdef __cplusplus\n"
4531 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4532 * which is not yet fully supported by gcc.
4535 hackname = vms_use_fast_setjmp;
4536 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4538 files = rtldef/setjmp.h;
4541 c_fix_arg = "%0 defined (__GNUC__) ||";
4543 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4547 * AIX and Interix headers define NULL to be cast to a void pointer,
4548 * which is illegal in ANSI C++.
4551 hackname = void_null;
4561 files = sys/param.h;
4562 files = sys/types.h;
4563 /* avoid changing C++ friendly NULL */
4564 bypass = __cplusplus;
4566 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4568 c_fix_arg = "#define NULL 0";
4569 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4574 * Make VxWorks header which is almost gcc ready fully gcc ready.
4577 hackname = vxworks_gcc_problem;
4578 files = types/vxTypesBase.h;
4579 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4581 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4584 sed = "/[ \t]size_t/i\\\n"
4585 "#ifndef _GCC_SIZE_T\\\n"
4586 "#define _GCC_SIZE_T\n";
4588 sed = "/[ \t]size_t/a\\\n"
4591 sed = "/[ \t]ptrdiff_t/i\\\n"
4592 "#ifndef _GCC_PTRDIFF_T\\\n"
4593 "#define _GCC_PTRDIFF_T\n";
4595 sed = "/[ \t]ptrdiff_t/a\\\n"
4598 sed = "/[ \t]wchar_t/i\\\n"
4599 "#ifndef _GCC_WCHAR_T\\\n"
4600 "#define _GCC_WCHAR_T\n";
4602 sed = "/[ \t]wchar_t/a\\\n"
4606 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4607 "typedef unsigned int size_t;\n"
4608 "typedef long ptrdiff_t;\n"
4609 "typedef unsigned short wchar_t;\n"
4610 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4614 * Wrap VxWorks ioctl to keep everything pretty
4617 hackname = vxworks_ioctl_macro;
4619 mach = "*-*-vxworks*";
4623 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4624 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4626 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4630 * Wrap VxWorks mkdir to be posix compliant
4633 hackname = vxworks_mkdir_macro;
4635 mach = "*-*-vxworks*";
4639 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4640 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4641 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4642 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4645 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4650 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4653 hackname = vxworks_needs_vxtypes;
4655 select = "uint_t([ \t]+_clocks_per_sec)";
4657 c_fix_arg = "unsigned int%1";
4658 test_text = "uint_t\t_clocks_per_sec;";
4663 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4666 hackname = vxworks_needs_vxworks;
4668 test = " -r types/vxTypesOld.h";
4669 test = " -n \"`egrep '#include' $file`\"";
4670 test = " -n \"`egrep ULONG $file`\"";
4671 select = "#[ \t]define[ \t]+__INCstath";
4673 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4674 "#include <types/vxTypesOld.h>\n";
4676 test_text = "`touch types/vxTypesOld.h`"
4677 "#include </dev/null> /* ULONG */\n"
4678 "# define\t__INCstath <sys/stat.h>";
4682 * Make it so VxWorks does not include gcc/regs.h accidentally
4685 hackname = vxworks_regs;
4686 mach = "*-*-vxworks*";
4688 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4690 c_fix_arg = "#include <arch/../regs.h>";
4692 test_text = "#include <regs.h>\n";
4697 * Another bad dependency in VxWorks 5.2 <time.h>.
4700 hackname = vxworks_time;
4702 test = " -r vxWorks.h";
4704 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4708 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4709 "#ifdef __cplusplus\n"
4710 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4712 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4714 "#define __gcc_VOIDFUNCPTR_defined\n"
4716 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4718 test_text = "`touch vxWorks.h`"
4719 "#define VOIDFUNCPTR (void(*)())";
4723 * This hack makes write const-correct on VxWorks
4726 hackname = vxworks_write_const;
4728 mach = "*-*-vxworks*";
4731 c_fix_arg = "extern int write (int, const char*, size_t);";
4732 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4734 "[\t ]*char[\t ]*\\*[\t ]*,"
4735 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4737 test_text = "extern int write ( int , char * , size_t ) ;";
4741 * There are several name conflicts with C++ reserved words in X11 header
4742 * files. These are fixed in some versions, so don't do the fixes if
4743 * we find __cplusplus in the file. These were found on the RS/6000.
4746 hackname = x11_class;
4747 files = X11/ShellP.h;
4748 bypass = __cplusplus;
4749 select = "^([ \t]*char \\*)class;(.*)";
4751 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4752 "#else\n%1class;%2\n#endif";
4761 * class in Xm/BaseClassI.h
4764 hackname = x11_class_usage;
4765 files = Xm/BaseClassI.h;
4766 bypass = "__cplusplus";
4768 select = " class\\)";
4770 c_fix_arg = " c_class)";
4772 test_text = "extern mumble (int class);\n";
4777 * new in Xm/Traversal.h
4781 files = Xm/Traversal.h;
4782 bypass = __cplusplus;
4784 sed = "/Widget\told, new;/i\\\n"
4785 "#ifdef __cplusplus\\\n"
4786 "\\\tWidget\told, c_new;\\\n"
4789 sed = "/Widget\told, new;/a\\\n"
4792 sed = "s/Widget new,/Widget c_new,/g";
4795 " Widget\told, new;\n"
4796 "};\nextern Wedged( Widget new, Widget old );";
4801 * Incorrect sprintf declaration in X11/Xmu.h
4804 hackname = x11_sprintf;
4806 files = X11/Xmu/Xmu.h;
4807 select = "^extern char \\*\tsprintf\\(\\);$";
4810 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4812 test_text = "extern char *\tsprintf();";