re PR fortran/57822 (I/O: "(g0)" wrongly prints "E+0000")
[official-gcc.git] / fixincludes / inclhack.def
blobce9a2ca6b4c5b9cdc1562771571c2b6456d6bf76
1 /* -*- Mode: C -*- */
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 \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key=$'hackname[ \t]*=[ \t]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
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
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
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
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
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");
61 #endif
62 #endif
64 _EOArg_;
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
72 fix = {
73 hackname = AAB_aix_fcntl;
74 files = fcntl.h;
75 select = "define open[ \t]open64";
76 mach = "*-*-aix*";
77 test-text = ''; /* no way to test */
79 c_fix = wrap;
81 c_fix_arg = "";
83 c_fix_arg = <<- _EOArg_
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
88 #undef open
89 #undef creat
90 #undef openat
91 /* Alias the symbols using asm */
92 extern "C" {
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
97 #endif
99 #endif
100 #endif
102 _EOArg_;
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
109 fix = {
110 hackname = AAB_darwin7_9_long_double_funcs;
111 mach = "*-*-darwin7.9*";
112 files = architecture/ppc/math.h;
113 bypass = "powl";
114 replace = <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
116 10.3.9. */
117 #ifndef __MATH__
118 # undef __APPLE_CC__
119 # define __APPLE_CC__ 1345
120 # include_next <architecture/ppc/math.h>
121 # undef __APPLE_CC__
122 # define __APPLE_CC__ 1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
126 # else
127 # define __LIBMLDBL_COMPAT(sym)
128 # endif /* __LONG_DOUBLE_128__ */
129 # endif /* __LIBMLDBL_COMPAT */
130 # ifdef __cplusplus
131 extern "C" {
132 # endif
133 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
190 # ifdef __cplusplus
192 # endif
193 #endif /* __MATH__ */
194 _EndOfHeader_;
198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
200 fix = {
201 hackname = AAB_fd_zero_asm_posix_types_h;
202 files = asm/posix_types.h;
203 mach = 'i[34567]86-*-linux*';
204 bypass = '} while';
205 bypass = 'x86_64';
206 bypass = 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
210 * the start, so that if #include_next gets another instance of
211 * the wrapper, this will follow the #include_next chain until
212 * we arrive at the real <asm/posix_types.h>.
214 replace = <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel. */
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include <features.h>
219 #include_next <asm/posix_types.h>
221 #if defined(__FD_ZERO) && !defined(__GLIBC__)
222 #undef __FD_ZERO
223 #define __FD_ZERO(fdsetp) \
224 do { \
225 int __d0, __d1; \
226 __asm__ __volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0), "=&D" (__d1) \
228 : "a" (0), "0" (__FDSET_LONGS), \
229 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
230 } while (0)
231 #endif
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif /* _POSIX_TYPES_H_WRAPPER */
235 _EndOfHeader_;
239 * This fixes __FD_ZERO bug for glibc-1.x
241 fix = {
242 hackname = AAB_fd_zero_gnu_types_h;
243 files = gnu/types.h;
244 mach = 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
248 * the start, so that if #include_next gets another instance of
249 * the wrapper, this will follow the #include_next chain until
250 * we arrive at the real <gnu/types.h>.
252 replace = <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
254 #ifndef _TYPES_H_WRAPPER
255 #include <features.h>
256 #include_next <gnu/types.h>
258 #if defined(__FD_ZERO) && !defined(__GLIBC__)
259 #undef __FD_ZERO
260 # define __FD_ZERO(fdsetp) \
261 do { \
262 int __d0, __d1; \
263 __asm__ __volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0), "=&D" (__d1) \
265 : "a" (0), "0" (__FDSET_LONGS), \
266 "1" ((__fd_set *) (fdsetp)) :"memory"); \
267 } while (0)
268 #endif
270 #define _TYPES_H_WRAPPER
271 #endif /* _TYPES_H_WRAPPER */
272 _EndOfHeader_;
276 * This fixes __FD_ZERO bug for glibc-2.0.x
278 fix = {
279 hackname = AAB_fd_zero_selectbits_h;
280 files = selectbits.h;
281 mach = 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
285 * the start, so that if #include_next gets another instance of
286 * the wrapper, this will follow the #include_next chain until
287 * we arrive at the real <selectbits.h>.
289 replace = <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include <features.h>
293 #include_next <selectbits.h>
295 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
296 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
297 && __GLIBC_MINOR__ == 0
298 #undef __FD_ZERO
299 #define __FD_ZERO(fdsetp) \\
300 do { \\
301 int __d0, __d1; \\
302 __asm__ __volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0), "=&D" (__d1) \\
304 : "a" (0), "0" (sizeof (__fd_set) \\
305 / sizeof (__fd_mask)), \\
306 "1" ((__fd_mask *) (fdsetp)) \\
307 : "memory"); \\
308 } while (0)
309 #endif
311 #define _SELECTBITS_H_WRAPPER
312 #endif /* _SELECTBITS_H_WRAPPER */
313 _EndOfHeader_;
317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
318 * the same interface as <stdarg.h>. No idea why they couldn't have just
319 * used the standard header.
321 fix = {
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris*';
325 replace = <<- _EndOfHeader_
326 #ifdef __STDC__
327 #include <stdarg.h>
328 #else
329 #include <varargs.h>
330 #endif
331 _EndOfHeader_;
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
341 fix = {
342 hackname = AAB_sun_memcpy;
343 files = memory.h;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
350 #ifndef __memory_h__
351 #define __memory_h__
353 #ifdef __STDC__
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
358 #else
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
365 extern int memcmp();
367 #endif /* __memory_h__ */
368 _EndOfHeader_;
372 * Fix assert.h on VxWorks:
374 fix = {
375 hackname = AAB_vxworks_assert;
376 files = assert.h;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
380 #ifndef _ASSERT_H
381 #define _ASSERT_H
383 #ifdef assert
384 #undef assert
385 #endif
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
389 #else
390 extern void __assert ();
391 #endif
393 #ifdef NDEBUG
394 #define assert(ign) ((void)0)
395 #else
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
405 #endif
407 #endif
408 _EndOfHeader_;
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
415 fix = {
416 hackname = AAB_vxworks_regs_vxtypes;
417 files = regs.h;
418 mach = "*-*-vxworks*";
420 replace = <<- _EndOfHeader_
421 #ifndef _REGS_H
422 #define _REGS_H
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
425 #endif
426 _EndOfHeader_;
430 * Make VxWorks stdint.h a bit more compliant - add typedefs
432 fix = {
433 hackname = AAB_vxworks_stdint;
434 files = stdint.h;
435 mach = "*-*-vxworks*";
437 replace = <<- _EndOfHeader_
438 #ifndef _STDINT_H
439 #define _STDINT_H
440 /* get int*_t, uint*_t */
441 #include <types/vxTypes.h>
443 /* get legacy vxworks types for compatibility */
444 #include <types/vxTypesOld.h>
446 typedef long intptr_t;
447 typedef unsigned long uintptr_t;
449 typedef int64_t intmax_t;
450 typedef uint64_t uintmax_t;
452 typedef int8_t int_least8_t;
453 typedef int16_t int_least16_t;
454 typedef int32_t int_least32_t;
455 typedef int64_t int_least64_t;
457 typedef uint8_t uint_least8_t;
458 typedef uint16_t uint_least16_t;
459 typedef uint32_t uint_least32_t;
460 typedef uint64_t uint_least64_t;
462 typedef int8_t int_fast8_t;
463 typedef int int_fast16_t;
464 typedef int32_t int_fast32_t;
465 typedef int64_t int_fast64_t;
467 typedef uint8_t uint_fast8_t;
468 typedef unsigned int uint_fast16_t;
469 typedef uint32_t uint_fast32_t;
470 typedef uint64_t uint_fast64_t;
472 /* Ranges */
473 #define UINT8_MAX (~(uint8_t)0)
474 #define UINT8_MIN 0
475 #define UINT16_MAX (~(uint16_t)0)
476 #define UINT16_MIN 0
477 #define UINT32_MAX (~(uint32_t)0)
478 #define UINT32_MIN 0
479 #define UINT64_MAX (~(uint64_t)0)
480 #define UINT64_MIN 0
482 #define UINTPTR_MAX (~(uintptr_t)0)
483 #define UINTPTR_MIN 0
485 /* Need to do int_fast16_t as well, as type
486 size may be architecture dependent */
487 #define UINT_FAST16_MAX (~(uint_fast16_t)0)
488 #define UINT_FAST16_MAX 0
490 #define INT8_MAX (UINT8_MAX>>1)
491 #define INT8_MIN (INT8_MAX+1)
492 #define INT16_MAX (UINT16_MAX>>1)
493 #define INT16_MIN (INT16_MAX+1)
494 #define INT32_MAX (UINT32_MAX>>1)
495 #define INT32_MIN (INT32_MAX+1)
496 #define INT64_MAX (UINT64_MAX>>1)
497 #define INT64_MIN (INT64_MAX+1)
499 #define INTPTR_MAX (UINTPTR_MAX>>1)
500 #define INTPTR_MIN (INTPTR_MAX+1)
502 #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
503 #define INT_FAST16_MIN (INT_FAST16_MAX+1)
505 /* now define equiv. constants */
506 #define UINT_FAST8_MAX UINT8_MAX
507 #define UINT_FAST8_MIN UINT_FAST8_MIN
508 #define INT_FAST8_MAX INT8_MAX
509 #define INT_FAST8_MIN INT8_MIN
510 #define UINT_FAST32_MAX UINT32_MAX
511 #define UINT_FAST32_MIN UINT32_MIN
512 #define INT_FAST32_MAX INT32_MAX
513 #define INT_FAST32_MIN INT32_MIN
514 #define UINT_FAST64_MAX UINT64_MAX
515 #define UINT_FAST64_MIN UINT64_MIN
516 #define INT_FAST64_MAX INT64_MAX
517 #define INT_FAST64_MIN INT64_MIN
519 #define UINT_LEAST8_MAX UINT8_MAX
520 #define UINT_LEAST8_MIN UINT8_MIN
521 #define INT_LEAST8_MAX INT8_MAX
522 #define INT_LEAST8_MIN INT8_MIN
523 #define UINT_LEAST16_MAX UINT16_MAX
524 #define UINT_LEAST16_MIN UINT16_MIN
525 #define INT_LEAST16_MAX INT16_MAX
526 #define INT_LEAST16_MIN INT16_MIN
527 #define UINT_LEAST32_MAX UINT32_MAX
528 #define UINT_LEAST32_MIN UINT32_MIN
529 #define INT_LEAST32_MAX INT32_MAX
530 #define INT_LEAST32_MIN INT32_MIN
531 #define UINT_LEAST64_MAX UINT64_MAX
532 #define UINT_LEAST64_MIN UINT64_MIN
533 #define INT_LEAST64_MAX INT64_MAX
534 #define INT_LEAST64_MIN INT64_MIN
536 #define UINTMAX_MAX UINT64_MAX
537 #define UINTMAX_MIN UINT64_MIN
538 #define INTMAX_MAX INT64_MAX
539 #define INTMAX_MIN INT64_MIN
541 #endif
542 _EndOfHeader_;
546 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
548 fix = {
549 hackname = AAB_vxworks_unistd;
550 files = unistd.h;
551 mach = "*-*-vxworks*";
553 replace = <<- _EndOfHeader_
554 #ifndef _UNISTD_H
555 #define _UNISTD_H
556 #include_next <unistd.h>
557 #include <ioLib.h>
558 #ifndef STDIN_FILENO
559 #define STDIN_FILENO 0
560 #endif
561 #ifndef STDOUT_FILENO
562 #define STDOUT_FILENO 1
563 #endif
564 #ifndef STDERR_FILENO
565 #define STDERR_FILENO 2
566 #endif
567 #endif /* _UNISTD_H */
568 _EndOfHeader_;
572 * assert.h on AIX 7 redefines static_assert as _Static_assert without
573 * protecting C++.
575 fix = {
576 hackname = aix_assert;
577 mach = "*-*-aix*";
578 files = assert.h;
579 select = "#define[ \t]static_assert[ \t]_Static_assert";
580 c_fix = format;
581 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
582 test_text = "#define static_assert _Static_assert";
586 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
587 * which only is provided by AIX xlc C99.
589 fix = {
590 hackname = aix_complex;
591 mach = "*-*-aix*";
592 files = complex.h;
593 select = "#define[ \t]_Complex_I[ \t]__I";
594 c_fix = format;
595 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
596 test_text = "#define _Complex_I __I\n";
600 * malloc.h on AIX6 uses XLC++ specific builtin syntax
602 fix = {
603 hackname = aix_malloc;
604 mach = "*-*-aix*";
605 files = "malloc.h";
606 select = "#ifdef __cplusplus";
607 c_fix = format;
608 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
609 test_text = "#ifdef __cplusplus";
613 * net/if_arp.h defines a variable fc_softc instead of adding a
614 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
616 fix = {
617 hackname = aix_net_if_arp;
618 mach = "*-*-aix*";
619 files = "net/if_arp.h";
620 select = "^struct fc_softc \\{";
621 c_fix = format;
622 c_fix_arg = "typedef struct _fc_softc {";
623 test_text = "struct fc_softc {\n int a;\n};";
627 * Fix AIX definition of NULL for G++.
629 fix = {
630 hackname = aix_null;
631 mach = "*-*-aix*";
632 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
633 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
634 bypass = __null;
635 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
636 c_fix = format;
637 c_fix_arg = <<- _EOFix_
638 #ifndef NULL
639 #ifdef __cplusplus
640 #ifdef __GNUG__
641 #define NULL __null
642 #else /* ! __GNUG__ */
643 #define NULL 0L
644 #endif /* __GNUG__ */
645 #else /* ! __cplusplus */
646 #define NULL ((void *)0)
647 #endif /* __cplusplus */
648 #endif /* !NULL */
649 _EOFix_;
650 test_text = "# define\tNULL \t(0L) /* typed NULL */";
654 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
655 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
656 * braces.
658 fix = {
659 hackname = aix_once_init_1;
660 mach = "*-*-aix*";
661 files = "pthread.h";
662 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
663 "\\{ \\\\\n";
664 c_fix = format;
665 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
666 "{{ \\\n";
667 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
668 "{ \\\\\n";
671 fix = {
672 hackname = aix_once_init_2;
673 mach = "*-*-aix*";
674 files = "pthread.h";
675 select = "[ \t]0 \\\\\n"
676 "\\}\n";
677 c_fix = format;
678 c_fix_arg = " 0 \\\n"
679 "}}\n";
680 test_text = " 0 \\\\\n"
681 "}\n";
684 fix = {
685 hackname = aix_mutex_initializer_1;
686 mach = "*-*-aix*";
687 files = "pthread.h";
688 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
689 "\\{ \\\\\n";
690 c_fix = format;
691 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
692 "{{ \\\n";
693 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
694 "{ \\\\\n";
697 fix = {
698 hackname = aix_cond_initializer_1;
699 mach = "*-*-aix*";
700 files = "pthread.h";
701 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
702 "\\{ \\\\\n";
703 c_fix = format;
704 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
705 "{{ \\\n";
706 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
707 "{ \\\\\n";
710 fix = {
711 hackname = aix_rwlock_initializer_1;
712 mach = "*-*-aix*";
713 files = "pthread.h";
714 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
715 "\\{ \\\\\n";
716 c_fix = format;
717 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
718 "{{ \\\n";
719 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
720 "{ \\\\\n";
724 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
725 * which violates a requirement of ISO C.
727 fix = {
728 hackname = aix_pthread;
729 files = "pthread.h";
730 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
731 c_fix = format;
732 c_fix_arg = "%1 %2";
733 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
734 "{...init stuff...}";
738 * AIX stdint.h fixes.
740 fix = {
741 hackname = aix_stdint_1;
742 mach = "*-*-aix*";
743 files = stdint-aix.h, stdint.h;
744 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
745 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
746 c_fix = format;
747 c_fix_arg = "#define UINT8_MAX (255)\n"
748 "#define UINT16_MAX (65535)";
749 test_text = "#define UINT8_MAX (255U)\n"
750 "#define UINT16_MAX (65535U)";
754 * aix_stdint_2
756 fix = {
757 hackname = aix_stdint_2;
758 mach = "*-*-aix*";
759 files = stdint-aix.h, stdint.h;
760 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
761 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
762 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
763 "#else\n"
764 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
765 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
766 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
767 c_fix = format;
768 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
769 "#define INTPTR_MAX 9223372036854775807L\n"
770 "#define UINTPTR_MAX 18446744073709551615UL\n"
771 "#else\n"
772 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
773 "#define INTPTR_MAX 2147483647L\n"
774 "#define UINTPTR_MAX 4294967295UL";
775 test_text = "#define INTPTR_MIN INT64_MIN\n"
776 "#define INTPTR_MAX INT64_MAX\n"
777 "#define UINTPTR_MAX UINT64_MAX\n"
778 "#else\n"
779 "#define INTPTR_MIN INT32_MIN\n"
780 "#define INTPTR_MAX INT32_MAX\n"
781 "#define UINTPTR_MAX UINT32_MAX";
785 * aix_stdint_3
787 fix = {
788 hackname = aix_stdint_3;
789 mach = "*-*-aix*";
790 files = stdint-aix.h, stdint.h;
791 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
792 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
793 "#else\n"
794 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
795 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
796 c_fix = format;
797 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
798 "#define PTRDIFF_MAX 9223372036854775807L\n"
799 "#else\n"
800 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
801 "#define PTRDIFF_MAX 2147483647L";
802 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
803 "#define PTRDIFF_MAX INT64_MAX\n"
804 "#else\n"
805 "#define PTRDIFF_MIN INT32_MIN\n"
806 "#define PTRDIFF_MAX INT32_MAX";
810 * aix_stdint_4
812 fix = {
813 hackname = aix_stdint_4;
814 mach = "*-*-aix*";
815 files = stdint-aix.h, stdint.h;
816 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
817 "#else\n"
818 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
819 c_fix = format;
820 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
821 "#else\n"
822 "#define SIZE_MAX 4294967295UL";
823 test_text = "#define SIZE_MAX UINT64_MAX\n"
824 "#else\n"
825 "#define SIZE_MAX UINT32_MAX";
829 * aix_stdint_5
831 fix = {
832 hackname = aix_stdint_5;
833 mach = "*-*-aix*";
834 files = stdint-aix.h, stdint.h;
835 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
836 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
837 c_fix = format;
838 c_fix_arg = "#define UINT8_C(c) c\n"
839 "#define UINT16_C(c) c";
840 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
841 "#define UINT16_C(c) __CONCAT__(c,U)";
845 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
846 * in an otherwise harmless (and #ifed out) macro definition
848 fix = {
849 hackname = aix_sysmachine;
850 files = sys/machine.h;
851 select = "\\\\ +\n";
852 c_fix = format;
853 c_fix_arg = "\\\n";
854 test_text = "#define FOO \\\n"
855 " bar \\ \n baz \\ \n bat";
859 * sys/wait.h on AIX 5.2 defines macros that have both signed and
860 * unsigned types in conditional expressions.
862 fix = {
863 hackname = aix_syswait_2;
864 files = sys/wait.h;
865 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
866 c_fix = format;
867 c_fix_arg = "? (int)%1";
868 test_text = "#define WSTOPSIG(__x) "
869 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
873 * sys/signal.h on some versions of AIX uses volatile in the typedef of
874 * sig_atomic_t, which causes gcc to generate a warning about duplicate
875 * volatile when a sig_atomic_t variable is declared volatile, as
876 * required by ANSI C.
878 fix = {
879 hackname = aix_volatile;
880 files = sys/signal.h;
881 select = "typedef volatile int sig_atomic_t";
882 c_fix = format;
883 c_fix_arg = "typedef int sig_atomic_t";
884 test_text = "typedef volatile int sig_atomic_t;";
888 * Fix __assert declaration in assert.h on Alpha OSF/1.
890 fix = {
891 hackname = alpha___assert;
892 files = "assert.h";
893 select = '__assert\(char \*, char \*, int\)';
894 c_fix = format;
895 c_fix_arg = "__assert(const char *, const char *, int)";
896 test_text = 'extern void __assert(char *, char *, int);';
900 * Fix assert macro in assert.h on Alpha OSF/1.
901 * The superfluous int cast breaks C++.
903 fix = {
904 hackname = alpha_assert;
905 files = "assert.h";
906 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
907 c_fix = format;
908 c_fix_arg = "%1(EX)";
909 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
910 ': __assert(#EX, __FILE__, __LINE__))';
914 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
916 fix = {
917 hackname = alpha_getopt;
918 files = "stdio.h";
919 files = "stdlib.h";
920 select = 'getopt\(int, char \*\[\], *char \*\)';
921 c_fix = format;
922 c_fix_arg = "getopt(int, char *const[], const char *)";
923 test_text = 'extern int getopt(int, char *[], char *);';
927 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
929 fix = {
930 hackname = alpha_if_semicolon;
931 files = net/if.h;
932 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
933 c_fix = format;
934 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
935 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
939 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
941 fix = {
942 hackname = alpha_parens;
943 files = sym.h;
944 select = '#ifndef\(__mips64\)';
945 c_fix = format;
946 c_fix_arg = "#ifndef __mips64";
947 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
951 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
952 * And OpenBSD.
954 fix = {
955 hackname = alpha_sbrk;
956 files = unistd.h;
957 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
958 c_fix = format;
959 c_fix_arg = "void *sbrk(";
960 test_text = "extern char* sbrk(ptrdiff_t increment);";
964 * For C++, avoid any typedef or macro definition of bool,
965 * and use the built in type instead.
966 * HP/UX 10.20 also has it in curses_colr/curses.h.
968 fix = {
969 hackname = avoid_bool_define;
970 files = curses.h;
971 files = curses_colr/curses.h;
972 files = term.h;
973 files = tinfo.h;
975 select = "#[ \t]*define[ \t]+bool[ \t]";
976 bypass = "__cplusplus";
978 c_fix = format;
979 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
980 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
982 test_text = "# define bool\t char \n";
986 * avoid_bool_type
988 fix = {
989 hackname = avoid_bool_type;
990 files = curses.h;
991 files = curses_colr/curses.h;
992 files = term.h;
993 files = tinfo.h;
995 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
996 bypass = "__cplusplus";
998 c_fix = format;
999 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1001 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1005 * For C++, avoid any typedef definition of wchar_t,
1006 * and use the built in type instead.
1007 * Don't do this for headers that are smart enough to do the right
1008 * thing (recent [n]curses.h and Xlib.h).
1009 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1010 * and will be broken by the edit.
1013 fix = {
1014 hackname = avoid_wchar_t_type;
1016 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1017 bypass = "__cplusplus";
1018 bypass = "_LINUX_NLS_H";
1019 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1021 c_fix = format;
1022 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1024 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1028 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1030 fix = {
1031 hackname = bad_struct_term;
1032 files = curses.h;
1033 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1034 c_fix = format;
1035 c_fix_arg = "struct term;";
1037 test_text = 'typedef struct term;';
1041 * Fix one other error in this file:
1042 * a mismatched quote not inside a C comment.
1044 fix = {
1045 hackname = badquote;
1046 files = sundev/vuid_event.h;
1047 select = "doesn't";
1048 c_fix = format;
1049 c_fix_arg = "does not";
1051 test_text = "/* doesn't have matched single quotes */";
1055 * check for broken assert.h that needs stdio.h
1057 fix = {
1058 hackname = broken_assert_stdio;
1059 files = assert.h;
1060 select = stderr;
1061 bypass = "include.*stdio\\.h";
1062 c_fix = wrap;
1063 c_fix_arg = "#include <stdio.h>\n";
1064 test_text = "extern FILE* stderr;";
1068 * check for broken assert.h that needs stdlib.h
1070 fix = {
1071 hackname = broken_assert_stdlib;
1072 files = assert.h;
1073 select = 'exit *\(|abort *\(';
1074 bypass = "include.*stdlib\\.h";
1075 c_fix = wrap;
1076 c_fix_arg = "#ifdef __cplusplus\n"
1077 "#include <stdlib.h>\n"
1078 "#endif\n";
1079 test_text = "extern void exit ( int );";
1083 * Remove `extern double cabs' declarations from math.h.
1084 * This conflicts with C99. Discovered on AIX.
1085 * Darwin hides its broken cabs in architecture-specific subdirs.
1087 fix = {
1088 hackname = broken_cabs;
1089 files = math.h, "architecture/*/math.h";
1090 select = "^extern[ \t]+double[ \t]+cabs";
1092 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1093 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1095 test_text = "#ifdef __STDC__\n"
1096 "extern double cabs(struct dbl_hypot);\n"
1097 "#else\n"
1098 "extern double cabs();\n"
1099 "#endif\n"
1100 "extern double cabs ( _Complex z );";
1104 * Fixup Darwin's broken check for __builtin_nanf.
1106 fix = {
1107 hackname = broken_nan;
1109 * It is tempting to omit the first "files" entry. Do not.
1110 * The testing machinery will take the first "files" entry as the name
1111 * of a test file to play with. It would be a nuisance to have a directory
1112 * with the name "*".
1114 files = "architecture/ppc/math.h";
1115 files = "architecture/*/math.h";
1116 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1117 bypass = "powl";
1118 c_fix = format;
1119 c_fix_arg = "#if 1";
1120 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1124 * Various systems derived from BSD4.4 contain a macro definition
1125 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1126 * Known to be fixed in FreeBSD 5 system headers.
1128 fix = {
1129 hackname = bsd_stdio_attrs_conflict;
1130 mach = "*-*-*bsd*";
1131 mach = "*-*-*darwin*";
1132 files = stdio.h;
1133 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1134 c_fix = format;
1135 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1136 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1137 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1138 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1139 test_text = '#define vfscanf __svfscanf';
1143 * Fix various macros used to define ioctl numbers.
1144 * The traditional syntax was:
1146 * #define _CTRL(n, x) (('n'<<8)+x)
1147 * #define TCTRLCFOO _CTRL(T, 1)
1149 * but this does not work with the C standard, which disallows macro
1150 * expansion inside strings. We have to rewrite it thus:
1152 * #define _CTRL(n, x) ((n<<8)+x)
1153 * #define TCTRLCFOO _CTRL('T', 1)
1155 * The select expressions match too much, but the c_fix code is cautious.
1157 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1159 fix = {
1160 hackname = ctrl_quotes_def;
1161 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1162 c_fix = char_macro_def;
1163 c_fix_arg = "CTRL";
1166 * This is two tests in order to ensure that the "CTRL(c)" can
1167 * be selected in isolation from the multi-arg format
1169 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1170 test_text = "#define _CTRL(c) ('c'&037)";
1174 * Fix various macros used to define ioctl numbers.
1176 fix = {
1177 hackname = ctrl_quotes_use;
1178 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1179 c_fix = char_macro_use;
1180 c_fix_arg = "CTRL";
1181 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1185 * sys/mman.h on HP/UX is not C++ ready,
1186 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1188 * rpc/types.h on OSF1/2.0 is not C++ ready,
1189 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1191 * The problem is the declaration of malloc.
1193 fix = {
1194 hackname = cxx_unready;
1195 files = sys/mman.h;
1196 files = rpc/types.h;
1197 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1198 not within a macro. */
1199 bypass = '"C"|__BEGIN_DECLS';
1201 c_fix = wrap;
1202 c_fix_arg = "#ifdef __cplusplus\n"
1203 "extern \"C\" {\n"
1204 "#endif\n";
1205 c_fix_arg = "#ifdef __cplusplus\n"
1206 "}\n"
1207 "#endif\n";
1208 test_text = "extern void* malloc( size_t );";
1212 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1213 * you have to not use "" includes.
1215 fix = {
1216 hackname = darwin_9_long_double_funcs_2;
1217 mach = "*-*-darwin7.9*";
1218 files = math.h;
1219 select = '#include[ \t]+\"';
1220 c_fix = format;
1221 c_fix_arg = "%1<%2.h>";
1223 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1225 test_text = '#include "architecture/ppc/math.h"';
1229 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1230 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1232 fix = {
1233 hackname = darwin_externc;
1234 mach = "*-*-darwin*";
1235 files = mach-o/swap.h;
1236 files = mach/mach_time.h;
1237 files = mach/mach_traps.h;
1238 files = mach/message.h;
1239 files = mach/mig.h;
1240 files = mach/semaphore.h;
1241 bypass = "extern \"C\"";
1242 bypass = "__BEGIN_DECLS";
1243 c_fix = wrap;
1244 c_fix_arg = "#ifdef __cplusplus\n"
1245 "extern \"C\" {\n"
1246 "#endif\n";
1247 c_fix_arg = "#ifdef __cplusplus\n"
1248 "}\n"
1249 "#endif\n";
1250 test_text = "extern void swap_fat_header();\n";
1254 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1255 * bad __GNUC__ tests.
1257 fix = {
1258 hackname = darwin_gcc4_breakage;
1259 mach = "*-*-darwin*";
1260 files = AvailabilityMacros.h;
1261 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1262 c_fix = format;
1263 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1264 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1265 "(__GNUC_MINOR__ >= 1)\n";
1269 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1270 * why would you ever put it in a system header file?
1272 fix = {
1273 hackname = darwin_private_extern;
1274 mach = "*-*-darwin*";
1275 files = mach-o/dyld.h;
1276 select = "__private_extern__ [a-z_]+ _dyld_";
1277 c_fix = format;
1278 c_fix_arg = "extern";
1279 c_fix_arg = "__private_extern__";
1280 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1281 "const char *dyld_func_name,\n"
1282 "unsigned long *address);\n";
1286 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1287 * unsigned constants.
1289 fix = {
1290 hackname = darwin_stdint_1;
1291 mach = "*-*-darwin*";
1292 files = stdint-darwin.h, stdint.h;
1293 c_fix = format;
1294 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1295 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1296 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1297 test_text = "#define UINT8_C(v) (v ## U)\n"
1298 "#define UINT16_C(v) (v ## U)";
1302 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1303 * with wrong types.
1305 fix = {
1306 hackname = darwin_stdint_2;
1307 mach = "*-*-darwin*";
1308 files = stdint-darwin.h, stdint.h;
1309 c_fix = format;
1310 c_fix_arg = "#if __WORDSIZE == 64\n"
1311 "#define INTPTR_MAX 9223372036854775807L\n"
1312 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1313 "#else\n"
1314 "#define INTPTR_MAX 2147483647L\n"
1315 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1316 "#endif";
1317 select = "#if __WORDSIZE == 64\n"
1318 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1319 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1320 "#else\n"
1321 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1322 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1323 "#endif";
1324 test_text = "#if __WORDSIZE == 64\n"
1325 "#define INTPTR_MIN INT64_MIN\n"
1326 "#define INTPTR_MAX INT64_MAX\n"
1327 "#else\n"
1328 "#define INTPTR_MIN INT32_MIN\n"
1329 "#define INTPTR_MAX INT32_MAX\n"
1330 "#endif";
1334 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1336 fix = {
1337 hackname = darwin_stdint_3;
1338 mach = "*-*-darwin*";
1339 files = stdint-darwin.h, stdint.h;
1340 c_fix = format;
1341 c_fix_arg = "#if __WORDSIZE == 64\n"
1342 "#define UINTPTR_MAX 18446744073709551615UL\n"
1343 "#else\n"
1344 "#define UINTPTR_MAX 4294967295UL\n"
1345 "#endif";
1346 select = "#if __WORDSIZE == 64\n"
1347 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1348 "#else\n"
1349 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1350 "#endif";
1351 test_text = "#if __WORDSIZE == 64\n"
1352 "#define UINTPTR_MAX UINT64_MAX\n"
1353 "#else\n"
1354 "#define UINTPTR_MAX UINT32_MAX\n"
1355 "#endif";
1359 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1361 fix = {
1362 hackname = darwin_stdint_4;
1363 mach = "*-*-darwin*";
1364 files = stdint-darwin.h, stdint.h;
1365 c_fix = format;
1366 c_fix_arg = "#if __WORDSIZE == 64\n"
1367 "#define SIZE_MAX 18446744073709551615UL\n"
1368 "#else\n"
1369 "#define SIZE_MAX 4294967295UL\n"
1370 "#endif";
1371 select = "#if __WORDSIZE == 64\n"
1372 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1373 "#else\n"
1374 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1375 "#endif";
1376 test_text = "#if __WORDSIZE == 64\n"
1377 "#define SIZE_MAX UINT64_MAX\n"
1378 "#else\n"
1379 "#define SIZE_MAX UINT32_MAX\n"
1380 "#endif";
1384 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1385 * with a wrong type.
1387 fix = {
1388 hackname = darwin_stdint_5;
1389 mach = "*-*-darwin*";
1390 files = stdint-darwin.h, stdint.h;
1391 c_fix = format;
1392 c_fix_arg = "#if __WORDSIZE == 64\n"
1393 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1394 "#define INTMAX_MAX 9223372036854775807L\n"
1395 "#define UINTMAX_MAX 18446744073709551615UL\n"
1396 "#else\n"
1397 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1398 "#define INTMAX_MAX 9223372036854775807LL\n"
1399 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1400 "#endif";
1401 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1402 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1403 "\n"
1404 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1405 test_text = "#define INTMAX_MIN INT64_MIN\n"
1406 "#define INTMAX_MAX INT64_MAX\n"
1407 "\n"
1408 "#define UINTMAX_MAX UINT64_MAX";
1412 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1413 * with a wrong type.
1415 fix = {
1416 hackname = darwin_stdint_6;
1417 mach = "*-*-darwin*";
1418 files = stdint-darwin.h, stdint.h;
1419 c_fix = format;
1420 c_fix_arg = "#if __WORDSIZE == 64\n"
1421 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1422 "#define PTRDIFF_MAX 9223372036854775807L\n"
1423 "#else\n"
1424 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1425 "#define PTRDIFF_MAX 2147483647\n"
1426 "#endif";
1427 select = "#if __WORDSIZE == 64\n"
1428 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1429 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1430 "#else\n"
1431 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1432 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1433 "#endif";
1434 test_text = "#if __WORDSIZE == 64\n"
1435 "#define PTRDIFF_MIN INT64_MIN\n"
1436 "#define PTRDIFF_MAX INT64_MAX\n"
1437 "#else\n"
1438 "#define PTRDIFF_MIN INT32_MIN\n"
1439 "#define PTRDIFF_MAX INT32_MAX\n"
1440 "#endif";
1444 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1445 * with a wrong type.
1447 fix = {
1448 hackname = darwin_stdint_7;
1449 mach = "*-*-darwin*";
1450 files = stdint-darwin.h, stdint.h;
1451 c_fix = format;
1452 c_fix_arg = "#if __WORDSIZE == 64\n"
1453 "#define INTMAX_C(v) (v ## L)\n"
1454 "#define UINTMAX_C(v) (v ## UL)\n"
1455 "#else\n"
1456 "#define INTMAX_C(v) (v ## LL)\n"
1457 "#define UINTMAX_C(v) (v ## ULL)\n"
1458 "#endif";
1459 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1460 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1461 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1462 "#define UINTMAX_C(v) (v ## ULL)";
1466 * Fix <c_asm.h> on Digital UNIX V4.0:
1467 * It contains a prototype for a DEC C internal asm() function,
1468 * clashing with gcc's asm keyword. So protect this with __DECC.
1470 fix = {
1471 hackname = dec_intern_asm;
1472 files = c_asm.h;
1473 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1474 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1475 "#endif\n";
1476 test_text =
1477 "float fasm {\n"
1478 " ... asm stuff ...\n"
1479 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1483 * Fix typo in <wchar.h> on DJGPP 2.03.
1485 fix = {
1486 hackname = djgpp_wchar_h;
1487 file = wchar.h;
1488 select = "__DJ_wint_t";
1489 bypass = "sys/djtypes.h";
1490 c_fix = format;
1491 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1492 c_fix_arg = "#include <stddef.h>";
1493 test_text = "#include <stddef.h>\n"
1494 "extern __DJ_wint_t x;\n";
1498 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1500 fix = {
1501 hackname = ecd_cursor;
1502 files = "sunwindow/win_lock.h";
1503 files = "sunwindow/win_cursor.h";
1504 select = 'ecd\.cursor';
1505 c_fix = format;
1506 c_fix_arg = 'ecd_cursor';
1508 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1512 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1513 * that fails when compiling for SSE-less 32-bit x86.
1515 fix = {
1516 hackname = feraiseexcept_nosse_divbyzero;
1517 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1518 files = bits/fenv.h, '*/bits/fenv.h';
1519 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1520 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1521 bypass = "\"fdivp .*; fwait\"";
1523 c_fix = format;
1524 c_fix_arg = <<- _EOText_
1525 # ifdef __SSE_MATH__
1527 # else
1528 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1529 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1530 # endif
1531 _EOText_;
1533 test_text = <<- _EOText_
1534 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1535 _EOText_;
1539 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1540 * that fails when compiling for SSE-less 32-bit x86.
1542 fix = {
1543 hackname = feraiseexcept_nosse_invalid;
1544 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1545 files = bits/fenv.h, '*/bits/fenv.h';
1546 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1547 ": \"x\" \\(__f\\)\\);$";
1548 bypass = "\"fdiv .*; fwait\"";
1550 c_fix = format;
1551 c_fix_arg = <<- _EOText_
1552 # ifdef __SSE_MATH__
1554 # else
1555 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1556 %1 : "=t" (__f) : "0" (__f));
1557 # endif
1558 _EOText_;
1560 test_text = <<- _EOText_
1561 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1562 _EOText_;
1566 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1567 * neither the existence of GCC 3 nor its exact feature set yet break
1568 * (by design?) when __GNUC__ is set beyond 2.
1570 fix = {
1571 hackname = freebsd_gcc3_breakage;
1572 mach = "*-*-freebsd*";
1573 files = sys/cdefs.h;
1574 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1575 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1576 c_fix = format;
1577 c_fix_arg = '%0 || __GNUC__ >= 3';
1578 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1582 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1583 * neither the existence of GCC 4 nor its exact feature set yet break
1584 * (by design?) when __GNUC__ is set beyond 3.
1586 fix = {
1587 hackname = freebsd_gcc4_breakage;
1588 mach = "*-*-freebsd*";
1589 files = sys/cdefs.h;
1590 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1591 c_fix = format;
1592 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1593 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1597 * Some versions of glibc don't expect the C99 inline semantics.
1599 fix = {
1600 hackname = glibc_c99_inline_1;
1601 files = features.h, '*/features.h';
1602 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1603 c_fix = format;
1604 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1605 test_text = <<-EOT
1606 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1607 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1608 # define __USE_EXTERN_INLINES 1
1609 #endif
1610 EOT;
1614 * Similar, but a version that didn't have __NO_INLINE__
1616 fix = {
1617 hackname = glibc_c99_inline_1a;
1618 files = features.h, '*/features.h';
1619 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1620 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1621 c_fix = format;
1622 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1623 test_text = <<-EOT
1624 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1625 # define __USE_EXTERN_INLINES 1
1626 #endif
1627 EOT;
1631 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1632 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1633 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1635 fix = {
1636 hackname = glibc_c99_inline_2;
1637 files = sys/stat.h, '*/sys/stat.h';
1638 select = "extern __inline__ int";
1639 sed = "s/extern int \\(stat\\)/"
1640 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1641 "__inline__ int \\1/";
1642 sed = "s/extern int \\([lf]stat\\)/"
1643 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1644 "__inline__ int \\1/";
1645 sed = "s/extern int \\(mknod\\)/"
1646 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1647 "__inline__ int \\1/";
1648 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1649 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1650 "__inline__ int __REDIRECT\\1 (\\2/";
1651 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1652 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1653 "__inline__ int __REDIRECT\\1 (\\2/";
1654 sed = "s/^extern __inline__ int/"
1655 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1656 "__inline__ int/";
1657 test_text = <<-EOT
1658 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1659 extern __inline__ int
1660 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1662 EOT;
1666 * glibc_c99_inline_3
1668 fix = {
1669 hackname = glibc_c99_inline_3;
1670 files = bits/string2.h, '*/bits/string2.h';
1671 select = "extern __inline";
1672 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1673 c_fix = format;
1674 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1675 c_fix_arg = "^# ifdef __cplusplus$";
1676 test_text = <<-EOT
1677 # ifdef __cplusplus
1678 # define __STRING_INLINE inline
1679 # else
1680 # define __STRING_INLINE extern __inline
1681 # endif
1682 EOT;
1686 * glibc_c99_inline_4
1688 fix = {
1689 hackname = glibc_c99_inline_4;
1690 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1691 pthread.h, '*/pthread.h';
1692 bypass = "__extern_inline|__gnu_inline__";
1693 select = "(^| )extern __inline";
1694 c_fix = format;
1695 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1696 test_text = <<-EOT
1697 __extension__ extern __inline unsigned int
1698 extern __inline unsigned int
1699 EOT;
1702 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1703 * so we replace them with versions that correspond to the
1704 * definition.
1706 fix = {
1707 hackname = glibc_mutex_init;
1708 files = pthread.h;
1709 select = '\{ *\{ *0, *\} *\}';
1710 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1711 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1712 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1713 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1714 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1715 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1716 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1717 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1718 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1719 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1720 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1721 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1722 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1723 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1724 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1725 "N;s/^[ \t]*#[ \t]*"
1726 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1727 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1728 "# \\1\\\n"
1729 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1730 "# else\\\n"
1731 "# \\1\\\n"
1732 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1733 "# endif/";
1734 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1735 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1736 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1737 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1739 test_text = <<- _EOText_
1740 #define PTHREAD_MUTEX_INITIALIZER \\
1741 { { 0, } }
1742 #ifdef __USE_GNU
1743 # if __WORDSIZE == 64
1744 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1745 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1746 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1747 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1748 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1749 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1750 # else
1751 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1752 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1753 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1754 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1755 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1756 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1757 # endif
1758 #endif
1759 # define PTHREAD_RWLOCK_INITIALIZER \\
1760 { { 0, } }
1761 # ifdef __USE_GNU
1762 # if __WORDSIZE == 64
1763 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1764 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1765 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1766 # else
1767 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1768 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1769 # endif
1770 # endif
1771 #define PTHREAD_COND_INITIALIZER { { 0, } }
1772 _EOText_;
1775 /* glibc versions before 2.5 have a version of stdint.h that defines
1776 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1777 versions with stdint.h based on those glibc versions. */
1778 fix = {
1779 hackname = glibc_stdint;
1780 files = stdint.h;
1781 select = "GNU C Library";
1782 c_fix = format;
1783 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1784 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1785 test_text = "/* This file is part of the GNU C Library. */\n"
1786 "# define UINT8_C(c)\tc ## U\n"
1787 "# define UINT16_C(c)\tc ## U";
1790 /* Some versions of glibc have a version of bits/string2.h that
1791 produces "value computed is not used" warnings from strncpy; fix
1792 this definition by using __builtin_strncpy instead as in newer
1793 versions. */
1794 fix = {
1795 hackname = glibc_strncpy;
1796 files = bits/string2.h, '*/bits/string2.h';
1797 bypass = "__builtin_strncpy";
1798 c_fix = format;
1799 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1800 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1801 test_text = <<-EOT
1802 # define strncpy(dest, src, n) \
1803 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1804 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1805 ? (char *) memcpy (dest, src, n) \\
1806 : strncpy (dest, src, n)) \\
1807 : strncpy (dest, src, n)))
1808 EOT;
1812 /* glibc's tgmath.h relies on an expression that is not an integer
1813 constant expression being treated as it was by GCC 4.4 and
1814 earlier. */
1815 fix = {
1816 hackname = glibc_tgmath;
1817 files = tgmath.h;
1818 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1819 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1820 c_fix = format;
1821 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1822 "(__builtin_classify_type ((type) 0) == 9 && "
1823 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1824 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1828 * Fix these files to use the types we think they should for
1829 * ptrdiff_t, size_t, and wchar_t.
1831 * This defines the types in terms of macros predefined by our 'cpp'.
1832 * This is supposedly necessary for glibc's handling of these types.
1833 * It's probably not necessary for anyone else, but it doesn't hurt.
1835 fix = {
1836 hackname = gnu_types;
1837 files = "sys/types.h";
1838 files = "stdlib.h";
1839 files = "sys/stdtypes.h";
1840 files = "stddef.h";
1841 files = "memory.h";
1842 files = "unistd.h";
1843 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1844 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1845 c_fix = gnu_type;
1846 /* The Solaris 10 headers already define these types correctly. */
1847 mach = '*-*-solaris2.1[0-9]*';
1848 not_machine = true;
1850 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1851 "typedef uint_t size_t; /* uint_t */\n"
1852 "typedef ushort_t wchar_t; /* ushort_t */";
1856 * Fix HP & Sony's use of "../machine/xxx.h"
1857 * to refer to: <machine/xxx.h>
1859 fix = {
1860 hackname = hp_inline;
1861 files = sys/spinlock.h;
1862 files = machine/machparam.h;
1863 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1865 c_fix = format;
1866 c_fix_arg = "%1<machine/%2.h>";
1868 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1869 '([a-z]+)\.h"';
1871 test_text = ' # include "../machine/mumble.h"';
1875 * Check for (...) in C++ code in HP/UX sys/file.h.
1877 fix = {
1878 hackname = hp_sysfile;
1879 files = sys/file.h;
1880 select = "HPUX_SOURCE";
1882 c_fix = format;
1883 c_fix_arg = "(struct file *, ...)";
1884 c_fix_arg = '\(\.\.\.\)';
1886 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1890 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1891 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1893 fix = {
1894 hackname = hppa_hpux_fp_macros;
1895 mach = "hppa*-hp-hpux11*";
1896 files = math.h;
1897 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1898 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1899 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1900 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1901 "#[ \t]*define[ \t]*FP_NAN.*\n";
1902 c_fix = format;
1903 c_fix_arg = <<- _EOFix_
1904 #endif /* _INCLUDE_HPUX_SOURCE */
1906 #if defined(_INCLUDE_HPUX_SOURCE) || \
1907 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1908 %0#endif
1910 #ifdef _INCLUDE_HPUX_SOURCE
1912 _EOFix_;
1914 test_text =
1915 "# define FP_NORMAL 0\n"
1916 "# define FP_ZERO 1\n"
1917 "# define FP_INFINITE 2\n"
1918 "# define FP_SUBNORMAL 3\n"
1919 "# define FP_NAN 4\n";
1923 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1924 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1926 fix = {
1927 hackname = hpux10_cpp_pow_inline;
1928 files = fixinc-test-limits.h, math.h;
1929 select = <<- END_POW_INLINE
1930 ^# +ifdef +__cplusplus
1932 +inline +double +pow\(double +__d,int +__expon\) +\{
1933 [ ]+return +pow\(__d,\(double\)__expon\);
1935 +extern +"C" +\{
1936 #else
1937 # +endif
1938 END_POW_INLINE;
1940 c_fix = format;
1941 c_fix_arg = "";
1943 test_text =
1944 "# ifdef __cplusplus\n"
1945 " }\n"
1946 " inline double pow(double __d,int __expon) {\n"
1947 "\t return pow(__d,(double)__expon);\n"
1948 " }\n"
1949 ' extern "C"' " {\n"
1950 "#else\n"
1951 "# endif";
1954 fix = {
1955 hackname = hpux11_cpp_pow_inline;
1956 files = math.h;
1957 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1958 " +return pow\\(d, \\(double\\)expon\\);\n"
1959 " +\\}\n";
1960 c_fix = format;
1961 c_fix_arg = "";
1963 test_text =
1964 " inline double pow(double d,int expon) {\n"
1965 " return pow(d, (double)expon);\n"
1966 " }\n";
1970 * Fix hpux 10.X missing ctype declarations 1
1972 fix = {
1973 hackname = hpux10_ctype_declarations1;
1974 files = ctype.h;
1975 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1976 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1977 c_fix = format;
1978 c_fix_arg = "#ifdef _PROTOTYPES\n"
1979 "extern int __tolower(int);\n"
1980 "extern int __toupper(int);\n"
1981 "#else /* NOT _PROTOTYPES */\n"
1982 "extern int __tolower();\n"
1983 "extern int __toupper();\n"
1984 "#endif /* _PROTOTYPES */\n\n"
1985 "%0\n";
1987 test_text = "# define _toupper(__c) __toupper(__c)\n";
1991 * Fix hpux 10.X missing ctype declarations 2
1993 fix = {
1994 hackname = hpux10_ctype_declarations2;
1995 files = ctype.h;
1996 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1997 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1998 c_fix = format;
1999 c_fix_arg = "%0\n\n"
2000 "#ifdef _PROTOTYPES\n"
2001 " extern int _isalnum(int);\n"
2002 " extern int _isalpha(int);\n"
2003 " extern int _iscntrl(int);\n"
2004 " extern int _isdigit(int);\n"
2005 " extern int _isgraph(int);\n"
2006 " extern int _islower(int);\n"
2007 " extern int _isprint(int);\n"
2008 " extern int _ispunct(int);\n"
2009 " extern int _isspace(int);\n"
2010 " extern int _isupper(int);\n"
2011 " extern int _isxdigit(int);\n"
2012 "# else /* not _PROTOTYPES */\n"
2013 " extern int _isalnum();\n"
2014 " extern int _isalpha();\n"
2015 " extern int _iscntrl();\n"
2016 " extern int _isdigit();\n"
2017 " extern int _isgraph();\n"
2018 " extern int _islower();\n"
2019 " extern int _isprint();\n"
2020 " extern int _ispunct();\n"
2021 " extern int _isspace();\n"
2022 " extern int _isupper();\n"
2023 " extern int _isxdigit();\n"
2024 "#endif /* _PROTOTYPES */\n";
2026 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2027 " extern unsigned int *__SB_masks;\n";
2031 * Fix hpux 10.X missing stdio declarations
2033 fix = {
2034 hackname = hpux10_stdio_declarations;
2035 files = stdio.h;
2036 select = "^#[ \t]*define _iob[ \t]*__iob";
2037 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2038 c_fix = format;
2039 c_fix_arg = "%0\n\n"
2040 "# if defined(__STDC__) || defined(__cplusplus)\n"
2041 " extern int snprintf(char *, size_t, const char *, ...);\n"
2042 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2043 "# else /* not __STDC__) || __cplusplus */\n"
2044 " extern int snprintf();\n"
2045 " extern int vsnprintf();\n"
2046 "# endif /* __STDC__) || __cplusplus */\n";
2048 test_text = "# define _iob __iob\n";
2052 * Make sure hpux defines abs in header.
2054 fix = {
2055 hackname = hpux11_abs;
2056 mach = "*-hp-hpux11*";
2057 files = stdlib.h;
2058 select = "ifndef _MATH_INCLUDED";
2059 c_fix = format;
2060 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2061 test_text = "#ifndef _MATH_INCLUDED";
2065 * hpux sendfile()
2067 fix = {
2068 hackname = hpux11_extern_sendfile;
2069 mach = "*-hp-hpux11.[12]*";
2070 files = sys/socket.h;
2071 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2072 c_fix = format;
2073 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2074 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2075 " const struct iovec *, int));\n";
2079 * hpux sendpath()
2081 fix = {
2082 hackname = hpux11_extern_sendpath;
2083 mach = "*-hp-hpux11.[12]*";
2084 files = sys/socket.h;
2085 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2086 c_fix = format;
2087 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2088 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2089 " const struct iovec *, int));\n";
2093 * Keep HP-UX 11 from stomping on C++ math namespace
2094 * with defines for fabsf.
2096 fix = {
2097 hackname = hpux11_fabsf;
2098 files = math.h;
2099 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2100 bypass = "__cplusplus";
2102 c_fix = format;
2103 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2105 test_text =
2106 "#ifdef _PA_RISC\n"
2107 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2108 "#endif";
2112 * Fix C99 constant in __POINTER_SET define.
2114 fix = {
2115 hackname = hpux11_pthread_const;
2116 mach = "*-hp-hpux11.[0-3]*";
2117 files = sys/pthread.h;
2118 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2120 c_fix = format;
2121 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2122 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2126 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2127 * being defined by having it define _hpux_size_t instead.
2129 fix = {
2130 hackname = hpux11_size_t;
2131 mach = "*-hp-hpux11*";
2132 select = "__size_t";
2134 c_fix = format;
2135 c_fix_arg = "_hpux_size_t";
2137 test_text =
2138 "#define __size_t size_t\n"
2139 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2143 * Fix hpux 11.00 broken snprintf declaration
2144 * (third argument is char *, needs to be const char * to prevent
2145 * spurious warnings with -Wwrite-strings or in C++).
2147 fix = {
2148 hackname = hpux11_snprintf;
2149 files = stdio.h;
2150 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2151 ' *(char *\*, *\.\.\.\);)';
2152 c_fix = format;
2153 c_fix_arg = '%1 const %3';
2155 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2156 "extern int snprintf(char *, __size_t, char *, ...);\n"
2157 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2161 * Fix hpux 11.00 broken vsnprintf declaration
2163 fix = {
2164 hackname = hpux11_vsnprintf;
2165 files = stdio.h;
2166 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2167 'const char \*,) __va__list\);';
2168 c_fix = format;
2169 c_fix_arg = "%1 __va_list);";
2171 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2172 ' __va__list);';
2176 * get rid of bogus inline definitions in HP-UX 8.0
2178 fix = {
2179 hackname = hpux8_bogus_inlines;
2180 files = math.h;
2181 select = inline;
2182 bypass = "__GNUG__";
2183 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2184 "@extern \"C\" int abs(int);@";
2185 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2186 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2187 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2188 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2189 "inline double sqr(double v) { return v**0.5; }";
2193 * hpux intptr
2195 fix = {
2196 hackname = hpux_c99_intptr;
2197 mach = "*-hp-hpux11.3*";
2198 files = stdint-hpux11.h, stdint.h;
2199 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2200 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2201 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2202 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2203 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2204 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2205 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2206 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2207 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2208 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2209 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2210 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2211 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2212 "#define PTRDIFF_MIN INT32_MIN\n"
2213 "#define INTPTR_MAX INT32_MAX\n"
2214 "#define INTPTR_MIN INT32_MIN\n"
2215 "#define UINTPTR_MAX UINT32_MAX\n"
2216 "#define SIZE_MAX UINT32_MAX\n";
2220 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2222 fix = {
2223 hackname = hpux_c99_inttypes;
2224 mach = "*-hp-hpux11.[23]*";
2225 files = inttypes.h;
2226 files = stdint-hpux11.h, stdint.h;
2227 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2228 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2229 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2230 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2231 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2232 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2233 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2234 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2235 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2236 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2237 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2238 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2242 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2244 fix = {
2245 hackname = hpux_c99_inttypes2;
2246 mach = "*-hp-hpux11.2*";
2247 files = stdint-hpux11.h, stdint.h;
2248 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2249 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2250 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2251 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2252 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2253 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2254 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2255 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2256 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2257 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2258 "# define INT16_C(__c) ((short)(__c))\n"
2259 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2263 * Fix hpux broken ctype macros
2265 fix = {
2266 hackname = hpux_ctype_macros;
2267 files = ctype.h;
2268 select = '((: |\()__SB_masks \? )'
2269 '(__SB_masks\[__(alnum|c)\] & _IS)';
2270 c_fix = format;
2271 c_fix_arg = "%1(int)%3";
2273 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2274 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2278 * hpux errno()
2280 fix = {
2281 hackname = hpux_extern_errno;
2282 mach = "*-hp-hpux10.*";
2283 mach = "*-hp-hpux11.[0-2]*";
2284 files = errno.h;
2285 select = "^[ \t]*extern int errno;$";
2286 c_fix = format;
2287 c_fix_arg = "#ifdef __cplusplus\n"
2288 "extern \"C\" {\n"
2289 "#endif\n"
2290 "%0\n"
2291 "#ifdef __cplusplus\n"
2292 "}\n"
2293 "#endif";
2294 test_text = " extern int errno;\n";
2298 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2300 fix = {
2301 hackname = hpux_htonl;
2302 files = netinet/in.h;
2303 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2304 "(/\\*\n"
2305 " \\* Macros for number representation conversion\\.\n"
2306 " \\*/\n"
2307 "#ifndef ntohl)";
2308 c_fix = format;
2309 c_fix_arg = "#if 1\n%1";
2311 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2312 "/*\n"
2313 " * Macros for number representation conversion.\n"
2314 " */\n"
2315 "#ifndef ntohl\n"
2316 "#define ntohl(x) (x)\n"
2317 "#define ntohs(x) (x)\n"
2318 "#define htonl(x) (x)\n"
2319 "#define htons(x) (x)\n"
2320 "#endif\n"
2321 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2325 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2327 fix = {
2328 hackname = hpux_imaginary_i;
2329 mach = "ia64-hp-hpux11.*";
2330 files = complex.h;
2331 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2332 c_fix = format;
2333 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2334 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2338 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2340 fix = {
2341 hackname = hpux_inttype_int8_t;
2342 mach = "*-hp-hpux1[01].*";
2343 files = sys/_inttypes.h;
2344 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2345 c_fix = format;
2346 c_fix_arg = "typedef signed char int%18_t;";
2347 test_text = "typedef char int_least8_t;\n"
2348 "typedef char int8_t;\n";
2352 * HP-UX long_double
2354 fix = {
2355 hackname = hpux_long_double;
2356 mach = "*-*-hpux10*";
2357 mach = "*-*-hpux11.[012]*";
2358 files = stdlib.h;
2359 select = "extern[ \t]long_double[ \t]strtold";
2360 bypass = "long_double_t";
2361 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2362 sed = "s/long_double/long double/g";
2364 test_text = "# ifndef _LONG_DOUBLE\n"
2365 "# define _LONG_DOUBLE\n"
2366 " typedef struct {\n"
2367 " unsigned int word1, word2, word3, word4;\n"
2368 " } long_double;\n"
2369 "# endif /* _LONG_DOUBLE */\n"
2370 "extern long_double strtold(const char *, char **);\n";
2374 * We cannot use the above rule on 11.31 because it removes the strtold
2375 * definition. ia64 is OK with no hack, PA needs some help.
2377 fix = {
2378 hackname = hpux_long_double_2;
2379 mach = "hppa*-*-hpux11.3*";
2380 files = stdlib.h;
2381 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2382 "defined\\(_PROTOTYPES\\) \\|\\| "
2383 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2384 c_fix = format;
2385 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2387 test_text = "# if !defined(__ia64) || "
2388 "!defined(_PROTOTYPES) || "
2389 "defined(_LONG_DOUBLE_STRUCT)\n";
2393 * Add missing braces to pthread initializer defines.
2395 fix = {
2396 hackname = hpux_pthread_initializers;
2397 mach = "*-hp-hpux11.[0-3]*";
2398 files = sys/pthread.h;
2399 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2400 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2401 sed = "s@^[ \t]*1,[ \t]*\\\\"
2402 "@\t{ 1, 0 }@";
2403 sed = "/^[ \t]*0$/d";
2404 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2405 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2406 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2407 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2408 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2409 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2410 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2411 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2412 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2413 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2414 sed = "s@__PTHREAD_COND_VALID, 0"
2415 "@{ __PTHREAD_COND_VALID, 0 }@";
2416 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2417 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2418 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2419 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2420 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2421 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2422 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2423 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2424 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2425 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2426 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2427 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2428 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2429 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2430 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2431 "}\n";
2435 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2436 * type and mpinfou is only defined when _KERNEL is set.
2438 fix = {
2439 hackname = hpux_spu_info;
2440 mach = "*-hp-hpux*";
2442 * It is tempting to omit the first "files" entry. Do not.
2443 * The testing machinery will take the first "files" entry as the name
2444 * of a test file to play with. It would be a nuisance to have a directory
2445 * with the name "*".
2447 files = "ia64/sys/getppdp.h";
2448 files = "*/sys/getppdp.h";
2449 select = "^.*extern.*spu_info.*";
2451 c_fix = format;
2452 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2454 test_text = "extern union mpinfou spu_info[];";
2458 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2460 fix = {
2461 hackname = hpux_stdint_least_fast;
2462 mach = "*-hp-hpux11.2*";
2463 files = stdint-hpux11.h, stdint.h;
2464 select =
2465 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2466 c_fix = format;
2467 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2468 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2469 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2470 _EOFix_;
2474 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2476 fix = {
2477 hackname = hpux_systime;
2478 files = sys/time.h;
2479 select = "^extern struct sigevent;";
2481 c_fix = format;
2482 c_fix_arg = "struct sigevent;";
2484 test_text = 'extern struct sigevent;';
2488 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2490 fix = {
2491 hackname = huge_val_hex;
2492 files = bits/huge_val.h, '*/bits/huge_val.h';
2493 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2494 bypass = "__builtin_huge_val";
2496 c_fix = format;
2497 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2499 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2503 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2505 fix = {
2506 hackname = huge_valf_hex;
2507 files = bits/huge_val.h, '*/bits/huge_val.h';
2508 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2509 bypass = "__builtin_huge_valf";
2511 c_fix = format;
2512 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2514 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2518 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2520 fix = {
2521 hackname = huge_vall_hex;
2522 files = bits/huge_val.h, '*/bits/huge_val.h';
2523 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2524 bypass = "__builtin_huge_vall";
2526 c_fix = format;
2527 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2529 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2533 * Fix return type of abort and free
2535 fix = {
2536 hackname = int_abort_free_and_exit;
2537 files = stdlib.h;
2538 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2539 bypass = "_CLASSIC_ANSI_TYPES";
2541 c_fix = format;
2542 c_fix_arg = "void\t%1(";
2544 test_text = "extern int abort(int);\n"
2545 "extern int free(void*);\n"
2546 "extern int exit(void*);";
2550 * Fix various macros used to define ioctl numbers.
2551 * The traditional syntax was:
2553 * #define _IO(n, x) (('n'<<8)+x)
2554 * #define TIOCFOO _IO(T, 1)
2556 * but this does not work with the C standard, which disallows macro
2557 * expansion inside strings. We have to rewrite it thus:
2559 * #define _IO(n, x) ((n<<8)+x)
2560 * #define TIOCFOO _IO('T', 1)
2562 * The select expressions match too much, but the c_fix code is cautious.
2564 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2566 fix = {
2567 hackname = io_quotes_def;
2568 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2569 c_fix = char_macro_def;
2570 c_fix_arg = "IO";
2571 test_text =
2572 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2573 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2574 "#define _IO(x,y) ('x'<<8|y)";
2575 test_text =
2576 "#define XX_IO(x) ('x'<<8|256)";
2580 * Fix the usage of the ioctl macro numbers.
2582 fix = {
2583 hackname = io_quotes_use;
2584 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2585 "\\( *[^,']";
2586 c_fix = char_macro_use;
2587 c_fix_arg = "IO";
2588 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2589 "#define TIOCFOO \\\\\n"
2590 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2594 * Check for missing ';' in struct
2596 fix = {
2597 hackname = ip_missing_semi;
2598 files = netinet/ip.h;
2599 select = "}$";
2600 sed = "/^struct/,/^};/s/}$/};/";
2601 test_text=
2602 "struct mumble {\n"
2603 " union {\n"
2604 " int x;\n"
2605 " }\n"
2606 "}; /* mumbled struct */\n";
2610 * Non-traditional "const" declaration in Irix's limits.h.
2612 fix = {
2613 hackname = irix_limits_const;
2614 files = fixinc-test-limits.h, limits.h;
2615 select = "^extern const ";
2616 c_fix = format;
2617 c_fix_arg = "extern __const ";
2618 test_text = "extern const char limit; /* test limits */";
2622 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2623 * taking char *. However, GCC uses void * for va_list, so
2624 * calling vfprintf with a va_list fails in C++. */
2625 fix = {
2626 hackname = irix_stdio_va_list;
2627 files = stdio.h;
2629 select = '/\* va_list \*/ char \*';
2630 c_fix = format;
2631 c_fix_arg = "__gnuc_va_list";
2632 test_text =
2633 "extern int printf( const char *, /* va_list */ char * );";
2637 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2638 * use / * * / to concatenate tokens.
2640 fix = {
2641 hackname = kandr_concat;
2642 files = "sparc/asm_linkage.h";
2643 files = "sun*/asm_linkage.h";
2644 files = "arm/as_support.h";
2645 files = "arm/mc_type.h";
2646 files = "arm/xcb.h";
2647 files = "dev/chardefmac.h";
2648 files = "dev/ps_irq.h";
2649 files = "dev/screen.h";
2650 files = "dev/scsi.h";
2651 files = "sys/tty.h";
2652 files = "Xm.acorn/XmP.h";
2653 files = bsd43/bsd43_.h;
2654 select = '/\*\*/';
2655 c_fix = format;
2656 c_fix_arg = '##';
2657 test_text = "#define __CONCAT__(a,b) a/**/b";
2661 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2662 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2663 * constant on recent versions of g++.
2665 fix = {
2666 hackname = linux_ia64_ucontext;
2667 files = "sys/ucontext.h";
2668 mach = "ia64-*-linux*";
2669 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2670 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2671 c_fix = format;
2672 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2673 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2674 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2678 * Remove header file warning from sys/time.h. Autoconf's
2679 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2680 * which causes warning on LynxOS. Remove the warning.
2682 fix = {
2683 hackname = lynxos_no_warning_in_sys_time_h;
2684 files = sys/time.h;
2685 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2686 c_fix = format;
2687 c_fix_arg = "";
2688 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2692 * Add missing declaration for putenv.
2694 fix = {
2695 hackname = lynxos_missing_putenv;
2696 mach = '*-*-lynxos*';
2697 files = stdlib.h;
2698 bypass = 'putenv[ \t]*\\(';
2699 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2700 c_fix = format;
2701 c_fix_arg = "%0\n"
2702 "extern int putenv _AP((char *));";
2703 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2704 test_text = "extern char *getenv _AP((const char *));";
2708 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2710 * On NetBSD, machine is a symbolic link to an architecture specific
2711 * directory name, so we can't match a specific file name here.
2713 fix = {
2714 hackname = machine_ansi_h_va_list;
2715 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2716 bypass = '__builtin_va_list';
2718 c_fix = format;
2719 c_fix_arg = "%1__builtin_va_list";
2720 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2722 test_text = " # define _BSD_VA_LIST_\tchar**";
2726 * Fix non-ansi machine name defines
2728 fix = {
2729 hackname = machine_name;
2730 c_test = machine_name;
2731 c_fix = machine_name;
2733 test_text = "/* MACH_DIFF: */\n"
2734 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2735 "\n/* no uniform test, so be careful :-) */";
2739 * Some math.h files define struct exception (it's in the System V
2740 * Interface Definition), which conflicts with the class exception defined
2741 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2742 * This is not a great fix, but I haven't been able to think of anything
2743 * better.
2745 fix = {
2746 hackname = math_exception;
2747 files = math.h;
2748 select = "struct exception";
2750 * This should be bypassed on __cplusplus, but some supposedly C++
2751 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2752 * exception either. So currently we bypass only for glibc, based on a
2753 * comment in the fixed glibc header. Ick.
2755 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2756 '_[a-z0-9A-Z_]+_exception; for C, exception';
2757 /* The Solaris 10 headers already get this right. */
2758 mach = '*-*-solaris2.1[0-9]*';
2759 not_machine = true;
2760 c_fix = wrap;
2762 c_fix_arg = "#ifdef __cplusplus\n"
2763 "#define exception __math_exception\n"
2764 "#endif\n";
2766 c_fix_arg = "#ifdef __cplusplus\n"
2767 "#undef exception\n"
2768 "#endif\n";
2770 test_text = "typedef struct exception t_math_exception;";
2774 * This looks pretty broken to me. ``dbl_max_def'' will contain
2775 * "define DBL_MAX " at the start, when what we really want is just
2776 * the value portion. Can't figure out how to write a test case
2777 * for this either :-(
2779 fix = {
2780 hackname = math_huge_val_from_dbl_max;
2781 files = math.h;
2784 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2785 * in math.h, this fix applies.
2787 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2788 bypass = "define[ \t]+DBL_MAX";
2790 shell =
2792 * See if we have a definition for DBL_MAX in float.h.
2793 * If we do, we will replace the one in math.h with that one.
2796 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2797 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2799 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2800 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2801 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2802 "\telse cat\n"
2803 "\tfi";
2805 test_text =
2806 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2807 "#define HUGE_VAL DBL_MAX";
2811 * nested comment
2813 fix = {
2814 hackname = nested_auth_des;
2815 files = rpc/rpc.h;
2816 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2817 c_fix = format;
2818 c_fix_arg = "%1*/ /*";
2819 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2823 * Some versions of NetBSD don't expect the C99 inline semantics.
2825 fix = {
2826 hackname = netbsd_c99_inline_1;
2827 mach = "*-*-netbsd*";
2828 files = signal.h;
2829 select = "extern __inline int";
2831 c_fix = format;
2832 c_fix_arg = "extern\n"
2833 "#ifdef __GNUC_STDC_INLINE__\n"
2834 "__attribute__((__gnu_inline__))\n"
2835 "#endif\n"
2836 "__inline int";
2838 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2842 * netbsd_c99_inline_2
2844 fix = {
2845 hackname = netbsd_c99_inline_2;
2846 mach = "*-*-netbsd*";
2847 files = signal.h;
2848 select = "#define _SIGINLINE extern __inline";
2850 c_fix = format;
2851 c_fix_arg = <<- _EOArg_
2852 #ifdef __GNUC_STDC_INLINE__
2853 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2854 #else
2856 #endif
2857 _EOArg_;
2859 test_text = "#define _SIGINLINE extern __inline";
2863 * NetBSD has a semicolon after the ending '}' for some extern "C".
2865 fix = {
2866 hackname = netbsd_extra_semicolon;
2867 mach = "*-*-netbsd*";
2868 files = sys/cdefs.h;
2869 select = "#define[ \t]*__END_DECLS[ \t]*};";
2871 c_fix = format;
2872 c_fix_arg = "#define __END_DECLS }";
2874 test_text = "#define __END_DECLS };";
2878 * newlib's stdint.h has several failures to conform to C99. The fix
2879 * for these removed a comment that can be matched to identify unfixed
2880 * versions.
2882 fix = {
2883 hackname = newlib_stdint_1;
2884 files = stdint-newlib.h, stdint.h;
2885 select = "@todo - Add support for wint_t types";
2886 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2887 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2888 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2889 sed = "s@#define INT_LEAST32_MIN.*@"
2890 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2891 sed = "s@#define INT_LEAST32_MAX.*@"
2892 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2893 sed = "s@#define UINT_LEAST32_MAX.*@"
2894 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2895 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
2896 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2897 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
2898 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2899 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
2900 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2901 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2902 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2903 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2904 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2905 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2906 test_text = "/* @todo - Add support for wint_t types. */\n"
2907 "#define INT32_MIN (-2147483647-1)\n"
2908 "#define INT32_MAX 2147483647\n"
2909 "#define UINT32_MAX 4294967295U\n"
2910 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2911 "#define INT_LEAST32_MAX 2147483647\n"
2912 "#define UINT_LEAST32_MAX 4294967295U\n"
2913 "#define INT_FAST8_MIN INT8_MIN\n"
2914 "#define INT_FAST8_MAX INT8_MAX\n"
2915 "#define UINT_FAST8_MAX UINT8_MAX\n"
2916 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2917 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2918 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2919 "#define UINT8_C(x) x##U\n"
2920 "#define UINT16_C(x) x##U";
2924 * newlib_stdint_2
2926 fix = {
2927 hackname = newlib_stdint_2;
2928 files = stdint-newlib.h, stdint.h;
2929 select = "@todo - Add support for wint_t types";
2930 c_fix = format;
2931 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2932 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2933 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2934 "#define WCHAR_MAX __WCHAR_MAX__\n"
2935 "#define WCHAR_MIN __WCHAR_MIN__\n"
2936 "#define WINT_MAX __WINT_MAX__\n"
2937 "#define WINT_MIN __WINT_MIN__\n\n"
2938 "%0";
2939 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2940 test_text = "/* @todo - Add support for wint_t types. */\n"
2941 "/** Macros for minimum-width integer constant expressions */";
2945 * NeXT 3.2 adds const prefix to some math functions.
2946 * These conflict with the built-in functions.
2948 fix = {
2949 hackname = next_math_prefix;
2950 files = ansi/math.h;
2951 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2953 c_fix = format;
2954 c_fix_arg = "extern double %1(";
2955 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2957 test_text = "extern\tdouble\t__const__\tmumble();";
2961 * NeXT 3.2 uses the word "template" as a parameter for some
2962 * functions. GCC reports an invalid use of a reserved key word
2963 * with the built-in functions.
2965 fix = {
2966 hackname = next_template;
2967 files = bsd/libc.h;
2968 select = "[ \t]template\\)";
2970 c_fix = format;
2971 c_fix_arg = "(%1)";
2972 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2973 test_text = "extern mumble( char * template); /* fix */";
2977 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2978 * function prototypes. That conflicts with the built-in functions.
2980 fix = {
2981 hackname = next_volitile;
2982 files = ansi/stdlib.h;
2983 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2985 c_fix = format;
2986 c_fix_arg = "extern void %1(";
2987 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2989 test_text = "extern\tvolatile\tvoid\tabort();";
2993 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2994 * Note that version 3 of the NeXT system has wait.h in a different directory,
2995 * so that this code won't do anything. But wait.h in version 3 has a
2996 * conditional, so it doesn't need this fix. So everything is okay.
2998 fix = {
2999 hackname = next_wait_union;
3000 files = sys/wait.h;
3002 select = 'wait\(union wait';
3003 c_fix = format;
3004 c_fix_arg = "wait(void";
3005 test_text = "extern pid_d wait(union wait*);";
3009 * a missing semi-colon at the end of the nodeent structure definition.
3011 fix = {
3012 hackname = nodeent_syntax;
3013 files = netdnet/dnetdb.h;
3014 select = "char[ \t]*\\*na_addr[ \t]*$";
3015 c_fix = format;
3016 c_fix_arg = "%0;";
3017 test_text = "char *na_addr\t";
3021 * Fix OpenBSD's NULL definition.
3023 fix = {
3024 hackname = openbsd_null_definition;
3025 mach = "*-*-openbsd*";
3026 files = locale.h, stddef.h, stdio.h, string.h,
3027 time.h, unistd.h, wchar.h, sys/param.h;
3028 select = "__GNUG__";
3029 c_fix = format;
3030 c_fix_arg = "#ifndef NULL\n"
3031 "#ifdef __cplusplus\n"
3032 "#ifdef __GNUG__\n"
3033 "#define NULL\t__null\n"
3034 "#else\t /* ! __GNUG__ */\n"
3035 "#define NULL\t0L\n"
3036 "#endif\t /* __GNUG__ */\n"
3037 "#else\t /* ! __cplusplus */\n"
3038 "#define NULL\t((void *)0)\n"
3039 "#endif\t /* __cplusplus */\n"
3040 "#endif\t /* !NULL */";
3042 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3043 "^#ifdef[ \t]*__GNUG__\n"
3044 "^#define[ \t]*NULL[ \t]*__null\n"
3045 "^#else\n"
3046 "^#define[ \t]*NULL[ \t]*0L\n"
3047 "^#endif\n"
3048 "^#endif";
3049 test_text =
3050 "#ifndef NULL\n"
3051 "#ifdef __GNUG__\n"
3052 "#define NULL __null\n"
3053 "#else\n"
3054 "#define NULL 0L\n"
3055 "#endif\n"
3056 "#endif\n";
3060 * obstack.h used casts as lvalues.
3062 * We need to change postincrements of casted pointers (which are
3063 * then dereferenced and assigned into) of the form
3065 * *((TYPE*)PTRVAR)++ = (VALUE)
3067 * into expressions like
3069 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3071 * which is correct for the cases used in obstack.h since PTRVAR is
3072 * of type char * and the value of the expression is not used.
3074 fix = {
3075 hackname = obstack_lvalue_cast;
3076 files = obstack.h;
3077 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3078 c_fix = format;
3079 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3080 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3084 * Fix OpenBSD's va_start define.
3086 fix = {
3087 hackname = openbsd_va_start;
3088 mach = "*-*-openbsd*";
3089 files = stdarg.h;
3090 select = '__builtin_stdarg_start';
3091 c_fix = format;
3092 c_fix_arg = __builtin_va_start;
3094 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3098 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3099 * defining regex.h related types. This causes libg++ build and usage
3100 * failures. Fixing this correctly requires checking and modifying 3 files.
3102 fix = {
3103 hackname = osf_namespace_a;
3104 files = reg_types.h;
3105 files = sys/lc_core.h;
3106 test = " -r reg_types.h";
3107 test = " -r sys/lc_core.h";
3108 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3109 test = " -z \"`grep __regex_t regex.h`\"";
3111 c_fix = format;
3112 c_fix_arg = "__%0";
3113 c_fix_arg = "reg(ex|off|match)_t";
3115 test_text = "`touch sys/lc_core.h`"
3116 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3117 "extern regex_t re;\n"
3118 "extern regoff_t ro;\n"
3119 "extern regmatch_t rm;\n";
3122 fix = {
3123 hackname = osf_namespace_c;
3124 files = regex.h;
3125 test = " -r reg_types.h";
3126 test = " -r sys/lc_core.h";
3127 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3128 test = " -z \"`grep __regex_t regex.h`\"";
3130 select = "#include <reg_types\.h>.*";
3131 c_fix = format;
3132 c_fix_arg = "%0\n"
3133 "typedef __regex_t\tregex_t;\n"
3134 "typedef __regoff_t\tregoff_t;\n"
3135 "typedef __regmatch_t\tregmatch_t;";
3137 test_text = "#include <reg_types.h>";
3141 * On broken glibc-2.3.3 systems an array of incomplete structures is
3142 * passed to __sigsetjmp. Fix that to take a pointer instead.
3144 fix = {
3145 hackname = pthread_incomplete_struct_argument;
3146 files = pthread.h;
3147 select = "struct __jmp_buf_tag";
3148 c_fix = format;
3149 c_fix_arg = "%1 *%2%3";
3150 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3151 "(__env)\\[1\\](.*)$";
3152 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3153 "int __savemask);";
3157 * Fix return type of fread and fwrite on sysV68
3159 fix = {
3160 hackname = read_ret_type;
3161 files = stdio.h;
3162 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3163 c_fix = format;
3164 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3165 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3167 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3171 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3173 fix = {
3174 hackname = rpc_xdr_lvalue_cast_a;
3175 files = rpc/xdr.h;
3176 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3177 c_fix = format;
3178 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3179 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3180 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3184 * rpc_xdr_lvalue_cast_b
3186 fix = {
3187 hackname = rpc_xdr_lvalue_cast_b;
3188 files = rpc/xdr.h;
3189 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3190 c_fix = format;
3191 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3192 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3193 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3197 * function class(double x) conflicts with C++ keyword on rs/6000
3199 fix = {
3200 hackname = rs6000_double;
3201 files = math.h;
3202 select = '[^a-zA-Z_]class\(';
3204 c_fix = format;
3205 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3206 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3208 test_text = "extern int class();";
3212 * Wrong fchmod prototype on RS/6000.
3214 fix = {
3215 hackname = rs6000_fchmod;
3216 files = sys/stat.h;
3217 select = 'fchmod\(char \*';
3218 c_fix = format;
3219 c_fix_arg = "fchmod(int";
3220 test_text = "extern int fchmod(char *, mode_t);";
3224 * parameters conflict with C++ new on rs/6000
3226 fix = {
3227 hackname = rs6000_param;
3228 files = "stdio.h";
3229 files = "unistd.h";
3231 select = 'rename\(const char \*old, const char \*new\)';
3232 c_fix = format;
3233 c_fix_arg = 'rename(const char *_old, const char *_new)';
3235 test_text = 'extern int rename(const char *old, const char *new);';
3239 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3240 * for C99. This is wrong for C++, which needs many C99 features, but
3241 * only supports __restrict.
3243 fix = {
3244 hackname = solaris___restrict;
3245 files = sys/feature_tests.h;
3246 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3247 mach = "*-*-solaris2*";
3248 c_fix = format;
3249 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3250 "#else\n%0\n#endif";
3251 test_text = "#define _RESTRICT_KYWD restrict";
3255 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3256 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3257 * and imaginary definitions which are not supported by GCC.
3259 fix = {
3260 hackname = solaris_complex;
3261 mach = "*-*-solaris2.*";
3262 files = complex.h;
3263 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3264 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3265 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3266 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3267 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3268 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3269 test_text = "#define _Complex_I _Complex_I\n"
3270 "#define complex _Complex\n"
3271 "#define _Imaginary_I _Imaginary_I\n"
3272 "#define imaginary _Imaginary\n"
3273 "#undef I\n"
3274 "#define I _Imaginary_I";
3278 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3279 * extern "C" instead so libstdc++ can use it.
3281 fix = {
3282 hackname = solaris_complex_cxx;
3283 mach = "*-*-solaris2.*";
3284 files = complex.h;
3285 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3286 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3287 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3288 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3289 test_text = "#if !defined(__cplusplus)\n"
3290 "#endif /* !defined(__cplusplus) */";
3294 * g++ rejects functions declared with both C and C++ linkage.
3296 fix = {
3297 hackname = solaris_cxx_linkage;
3298 mach = '*-*-solaris2*';
3299 files = "iso/stdlib_iso.h";
3300 select = "(#if __cplusplus >= 199711L)\n"
3301 "(extern \"C\\+\\+\" \\{\n)"
3302 "(.*(bsearch|qsort).*)";
3303 c_fix = format;
3304 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3306 test_text =
3307 "#if __cplusplus >= 199711L\n"
3308 "extern \"C++\" {\n"
3309 " void *bsearch(const void *, const void *, size_t, size_t,";
3313 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3314 * _STRICT_STDC, but uses it.
3316 fix = {
3317 hackname = solaris_getc_strict_stdc;
3318 mach = "*-*-solaris2*";
3319 files = "iso/stdio_iso.h";
3320 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3321 c_fix = format;
3322 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3324 test_text =
3325 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3329 * Sun Solaris 2 has a version of sys/int_const.h that defines
3330 * UINT8_C and UINT16_C to unsigned constants.
3332 fix = {
3333 hackname = solaris_int_const;
3334 files = sys/int_const.h;
3335 mach = '*-*-solaris2*';
3336 c_fix = format;
3337 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3338 "%1\n"
3339 "#define\tUINT16_C(c)\t(c)";
3340 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3341 "(/\*.*\*/)\n"
3342 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3343 test_text =
3344 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3345 "/* CSTYLED */\n"
3346 "#define UINT16_C(c) __CONCAT__(c,u)";
3350 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3351 * UINT8_MAX and UINT16_MAX to unsigned constants.
3353 fix = {
3354 hackname = solaris_int_limits_1;
3355 files = sys/int_limits.h;
3356 mach = '*-*-solaris2*';
3357 c_fix = format;
3358 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3359 "#define\tUINT16_MAX\t(65535)";
3360 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3361 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3362 test_text =
3363 "#define UINT8_MAX (255U)\n"
3364 "#define UINT16_MAX (65535U)";
3368 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3369 * INT_FAST16 limits to wrong values for sys/int_types.h.
3371 fix = {
3372 hackname = solaris_int_limits_2;
3373 files = sys/int_limits.h;
3374 mach = '*-*-solaris2*';
3375 c_fix = format;
3376 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3377 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3378 test_text =
3379 "#define INT_FAST16_MAX INT16_MAX\n"
3380 "#define UINT_FAST16_MAX UINT16_MAX\n"
3381 "#define INT_FAST16_MIN INT16_MIN";
3385 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3386 * SIZE_MAX as unsigned long.
3388 fix = {
3389 hackname = solaris_int_limits_3;
3390 files = sys/int_limits.h;
3391 mach = '*-*-solaris2*';
3392 c_fix = format;
3393 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3394 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3395 test_text =
3396 "#define SIZE_MAX 4294967295UL";
3400 * Sun Solaris 10 defines several C99 math macros in terms of
3401 * builtins specific to the Studio compiler, in particular not
3402 * compatible with the GNU compiler.
3404 fix = {
3405 hackname = solaris_math_1;
3406 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3407 bypass = "__GNUC__";
3408 files = iso/math_c99.h;
3409 c_fix = format;
3410 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3411 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3412 test_text =
3413 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3414 "#undef HUGE_VAL\n"
3415 "#define HUGE_VAL __builtin_huge_val\n"
3416 "#undef HUGE_VALF\n"
3417 "#define HUGE_VALF __builtin_huge_valf\n"
3418 "#undef HUGE_VALL\n"
3419 "#define HUGE_VALL __builtin_huge_vall";
3423 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3424 * exception. Provide an alternative using GCC's builtin.
3426 fix = {
3427 hackname = solaris_math_10;
3428 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3429 files = iso/math_c99.h;
3430 c_fix = format;
3431 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3432 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3433 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3434 "[ \t]*\\\\\n"
3435 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3436 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3437 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3438 "\\(-INFINITY\\);[ \t]*\\}\\)";
3439 test_text =
3440 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3441 "#undef isinf\n"
3442 "#define isinf(x) __extension__( \\\\\n"
3443 " { __typeof(x) __x_i = (x); \\\\\n"
3444 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3445 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3449 * Solaris math INFINITY
3451 fix = {
3452 hackname = solaris_math_2;
3453 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3454 bypass = "__GNUC__";
3455 files = iso/math_c99.h;
3456 c_fix = format;
3457 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3458 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3459 test_text =
3460 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3461 "#undef INFINITY\n"
3462 "#define INFINITY __builtin_infinity";
3466 * Solaris math NAN
3468 fix = {
3469 hackname = solaris_math_3;
3470 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3471 bypass = "__GNUC__";
3472 files = iso/math_c99.h;
3473 c_fix = format;
3474 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3475 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3476 test_text =
3477 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3478 "#undef NAN\n"
3479 "#define NAN __builtin_nan";
3483 * Solaris math fpclassify
3485 fix = {
3486 hackname = solaris_math_4;
3487 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3488 bypass = "__GNUC__";
3489 files = iso/math_c99.h;
3490 c_fix = format;
3491 c_fix_arg = "#define\tfpclassify(x) \\\n"
3492 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3493 "FP_SUBNORMAL, FP_ZERO, (x))";
3494 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3495 test_text =
3496 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3497 "#undef fpclassify\n"
3498 "#define fpclassify(x) __builtin_fpclassify(x)";
3502 * Solaris math signbit
3504 fix = {
3505 hackname = solaris_math_8;
3506 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3507 bypass = "__GNUC__";
3508 files = iso/math_c99.h;
3509 c_fix = format;
3510 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3511 "\t\t\t ? __builtin_signbitf(x) \\\n"
3512 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3513 "\t\t\t ? __builtin_signbitl(x) \\\n"
3514 "\t\t\t : __builtin_signbit(x))";
3515 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3516 test_text = <<- _EOText_
3517 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3518 #undef signbit
3519 #define signbit(x) __builtin_signbit(x)
3520 _EOText_;
3524 * Solaris math comparison macros
3526 fix = {
3527 hackname = solaris_math_9;
3528 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3529 bypass = "__GNUC__";
3530 files = iso/math_c99.h;
3531 c_fix = format;
3532 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3533 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3534 "__builtin_[a-z]+\\(y\\)\\)";
3535 test_text =
3536 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3537 "#undef isgreater\n"
3538 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3539 "#undef isgreaterequal\n"
3540 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3541 "#undef isless\n"
3542 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3543 "#undef islessequal\n"
3544 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3545 "#undef islessgreater\n"
3546 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3547 "#undef isunordered\n"
3548 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3552 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3553 * warnings.
3555 fix = {
3556 hackname = solaris_math_11;
3557 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3558 files = iso/math_c99.h;
3559 c_fix = format;
3560 c_fix_arg = << _EOArg_
3561 #undef signbit
3562 #define signbit(x) (sizeof(x) == sizeof(float) \
3563 ? __builtin_signbitf(x) \
3564 : sizeof(x) == sizeof(long double) \
3565 ? __builtin_signbitl(x) \
3566 : __builtin_signbit(x))
3567 _EOArg_;
3568 c_fix_arg = << _EOArg_
3569 ^#undef[ ]+signbit
3570 #if defined\(__sparc\)
3571 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3572 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3573 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3574 #elif defined\(__i386\) \|\| defined\(__amd64\)
3575 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3576 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3577 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3578 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3579 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3580 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3581 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3582 #endif
3583 _EOArg_;
3584 test_text = << _EOText_
3585 /* @(#)math_c99.h 1.14 13/03/27 */
3586 #undef signbit
3587 #if defined(__sparc)
3588 #define signbit(x) __extension__( \\
3589 { __typeof(x) __x_s = (x); \\
3590 (int) (*(unsigned *) &__x_s >> 31); })
3591 #elif defined(__i386) || defined(__amd64)
3592 #define signbit(x) __extension__( \\
3593 { __typeof(x) __x_s = (x); \\
3594 (sizeof (__x_s) == sizeof (float) ? \\
3595 (int) (*(unsigned *) &__x_s >> 31) : \\
3596 sizeof (__x_s) == sizeof (double) ? \\
3597 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3598 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3599 #endif
3600 _EOText_;
3604 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3605 * structure. As such, it need two levels of brackets, but only
3606 * contains one. Wrap the macro definition in an extra layer.
3608 fix = {
3609 hackname = solaris_once_init_1;
3610 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3611 files = pthread.h;
3612 mach = '*-*-solaris*';
3613 c_fix = format;
3614 c_fix_arg = "%1{%2}%3";
3615 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3616 test_text =
3617 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3618 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3622 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3623 * posix_spawn declarations, which doesn't work with C++.
3625 fix = {
3626 hackname = solaris_posix_spawn_restrict;
3627 files = spawn.h;
3628 mach = '*-*-solaris2*';
3629 c_fix = format;
3630 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3631 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3632 test_text =
3633 "char *const argv[_RESTRICT_KYWD],\n"
3634 "char *const envp[_RESTRICT_KYWD]);";
3638 * The pow overloads with int were removed in C++ 2011 DR 550.
3640 fix = {
3641 hackname = solaris_pow_int_overload;
3642 mach = '*-*-solaris2*';
3643 files = "iso/math_iso.h";
3644 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3645 " *\\{[^{}]*\n[^{}]*\\}";
3646 c_fix = format;
3647 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3649 test_text =
3650 " inline long double pow(long double __X, int __Y) { return\n"
3651 " __powl(__X, (long double) (__Y)); }";
3655 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3656 * fields of the pthread_rwlock_t structure, which are of type
3657 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3658 * defined (e.g. by -ansi) it is a union. So change the initializer
3659 * to "{0}" instead.
3661 fix = {
3662 hackname = solaris_rwlock_init_1;
3663 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3664 files = pthread.h;
3665 mach = '*-*-solaris*';
3666 c_fix = format;
3667 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3668 "%0\n"
3669 "#else\n"
3670 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3671 "#endif";
3672 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3673 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3675 test_text =
3676 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3677 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3681 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3682 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3684 fix = {
3685 hackname = solaris_std___filbuf;
3686 files = stdio.h;
3687 mach = '*-*-solaris2*';
3688 bypass = "using std::__filbuf";
3689 select = "(using std::perror;\n)(#endif)";
3690 c_fix = format;
3691 c_fix_arg = "%1#ifndef _LP64\n"
3692 "using std::__filbuf;\n"
3693 "using std::__flsbuf;\n"
3694 "#endif\n%2";
3696 test_text = "using std::perror;\n"
3697 "#endif";
3701 * Sun Solaris 8 has what appears to be some gross workaround for
3702 * some old version of their c++ compiler. G++ doesn't want it
3703 * either, but doesn't want to be tied to SunPRO version numbers.
3705 fix = {
3706 hackname = solaris_stdio_tag;
3707 files = stdio_tag.h;
3709 select = '__cplusplus < 54321L';
3710 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3711 "!defined(__GNUC__)" so we no longer need to fix it. */
3712 bypass = '__GNUC__';
3713 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3715 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3719 * a missing semi-colon at the end of the statsswtch structure definition.
3721 fix = {
3722 hackname = statsswtch;
3723 files = rpcsvc/rstat.h;
3724 select = "boottime$";
3725 c_fix = format;
3726 c_fix_arg = "boottime;";
3727 test_text = "struct statswtch {\n int boottime\n};";
3731 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3732 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3733 * OK too.
3735 fix = {
3736 hackname = stdio_stdarg_h;
3737 files = stdio.h;
3738 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3740 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3741 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3743 mach = '*-*-solaris2.1[0-9]*';
3744 not_machine = true;
3746 c_fix = wrap;
3748 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3750 test_text = "";
3754 * Don't use or define the name va_list in stdio.h. This is for
3755 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3756 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3757 * indicate that the header knows what it's doing -- under SUSv2,
3758 * stdio.h is required to define va_list, and we shouldn't break
3759 * that.
3761 fix = {
3762 hackname = stdio_va_list;
3763 files = stdio.h;
3764 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3766 * On Solaris 10, the definition in
3767 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3768 * there is therefore no need for this fix there.
3770 mach = '*-*-solaris2.1[0-9]*';
3771 not_machine = true;
3774 * Use __gnuc_va_list in arg types in place of va_list.
3775 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3776 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3777 * trailing parentheses and semicolon save all other systems from this.
3778 * Define __not_va_list__ (something harmless and unused)
3779 * instead of va_list.
3780 * Don't claim to have defined va_list.
3782 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3783 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3784 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3785 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3786 "s@ va_list@ __not_va_list__@\n"
3787 "s@\\*va_list@*__not_va_list__@\n"
3788 "s@ __va_list)@ __gnuc_va_list)@\n"
3789 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3790 "@typedef \\1 __not_va_list__;@\n"
3791 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3792 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3793 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3794 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3795 "s@VA_LIST@DUMMY_VA_LIST@\n"
3796 "s@_Va_LIST@_VA_LIST@";
3797 test_text = "extern void mumble( va_list);";
3801 * Fix headers that use va_list from stdio.h to use the updated
3802 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3803 * dealt with elsewhere. The presence of __gnuc_va_list,
3804 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3805 * knows what it's doing.
3807 fix = {
3808 hackname = stdio_va_list_clients;
3809 files = com_err.h;
3810 files = cps.h;
3811 files = curses.h;
3812 files = krb5.h;
3813 files = lc_core.h;
3814 files = pfmt.h;
3815 files = wchar.h;
3816 files = curses_colr/curses.h;
3817 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3818 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3819 otherwise protected. */
3820 bypass = 'include <stdarg\.h>|#ifdef va_start';
3823 * Use __gnuc_va_list in arg types in place of va_list.
3824 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3825 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3826 * trailing parentheses and semicolon save all other systems from this.
3827 * Define __not_va_list__ (something harmless and unused)
3828 * instead of va_list.
3829 * Don't claim to have defined va_list.
3831 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3832 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3833 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3834 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3835 "s@ va_list@ __not_va_list__@\n"
3836 "s@\\*va_list@*__not_va_list__@\n"
3837 "s@ __va_list)@ __gnuc_va_list)@\n"
3838 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3839 "@typedef \\1 __not_va_list__;@\n"
3840 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3841 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3842 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3843 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3844 "s@VA_LIST@DUMMY_VA_LIST@\n"
3845 "s@_Va_LIST@_VA_LIST@";
3846 test_text = "extern void mumble( va_list);";
3850 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3851 * is "!defined( __STRICT_ANSI__ )"
3853 fix = {
3854 hackname = strict_ansi_not;
3855 select = "^([ \t]*#[ \t]*if.*)"
3856 "(!__STDC__"
3857 "|__STDC__[ \t]*==[ \t]*0"
3858 "|__STDC__[ \t]*!=[ \t]*1"
3859 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3860 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3861 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3862 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3863 is not defined by GCC, so it is safe. */
3864 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3865 c_test = stdc_0_in_system_headers;
3867 c_fix = format;
3868 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3870 test_text = "#if !__STDC__ \n"
3871 "#if __STDC__ == 0\n"
3872 "#if __STDC__ != 1\n"
3873 "#if __STDC__ - 0 == 0"
3874 "/* not std C */\nint foo;\n"
3875 "\n#end-end-end-end-if :-)";
3879 * "__STDC__-0==0"
3880 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3882 fix = {
3883 hackname = strict_ansi_not_ctd;
3884 files = math.h, limits.h, stdio.h, signal.h,
3885 stdlib.h, sys/signal.h, time.h;
3887 * Starting at the beginning of a line, skip white space and
3888 * a leading "(" or "&&" or "||". One of those must be found.
3889 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3890 * expression. If these are nested, then they must accumulate
3891 * because we won't match any closing parentheses. Finally,
3892 * after skipping over all that, we must then match our suspect
3893 * phrase: "__STDC__-0==0" with or without white space.
3895 select = "^([ \t]*" '(\(|&&|\|\|)'
3896 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3897 "[ \t(]*)"
3898 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3899 c_test = stdc_0_in_system_headers;
3901 c_fix = format;
3902 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3904 test_text = "#if 1 && \\\\\n"
3905 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3906 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3907 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3908 "int foo;\n#endif";
3912 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3913 * is "defined( __STRICT_ANSI__ )"
3915 fix = {
3916 hackname = strict_ansi_only;
3917 select = "^([ \t]*#[ \t]*if.*)"
3918 "(__STDC__[ \t]*!=[ \t]*0"
3919 "|__STDC__[ \t]*==[ \t]*1"
3920 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3921 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3922 c_test = stdc_0_in_system_headers;
3924 c_fix = format;
3925 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3927 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3931 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3932 * in prototype without previous definition.
3934 fix = {
3935 hackname = struct_file;
3936 files = rpc/xdr.h;
3937 select = '^.*xdrstdio_create.*struct __file_s';
3938 c_fix = format;
3939 c_fix_arg = "struct __file_s;\n%0";
3940 test_text = "extern void xdrstdio_create( struct __file_s* );";
3944 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3945 * in prototype without previous definition.
3947 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3948 * function, and does define it.
3950 fix = {
3951 hackname = struct_sockaddr;
3952 files = rpc/auth.h;
3953 select = "^.*authdes_create.*struct sockaddr[^_]";
3954 bypass = "<sys/socket\.h>";
3955 bypass = "struct sockaddr;\n";
3956 c_fix = format;
3957 c_fix_arg = "struct sockaddr;\n%0";
3958 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3962 * Apply fix this to all OSs since this problem seems to effect
3963 * more than just SunOS.
3965 fix = {
3966 hackname = sun_auth_proto;
3967 files = rpc/auth.h;
3968 files = rpc/clnt.h;
3969 files = rpc/svc.h;
3970 files = rpc/xdr.h;
3971 bypass = "__cplusplus";
3973 * Select those files containing '(*name)()'.
3975 select = '\(\*[a-z][a-z_]*\)\(\)';
3977 c_fix = format;
3978 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3979 "#else\n%1();%2\n#endif";
3980 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3982 test_text =
3983 "struct auth_t {\n"
3984 " int (*name)(); /* C++ bad */\n"
3985 "};";
3989 * Fix bogus #ifdef on SunOS 4.1.
3991 fix = {
3992 hackname = sun_bogus_ifdef;
3993 files = "hsfs/hsfs_spec.h";
3994 files = "hsfs/iso_spec.h";
3995 select = '#ifdef(.*\|\|.*)';
3996 c_fix = format;
3997 c_fix_arg = "#if%1";
3999 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4003 * Fix the CAT macro in SunOS memvar.h.
4005 fix = {
4006 hackname = sun_catmacro;
4007 files = pixrect/memvar.h;
4008 select = "^#define[ \t]+CAT\\(a,b\\).*";
4009 c_fix = format;
4011 c_fix_arg =
4012 "#ifdef __STDC__\n"
4013 "# define CAT(a,b) a##b\n"
4014 "#else\n%0\n#endif";
4016 test_text =
4017 "#define CAT(a,b)\ta/**/b";
4021 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4022 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4024 fix = {
4025 hackname = sun_malloc;
4026 files = malloc.h;
4027 bypass = "_CLASSIC_ANSI_TYPES";
4029 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4030 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4031 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4032 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4033 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4035 test_text =
4036 "typedef char *\tmalloc_t;\n"
4037 "int \tfree();\n"
4038 "char*\tmalloc();\n"
4039 "char*\tcalloc();\n"
4040 "char*\trealloc();";
4044 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4046 fix = {
4047 hackname = sun_rusers_semi;
4048 files = rpcsvc/rusers.h;
4049 select = "_cnt$";
4050 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4051 test_text = "struct mumble\n int _cnt\n};";
4055 * signal.h on SunOS defines signal using (),
4056 * which causes trouble when compiling with g++ -pedantic.
4058 fix = {
4059 hackname = sun_signal;
4060 files = sys/signal.h;
4061 files = signal.h;
4062 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4064 c_fix = format;
4065 c_fix_arg =
4066 "#ifdef __cplusplus\n"
4067 "void\t(*signal(...))(...);\n"
4068 "#else\n%0\n#endif";
4070 test_text = "void\t(*signal())();";
4074 * Correct the return type for strlen in strings.h in SunOS 4.
4076 fix = {
4077 hackname = sunos_strlen;
4078 files = strings.h;
4079 select = "int[ \t]*strlen\\(\\);(.*)";
4080 c_fix = format;
4081 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4082 test_text = " int\tstrlen(); /* string length */";
4086 * Linux kernel's vt.h breaks C++
4088 fix = {
4089 hackname = suse_linux_vt_cxx;
4090 files = linux/vt.h;
4092 select = "^[ \t]*unsigned int new;";
4093 c_fix = format;
4094 c_fix_arg = "unsigned int newev;";
4096 test_text = " unsigned int new; /* New console (if changing) */";
4100 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4101 * that is visible to any ANSI compiler using this include. Simply
4102 * delete the lines that #define some string functions to internal forms.
4104 fix = {
4105 hackname = svr4_disable_opt;
4106 files = string.h;
4107 select = '#define.*__std_hdr_';
4108 sed = '/#define.*__std_hdr_/d';
4109 test_text = "#define strlen __std_hdr_strlen\n";
4113 * Fix broken decl of getcwd present on some svr4 systems.
4115 fix = {
4116 hackname = svr4_getcwd;
4117 files = stdlib.h;
4118 files = unistd.h;
4119 files = prototypes.h;
4120 select = 'getcwd\(char \*, int\)';
4122 c_fix = format;
4123 c_fix_arg = "getcwd(char *, size_t)";
4125 test_text = "extern char* getcwd(char *, int);";
4129 * Fix broken decl of profil present on some svr4 systems.
4131 fix = {
4132 hackname = svr4_profil;
4133 files = stdlib.h;
4134 files = unistd.h;
4136 select =
4137 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4138 c_fix = format;
4139 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4141 test_text =
4142 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4146 * Correct types for signal handler constants like SIG_DFL; they might be
4147 * void (*) (), and should be void (*) (int). C++ doesn't like the
4148 * old style.
4150 fix = {
4151 hackname = svr4_sighandler_type;
4152 files = sys/signal.h;
4153 select = 'void *\(\*\)\(\)';
4154 c_fix = format;
4155 c_fix_arg = "void (*)(int)";
4156 test_text = "#define SIG_DFL (void(*)())0\n"
4157 "#define SIG_IGN (void (*)())0\n";
4161 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4162 * function 'getrnge' in <regexp.h> before they declare it. For these
4163 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4164 * early on.
4166 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4167 * so put the declaration right after the declaration of 'size'.
4169 * Don't do this if there is already a `static void getrnge' declaration
4170 * present, since this would cause a redeclaration error. Solaris 2.x has
4171 * such a declaration.
4173 fix = {
4174 hackname = svr4_undeclared_getrnge;
4175 files = regexp.h;
4176 select = "getrnge";
4177 bypass = "static void getrnge";
4178 c_fix = format;
4179 c_fix_arg = "%0\n"
4180 "static int getrnge ();";
4181 c_fix_arg = "^static int[ \t]+size;";
4182 test_text = "static int size;\n"
4183 "/* stuff which calls getrnge() */\n"
4184 "static getrnge()\n"
4185 "{}";
4189 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4190 * in string.h on sysV68
4191 * Correct the return type for strlen in string.h on Lynx.
4192 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4193 * Add missing const for strdup on OSF/1 V3.0.
4194 * On sysV88 layout is slightly different.
4196 fix = {
4197 hackname = sysv68_string;
4198 files = testing.h;
4199 files = string.h;
4200 bypass = "_CLASSIC_ANSI_TYPES";
4202 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4203 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4204 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4206 sed = "/^extern char$/N";
4207 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4209 sed = "/^extern int$/N";
4210 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4212 sed = "/^\tstrncmp(),$/N";
4213 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4214 '\1;' "\\\nextern unsigned int\\\n\\2/";
4216 test_text =
4217 "extern int strlen();\n"
4219 "extern int ffs(long);\n"
4221 "extern char\n"
4222 "\t*memccpy(),\n"
4223 "\tmemcpy();\n"
4225 "extern int\n"
4226 "\tstrcmp(),\n"
4227 "\tstrncmp(),\n"
4228 "\tstrlen(),\n"
4229 "\tstrspn();\n"
4231 "extern int\n"
4232 "\tstrlen(), strspn();";
4236 * Fix return type of calloc, malloc, realloc, bsearch and exit
4238 fix = {
4239 hackname = sysz_stdlib_for_sun;
4240 files = stdlib.h;
4241 bypass = "_CLASSIC_ANSI_TYPES";
4243 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4244 c_fix = format;
4245 c_fix_arg = "void *\t%1(";
4247 test_text =
4248 "extern char*\tcalloc(size_t);\n"
4249 "extern char*\tmalloc(size_t);\n"
4250 "extern char*\trealloc(void*,size_t);\n"
4251 "extern char*\tbsearch(void*,size_t,size_t);\n";
4255 * __thread is now a keyword.
4257 fix = {
4258 hackname = thread_keyword;
4259 files = "pthread.h";
4260 files = bits/sigthread.h, '*/bits/sigthread.h';
4261 select = "([* ])__thread([,)])";
4262 c_fix = format;
4263 c_fix_arg = "%1__thr%2";
4265 test_text =
4266 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4267 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4268 "extern int pthread_cancel (pthread_t __thread);";
4272 * if the #if says _cplusplus, not the double underscore __cplusplus
4273 * that it should be
4275 fix = {
4276 hackname = tinfo_cplusplus;
4277 files = tinfo.h;
4278 select = "[ \t]_cplusplus";
4280 c_fix = format;
4281 c_fix_arg = " __cplusplus";
4282 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4286 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4288 fix = {
4289 hackname = ultrix_const;
4290 files = stdio.h;
4291 select = 'perror\( char \*';
4293 c_fix = format;
4294 c_fix_arg = "%1 const %3 *__";
4295 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4296 "[ \t]+(char|void) \\*__";
4298 test_text =
4299 "extern void perror( char *__s );\n"
4300 "extern int fputs( char *__s, FILE *);\n"
4301 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4302 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4303 "extern int scanf( char *__format, ...);\n";
4307 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4309 fix = {
4310 hackname = ultrix_const2;
4311 files = stdio.h;
4313 select = '\*fopen\( char \*';
4314 c_fix = format;
4315 c_fix_arg = "%1( const char *%3, const char *";
4316 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4317 "[ \t]*char[ \t]*\\*([^,]*),"
4318 "[ \t]*char[ \t]*\\*[ \t]*";
4320 test_text =
4321 "extern FILE *fopen( char *__filename, char *__type );\n"
4322 "extern int sscanf( char *__s, char *__format, ...);\n"
4323 "extern FILE *popen(char *, char *);\n"
4324 "extern char *tempnam(char*,char*);\n";
4328 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4330 fix = {
4331 hackname = va_i960_macro;
4332 files = arch/i960/archI960.h;
4333 select = "__(vsiz|vali|vpad|alignof__)";
4335 c_fix = format;
4336 c_fix_arg = "__vx%1";
4338 test_text =
4339 "extern int __vsiz vsiz;\n"
4340 "extern int __vali vali;\n"
4341 "extern int __vpad vpad;\n"
4342 "#define __alignof__(x) ...";
4346 * On VMS, add missing braces around sigset_t constants.
4348 fix = {
4349 hackname = vms_add_missing_braces;
4350 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4351 mach = "*-*-*vms*";
4352 files = "rtldef/signal.h";
4353 c_fix = format;
4355 c_fix_arg = '%1 {%2} ';
4357 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4358 "{0x00000000, 0x00000000},\n"
4359 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4363 * On VMS, some DEC-C builtins are directly used.
4365 fix = {
4366 hackname = vms_decc_builtin;
4367 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4368 mach = "*-*-*vms*";
4369 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4370 rtldef/socket.h;
4371 sed = "s@__MEMSET@memset@";
4372 sed = "s@__MEMMOVE@memmove@";
4373 sed = "s@__MEMCPY@memcpy@";
4374 sed = "s@__STRLEN@strlen@";
4375 sed = "s@__STRCPY@strcpy@";
4377 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4381 * Define __CAN_USE_EXTERN_PREFIX on vms.
4383 fix = {
4384 hackname = vms_define_can_use_extern_prefix;
4385 files = "rtldef/decc$types.h";
4386 select = "#[ \t]*else\n"
4387 "#[ \t]*if defined\\(__DECCXX\\)\n"
4388 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4389 mach = "*-*-*vms*";
4390 c_fix = format;
4392 c_fix_arg = "%0"
4393 "# elif defined (__GNUC__)\n"
4394 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4396 test_text = "# else\n"
4397 "# if defined(__DECCXX)\n"
4398 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4399 "# endif\n"
4400 "# endif\n";
4404 * On VMS, disable the use of dec-c string builtins
4406 fix = {
4407 hackname = vms_disable_decc_string_builtins;
4408 select = "#if !defined\\(__VAX\\)\n";
4409 mach = "*-*-*vms*";
4410 files = "rtldef/string.h";
4411 c_fix = format;
4413 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4415 test_text = "#if !defined(__VAX)\n";
4419 * On VMS, fix incompatible redeclaration of hostalias.
4421 fix = {
4422 hackname = vms_do_not_redeclare_hostalias;
4423 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4424 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4425 mach = "*-*-*vms*";
4426 files = "rtldef/resolv.h";
4427 c_fix = format;
4429 c_fix_arg = "%1\n"
4430 "/* %2 */";
4432 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4433 "__char_ptr32 hostalias (const char *);\n";
4437 * On VMS, forward declare structure before referencing them in prototypes.
4439 fix = {
4440 hackname = vms_forward_declare_struct;
4441 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4442 "#ifdef __cplusplus\n";
4443 mach = "*-*-*vms*";
4444 files = rtldef/if.h;
4445 c_fix = format;
4447 c_fix_arg = "%1"
4448 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4450 test_text = "/* forward decls for C++ */\n"
4451 "#ifdef __cplusplus\n"
4452 "struct foo;\n"
4453 "#endif\n";
4457 * On VMS, do not declare getopt and al if pointers are 64 bit.
4459 fix = {
4460 hackname = vms_no_64bit_getopt;
4461 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4462 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4463 mach = "*-*-*vms*";
4464 files = rtldef/stdio.h, rtldef/unistd.h;
4465 c_fix = format;
4467 c_fix_arg = <<- _EOArg_
4468 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4469 %0#endif
4471 _EOArg_;
4473 test_text = "int getopt (int, char * const [], const char *);";
4477 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4478 * which is not yet fully supported by gcc.
4480 fix = {
4481 hackname = vms_use_fast_setjmp;
4482 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4483 mach = "*-*-*vms*";
4484 files = rtldef/setjmp.h;
4485 c_fix = format;
4487 c_fix_arg = "%0 defined (__GNUC__) ||";
4489 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4493 * On VMS, use pragma extern_model instead of VAX-C keywords.
4495 fix = {
4496 hackname = vms_use_pragma_extern_model;
4497 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4498 "# pragma extern_model __save\n";
4499 mach = "*-*-*vms*";
4500 c_fix = format;
4502 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4503 "# pragma extern_model __save\n";
4505 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4506 "# pragma extern_model __save\n"
4507 "# pragma extern_model strict_refdef\n"
4508 " extern struct x zz$yy;\n"
4509 "# pragma extern_model __restore\n"
4510 "#endif\n";
4514 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4515 * conflict while building gcc. Likewise for <builtins.h>
4517 fix = {
4518 hackname = vms_use_quoted_include;
4519 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4520 mach = "*-*-*vms*";
4521 files = rtldef/wait.h, starlet_c/pthread.h;
4522 c_fix = format;
4524 c_fix_arg = '%1<sys/%2.h>';
4526 test_text = "# include <resource.h>";
4530 * AIX and Interix headers define NULL to be cast to a void pointer,
4531 * which is illegal in ANSI C++.
4533 fix = {
4534 hackname = void_null;
4535 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4536 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4537 /* avoid changing C++ friendly NULL */
4538 bypass = __cplusplus;
4539 bypass = __null;
4540 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4541 c_fix = format;
4542 c_fix_arg = <<- _EOFix_
4543 #ifndef NULL
4544 #ifdef __cplusplus
4545 #ifdef __GNUG__
4546 #define NULL __null
4547 #else /* ! __GNUG__ */
4548 #define NULL 0L
4549 #endif /* __GNUG__ */
4550 #else /* ! __cplusplus */
4551 #define NULL ((void *)0)
4552 #endif /* __cplusplus */
4553 #endif /* !NULL */
4554 _EOFix_;
4555 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4559 * Make VxWorks header which is almost gcc ready fully gcc ready.
4561 fix = {
4562 hackname = vxworks_gcc_problem;
4563 files = types/vxTypesBase.h;
4564 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4566 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4567 "#if 1/";
4569 sed = "/[ \t]size_t/i\\\n"
4570 "#ifndef _GCC_SIZE_T\\\n"
4571 "#define _GCC_SIZE_T\n";
4573 sed = "/[ \t]size_t/a\\\n"
4574 "#endif\n";
4576 sed = "/[ \t]ptrdiff_t/i\\\n"
4577 "#ifndef _GCC_PTRDIFF_T\\\n"
4578 "#define _GCC_PTRDIFF_T\n";
4580 sed = "/[ \t]ptrdiff_t/a\\\n"
4581 "#endif\n";
4583 sed = "/[ \t]wchar_t/i\\\n"
4584 "#ifndef _GCC_WCHAR_T\\\n"
4585 "#define _GCC_WCHAR_T\n";
4587 sed = "/[ \t]wchar_t/a\\\n"
4588 "#endif\n";
4590 test_text =
4591 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4592 "typedef unsigned int size_t;\n"
4593 "typedef long ptrdiff_t;\n"
4594 "typedef unsigned short wchar_t;\n"
4595 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4599 * Wrap VxWorks ioctl to keep everything pretty
4601 fix = {
4602 hackname = vxworks_ioctl_macro;
4603 files = ioLib.h;
4604 mach = "*-*-vxworks*";
4606 c_fix = format;
4607 c_fix_arg = "%0\n"
4608 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4609 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4611 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4615 * Wrap VxWorks mkdir to be posix compliant
4617 fix = {
4618 hackname = vxworks_mkdir_macro;
4619 files = sys/stat.h;
4620 mach = "*-*-vxworks*";
4622 c_fix = format;
4623 c_fix_arg = "%0\n"
4624 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4625 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4626 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4627 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4628 "\\)[\t ]*;";
4630 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4634 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4636 fix = {
4637 hackname = vxworks_needs_vxtypes;
4638 files = time.h;
4639 select = "uint_t([ \t]+_clocks_per_sec)";
4640 c_fix = format;
4641 c_fix_arg = "unsigned int%1";
4642 test_text = "uint_t\t_clocks_per_sec;";
4646 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4648 fix = {
4649 hackname = vxworks_needs_vxworks;
4650 files = sys/stat.h;
4651 test = " -r types/vxTypesOld.h";
4652 test = " -n \"`egrep '#include' $file`\"";
4653 test = " -n \"`egrep ULONG $file`\"";
4654 select = "#[ \t]define[ \t]+__INCstath";
4656 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4657 "#include <types/vxTypesOld.h>\n";
4659 test_text = "`touch types/vxTypesOld.h`"
4660 "#include </dev/null> /* ULONG */\n"
4661 "# define\t__INCstath <sys/stat.h>";
4665 * Make it so VxWorks does not include gcc/regs.h accidentally
4667 fix = {
4668 hackname = vxworks_regs;
4669 mach = "*-*-vxworks*";
4671 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4672 c_fix = format;
4673 c_fix_arg = "#include <arch/../regs.h>";
4675 test_text = "#include <regs.h>\n";
4679 * Another bad dependency in VxWorks 5.2 <time.h>.
4681 fix = {
4682 hackname = vxworks_time;
4683 files = time.h;
4684 test = " -r vxWorks.h";
4686 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4687 c_fix = format;
4689 c_fix_arg =
4690 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4691 "#ifdef __cplusplus\n"
4692 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4693 "#else\n"
4694 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4695 "#endif\n"
4696 "#define __gcc_VOIDFUNCPTR_defined\n"
4697 "#endif\n"
4698 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4700 test_text = "`touch vxWorks.h`"
4701 "#define VOIDFUNCPTR (void(*)())";
4705 * This hack makes write const-correct on VxWorks
4707 fix = {
4708 hackname = vxworks_write_const;
4709 files = ioLib.h;
4710 mach = "*-*-vxworks*";
4712 c_fix = format;
4713 c_fix_arg = "extern int write (int, const char*, size_t);";
4714 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4715 "[\t ]*int[\t ]*,"
4716 "[\t ]*char[\t ]*\\*[\t ]*,"
4717 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4719 test_text = "extern int write ( int , char * , size_t ) ;";
4723 * There are several name conflicts with C++ reserved words in X11 header
4724 * files. These are fixed in some versions, so don't do the fixes if
4725 * we find __cplusplus in the file. These were found on the RS/6000.
4727 fix = {
4728 hackname = x11_class;
4729 files = X11/ShellP.h;
4730 bypass = __cplusplus;
4731 select = "^([ \t]*char \\*)class;(.*)";
4732 c_fix = format;
4733 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4734 "#else\n%1class;%2\n#endif";
4735 test_text =
4736 "struct {\n"
4737 " char *class;\n"
4738 "} mumble;\n";
4742 * class in Xm/BaseClassI.h
4744 fix = {
4745 hackname = x11_class_usage;
4746 files = Xm/BaseClassI.h;
4747 bypass = "__cplusplus";
4749 select = " class\\)";
4750 c_fix = format;
4751 c_fix_arg = " c_class)";
4753 test_text = "extern mumble (int class);\n";
4757 * new in Xm/Traversal.h
4759 fix = {
4760 hackname = x11_new;
4761 files = Xm/Traversal.h;
4762 bypass = __cplusplus;
4764 sed = "/Widget\told, new;/i\\\n"
4765 "#ifdef __cplusplus\\\n"
4766 "\\\tWidget\told, c_new;\\\n"
4767 "#else\n";
4769 sed = "/Widget\told, new;/a\\\n"
4770 "#endif\n";
4772 sed = "s/Widget new,/Widget c_new,/g";
4773 test_text =
4774 "struct wedge {\n"
4775 " Widget\told, new;\n"
4776 "};\nextern Wedged( Widget new, Widget old );";
4780 * Incorrect sprintf declaration in X11/Xmu.h
4782 fix = {
4783 hackname = x11_sprintf;
4784 files = X11/Xmu.h;
4785 files = X11/Xmu/Xmu.h;
4786 select = "^extern char \\*\tsprintf\\(\\);$";
4788 c_fix = format;
4789 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4791 test_text = "extern char *\tsprintf();";
4793 /*EOF*/