Merged from trunk from revision r222717 up to r222905.
[official-gcc.git] / fixincludes / inclhack.def
blob314e283c533f41ee6b94dda968883870f19ee239
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 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
847 fix = {
848 hackname = aix_strtof_const;
849 files = stdlib.h;
850 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
851 c_fix = format;
852 c_fix_arg = "%1(const char *, char **);";
853 test_text = "extern float strtof(char *, char **);";
857 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
858 * in an otherwise harmless (and #ifed out) macro definition
860 fix = {
861 hackname = aix_sysmachine;
862 files = sys/machine.h;
863 select = "\\\\ +\n";
864 c_fix = format;
865 c_fix_arg = "\\\n";
866 test_text = "#define FOO \\\n"
867 " bar \\ \n baz \\ \n bat";
871 * sys/wait.h on AIX 5.2 defines macros that have both signed and
872 * unsigned types in conditional expressions.
874 fix = {
875 hackname = aix_syswait_2;
876 files = sys/wait.h;
877 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
878 c_fix = format;
879 c_fix_arg = "? (int)%1";
880 test_text = "#define WSTOPSIG(__x) "
881 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
885 * sys/signal.h on some versions of AIX uses volatile in the typedef of
886 * sig_atomic_t, which causes gcc to generate a warning about duplicate
887 * volatile when a sig_atomic_t variable is declared volatile, as
888 * required by ANSI C.
890 fix = {
891 hackname = aix_volatile;
892 files = sys/signal.h;
893 select = "typedef volatile int sig_atomic_t";
894 c_fix = format;
895 c_fix_arg = "typedef int sig_atomic_t";
896 test_text = "typedef volatile int sig_atomic_t;";
900 * Fix __assert declaration in assert.h on Alpha OSF/1.
902 fix = {
903 hackname = alpha___assert;
904 files = "assert.h";
905 select = '__assert\(char \*, char \*, int\)';
906 c_fix = format;
907 c_fix_arg = "__assert(const char *, const char *, int)";
908 test_text = 'extern void __assert(char *, char *, int);';
912 * Fix assert macro in assert.h on Alpha OSF/1.
913 * The superfluous int cast breaks C++.
915 fix = {
916 hackname = alpha_assert;
917 files = "assert.h";
918 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
919 c_fix = format;
920 c_fix_arg = "%1(EX)";
921 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
922 ': __assert(#EX, __FILE__, __LINE__))';
926 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
928 fix = {
929 hackname = alpha_getopt;
930 files = "stdio.h";
931 files = "stdlib.h";
932 select = 'getopt\(int, char \*\[\], *char \*\)';
933 c_fix = format;
934 c_fix_arg = "getopt(int, char *const[], const char *)";
935 test_text = 'extern int getopt(int, char *[], char *);';
939 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
941 fix = {
942 hackname = alpha_if_semicolon;
943 files = net/if.h;
944 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
945 c_fix = format;
946 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
947 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
951 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
953 fix = {
954 hackname = alpha_parens;
955 files = sym.h;
956 select = '#ifndef\(__mips64\)';
957 c_fix = format;
958 c_fix_arg = "#ifndef __mips64";
959 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
963 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
964 * And OpenBSD.
966 fix = {
967 hackname = alpha_sbrk;
968 files = unistd.h;
969 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
970 c_fix = format;
971 c_fix_arg = "void *sbrk(";
972 test_text = "extern char* sbrk(ptrdiff_t increment);";
976 * For C++, avoid any typedef or macro definition of bool,
977 * and use the built in type instead.
978 * HP/UX 10.20 also has it in curses_colr/curses.h.
980 fix = {
981 hackname = avoid_bool_define;
982 files = curses.h;
983 files = curses_colr/curses.h;
984 files = term.h;
985 files = tinfo.h;
987 select = "#[ \t]*define[ \t]+bool[ \t]";
988 bypass = "__cplusplus";
990 c_fix = format;
991 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
992 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
994 test_text = "# define bool\t char \n";
998 * avoid_bool_type
1000 fix = {
1001 hackname = avoid_bool_type;
1002 files = curses.h;
1003 files = curses_colr/curses.h;
1004 files = term.h;
1005 files = tinfo.h;
1007 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1008 bypass = "__cplusplus";
1010 c_fix = format;
1011 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1013 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1017 * For C++, avoid any typedef definition of wchar_t,
1018 * and use the built in type instead.
1019 * Don't do this for headers that are smart enough to do the right
1020 * thing (recent [n]curses.h and Xlib.h).
1021 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1022 * and will be broken by the edit.
1025 fix = {
1026 hackname = avoid_wchar_t_type;
1028 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1029 bypass = "__cplusplus";
1030 bypass = "_LINUX_NLS_H";
1031 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1033 c_fix = format;
1034 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1036 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1040 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1042 fix = {
1043 hackname = bad_struct_term;
1044 files = curses.h;
1045 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1046 c_fix = format;
1047 c_fix_arg = "struct term;";
1049 test_text = 'typedef struct term;';
1053 * Fix one other error in this file:
1054 * a mismatched quote not inside a C comment.
1056 fix = {
1057 hackname = badquote;
1058 files = sundev/vuid_event.h;
1059 select = "doesn't";
1060 c_fix = format;
1061 c_fix_arg = "does not";
1063 test_text = "/* doesn't have matched single quotes */";
1067 * check for broken assert.h that needs stdio.h
1069 fix = {
1070 hackname = broken_assert_stdio;
1071 files = assert.h;
1072 select = stderr;
1073 bypass = "include.*stdio\\.h";
1074 c_fix = wrap;
1075 c_fix_arg = "#include <stdio.h>\n";
1076 test_text = "extern FILE* stderr;";
1080 * check for broken assert.h that needs stdlib.h
1082 fix = {
1083 hackname = broken_assert_stdlib;
1084 files = assert.h;
1085 select = 'exit *\(|abort *\(';
1086 bypass = "include.*stdlib\\.h";
1087 c_fix = wrap;
1088 c_fix_arg = "#ifdef __cplusplus\n"
1089 "#include <stdlib.h>\n"
1090 "#endif\n";
1091 test_text = "extern void exit ( int );";
1095 * Remove `extern double cabs' declarations from math.h.
1096 * This conflicts with C99. Discovered on AIX.
1097 * Darwin hides its broken cabs in architecture-specific subdirs.
1099 fix = {
1100 hackname = broken_cabs;
1101 files = math.h, "architecture/*/math.h";
1102 select = "^extern[ \t]+double[ \t]+cabs";
1104 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1105 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1107 test_text = "#ifdef __STDC__\n"
1108 "extern double cabs(struct dbl_hypot);\n"
1109 "#else\n"
1110 "extern double cabs();\n"
1111 "#endif\n"
1112 "extern double cabs ( _Complex z );";
1116 * Fixup Darwin's broken check for __builtin_nanf.
1118 fix = {
1119 hackname = broken_nan;
1121 * It is tempting to omit the first "files" entry. Do not.
1122 * The testing machinery will take the first "files" entry as the name
1123 * of a test file to play with. It would be a nuisance to have a directory
1124 * with the name "*".
1126 files = "architecture/ppc/math.h";
1127 files = "architecture/*/math.h";
1128 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1129 bypass = "powl";
1130 c_fix = format;
1131 c_fix_arg = "#if 1";
1132 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1136 * Various systems derived from BSD4.4 contain a macro definition
1137 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1138 * Known to be fixed in FreeBSD 5 system headers.
1140 fix = {
1141 hackname = bsd_stdio_attrs_conflict;
1142 mach = "*-*-*bsd*";
1143 mach = "*-*-*darwin*";
1144 files = stdio.h;
1145 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1146 c_fix = format;
1147 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1148 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1149 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1150 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1151 test_text = '#define vfscanf __svfscanf';
1155 * Fix various macros used to define ioctl numbers.
1156 * The traditional syntax was:
1158 * #define _CTRL(n, x) (('n'<<8)+x)
1159 * #define TCTRLCFOO _CTRL(T, 1)
1161 * but this does not work with the C standard, which disallows macro
1162 * expansion inside strings. We have to rewrite it thus:
1164 * #define _CTRL(n, x) ((n<<8)+x)
1165 * #define TCTRLCFOO _CTRL('T', 1)
1167 * The select expressions match too much, but the c_fix code is cautious.
1169 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1171 fix = {
1172 hackname = ctrl_quotes_def;
1173 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1174 c_fix = char_macro_def;
1175 c_fix_arg = "CTRL";
1178 * This is two tests in order to ensure that the "CTRL(c)" can
1179 * be selected in isolation from the multi-arg format
1181 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1182 test_text = "#define _CTRL(c) ('c'&037)";
1186 * Fix various macros used to define ioctl numbers.
1188 fix = {
1189 hackname = ctrl_quotes_use;
1190 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1191 c_fix = char_macro_use;
1192 c_fix_arg = "CTRL";
1193 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1197 * sys/mman.h on HP/UX is not C++ ready,
1198 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1200 * rpc/types.h on OSF1/2.0 is not C++ ready,
1201 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1203 * The problem is the declaration of malloc.
1205 fix = {
1206 hackname = cxx_unready;
1207 files = sys/mman.h;
1208 files = rpc/types.h;
1209 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1210 not within a macro. */
1211 bypass = '"C"|__BEGIN_DECLS';
1213 c_fix = wrap;
1214 c_fix_arg = "#ifdef __cplusplus\n"
1215 "extern \"C\" {\n"
1216 "#endif\n";
1217 c_fix_arg = "#ifdef __cplusplus\n"
1218 "}\n"
1219 "#endif\n";
1220 test_text = "extern void* malloc( size_t );";
1224 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1225 * you have to not use "" includes.
1227 fix = {
1228 hackname = darwin_9_long_double_funcs_2;
1229 mach = "*-*-darwin7.9*";
1230 files = math.h;
1231 select = '#include[ \t]+\"';
1232 c_fix = format;
1233 c_fix_arg = "%1<%2.h>";
1235 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1237 test_text = '#include "architecture/ppc/math.h"';
1241 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1242 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1244 fix = {
1245 hackname = darwin_externc;
1246 mach = "*-*-darwin*";
1247 files = mach-o/swap.h;
1248 files = mach/mach_time.h;
1249 files = mach/mach_traps.h;
1250 files = mach/message.h;
1251 files = mach/mig.h;
1252 files = mach/semaphore.h;
1253 bypass = "extern \"C\"";
1254 bypass = "__BEGIN_DECLS";
1255 c_fix = wrap;
1256 c_fix_arg = "#ifdef __cplusplus\n"
1257 "extern \"C\" {\n"
1258 "#endif\n";
1259 c_fix_arg = "#ifdef __cplusplus\n"
1260 "}\n"
1261 "#endif\n";
1262 test_text = "extern void swap_fat_header();\n";
1266 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1267 * bad __GNUC__ tests.
1269 fix = {
1270 hackname = darwin_gcc4_breakage;
1271 mach = "*-*-darwin*";
1272 files = AvailabilityMacros.h;
1273 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1274 c_fix = format;
1275 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1276 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1277 "(__GNUC_MINOR__ >= 1)\n";
1281 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1282 * why would you ever put it in a system header file?
1284 fix = {
1285 hackname = darwin_private_extern;
1286 mach = "*-*-darwin*";
1287 files = mach-o/dyld.h;
1288 select = "__private_extern__ [a-z_]+ _dyld_";
1289 c_fix = format;
1290 c_fix_arg = "extern";
1291 c_fix_arg = "__private_extern__";
1292 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1293 "const char *dyld_func_name,\n"
1294 "unsigned long *address);\n";
1298 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1299 * unsigned constants.
1301 fix = {
1302 hackname = darwin_stdint_1;
1303 mach = "*-*-darwin*";
1304 files = stdint-darwin.h, stdint.h;
1305 c_fix = format;
1306 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1307 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1308 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1309 test_text = "#define UINT8_C(v) (v ## U)\n"
1310 "#define UINT16_C(v) (v ## U)";
1314 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1315 * with wrong types.
1317 fix = {
1318 hackname = darwin_stdint_2;
1319 mach = "*-*-darwin*";
1320 files = stdint-darwin.h, stdint.h;
1321 c_fix = format;
1322 c_fix_arg = "#if __WORDSIZE == 64\n"
1323 "#define INTPTR_MAX 9223372036854775807L\n"
1324 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1325 "#else\n"
1326 "#define INTPTR_MAX 2147483647L\n"
1327 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1328 "#endif";
1329 select = "#if __WORDSIZE == 64\n"
1330 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1331 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1332 "#else\n"
1333 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1334 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1335 "#endif";
1336 test_text = "#if __WORDSIZE == 64\n"
1337 "#define INTPTR_MIN INT64_MIN\n"
1338 "#define INTPTR_MAX INT64_MAX\n"
1339 "#else\n"
1340 "#define INTPTR_MIN INT32_MIN\n"
1341 "#define INTPTR_MAX INT32_MAX\n"
1342 "#endif";
1346 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1348 fix = {
1349 hackname = darwin_stdint_3;
1350 mach = "*-*-darwin*";
1351 files = stdint-darwin.h, stdint.h;
1352 c_fix = format;
1353 c_fix_arg = "#if __WORDSIZE == 64\n"
1354 "#define UINTPTR_MAX 18446744073709551615UL\n"
1355 "#else\n"
1356 "#define UINTPTR_MAX 4294967295UL\n"
1357 "#endif";
1358 select = "#if __WORDSIZE == 64\n"
1359 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1360 "#else\n"
1361 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1362 "#endif";
1363 test_text = "#if __WORDSIZE == 64\n"
1364 "#define UINTPTR_MAX UINT64_MAX\n"
1365 "#else\n"
1366 "#define UINTPTR_MAX UINT32_MAX\n"
1367 "#endif";
1371 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1373 fix = {
1374 hackname = darwin_stdint_4;
1375 mach = "*-*-darwin*";
1376 files = stdint-darwin.h, stdint.h;
1377 c_fix = format;
1378 c_fix_arg = "#if __WORDSIZE == 64\n"
1379 "#define SIZE_MAX 18446744073709551615UL\n"
1380 "#else\n"
1381 "#define SIZE_MAX 4294967295UL\n"
1382 "#endif";
1383 select = "#if __WORDSIZE == 64\n"
1384 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1385 "#else\n"
1386 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1387 "#endif";
1388 test_text = "#if __WORDSIZE == 64\n"
1389 "#define SIZE_MAX UINT64_MAX\n"
1390 "#else\n"
1391 "#define SIZE_MAX UINT32_MAX\n"
1392 "#endif";
1396 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1397 * with a wrong type.
1399 fix = {
1400 hackname = darwin_stdint_5;
1401 mach = "*-*-darwin*";
1402 files = stdint-darwin.h, stdint.h;
1403 c_fix = format;
1404 c_fix_arg = "#if __WORDSIZE == 64\n"
1405 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1406 "#define INTMAX_MAX 9223372036854775807L\n"
1407 "#define UINTMAX_MAX 18446744073709551615UL\n"
1408 "#else\n"
1409 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1410 "#define INTMAX_MAX 9223372036854775807LL\n"
1411 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1412 "#endif";
1413 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1414 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1415 "\n"
1416 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1417 test_text = "#define INTMAX_MIN INT64_MIN\n"
1418 "#define INTMAX_MAX INT64_MAX\n"
1419 "\n"
1420 "#define UINTMAX_MAX UINT64_MAX";
1424 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1425 * with a wrong type.
1427 fix = {
1428 hackname = darwin_stdint_6;
1429 mach = "*-*-darwin*";
1430 files = stdint-darwin.h, stdint.h;
1431 c_fix = format;
1432 c_fix_arg = "#if __WORDSIZE == 64\n"
1433 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1434 "#define PTRDIFF_MAX 9223372036854775807L\n"
1435 "#else\n"
1436 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1437 "#define PTRDIFF_MAX 2147483647\n"
1438 "#endif";
1439 select = "#if __WORDSIZE == 64\n"
1440 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1441 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1442 "#else\n"
1443 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1444 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1445 "#endif";
1446 test_text = "#if __WORDSIZE == 64\n"
1447 "#define PTRDIFF_MIN INT64_MIN\n"
1448 "#define PTRDIFF_MAX INT64_MAX\n"
1449 "#else\n"
1450 "#define PTRDIFF_MIN INT32_MIN\n"
1451 "#define PTRDIFF_MAX INT32_MAX\n"
1452 "#endif";
1456 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1457 * with a wrong type.
1459 fix = {
1460 hackname = darwin_stdint_7;
1461 mach = "*-*-darwin*";
1462 files = stdint-darwin.h, stdint.h;
1463 c_fix = format;
1464 c_fix_arg = "#if __WORDSIZE == 64\n"
1465 "#define INTMAX_C(v) (v ## L)\n"
1466 "#define UINTMAX_C(v) (v ## UL)\n"
1467 "#else\n"
1468 "#define INTMAX_C(v) (v ## LL)\n"
1469 "#define UINTMAX_C(v) (v ## ULL)\n"
1470 "#endif";
1471 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1472 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1473 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1474 "#define UINTMAX_C(v) (v ## ULL)";
1478 * Fix <c_asm.h> on Digital UNIX V4.0:
1479 * It contains a prototype for a DEC C internal asm() function,
1480 * clashing with gcc's asm keyword. So protect this with __DECC.
1482 fix = {
1483 hackname = dec_intern_asm;
1484 files = c_asm.h;
1485 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1486 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1487 "#endif\n";
1488 test_text =
1489 "float fasm {\n"
1490 " ... asm stuff ...\n"
1491 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1495 * Fix typo in <wchar.h> on DJGPP 2.03.
1497 fix = {
1498 hackname = djgpp_wchar_h;
1499 file = wchar.h;
1500 select = "__DJ_wint_t";
1501 bypass = "sys/djtypes.h";
1502 c_fix = format;
1503 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1504 c_fix_arg = "#include <stddef.h>";
1505 test_text = "#include <stddef.h>\n"
1506 "extern __DJ_wint_t x;\n";
1510 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1512 fix = {
1513 hackname = ecd_cursor;
1514 files = "sunwindow/win_lock.h";
1515 files = "sunwindow/win_cursor.h";
1516 select = 'ecd\.cursor';
1517 c_fix = format;
1518 c_fix_arg = 'ecd_cursor';
1520 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1524 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1525 * that fails when compiling for SSE-less 32-bit x86.
1527 fix = {
1528 hackname = feraiseexcept_nosse_divbyzero;
1529 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1530 files = bits/fenv.h, '*/bits/fenv.h';
1531 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1532 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1533 bypass = "\"fdivp .*; fwait\"";
1535 c_fix = format;
1536 c_fix_arg = <<- _EOText_
1537 # ifdef __SSE_MATH__
1539 # else
1540 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1541 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1542 # endif
1543 _EOText_;
1545 test_text = <<- _EOText_
1546 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1547 _EOText_;
1551 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1552 * that fails when compiling for SSE-less 32-bit x86.
1554 fix = {
1555 hackname = feraiseexcept_nosse_invalid;
1556 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1557 files = bits/fenv.h, '*/bits/fenv.h';
1558 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1559 ": \"x\" \\(__f\\)\\);$";
1560 bypass = "\"fdiv .*; fwait\"";
1562 c_fix = format;
1563 c_fix_arg = <<- _EOText_
1564 # ifdef __SSE_MATH__
1566 # else
1567 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1568 %1 : "=t" (__f) : "0" (__f));
1569 # endif
1570 _EOText_;
1572 test_text = <<- _EOText_
1573 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1574 _EOText_;
1578 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1579 * neither the existence of GCC 3 nor its exact feature set yet break
1580 * (by design?) when __GNUC__ is set beyond 2.
1582 fix = {
1583 hackname = freebsd_gcc3_breakage;
1584 mach = "*-*-freebsd*";
1585 files = sys/cdefs.h;
1586 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1587 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1588 c_fix = format;
1589 c_fix_arg = '%0 || __GNUC__ >= 3';
1590 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1594 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1595 * neither the existence of GCC 4 nor its exact feature set yet break
1596 * (by design?) when __GNUC__ is set beyond 3.
1598 fix = {
1599 hackname = freebsd_gcc4_breakage;
1600 mach = "*-*-freebsd*";
1601 files = sys/cdefs.h;
1602 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1603 c_fix = format;
1604 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1605 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1609 * Some versions of glibc don't expect the C99 inline semantics.
1611 fix = {
1612 hackname = glibc_c99_inline_1;
1613 files = features.h, '*/features.h';
1614 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1615 c_fix = format;
1616 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1617 test_text = <<-EOT
1618 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1619 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1620 # define __USE_EXTERN_INLINES 1
1621 #endif
1622 EOT;
1626 * Similar, but a version that didn't have __NO_INLINE__
1628 fix = {
1629 hackname = glibc_c99_inline_1a;
1630 files = features.h, '*/features.h';
1631 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1632 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1633 c_fix = format;
1634 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1635 test_text = <<-EOT
1636 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1637 # define __USE_EXTERN_INLINES 1
1638 #endif
1639 EOT;
1643 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1644 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1645 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1647 fix = {
1648 hackname = glibc_c99_inline_2;
1649 files = sys/stat.h, '*/sys/stat.h';
1650 select = "extern __inline__ int";
1651 sed = "s/extern int \\(stat\\)/"
1652 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1653 "__inline__ int \\1/";
1654 sed = "s/extern int \\([lf]stat\\)/"
1655 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1656 "__inline__ int \\1/";
1657 sed = "s/extern int \\(mknod\\)/"
1658 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1659 "__inline__ int \\1/";
1660 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1661 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1662 "__inline__ int __REDIRECT\\1 (\\2/";
1663 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1664 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1665 "__inline__ int __REDIRECT\\1 (\\2/";
1666 sed = "s/^extern __inline__ int/"
1667 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1668 "__inline__ int/";
1669 test_text = <<-EOT
1670 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1671 extern __inline__ int
1672 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1674 EOT;
1678 * glibc_c99_inline_3
1680 fix = {
1681 hackname = glibc_c99_inline_3;
1682 files = bits/string2.h, '*/bits/string2.h';
1683 select = "extern __inline";
1684 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1685 c_fix = format;
1686 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1687 c_fix_arg = "^# ifdef __cplusplus$";
1688 test_text = <<-EOT
1689 # ifdef __cplusplus
1690 # define __STRING_INLINE inline
1691 # else
1692 # define __STRING_INLINE extern __inline
1693 # endif
1694 EOT;
1698 * glibc_c99_inline_4
1700 fix = {
1701 hackname = glibc_c99_inline_4;
1702 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1703 pthread.h, '*/pthread.h';
1704 bypass = "__extern_inline|__gnu_inline__";
1705 select = "(^| )extern __inline";
1706 c_fix = format;
1707 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1708 test_text = <<-EOT
1709 __extension__ extern __inline unsigned int
1710 extern __inline unsigned int
1711 EOT;
1714 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1715 * so we replace them with versions that correspond to the
1716 * definition.
1718 fix = {
1719 hackname = glibc_mutex_init;
1720 files = pthread.h;
1721 select = '\{ *\{ *0, *\} *\}';
1722 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1723 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1724 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1725 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1726 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1727 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1728 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1729 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1730 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1731 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1732 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1733 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1734 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1735 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1736 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1737 "N;s/^[ \t]*#[ \t]*"
1738 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1739 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1740 "# \\1\\\n"
1741 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1742 "# else\\\n"
1743 "# \\1\\\n"
1744 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1745 "# endif/";
1746 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1747 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1748 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1749 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1751 test_text = <<- _EOText_
1752 #define PTHREAD_MUTEX_INITIALIZER \\
1753 { { 0, } }
1754 #ifdef __USE_GNU
1755 # if __WORDSIZE == 64
1756 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1757 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1758 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1759 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1760 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1761 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1762 # else
1763 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1764 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1765 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1766 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1767 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1768 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1769 # endif
1770 #endif
1771 # define PTHREAD_RWLOCK_INITIALIZER \\
1772 { { 0, } }
1773 # ifdef __USE_GNU
1774 # if __WORDSIZE == 64
1775 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1776 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1777 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1778 # else
1779 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1780 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1781 # endif
1782 # endif
1783 #define PTHREAD_COND_INITIALIZER { { 0, } }
1784 _EOText_;
1787 /* glibc versions before 2.5 have a version of stdint.h that defines
1788 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1789 versions with stdint.h based on those glibc versions. */
1790 fix = {
1791 hackname = glibc_stdint;
1792 files = stdint.h;
1793 select = "GNU C Library";
1794 c_fix = format;
1795 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1796 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1797 test_text = "/* This file is part of the GNU C Library. */\n"
1798 "# define UINT8_C(c)\tc ## U\n"
1799 "# define UINT16_C(c)\tc ## U";
1802 /* Some versions of glibc have a version of bits/string2.h that
1803 produces "value computed is not used" warnings from strncpy; fix
1804 this definition by using __builtin_strncpy instead as in newer
1805 versions. */
1806 fix = {
1807 hackname = glibc_strncpy;
1808 files = bits/string2.h, '*/bits/string2.h';
1809 bypass = "__builtin_strncpy";
1810 c_fix = format;
1811 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1812 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1813 test_text = <<-EOT
1814 # define strncpy(dest, src, n) \
1815 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1816 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1817 ? (char *) memcpy (dest, src, n) \\
1818 : strncpy (dest, src, n)) \\
1819 : strncpy (dest, src, n)))
1820 EOT;
1824 /* glibc's tgmath.h relies on an expression that is not an integer
1825 constant expression being treated as it was by GCC 4.4 and
1826 earlier. */
1827 fix = {
1828 hackname = glibc_tgmath;
1829 files = tgmath.h;
1830 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1831 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1832 c_fix = format;
1833 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1834 "(__builtin_classify_type ((type) 0) == 9 && "
1835 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1836 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1840 * Fix these files to use the types we think they should for
1841 * ptrdiff_t, size_t, and wchar_t.
1843 * This defines the types in terms of macros predefined by our 'cpp'.
1844 * This is supposedly necessary for glibc's handling of these types.
1845 * It's probably not necessary for anyone else, but it doesn't hurt.
1847 fix = {
1848 hackname = gnu_types;
1849 files = "sys/types.h";
1850 files = "stdlib.h";
1851 files = "sys/stdtypes.h";
1852 files = "stddef.h";
1853 files = "memory.h";
1854 files = "unistd.h";
1855 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1856 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1857 c_fix = gnu_type;
1858 /* The Solaris 10 headers already define these types correctly. */
1859 mach = '*-*-solaris2.1[0-9]*';
1860 not_machine = true;
1862 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1863 "typedef uint_t size_t; /* uint_t */\n"
1864 "typedef ushort_t wchar_t; /* ushort_t */";
1868 * Fix HP & Sony's use of "../machine/xxx.h"
1869 * to refer to: <machine/xxx.h>
1871 fix = {
1872 hackname = hp_inline;
1873 files = sys/spinlock.h;
1874 files = machine/machparam.h;
1875 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1877 c_fix = format;
1878 c_fix_arg = "%1<machine/%2.h>";
1880 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1881 '([a-z]+)\.h"';
1883 test_text = ' # include "../machine/mumble.h"';
1887 * Check for (...) in C++ code in HP/UX sys/file.h.
1889 fix = {
1890 hackname = hp_sysfile;
1891 files = sys/file.h;
1892 select = "HPUX_SOURCE";
1894 c_fix = format;
1895 c_fix_arg = "(struct file *, ...)";
1896 c_fix_arg = '\(\.\.\.\)';
1898 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1902 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1903 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1905 fix = {
1906 hackname = hppa_hpux_fp_macros;
1907 mach = "hppa*-hp-hpux11*";
1908 files = math.h;
1909 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1910 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1911 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1912 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1913 "#[ \t]*define[ \t]*FP_NAN.*\n";
1914 c_fix = format;
1915 c_fix_arg = <<- _EOFix_
1916 #endif /* _INCLUDE_HPUX_SOURCE */
1918 #if defined(_INCLUDE_HPUX_SOURCE) || \
1919 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1920 %0#endif
1922 #ifdef _INCLUDE_HPUX_SOURCE
1924 _EOFix_;
1926 test_text =
1927 "# define FP_NORMAL 0\n"
1928 "# define FP_ZERO 1\n"
1929 "# define FP_INFINITE 2\n"
1930 "# define FP_SUBNORMAL 3\n"
1931 "# define FP_NAN 4\n";
1935 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1936 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1938 fix = {
1939 hackname = hpux10_cpp_pow_inline;
1940 files = fixinc-test-limits.h, math.h;
1941 select = <<- END_POW_INLINE
1942 ^# +ifdef +__cplusplus
1944 +inline +double +pow\(double +__d,int +__expon\) +\{
1945 [ ]+return +pow\(__d,\(double\)__expon\);
1947 +extern +"C" +\{
1948 #else
1949 # +endif
1950 END_POW_INLINE;
1952 c_fix = format;
1953 c_fix_arg = "";
1955 test_text =
1956 "# ifdef __cplusplus\n"
1957 " }\n"
1958 " inline double pow(double __d,int __expon) {\n"
1959 "\t return pow(__d,(double)__expon);\n"
1960 " }\n"
1961 ' extern "C"' " {\n"
1962 "#else\n"
1963 "# endif";
1966 fix = {
1967 hackname = hpux11_cpp_pow_inline;
1968 files = math.h;
1969 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1970 " +return pow\\(d, \\(double\\)expon\\);\n"
1971 " +\\}\n";
1972 c_fix = format;
1973 c_fix_arg = "";
1975 test_text =
1976 " inline double pow(double d,int expon) {\n"
1977 " return pow(d, (double)expon);\n"
1978 " }\n";
1982 * Fix hpux 10.X missing ctype declarations 1
1984 fix = {
1985 hackname = hpux10_ctype_declarations1;
1986 files = ctype.h;
1987 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1988 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1989 c_fix = format;
1990 c_fix_arg = "#ifdef _PROTOTYPES\n"
1991 "extern int __tolower(int);\n"
1992 "extern int __toupper(int);\n"
1993 "#else /* NOT _PROTOTYPES */\n"
1994 "extern int __tolower();\n"
1995 "extern int __toupper();\n"
1996 "#endif /* _PROTOTYPES */\n\n"
1997 "%0\n";
1999 test_text = "# define _toupper(__c) __toupper(__c)\n";
2003 * Fix hpux 10.X missing ctype declarations 2
2005 fix = {
2006 hackname = hpux10_ctype_declarations2;
2007 files = ctype.h;
2008 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2009 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2010 c_fix = format;
2011 c_fix_arg = "%0\n\n"
2012 "#ifdef _PROTOTYPES\n"
2013 " extern int _isalnum(int);\n"
2014 " extern int _isalpha(int);\n"
2015 " extern int _iscntrl(int);\n"
2016 " extern int _isdigit(int);\n"
2017 " extern int _isgraph(int);\n"
2018 " extern int _islower(int);\n"
2019 " extern int _isprint(int);\n"
2020 " extern int _ispunct(int);\n"
2021 " extern int _isspace(int);\n"
2022 " extern int _isupper(int);\n"
2023 " extern int _isxdigit(int);\n"
2024 "# else /* not _PROTOTYPES */\n"
2025 " extern int _isalnum();\n"
2026 " extern int _isalpha();\n"
2027 " extern int _iscntrl();\n"
2028 " extern int _isdigit();\n"
2029 " extern int _isgraph();\n"
2030 " extern int _islower();\n"
2031 " extern int _isprint();\n"
2032 " extern int _ispunct();\n"
2033 " extern int _isspace();\n"
2034 " extern int _isupper();\n"
2035 " extern int _isxdigit();\n"
2036 "#endif /* _PROTOTYPES */\n";
2038 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2039 " extern unsigned int *__SB_masks;\n";
2043 * Fix hpux 10.X missing stdio declarations
2045 fix = {
2046 hackname = hpux10_stdio_declarations;
2047 files = stdio.h;
2048 select = "^#[ \t]*define _iob[ \t]*__iob";
2049 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2050 c_fix = format;
2051 c_fix_arg = "%0\n\n"
2052 "# if defined(__STDC__) || defined(__cplusplus)\n"
2053 " extern int snprintf(char *, size_t, const char *, ...);\n"
2054 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2055 "# else /* not __STDC__) || __cplusplus */\n"
2056 " extern int snprintf();\n"
2057 " extern int vsnprintf();\n"
2058 "# endif /* __STDC__) || __cplusplus */\n";
2060 test_text = "# define _iob __iob\n";
2064 * Make sure hpux defines abs in header.
2066 fix = {
2067 hackname = hpux11_abs;
2068 mach = "*-hp-hpux11*";
2069 files = stdlib.h;
2070 select = "ifndef _MATH_INCLUDED";
2071 c_fix = format;
2072 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2073 test_text = "#ifndef _MATH_INCLUDED";
2077 * Fix hpux11 __LWP_RWLOCK_VALID define
2079 fix = {
2080 hackname = hpux11_lwp_rwlock_valid;
2081 mach = "*-hp-hpux11*";
2082 files = sys/pthread.h;
2083 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2084 c_fix = format;
2085 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2086 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2090 * hpux sendfile()
2092 fix = {
2093 hackname = hpux11_extern_sendfile;
2094 mach = "*-hp-hpux11.[12]*";
2095 files = sys/socket.h;
2096 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2097 c_fix = format;
2098 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2099 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2100 " const struct iovec *, int));\n";
2104 * hpux sendpath()
2106 fix = {
2107 hackname = hpux11_extern_sendpath;
2108 mach = "*-hp-hpux11.[12]*";
2109 files = sys/socket.h;
2110 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2111 c_fix = format;
2112 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2113 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2114 " const struct iovec *, int));\n";
2118 * Keep HP-UX 11 from stomping on C++ math namespace
2119 * with defines for fabsf.
2121 fix = {
2122 hackname = hpux11_fabsf;
2123 files = math.h;
2124 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2125 bypass = "__cplusplus";
2127 c_fix = format;
2128 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2130 test_text =
2131 "#ifdef _PA_RISC\n"
2132 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2133 "#endif";
2137 * Fix C99 constant in __POINTER_SET define.
2139 fix = {
2140 hackname = hpux11_pthread_const;
2141 mach = "*-hp-hpux11.[0-3]*";
2142 files = sys/pthread.h;
2143 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2145 c_fix = format;
2146 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2147 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2151 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2152 * being defined by having it define _hpux_size_t instead.
2154 fix = {
2155 hackname = hpux11_size_t;
2156 mach = "*-hp-hpux11*";
2157 select = "__size_t";
2159 c_fix = format;
2160 c_fix_arg = "_hpux_size_t";
2162 test_text =
2163 "#define __size_t size_t\n"
2164 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2168 * Fix hpux 11.00 broken snprintf declaration
2169 * (third argument is char *, needs to be const char * to prevent
2170 * spurious warnings with -Wwrite-strings or in C++).
2172 fix = {
2173 hackname = hpux11_snprintf;
2174 files = stdio.h;
2175 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2176 ' *(char *\*, *\.\.\.\);)';
2177 c_fix = format;
2178 c_fix_arg = '%1 const %3';
2180 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2181 "extern int snprintf(char *, __size_t, char *, ...);\n"
2182 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2186 * Fix hpux 11.00 broken vsnprintf declaration
2188 fix = {
2189 hackname = hpux11_vsnprintf;
2190 files = stdio.h;
2191 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2192 'const char \*,) __va__list\);';
2193 c_fix = format;
2194 c_fix_arg = "%1 __va_list);";
2196 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2197 ' __va__list);';
2201 * get rid of bogus inline definitions in HP-UX 8.0
2203 fix = {
2204 hackname = hpux8_bogus_inlines;
2205 files = math.h;
2206 select = inline;
2207 bypass = "__GNUG__";
2208 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2209 "@extern \"C\" int abs(int);@";
2210 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2211 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2212 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2213 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2214 "inline double sqr(double v) { return v**0.5; }";
2218 * hpux intptr
2220 fix = {
2221 hackname = hpux_c99_intptr;
2222 mach = "*-hp-hpux11.3*";
2223 files = stdint-hpux11.h, stdint.h;
2224 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2225 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2226 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2227 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2228 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2229 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2230 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2231 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2232 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2233 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2234 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2235 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2236 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2237 "#define PTRDIFF_MIN INT32_MIN\n"
2238 "#define INTPTR_MAX INT32_MAX\n"
2239 "#define INTPTR_MIN INT32_MIN\n"
2240 "#define UINTPTR_MAX UINT32_MAX\n"
2241 "#define SIZE_MAX UINT32_MAX\n";
2245 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2247 fix = {
2248 hackname = hpux_c99_inttypes;
2249 mach = "*-hp-hpux11.[23]*";
2250 files = inttypes.h;
2251 files = stdint-hpux11.h, stdint.h;
2252 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2253 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2254 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2255 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2256 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2257 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2258 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2259 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2260 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2261 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2262 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2263 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2267 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2269 fix = {
2270 hackname = hpux_c99_inttypes2;
2271 mach = "*-hp-hpux11.2*";
2272 files = stdint-hpux11.h, stdint.h;
2273 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2274 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2275 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2276 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2277 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2278 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2279 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2280 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2281 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2282 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2283 "# define INT16_C(__c) ((short)(__c))\n"
2284 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2288 * Fix hpux broken ctype macros
2290 fix = {
2291 hackname = hpux_ctype_macros;
2292 files = ctype.h;
2293 select = '((: |\()__SB_masks \? )'
2294 '(__SB_masks\[__(alnum|c)\] & _IS)';
2295 c_fix = format;
2296 c_fix_arg = "%1(int)%3";
2298 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2299 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2303 * hpux errno()
2305 fix = {
2306 hackname = hpux_extern_errno;
2307 mach = "*-hp-hpux10.*";
2308 mach = "*-hp-hpux11.[0-2]*";
2309 files = errno.h;
2310 select = "^[ \t]*extern int errno;$";
2311 c_fix = format;
2312 c_fix_arg = "#ifdef __cplusplus\n"
2313 "extern \"C\" {\n"
2314 "#endif\n"
2315 "%0\n"
2316 "#ifdef __cplusplus\n"
2317 "}\n"
2318 "#endif";
2319 test_text = " extern int errno;\n";
2323 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2325 fix = {
2326 hackname = hpux_htonl;
2327 files = netinet/in.h;
2328 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2329 "(/\\*\n"
2330 " \\* Macros for number representation conversion\\.\n"
2331 " \\*/\n"
2332 "#ifndef ntohl)";
2333 c_fix = format;
2334 c_fix_arg = "#if 1\n%1";
2336 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2337 "/*\n"
2338 " * Macros for number representation conversion.\n"
2339 " */\n"
2340 "#ifndef ntohl\n"
2341 "#define ntohl(x) (x)\n"
2342 "#define ntohs(x) (x)\n"
2343 "#define htonl(x) (x)\n"
2344 "#define htons(x) (x)\n"
2345 "#endif\n"
2346 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2350 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2352 fix = {
2353 hackname = hpux_imaginary_i;
2354 mach = "ia64-hp-hpux11.*";
2355 files = complex.h;
2356 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2357 c_fix = format;
2358 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2359 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2363 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2365 fix = {
2366 hackname = hpux_inttype_int8_t;
2367 mach = "*-hp-hpux1[01].*";
2368 files = sys/_inttypes.h;
2369 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2370 c_fix = format;
2371 c_fix_arg = "typedef signed char int%18_t;";
2372 test_text = "typedef char int_least8_t;\n"
2373 "typedef char int8_t;\n";
2377 * HP-UX long_double
2379 fix = {
2380 hackname = hpux_long_double;
2381 mach = "*-*-hpux10*";
2382 mach = "*-*-hpux11.[012]*";
2383 files = stdlib.h;
2384 select = "extern[ \t]long_double[ \t]strtold";
2385 bypass = "long_double_t";
2386 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2387 sed = "s/long_double/long double/g";
2389 test_text = "# ifndef _LONG_DOUBLE\n"
2390 "# define _LONG_DOUBLE\n"
2391 " typedef struct {\n"
2392 " unsigned int word1, word2, word3, word4;\n"
2393 " } long_double;\n"
2394 "# endif /* _LONG_DOUBLE */\n"
2395 "extern long_double strtold(const char *, char **);\n";
2399 * We cannot use the above rule on 11.31 because it removes the strtold
2400 * definition. ia64 is OK with no hack, PA needs some help.
2402 fix = {
2403 hackname = hpux_long_double_2;
2404 mach = "hppa*-*-hpux11.3*";
2405 files = stdlib.h;
2406 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2407 "defined\\(_PROTOTYPES\\) \\|\\| "
2408 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2409 c_fix = format;
2410 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2412 test_text = "# if !defined(__ia64) || "
2413 "!defined(_PROTOTYPES) || "
2414 "defined(_LONG_DOUBLE_STRUCT)\n";
2418 * Add missing braces to pthread initializer defines.
2420 fix = {
2421 hackname = hpux_pthread_initializers;
2422 mach = "*-hp-hpux11.[0-3]*";
2423 files = sys/pthread.h;
2424 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2425 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2426 sed = "s@^[ \t]*1,[ \t]*\\\\"
2427 "@\t{ 1, 0 }@";
2428 sed = "/^[ \t]*0$/d";
2429 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2430 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2431 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2432 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2433 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2434 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2435 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2436 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2437 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2438 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2439 sed = "s@__PTHREAD_COND_VALID, 0"
2440 "@{ __PTHREAD_COND_VALID, 0 }@";
2441 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2442 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2443 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2444 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2445 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2446 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2447 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2448 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2449 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2450 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2451 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2452 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2453 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2454 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2455 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2456 "}\n";
2460 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2461 * type and mpinfou is only defined when _KERNEL is set.
2463 fix = {
2464 hackname = hpux_spu_info;
2465 mach = "*-hp-hpux*";
2467 * It is tempting to omit the first "files" entry. Do not.
2468 * The testing machinery will take the first "files" entry as the name
2469 * of a test file to play with. It would be a nuisance to have a directory
2470 * with the name "*".
2472 files = "ia64/sys/getppdp.h";
2473 files = "*/sys/getppdp.h";
2474 select = "^.*extern.*spu_info.*";
2476 c_fix = format;
2477 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2479 test_text = "extern union mpinfou spu_info[];";
2483 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2485 fix = {
2486 hackname = hpux_stdint_least_fast;
2487 mach = "*-hp-hpux11.2*";
2488 files = stdint-hpux11.h, stdint.h;
2489 select =
2490 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2491 c_fix = format;
2492 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2493 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2494 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2495 _EOFix_;
2499 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2501 fix = {
2502 hackname = hpux_systime;
2503 files = sys/time.h;
2504 select = "^extern struct sigevent;";
2506 c_fix = format;
2507 c_fix_arg = "struct sigevent;";
2509 test_text = 'extern struct sigevent;';
2513 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2515 fix = {
2516 hackname = huge_val_hex;
2517 files = bits/huge_val.h, '*/bits/huge_val.h';
2518 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2519 bypass = "__builtin_huge_val";
2521 c_fix = format;
2522 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2524 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2528 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2530 fix = {
2531 hackname = huge_valf_hex;
2532 files = bits/huge_val.h, '*/bits/huge_val.h';
2533 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2534 bypass = "__builtin_huge_valf";
2536 c_fix = format;
2537 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2539 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2543 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2545 fix = {
2546 hackname = huge_vall_hex;
2547 files = bits/huge_val.h, '*/bits/huge_val.h';
2548 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2549 bypass = "__builtin_huge_vall";
2551 c_fix = format;
2552 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2554 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2558 * Fix return type of abort and free
2560 fix = {
2561 hackname = int_abort_free_and_exit;
2562 files = stdlib.h;
2563 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2564 bypass = "_CLASSIC_ANSI_TYPES";
2566 c_fix = format;
2567 c_fix_arg = "void\t%1(";
2569 test_text = "extern int abort(int);\n"
2570 "extern int free(void*);\n"
2571 "extern int exit(void*);";
2575 * Fix various macros used to define ioctl numbers.
2576 * The traditional syntax was:
2578 * #define _IO(n, x) (('n'<<8)+x)
2579 * #define TIOCFOO _IO(T, 1)
2581 * but this does not work with the C standard, which disallows macro
2582 * expansion inside strings. We have to rewrite it thus:
2584 * #define _IO(n, x) ((n<<8)+x)
2585 * #define TIOCFOO _IO('T', 1)
2587 * The select expressions match too much, but the c_fix code is cautious.
2589 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2591 fix = {
2592 hackname = io_quotes_def;
2593 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2594 c_fix = char_macro_def;
2595 c_fix_arg = "IO";
2596 test_text =
2597 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2598 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2599 "#define _IO(x,y) ('x'<<8|y)";
2600 test_text =
2601 "#define XX_IO(x) ('x'<<8|256)";
2605 * Fix the usage of the ioctl macro numbers.
2607 fix = {
2608 hackname = io_quotes_use;
2609 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2610 "\\( *[^,']";
2611 c_fix = char_macro_use;
2612 c_fix_arg = "IO";
2613 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2614 "#define TIOCFOO \\\\\n"
2615 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2619 * Check for missing ';' in struct
2621 fix = {
2622 hackname = ip_missing_semi;
2623 files = netinet/ip.h;
2624 select = "}$";
2625 sed = "/^struct/,/^};/s/}$/};/";
2626 test_text=
2627 "struct mumble {\n"
2628 " union {\n"
2629 " int x;\n"
2630 " }\n"
2631 "}; /* mumbled struct */\n";
2635 * Non-traditional "const" declaration in Irix's limits.h.
2637 fix = {
2638 hackname = irix_limits_const;
2639 files = fixinc-test-limits.h, limits.h;
2640 select = "^extern const ";
2641 c_fix = format;
2642 c_fix_arg = "extern __const ";
2643 test_text = "extern const char limit; /* test limits */";
2647 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2648 * taking char *. However, GCC uses void * for va_list, so
2649 * calling vfprintf with a va_list fails in C++. */
2650 fix = {
2651 hackname = irix_stdio_va_list;
2652 files = stdio.h;
2654 select = '/\* va_list \*/ char \*';
2655 c_fix = format;
2656 c_fix_arg = "__gnuc_va_list";
2657 test_text =
2658 "extern int printf( const char *, /* va_list */ char * );";
2662 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2663 * use / * * / to concatenate tokens.
2665 fix = {
2666 hackname = kandr_concat;
2667 files = "sparc/asm_linkage.h";
2668 files = "sun*/asm_linkage.h";
2669 files = "arm/as_support.h";
2670 files = "arm/mc_type.h";
2671 files = "arm/xcb.h";
2672 files = "dev/chardefmac.h";
2673 files = "dev/ps_irq.h";
2674 files = "dev/screen.h";
2675 files = "dev/scsi.h";
2676 files = "sys/tty.h";
2677 files = "Xm.acorn/XmP.h";
2678 files = bsd43/bsd43_.h;
2679 select = '/\*\*/';
2680 c_fix = format;
2681 c_fix_arg = '##';
2682 test_text = "#define __CONCAT__(a,b) a/**/b";
2686 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2687 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2688 * constant on recent versions of g++.
2690 fix = {
2691 hackname = linux_ia64_ucontext;
2692 files = "sys/ucontext.h";
2693 mach = "ia64-*-linux*";
2694 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2695 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2696 c_fix = format;
2697 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2698 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2699 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2703 * Remove header file warning from sys/time.h. Autoconf's
2704 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2705 * which causes warning on LynxOS. Remove the warning.
2707 fix = {
2708 hackname = lynxos_no_warning_in_sys_time_h;
2709 files = sys/time.h;
2710 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2711 c_fix = format;
2712 c_fix_arg = "";
2713 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2717 * Add missing declaration for putenv.
2719 fix = {
2720 hackname = lynxos_missing_putenv;
2721 mach = '*-*-lynxos*';
2722 files = stdlib.h;
2723 bypass = 'putenv[ \t]*\\(';
2724 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2725 c_fix = format;
2726 c_fix_arg = "%0\n"
2727 "extern int putenv _AP((char *));";
2728 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2729 test_text = "extern char *getenv _AP((const char *));";
2733 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2735 * On NetBSD, machine is a symbolic link to an architecture specific
2736 * directory name, so we can't match a specific file name here.
2738 fix = {
2739 hackname = machine_ansi_h_va_list;
2740 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2741 bypass = '__builtin_va_list';
2743 c_fix = format;
2744 c_fix_arg = "%1__builtin_va_list";
2745 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2747 test_text = " # define _BSD_VA_LIST_\tchar**";
2751 * Fix non-ansi machine name defines
2753 fix = {
2754 hackname = machine_name;
2755 c_test = machine_name;
2756 c_fix = machine_name;
2758 test_text = "/* MACH_DIFF: */\n"
2759 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2760 "\n/* no uniform test, so be careful :-) */";
2764 * Some math.h files define struct exception (it's in the System V
2765 * Interface Definition), which conflicts with the class exception defined
2766 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2767 * This is not a great fix, but I haven't been able to think of anything
2768 * better.
2770 fix = {
2771 hackname = math_exception;
2772 files = math.h;
2773 select = "struct exception";
2775 * This should be bypassed on __cplusplus, but some supposedly C++
2776 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2777 * exception either. So currently we bypass only for glibc, based on a
2778 * comment in the fixed glibc header. Ick.
2780 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2781 '_[a-z0-9A-Z_]+_exception; for C, exception';
2782 /* The Solaris 10 headers already get this right. */
2783 mach = '*-*-solaris2.1[0-9]*';
2784 not_machine = true;
2785 c_fix = wrap;
2787 c_fix_arg = "#ifdef __cplusplus\n"
2788 "#define exception __math_exception\n"
2789 "#endif\n";
2791 c_fix_arg = "#ifdef __cplusplus\n"
2792 "#undef exception\n"
2793 "#endif\n";
2795 test_text = "typedef struct exception t_math_exception;";
2799 * This looks pretty broken to me. ``dbl_max_def'' will contain
2800 * "define DBL_MAX " at the start, when what we really want is just
2801 * the value portion. Can't figure out how to write a test case
2802 * for this either :-(
2804 fix = {
2805 hackname = math_huge_val_from_dbl_max;
2806 files = math.h;
2809 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2810 * in math.h, this fix applies.
2812 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2813 bypass = "define[ \t]+DBL_MAX";
2815 shell =
2817 * See if we have a definition for DBL_MAX in float.h.
2818 * If we do, we will replace the one in math.h with that one.
2821 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2822 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2824 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2825 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2826 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2827 "\telse cat\n"
2828 "\tfi";
2830 test_text =
2831 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2832 "#define HUGE_VAL DBL_MAX";
2836 * nested comment
2838 fix = {
2839 hackname = nested_auth_des;
2840 files = rpc/rpc.h;
2841 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2842 c_fix = format;
2843 c_fix_arg = "%1*/ /*";
2844 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2848 * Some versions of NetBSD don't expect the C99 inline semantics.
2850 fix = {
2851 hackname = netbsd_c99_inline_1;
2852 mach = "*-*-netbsd*";
2853 files = signal.h;
2854 select = "extern __inline int";
2856 c_fix = format;
2857 c_fix_arg = "extern\n"
2858 "#ifdef __GNUC_STDC_INLINE__\n"
2859 "__attribute__((__gnu_inline__))\n"
2860 "#endif\n"
2861 "__inline int";
2863 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2867 * netbsd_c99_inline_2
2869 fix = {
2870 hackname = netbsd_c99_inline_2;
2871 mach = "*-*-netbsd*";
2872 files = signal.h;
2873 select = "#define _SIGINLINE extern __inline";
2875 c_fix = format;
2876 c_fix_arg = <<- _EOArg_
2877 #ifdef __GNUC_STDC_INLINE__
2878 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2879 #else
2881 #endif
2882 _EOArg_;
2884 test_text = "#define _SIGINLINE extern __inline";
2888 * NetBSD has a semicolon after the ending '}' for some extern "C".
2890 fix = {
2891 hackname = netbsd_extra_semicolon;
2892 mach = "*-*-netbsd*";
2893 files = sys/cdefs.h;
2894 select = "#define[ \t]*__END_DECLS[ \t]*};";
2896 c_fix = format;
2897 c_fix_arg = "#define __END_DECLS }";
2899 test_text = "#define __END_DECLS };";
2903 * newlib's stdint.h has several failures to conform to C99. The fix
2904 * for these removed a comment that can be matched to identify unfixed
2905 * versions.
2907 fix = {
2908 hackname = newlib_stdint_1;
2909 files = stdint-newlib.h, stdint.h;
2910 select = "@todo - Add support for wint_t types";
2911 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2912 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2913 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2914 sed = "s@#define INT_LEAST32_MIN.*@"
2915 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2916 sed = "s@#define INT_LEAST32_MAX.*@"
2917 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2918 sed = "s@#define UINT_LEAST32_MAX.*@"
2919 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2920 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
2921 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2922 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
2923 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2924 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
2925 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2926 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2927 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2928 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2929 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2930 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2931 test_text = "/* @todo - Add support for wint_t types. */\n"
2932 "#define INT32_MIN (-2147483647-1)\n"
2933 "#define INT32_MAX 2147483647\n"
2934 "#define UINT32_MAX 4294967295U\n"
2935 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2936 "#define INT_LEAST32_MAX 2147483647\n"
2937 "#define UINT_LEAST32_MAX 4294967295U\n"
2938 "#define INT_FAST8_MIN INT8_MIN\n"
2939 "#define INT_FAST8_MAX INT8_MAX\n"
2940 "#define UINT_FAST8_MAX UINT8_MAX\n"
2941 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2942 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2943 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2944 "#define UINT8_C(x) x##U\n"
2945 "#define UINT16_C(x) x##U";
2949 * newlib_stdint_2
2951 fix = {
2952 hackname = newlib_stdint_2;
2953 files = stdint-newlib.h, stdint.h;
2954 select = "@todo - Add support for wint_t types";
2955 c_fix = format;
2956 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2957 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2958 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2959 "#define WCHAR_MAX __WCHAR_MAX__\n"
2960 "#define WCHAR_MIN __WCHAR_MIN__\n"
2961 "#define WINT_MAX __WINT_MAX__\n"
2962 "#define WINT_MIN __WINT_MIN__\n\n"
2963 "%0";
2964 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2965 test_text = "/* @todo - Add support for wint_t types. */\n"
2966 "/** Macros for minimum-width integer constant expressions */";
2970 * NeXT 3.2 adds const prefix to some math functions.
2971 * These conflict with the built-in functions.
2973 fix = {
2974 hackname = next_math_prefix;
2975 files = ansi/math.h;
2976 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2978 c_fix = format;
2979 c_fix_arg = "extern double %1(";
2980 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2982 test_text = "extern\tdouble\t__const__\tmumble();";
2986 * NeXT 3.2 uses the word "template" as a parameter for some
2987 * functions. GCC reports an invalid use of a reserved key word
2988 * with the built-in functions.
2990 fix = {
2991 hackname = next_template;
2992 files = bsd/libc.h;
2993 select = "[ \t]template\\)";
2995 c_fix = format;
2996 c_fix_arg = "(%1)";
2997 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2998 test_text = "extern mumble( char * template); /* fix */";
3002 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3003 * function prototypes. That conflicts with the built-in functions.
3005 fix = {
3006 hackname = next_volitile;
3007 files = ansi/stdlib.h;
3008 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3010 c_fix = format;
3011 c_fix_arg = "extern void %1(";
3012 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3014 test_text = "extern\tvolatile\tvoid\tabort();";
3018 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3019 * Note that version 3 of the NeXT system has wait.h in a different directory,
3020 * so that this code won't do anything. But wait.h in version 3 has a
3021 * conditional, so it doesn't need this fix. So everything is okay.
3023 fix = {
3024 hackname = next_wait_union;
3025 files = sys/wait.h;
3027 select = 'wait\(union wait';
3028 c_fix = format;
3029 c_fix_arg = "wait(void";
3030 test_text = "extern pid_d wait(union wait*);";
3034 * a missing semi-colon at the end of the nodeent structure definition.
3036 fix = {
3037 hackname = nodeent_syntax;
3038 files = netdnet/dnetdb.h;
3039 select = "char[ \t]*\\*na_addr[ \t]*$";
3040 c_fix = format;
3041 c_fix_arg = "%0;";
3042 test_text = "char *na_addr\t";
3046 * Fix OpenBSD's NULL definition.
3048 fix = {
3049 hackname = openbsd_null_definition;
3050 mach = "*-*-openbsd*";
3051 files = locale.h, stddef.h, stdio.h, string.h,
3052 time.h, unistd.h, wchar.h, sys/param.h;
3053 select = "__GNUG__";
3054 c_fix = format;
3055 c_fix_arg = "#ifndef NULL\n"
3056 "#ifdef __cplusplus\n"
3057 "#ifdef __GNUG__\n"
3058 "#define NULL\t__null\n"
3059 "#else\t /* ! __GNUG__ */\n"
3060 "#define NULL\t0L\n"
3061 "#endif\t /* __GNUG__ */\n"
3062 "#else\t /* ! __cplusplus */\n"
3063 "#define NULL\t((void *)0)\n"
3064 "#endif\t /* __cplusplus */\n"
3065 "#endif\t /* !NULL */";
3067 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3068 "^#ifdef[ \t]*__GNUG__\n"
3069 "^#define[ \t]*NULL[ \t]*__null\n"
3070 "^#else\n"
3071 "^#define[ \t]*NULL[ \t]*0L\n"
3072 "^#endif\n"
3073 "^#endif";
3074 test_text =
3075 "#ifndef NULL\n"
3076 "#ifdef __GNUG__\n"
3077 "#define NULL __null\n"
3078 "#else\n"
3079 "#define NULL 0L\n"
3080 "#endif\n"
3081 "#endif\n";
3085 * obstack.h used casts as lvalues.
3087 * We need to change postincrements of casted pointers (which are
3088 * then dereferenced and assigned into) of the form
3090 * *((TYPE*)PTRVAR)++ = (VALUE)
3092 * into expressions like
3094 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3096 * which is correct for the cases used in obstack.h since PTRVAR is
3097 * of type char * and the value of the expression is not used.
3099 fix = {
3100 hackname = obstack_lvalue_cast;
3101 files = obstack.h;
3102 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3103 c_fix = format;
3104 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3105 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3109 * Fix OpenBSD's va_start define.
3111 fix = {
3112 hackname = openbsd_va_start;
3113 mach = "*-*-openbsd*";
3114 files = stdarg.h;
3115 select = '__builtin_stdarg_start';
3116 c_fix = format;
3117 c_fix_arg = __builtin_va_start;
3119 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3123 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3124 * defining regex.h related types. This causes libg++ build and usage
3125 * failures. Fixing this correctly requires checking and modifying 3 files.
3127 fix = {
3128 hackname = osf_namespace_a;
3129 files = reg_types.h;
3130 files = sys/lc_core.h;
3131 test = " -r reg_types.h";
3132 test = " -r sys/lc_core.h";
3133 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3134 test = " -z \"`grep __regex_t regex.h`\"";
3136 c_fix = format;
3137 c_fix_arg = "__%0";
3138 c_fix_arg = "reg(ex|off|match)_t";
3140 test_text = "`touch sys/lc_core.h`"
3141 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3142 "extern regex_t re;\n"
3143 "extern regoff_t ro;\n"
3144 "extern regmatch_t rm;\n";
3147 fix = {
3148 hackname = osf_namespace_c;
3149 files = regex.h;
3150 test = " -r reg_types.h";
3151 test = " -r sys/lc_core.h";
3152 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3153 test = " -z \"`grep __regex_t regex.h`\"";
3155 select = "#include <reg_types\.h>.*";
3156 c_fix = format;
3157 c_fix_arg = "%0\n"
3158 "typedef __regex_t\tregex_t;\n"
3159 "typedef __regoff_t\tregoff_t;\n"
3160 "typedef __regmatch_t\tregmatch_t;";
3162 test_text = "#include <reg_types.h>";
3166 * On broken glibc-2.3.3 systems an array of incomplete structures is
3167 * passed to __sigsetjmp. Fix that to take a pointer instead.
3169 fix = {
3170 hackname = pthread_incomplete_struct_argument;
3171 files = pthread.h;
3172 select = "struct __jmp_buf_tag";
3173 c_fix = format;
3174 c_fix_arg = "%1 *%2%3";
3175 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3176 "(__env)\\[1\\](.*)$";
3177 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3178 "int __savemask);";
3182 * Fix return type of fread and fwrite on sysV68
3184 fix = {
3185 hackname = read_ret_type;
3186 files = stdio.h;
3187 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3188 c_fix = format;
3189 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3190 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3192 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3196 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3198 fix = {
3199 hackname = rpc_xdr_lvalue_cast_a;
3200 files = rpc/xdr.h;
3201 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3202 c_fix = format;
3203 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3204 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3205 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3209 * rpc_xdr_lvalue_cast_b
3211 fix = {
3212 hackname = rpc_xdr_lvalue_cast_b;
3213 files = rpc/xdr.h;
3214 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3215 c_fix = format;
3216 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3217 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3218 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3222 * function class(double x) conflicts with C++ keyword on rs/6000
3224 fix = {
3225 hackname = rs6000_double;
3226 files = math.h;
3227 select = '[^a-zA-Z_]class\(';
3229 c_fix = format;
3230 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3231 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3233 test_text = "extern int class();";
3237 * Wrong fchmod prototype on RS/6000.
3239 fix = {
3240 hackname = rs6000_fchmod;
3241 files = sys/stat.h;
3242 select = 'fchmod\(char \*';
3243 c_fix = format;
3244 c_fix_arg = "fchmod(int";
3245 test_text = "extern int fchmod(char *, mode_t);";
3249 * parameters conflict with C++ new on rs/6000
3251 fix = {
3252 hackname = rs6000_param;
3253 files = "stdio.h";
3254 files = "unistd.h";
3256 select = 'rename\(const char \*old, const char \*new\)';
3257 c_fix = format;
3258 c_fix_arg = 'rename(const char *_old, const char *_new)';
3260 test_text = 'extern int rename(const char *old, const char *new);';
3264 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3265 * for C99. This is wrong for C++, which needs many C99 features, but
3266 * only supports __restrict.
3268 fix = {
3269 hackname = solaris___restrict;
3270 files = sys/feature_tests.h;
3271 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3272 mach = "*-*-solaris2*";
3273 c_fix = format;
3274 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3275 "#else\n%0\n#endif";
3276 test_text = "#define _RESTRICT_KYWD restrict";
3280 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3281 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3282 * and imaginary definitions which are not supported by GCC.
3284 fix = {
3285 hackname = solaris_complex;
3286 mach = "*-*-solaris2.*";
3287 files = complex.h;
3288 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3289 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3290 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3291 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3292 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3293 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3294 test_text = "#define _Complex_I _Complex_I\n"
3295 "#define complex _Complex\n"
3296 "#define _Imaginary_I _Imaginary_I\n"
3297 "#define imaginary _Imaginary\n"
3298 "#undef I\n"
3299 "#define I _Imaginary_I";
3303 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3304 * extern "C" instead so libstdc++ can use it.
3306 fix = {
3307 hackname = solaris_complex_cxx;
3308 mach = "*-*-solaris2.*";
3309 files = complex.h;
3310 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3311 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3312 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3313 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3314 test_text = "#if !defined(__cplusplus)\n"
3315 "#endif /* !defined(__cplusplus) */";
3319 * g++ rejects functions declared with both C and C++ linkage.
3321 fix = {
3322 hackname = solaris_cxx_linkage;
3323 mach = '*-*-solaris2*';
3324 files = "iso/stdlib_iso.h";
3325 select = "(#if __cplusplus >= 199711L)\n"
3326 "(extern \"C\\+\\+\" \\{\n)"
3327 "(.*(bsearch|qsort).*)";
3328 c_fix = format;
3329 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3331 test_text =
3332 "#if __cplusplus >= 199711L\n"
3333 "extern \"C++\" {\n"
3334 " void *bsearch(const void *, const void *, size_t, size_t,";
3338 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3339 * _STRICT_STDC, but uses it.
3341 fix = {
3342 hackname = solaris_getc_strict_stdc;
3343 mach = "*-*-solaris2*";
3344 files = "iso/stdio_iso.h";
3345 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3346 c_fix = format;
3347 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3349 test_text =
3350 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3354 * Sun Solaris 2 has a version of sys/int_const.h that defines
3355 * UINT8_C and UINT16_C to unsigned constants.
3357 fix = {
3358 hackname = solaris_int_const;
3359 files = sys/int_const.h;
3360 mach = '*-*-solaris2*';
3361 c_fix = format;
3362 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3363 "%1\n"
3364 "#define\tUINT16_C(c)\t(c)";
3365 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3366 "(/\*.*\*/)\n"
3367 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3368 test_text =
3369 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3370 "/* CSTYLED */\n"
3371 "#define UINT16_C(c) __CONCAT__(c,u)";
3375 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3376 * UINT8_MAX and UINT16_MAX to unsigned constants.
3378 fix = {
3379 hackname = solaris_int_limits_1;
3380 files = sys/int_limits.h;
3381 mach = '*-*-solaris2*';
3382 c_fix = format;
3383 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3384 "#define\tUINT16_MAX\t(65535)";
3385 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3386 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3387 test_text =
3388 "#define UINT8_MAX (255U)\n"
3389 "#define UINT16_MAX (65535U)";
3393 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3394 * INT_FAST16 limits to wrong values for sys/int_types.h.
3396 fix = {
3397 hackname = solaris_int_limits_2;
3398 files = sys/int_limits.h;
3399 mach = '*-*-solaris2*';
3400 c_fix = format;
3401 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3402 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3403 test_text =
3404 "#define INT_FAST16_MAX INT16_MAX\n"
3405 "#define UINT_FAST16_MAX UINT16_MAX\n"
3406 "#define INT_FAST16_MIN INT16_MIN";
3410 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3411 * SIZE_MAX as unsigned long.
3413 fix = {
3414 hackname = solaris_int_limits_3;
3415 files = sys/int_limits.h;
3416 mach = '*-*-solaris2*';
3417 c_fix = format;
3418 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3419 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3420 test_text =
3421 "#define SIZE_MAX 4294967295UL";
3425 * Sun Solaris 10 defines several C99 math macros in terms of
3426 * builtins specific to the Studio compiler, in particular not
3427 * compatible with the GNU compiler.
3429 fix = {
3430 hackname = solaris_math_1;
3431 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3432 bypass = "__GNUC__";
3433 files = iso/math_c99.h;
3434 c_fix = format;
3435 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3436 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3437 test_text =
3438 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3439 "#undef HUGE_VAL\n"
3440 "#define HUGE_VAL __builtin_huge_val\n"
3441 "#undef HUGE_VALF\n"
3442 "#define HUGE_VALF __builtin_huge_valf\n"
3443 "#undef HUGE_VALL\n"
3444 "#define HUGE_VALL __builtin_huge_vall";
3448 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3449 * exception. Provide an alternative using GCC's builtin.
3451 fix = {
3452 hackname = solaris_math_10;
3453 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3454 files = iso/math_c99.h;
3455 c_fix = format;
3456 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3457 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3458 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3459 "[ \t]*\\\\\n"
3460 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3461 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3462 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3463 "\\(-INFINITY\\);[ \t]*\\}\\)";
3464 test_text =
3465 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3466 "#undef isinf\n"
3467 "#define isinf(x) __extension__( \\\\\n"
3468 " { __typeof(x) __x_i = (x); \\\\\n"
3469 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3470 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3474 * Solaris math INFINITY
3476 fix = {
3477 hackname = solaris_math_2;
3478 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3479 bypass = "__GNUC__";
3480 files = iso/math_c99.h;
3481 c_fix = format;
3482 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3483 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3484 test_text =
3485 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3486 "#undef INFINITY\n"
3487 "#define INFINITY __builtin_infinity";
3491 * Solaris math NAN
3493 fix = {
3494 hackname = solaris_math_3;
3495 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3496 bypass = "__GNUC__";
3497 files = iso/math_c99.h;
3498 c_fix = format;
3499 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3500 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3501 test_text =
3502 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3503 "#undef NAN\n"
3504 "#define NAN __builtin_nan";
3508 * Solaris math fpclassify
3510 fix = {
3511 hackname = solaris_math_4;
3512 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3513 bypass = "__GNUC__";
3514 files = iso/math_c99.h;
3515 c_fix = format;
3516 c_fix_arg = "#define\tfpclassify(x) \\\n"
3517 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3518 "FP_SUBNORMAL, FP_ZERO, (x))";
3519 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3520 test_text =
3521 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3522 "#undef fpclassify\n"
3523 "#define fpclassify(x) __builtin_fpclassify(x)";
3527 * Solaris math signbit
3529 fix = {
3530 hackname = solaris_math_8;
3531 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3532 bypass = "__GNUC__";
3533 files = iso/math_c99.h;
3534 c_fix = format;
3535 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3536 "\t\t\t ? __builtin_signbitf(x) \\\n"
3537 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3538 "\t\t\t ? __builtin_signbitl(x) \\\n"
3539 "\t\t\t : __builtin_signbit(x))";
3540 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3541 test_text = <<- _EOText_
3542 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3543 #undef signbit
3544 #define signbit(x) __builtin_signbit(x)
3545 _EOText_;
3549 * Solaris math comparison macros
3551 fix = {
3552 hackname = solaris_math_9;
3553 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3554 bypass = "__GNUC__";
3555 files = iso/math_c99.h;
3556 c_fix = format;
3557 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3558 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3559 "__builtin_[a-z]+\\(y\\)\\)";
3560 test_text =
3561 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3562 "#undef isgreater\n"
3563 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3564 "#undef isgreaterequal\n"
3565 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3566 "#undef isless\n"
3567 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3568 "#undef islessequal\n"
3569 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3570 "#undef islessgreater\n"
3571 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3572 "#undef isunordered\n"
3573 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3577 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3578 * warnings.
3580 fix = {
3581 hackname = solaris_math_11;
3582 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3583 files = iso/math_c99.h;
3584 c_fix = format;
3585 c_fix_arg = << _EOArg_
3586 #undef signbit
3587 #define signbit(x) (sizeof(x) == sizeof(float) \
3588 ? __builtin_signbitf(x) \
3589 : sizeof(x) == sizeof(long double) \
3590 ? __builtin_signbitl(x) \
3591 : __builtin_signbit(x))
3592 _EOArg_;
3593 c_fix_arg = << _EOArg_
3594 ^#undef[ ]+signbit
3595 #if defined\(__sparc\)
3596 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3597 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3598 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3599 #elif defined\(__i386\) \|\| defined\(__amd64\)
3600 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3601 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3602 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3603 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3604 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3605 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3606 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3607 #endif
3608 _EOArg_;
3609 test_text = << _EOText_
3610 /* @(#)math_c99.h 1.14 13/03/27 */
3611 #undef signbit
3612 #if defined(__sparc)
3613 #define signbit(x) __extension__( \\
3614 { __typeof(x) __x_s = (x); \\
3615 (int) (*(unsigned *) &__x_s >> 31); })
3616 #elif defined(__i386) || defined(__amd64)
3617 #define signbit(x) __extension__( \\
3618 { __typeof(x) __x_s = (x); \\
3619 (sizeof (__x_s) == sizeof (float) ? \\
3620 (int) (*(unsigned *) &__x_s >> 31) : \\
3621 sizeof (__x_s) == sizeof (double) ? \\
3622 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3623 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3624 #endif
3625 _EOText_;
3629 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3630 * structure. As such, it need two levels of brackets, but only
3631 * contains one. Wrap the macro definition in an extra layer.
3633 fix = {
3634 hackname = solaris_once_init_1;
3635 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3636 files = pthread.h;
3637 mach = '*-*-solaris*';
3638 c_fix = format;
3639 c_fix_arg = "%1{%2}%3";
3640 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3641 test_text =
3642 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3643 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3647 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3648 * posix_spawn declarations, which doesn't work with C++.
3650 fix = {
3651 hackname = solaris_posix_spawn_restrict;
3652 files = spawn.h;
3653 mach = '*-*-solaris2*';
3654 c_fix = format;
3655 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3656 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3657 test_text =
3658 "char *const argv[_RESTRICT_KYWD],\n"
3659 "char *const envp[_RESTRICT_KYWD]);";
3663 * The pow overloads with int were removed in C++ 2011 DR 550.
3665 fix = {
3666 hackname = solaris_pow_int_overload;
3667 mach = '*-*-solaris2*';
3668 files = "iso/math_iso.h";
3669 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3670 " *\\{[^{}]*\n[^{}]*\\}";
3671 c_fix = format;
3672 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3674 test_text =
3675 " inline long double pow(long double __X, int __Y) { return\n"
3676 " __powl(__X, (long double) (__Y)); }";
3680 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3681 * fields of the pthread_rwlock_t structure, which are of type
3682 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3683 * defined (e.g. by -ansi) it is a union. So change the initializer
3684 * to "{0}" instead.
3686 fix = {
3687 hackname = solaris_rwlock_init_1;
3688 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3689 files = pthread.h;
3690 mach = '*-*-solaris*';
3691 c_fix = format;
3692 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3693 "%0\n"
3694 "#else\n"
3695 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3696 "#endif";
3697 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3698 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3700 test_text =
3701 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3702 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3706 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3707 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3709 fix = {
3710 hackname = solaris_std___filbuf;
3711 files = stdio.h;
3712 mach = '*-*-solaris2*';
3713 bypass = "using std::__filbuf";
3714 select = "(using std::perror;\n)(#endif)";
3715 c_fix = format;
3716 c_fix_arg = "%1#ifndef _LP64\n"
3717 "using std::__filbuf;\n"
3718 "using std::__flsbuf;\n"
3719 "#endif\n%2";
3721 test_text = "using std::perror;\n"
3722 "#endif";
3726 * Sun Solaris 8 has what appears to be some gross workaround for
3727 * some old version of their c++ compiler. G++ doesn't want it
3728 * either, but doesn't want to be tied to SunPRO version numbers.
3730 fix = {
3731 hackname = solaris_stdio_tag;
3732 files = stdio_tag.h;
3734 select = '__cplusplus < 54321L';
3735 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3736 "!defined(__GNUC__)" so we no longer need to fix it. */
3737 bypass = '__GNUC__';
3738 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3740 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3744 * a missing semi-colon at the end of the statsswtch structure definition.
3746 fix = {
3747 hackname = statsswtch;
3748 files = rpcsvc/rstat.h;
3749 select = "boottime$";
3750 c_fix = format;
3751 c_fix_arg = "boottime;";
3752 test_text = "struct statswtch {\n int boottime\n};";
3756 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3757 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3758 * OK too.
3760 fix = {
3761 hackname = stdio_stdarg_h;
3762 files = stdio.h;
3763 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3765 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3766 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3768 mach = '*-*-solaris2.1[0-9]*';
3769 not_machine = true;
3771 c_fix = wrap;
3773 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3775 test_text = "";
3779 * Don't use or define the name va_list in stdio.h. This is for
3780 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3781 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3782 * indicate that the header knows what it's doing -- under SUSv2,
3783 * stdio.h is required to define va_list, and we shouldn't break
3784 * that.
3786 fix = {
3787 hackname = stdio_va_list;
3788 files = stdio.h;
3789 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3791 * On Solaris 10, the definition in
3792 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3793 * there is therefore no need for this fix there.
3795 mach = '*-*-solaris2.1[0-9]*';
3796 not_machine = true;
3799 * Use __gnuc_va_list in arg types in place of va_list.
3800 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3801 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3802 * trailing parentheses and semicolon save all other systems from this.
3803 * Define __not_va_list__ (something harmless and unused)
3804 * instead of va_list.
3805 * Don't claim to have defined va_list.
3807 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3808 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3809 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3810 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3811 "s@ va_list@ __not_va_list__@\n"
3812 "s@\\*va_list@*__not_va_list__@\n"
3813 "s@ __va_list)@ __gnuc_va_list)@\n"
3814 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3815 "@typedef \\1 __not_va_list__;@\n"
3816 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3817 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3818 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3819 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3820 "s@VA_LIST@DUMMY_VA_LIST@\n"
3821 "s@_Va_LIST@_VA_LIST@";
3822 test_text = "extern void mumble( va_list);";
3826 * Fix headers that use va_list from stdio.h to use the updated
3827 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3828 * dealt with elsewhere. The presence of __gnuc_va_list,
3829 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3830 * knows what it's doing.
3832 fix = {
3833 hackname = stdio_va_list_clients;
3834 files = com_err.h;
3835 files = cps.h;
3836 files = curses.h;
3837 files = krb5.h;
3838 files = lc_core.h;
3839 files = pfmt.h;
3840 files = wchar.h;
3841 files = curses_colr/curses.h;
3842 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3843 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3844 otherwise protected. */
3845 bypass = 'include <stdarg\.h>|#ifdef va_start';
3848 * Use __gnuc_va_list in arg types in place of va_list.
3849 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3850 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3851 * trailing parentheses and semicolon save all other systems from this.
3852 * Define __not_va_list__ (something harmless and unused)
3853 * instead of va_list.
3854 * Don't claim to have defined va_list.
3856 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3857 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3858 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3859 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3860 "s@ va_list@ __not_va_list__@\n"
3861 "s@\\*va_list@*__not_va_list__@\n"
3862 "s@ __va_list)@ __gnuc_va_list)@\n"
3863 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3864 "@typedef \\1 __not_va_list__;@\n"
3865 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3866 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3867 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3868 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3869 "s@VA_LIST@DUMMY_VA_LIST@\n"
3870 "s@_Va_LIST@_VA_LIST@";
3871 test_text = "extern void mumble( va_list);";
3875 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3876 * is "!defined( __STRICT_ANSI__ )"
3878 fix = {
3879 hackname = strict_ansi_not;
3880 select = "^([ \t]*#[ \t]*if.*)"
3881 "(!__STDC__"
3882 "|__STDC__[ \t]*==[ \t]*0"
3883 "|__STDC__[ \t]*!=[ \t]*1"
3884 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3885 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3886 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3887 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3888 is not defined by GCC, so it is safe. */
3889 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3890 c_test = stdc_0_in_system_headers;
3892 c_fix = format;
3893 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3895 test_text = "#if !__STDC__ \n"
3896 "#if __STDC__ == 0\n"
3897 "#if __STDC__ != 1\n"
3898 "#if __STDC__ - 0 == 0"
3899 "/* not std C */\nint foo;\n"
3900 "\n#end-end-end-end-if :-)";
3904 * "__STDC__-0==0"
3905 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3907 fix = {
3908 hackname = strict_ansi_not_ctd;
3909 files = math.h, limits.h, stdio.h, signal.h,
3910 stdlib.h, sys/signal.h, time.h;
3912 * Starting at the beginning of a line, skip white space and
3913 * a leading "(" or "&&" or "||". One of those must be found.
3914 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3915 * expression. If these are nested, then they must accumulate
3916 * because we won't match any closing parentheses. Finally,
3917 * after skipping over all that, we must then match our suspect
3918 * phrase: "__STDC__-0==0" with or without white space.
3920 select = "^([ \t]*" '(\(|&&|\|\|)'
3921 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3922 "[ \t(]*)"
3923 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3924 c_test = stdc_0_in_system_headers;
3926 c_fix = format;
3927 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3929 test_text = "#if 1 && \\\\\n"
3930 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3931 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3932 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3933 "int foo;\n#endif";
3937 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3938 * is "defined( __STRICT_ANSI__ )"
3940 fix = {
3941 hackname = strict_ansi_only;
3942 select = "^([ \t]*#[ \t]*if.*)"
3943 "(__STDC__[ \t]*!=[ \t]*0"
3944 "|__STDC__[ \t]*==[ \t]*1"
3945 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3946 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3947 c_test = stdc_0_in_system_headers;
3949 c_fix = format;
3950 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3952 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3956 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3957 * in prototype without previous definition.
3959 fix = {
3960 hackname = struct_file;
3961 files = rpc/xdr.h;
3962 select = '^.*xdrstdio_create.*struct __file_s';
3963 c_fix = format;
3964 c_fix_arg = "struct __file_s;\n%0";
3965 test_text = "extern void xdrstdio_create( struct __file_s* );";
3969 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3970 * in prototype without previous definition.
3972 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3973 * function, and does define it.
3975 fix = {
3976 hackname = struct_sockaddr;
3977 files = rpc/auth.h;
3978 select = "^.*authdes_create.*struct sockaddr[^_]";
3979 bypass = "<sys/socket\.h>";
3980 bypass = "struct sockaddr;\n";
3981 c_fix = format;
3982 c_fix_arg = "struct sockaddr;\n%0";
3983 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3987 * Apply fix this to all OSs since this problem seems to effect
3988 * more than just SunOS.
3990 fix = {
3991 hackname = sun_auth_proto;
3992 files = rpc/auth.h;
3993 files = rpc/clnt.h;
3994 files = rpc/svc.h;
3995 files = rpc/xdr.h;
3996 bypass = "__cplusplus";
3998 * Select those files containing '(*name)()'.
4000 select = '\(\*[a-z][a-z_]*\)\(\)';
4002 c_fix = format;
4003 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4004 "#else\n%1();%2\n#endif";
4005 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4007 test_text =
4008 "struct auth_t {\n"
4009 " int (*name)(); /* C++ bad */\n"
4010 "};";
4014 * Fix bogus #ifdef on SunOS 4.1.
4016 fix = {
4017 hackname = sun_bogus_ifdef;
4018 files = "hsfs/hsfs_spec.h";
4019 files = "hsfs/iso_spec.h";
4020 select = '#ifdef(.*\|\|.*)';
4021 c_fix = format;
4022 c_fix_arg = "#if%1";
4024 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4028 * Fix the CAT macro in SunOS memvar.h.
4030 fix = {
4031 hackname = sun_catmacro;
4032 files = pixrect/memvar.h;
4033 select = "^#define[ \t]+CAT\\(a,b\\).*";
4034 c_fix = format;
4036 c_fix_arg =
4037 "#ifdef __STDC__\n"
4038 "# define CAT(a,b) a##b\n"
4039 "#else\n%0\n#endif";
4041 test_text =
4042 "#define CAT(a,b)\ta/**/b";
4046 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4047 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4049 fix = {
4050 hackname = sun_malloc;
4051 files = malloc.h;
4052 bypass = "_CLASSIC_ANSI_TYPES";
4054 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4055 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4056 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4057 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4058 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4060 test_text =
4061 "typedef char *\tmalloc_t;\n"
4062 "int \tfree();\n"
4063 "char*\tmalloc();\n"
4064 "char*\tcalloc();\n"
4065 "char*\trealloc();";
4069 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4071 fix = {
4072 hackname = sun_rusers_semi;
4073 files = rpcsvc/rusers.h;
4074 select = "_cnt$";
4075 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4076 test_text = "struct mumble\n int _cnt\n};";
4080 * signal.h on SunOS defines signal using (),
4081 * which causes trouble when compiling with g++ -pedantic.
4083 fix = {
4084 hackname = sun_signal;
4085 files = sys/signal.h;
4086 files = signal.h;
4087 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4089 c_fix = format;
4090 c_fix_arg =
4091 "#ifdef __cplusplus\n"
4092 "void\t(*signal(...))(...);\n"
4093 "#else\n%0\n#endif";
4095 test_text = "void\t(*signal())();";
4099 * Correct the return type for strlen in strings.h in SunOS 4.
4101 fix = {
4102 hackname = sunos_strlen;
4103 files = strings.h;
4104 select = "int[ \t]*strlen\\(\\);(.*)";
4105 c_fix = format;
4106 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4107 test_text = " int\tstrlen(); /* string length */";
4111 * Linux kernel's vt.h breaks C++
4113 fix = {
4114 hackname = suse_linux_vt_cxx;
4115 files = linux/vt.h;
4117 select = "^[ \t]*unsigned int new;";
4118 c_fix = format;
4119 c_fix_arg = "unsigned int newev;";
4121 test_text = " unsigned int new; /* New console (if changing) */";
4125 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4126 * that is visible to any ANSI compiler using this include. Simply
4127 * delete the lines that #define some string functions to internal forms.
4129 fix = {
4130 hackname = svr4_disable_opt;
4131 files = string.h;
4132 select = '#define.*__std_hdr_';
4133 sed = '/#define.*__std_hdr_/d';
4134 test_text = "#define strlen __std_hdr_strlen\n";
4138 * Fix broken decl of getcwd present on some svr4 systems.
4140 fix = {
4141 hackname = svr4_getcwd;
4142 files = stdlib.h;
4143 files = unistd.h;
4144 files = prototypes.h;
4145 select = 'getcwd\(char \*, int\)';
4147 c_fix = format;
4148 c_fix_arg = "getcwd(char *, size_t)";
4150 test_text = "extern char* getcwd(char *, int);";
4154 * Fix broken decl of profil present on some svr4 systems.
4156 fix = {
4157 hackname = svr4_profil;
4158 files = stdlib.h;
4159 files = unistd.h;
4161 select =
4162 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4163 c_fix = format;
4164 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4166 test_text =
4167 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4171 * Correct types for signal handler constants like SIG_DFL; they might be
4172 * void (*) (), and should be void (*) (int). C++ doesn't like the
4173 * old style.
4175 fix = {
4176 hackname = svr4_sighandler_type;
4177 files = sys/signal.h;
4178 select = 'void *\(\*\)\(\)';
4179 c_fix = format;
4180 c_fix_arg = "void (*)(int)";
4181 test_text = "#define SIG_DFL (void(*)())0\n"
4182 "#define SIG_IGN (void (*)())0\n";
4186 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4187 * function 'getrnge' in <regexp.h> before they declare it. For these
4188 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4189 * early on.
4191 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4192 * so put the declaration right after the declaration of 'size'.
4194 * Don't do this if there is already a `static void getrnge' declaration
4195 * present, since this would cause a redeclaration error. Solaris 2.x has
4196 * such a declaration.
4198 fix = {
4199 hackname = svr4_undeclared_getrnge;
4200 files = regexp.h;
4201 select = "getrnge";
4202 bypass = "static void getrnge";
4203 c_fix = format;
4204 c_fix_arg = "%0\n"
4205 "static int getrnge ();";
4206 c_fix_arg = "^static int[ \t]+size;";
4207 test_text = "static int size;\n"
4208 "/* stuff which calls getrnge() */\n"
4209 "static getrnge()\n"
4210 "{}";
4214 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4215 * in string.h on sysV68
4216 * Correct the return type for strlen in string.h on Lynx.
4217 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4218 * Add missing const for strdup on OSF/1 V3.0.
4219 * On sysV88 layout is slightly different.
4221 fix = {
4222 hackname = sysv68_string;
4223 files = testing.h;
4224 files = string.h;
4225 bypass = "_CLASSIC_ANSI_TYPES";
4227 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4228 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4229 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4231 sed = "/^extern char$/N";
4232 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4234 sed = "/^extern int$/N";
4235 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4237 sed = "/^\tstrncmp(),$/N";
4238 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4239 '\1;' "\\\nextern unsigned int\\\n\\2/";
4241 test_text =
4242 "extern int strlen();\n"
4244 "extern int ffs(long);\n"
4246 "extern char\n"
4247 "\t*memccpy(),\n"
4248 "\tmemcpy();\n"
4250 "extern int\n"
4251 "\tstrcmp(),\n"
4252 "\tstrncmp(),\n"
4253 "\tstrlen(),\n"
4254 "\tstrspn();\n"
4256 "extern int\n"
4257 "\tstrlen(), strspn();";
4261 * Fix return type of calloc, malloc, realloc, bsearch and exit
4263 fix = {
4264 hackname = sysz_stdlib_for_sun;
4265 files = stdlib.h;
4266 bypass = "_CLASSIC_ANSI_TYPES";
4268 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4269 c_fix = format;
4270 c_fix_arg = "void *\t%1(";
4272 test_text =
4273 "extern char*\tcalloc(size_t);\n"
4274 "extern char*\tmalloc(size_t);\n"
4275 "extern char*\trealloc(void*,size_t);\n"
4276 "extern char*\tbsearch(void*,size_t,size_t);\n";
4280 * __thread is now a keyword.
4282 fix = {
4283 hackname = thread_keyword;
4284 files = "pthread.h";
4285 files = bits/sigthread.h, '*/bits/sigthread.h';
4286 select = "([* ])__thread([,)])";
4287 c_fix = format;
4288 c_fix_arg = "%1__thr%2";
4290 test_text =
4291 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4292 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4293 "extern int pthread_cancel (pthread_t __thread);";
4297 * if the #if says _cplusplus, not the double underscore __cplusplus
4298 * that it should be
4300 fix = {
4301 hackname = tinfo_cplusplus;
4302 files = tinfo.h;
4303 select = "[ \t]_cplusplus";
4305 c_fix = format;
4306 c_fix_arg = " __cplusplus";
4307 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4311 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4313 fix = {
4314 hackname = ultrix_const;
4315 files = stdio.h;
4316 select = 'perror\( char \*';
4318 c_fix = format;
4319 c_fix_arg = "%1 const %3 *__";
4320 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4321 "[ \t]+(char|void) \\*__";
4323 test_text =
4324 "extern void perror( char *__s );\n"
4325 "extern int fputs( char *__s, FILE *);\n"
4326 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4327 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4328 "extern int scanf( char *__format, ...);\n";
4332 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4334 fix = {
4335 hackname = ultrix_const2;
4336 files = stdio.h;
4338 select = '\*fopen\( char \*';
4339 c_fix = format;
4340 c_fix_arg = "%1( const char *%3, const char *";
4341 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4342 "[ \t]*char[ \t]*\\*([^,]*),"
4343 "[ \t]*char[ \t]*\\*[ \t]*";
4345 test_text =
4346 "extern FILE *fopen( char *__filename, char *__type );\n"
4347 "extern int sscanf( char *__s, char *__format, ...);\n"
4348 "extern FILE *popen(char *, char *);\n"
4349 "extern char *tempnam(char*,char*);\n";
4353 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4355 fix = {
4356 hackname = va_i960_macro;
4357 files = arch/i960/archI960.h;
4358 select = "__(vsiz|vali|vpad|alignof__)";
4360 c_fix = format;
4361 c_fix_arg = "__vx%1";
4363 test_text =
4364 "extern int __vsiz vsiz;\n"
4365 "extern int __vali vali;\n"
4366 "extern int __vpad vpad;\n"
4367 "#define __alignof__(x) ...";
4371 * On VMS, add missing braces around sigset_t constants.
4373 fix = {
4374 hackname = vms_add_missing_braces;
4375 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4376 mach = "*-*-*vms*";
4377 files = "rtldef/signal.h";
4378 c_fix = format;
4380 c_fix_arg = '%1 {%2} ';
4382 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4383 "{0x00000000, 0x00000000},\n"
4384 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4388 * On VMS, some DEC-C builtins are directly used.
4390 fix = {
4391 hackname = vms_decc_builtin;
4392 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4393 mach = "*-*-*vms*";
4394 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4395 rtldef/socket.h;
4396 sed = "s@__MEMSET@memset@";
4397 sed = "s@__MEMMOVE@memmove@";
4398 sed = "s@__MEMCPY@memcpy@";
4399 sed = "s@__STRLEN@strlen@";
4400 sed = "s@__STRCPY@strcpy@";
4402 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4406 * Define __CAN_USE_EXTERN_PREFIX on vms.
4408 fix = {
4409 hackname = vms_define_can_use_extern_prefix;
4410 files = "rtldef/decc$types.h";
4411 select = "#[ \t]*else\n"
4412 "#[ \t]*if defined\\(__DECCXX\\)\n"
4413 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4414 mach = "*-*-*vms*";
4415 c_fix = format;
4417 c_fix_arg = "%0"
4418 "# elif defined (__GNUC__)\n"
4419 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4421 test_text = "# else\n"
4422 "# if defined(__DECCXX)\n"
4423 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4424 "# endif\n"
4425 "# endif\n";
4429 * On VMS, disable the use of dec-c string builtins
4431 fix = {
4432 hackname = vms_disable_decc_string_builtins;
4433 select = "#if !defined\\(__VAX\\)\n";
4434 mach = "*-*-*vms*";
4435 files = "rtldef/string.h";
4436 c_fix = format;
4438 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4440 test_text = "#if !defined(__VAX)\n";
4444 * On VMS, fix incompatible redeclaration of hostalias.
4446 fix = {
4447 hackname = vms_do_not_redeclare_hostalias;
4448 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4449 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4450 mach = "*-*-*vms*";
4451 files = "rtldef/resolv.h";
4452 c_fix = format;
4454 c_fix_arg = "%1\n"
4455 "/* %2 */";
4457 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4458 "__char_ptr32 hostalias (const char *);\n";
4462 * On VMS, forward declare structure before referencing them in prototypes.
4464 fix = {
4465 hackname = vms_forward_declare_struct;
4466 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4467 "#ifdef __cplusplus\n";
4468 mach = "*-*-*vms*";
4469 files = rtldef/if.h;
4470 c_fix = format;
4472 c_fix_arg = "%1"
4473 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4475 test_text = "/* forward decls for C++ */\n"
4476 "#ifdef __cplusplus\n"
4477 "struct foo;\n"
4478 "#endif\n";
4482 * On VMS, do not declare getopt and al if pointers are 64 bit.
4484 fix = {
4485 hackname = vms_no_64bit_getopt;
4486 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4487 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4488 mach = "*-*-*vms*";
4489 files = rtldef/stdio.h, rtldef/unistd.h;
4490 c_fix = format;
4492 c_fix_arg = <<- _EOArg_
4493 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4494 %0#endif
4496 _EOArg_;
4498 test_text = "int getopt (int, char * const [], const char *);";
4502 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4503 * which is not yet fully supported by gcc.
4505 fix = {
4506 hackname = vms_use_fast_setjmp;
4507 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4508 mach = "*-*-*vms*";
4509 files = rtldef/setjmp.h;
4510 c_fix = format;
4512 c_fix_arg = "%0 defined (__GNUC__) ||";
4514 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4518 * On VMS, use pragma extern_model instead of VAX-C keywords.
4520 fix = {
4521 hackname = vms_use_pragma_extern_model;
4522 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4523 "# pragma extern_model __save\n";
4524 mach = "*-*-*vms*";
4525 c_fix = format;
4527 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4528 "# pragma extern_model __save\n";
4530 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4531 "# pragma extern_model __save\n"
4532 "# pragma extern_model strict_refdef\n"
4533 " extern struct x zz$yy;\n"
4534 "# pragma extern_model __restore\n"
4535 "#endif\n";
4539 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4540 * conflict while building gcc. Likewise for <builtins.h>
4542 fix = {
4543 hackname = vms_use_quoted_include;
4544 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4545 mach = "*-*-*vms*";
4546 files = rtldef/wait.h, starlet_c/pthread.h;
4547 c_fix = format;
4549 c_fix_arg = '%1<sys/%2.h>';
4551 test_text = "# include <resource.h>";
4555 * AIX and Interix headers define NULL to be cast to a void pointer,
4556 * which is illegal in ANSI C++.
4558 fix = {
4559 hackname = void_null;
4560 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4561 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4562 /* avoid changing C++ friendly NULL */
4563 bypass = __cplusplus;
4564 bypass = __null;
4565 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4566 c_fix = format;
4567 c_fix_arg = <<- _EOFix_
4568 #ifndef NULL
4569 #ifdef __cplusplus
4570 #ifdef __GNUG__
4571 #define NULL __null
4572 #else /* ! __GNUG__ */
4573 #define NULL 0L
4574 #endif /* __GNUG__ */
4575 #else /* ! __cplusplus */
4576 #define NULL ((void *)0)
4577 #endif /* __cplusplus */
4578 #endif /* !NULL */
4579 _EOFix_;
4580 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4584 * Make VxWorks header which is almost gcc ready fully gcc ready.
4586 fix = {
4587 hackname = vxworks_gcc_problem;
4588 files = types/vxTypesBase.h;
4589 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4591 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4592 "#if 1/";
4594 sed = "/[ \t]size_t/i\\\n"
4595 "#ifndef _GCC_SIZE_T\\\n"
4596 "#define _GCC_SIZE_T\n";
4598 sed = "/[ \t]size_t/a\\\n"
4599 "#endif\n";
4601 sed = "/[ \t]ptrdiff_t/i\\\n"
4602 "#ifndef _GCC_PTRDIFF_T\\\n"
4603 "#define _GCC_PTRDIFF_T\n";
4605 sed = "/[ \t]ptrdiff_t/a\\\n"
4606 "#endif\n";
4608 sed = "/[ \t]wchar_t/i\\\n"
4609 "#ifndef _GCC_WCHAR_T\\\n"
4610 "#define _GCC_WCHAR_T\n";
4612 sed = "/[ \t]wchar_t/a\\\n"
4613 "#endif\n";
4615 test_text =
4616 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4617 "typedef unsigned int size_t;\n"
4618 "typedef long ptrdiff_t;\n"
4619 "typedef unsigned short wchar_t;\n"
4620 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4624 * Wrap VxWorks ioctl to keep everything pretty
4626 fix = {
4627 hackname = vxworks_ioctl_macro;
4628 files = ioLib.h;
4629 mach = "*-*-vxworks*";
4631 c_fix = format;
4632 c_fix_arg = "%0\n"
4633 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4634 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4636 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4640 * Wrap VxWorks mkdir to be posix compliant
4642 fix = {
4643 hackname = vxworks_mkdir_macro;
4644 files = sys/stat.h;
4645 mach = "*-*-vxworks*";
4647 c_fix = format;
4648 c_fix_arg = "%0\n"
4649 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4650 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4651 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4652 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4653 "\\)[\t ]*;";
4655 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4659 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4661 fix = {
4662 hackname = vxworks_needs_vxtypes;
4663 files = time.h;
4664 select = "uint_t([ \t]+_clocks_per_sec)";
4665 c_fix = format;
4666 c_fix_arg = "unsigned int%1";
4667 test_text = "uint_t\t_clocks_per_sec;";
4671 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4673 fix = {
4674 hackname = vxworks_needs_vxworks;
4675 files = sys/stat.h;
4676 test = " -r types/vxTypesOld.h";
4677 test = " -n \"`egrep '#include' $file`\"";
4678 test = " -n \"`egrep ULONG $file`\"";
4679 select = "#[ \t]define[ \t]+__INCstath";
4681 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4682 "#include <types/vxTypesOld.h>\n";
4684 test_text = "`touch types/vxTypesOld.h`"
4685 "#include </dev/null> /* ULONG */\n"
4686 "# define\t__INCstath <sys/stat.h>";
4690 * Make it so VxWorks does not include gcc/regs.h accidentally
4692 fix = {
4693 hackname = vxworks_regs;
4694 mach = "*-*-vxworks*";
4696 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4697 c_fix = format;
4698 c_fix_arg = "#include <arch/../regs.h>";
4700 test_text = "#include <regs.h>\n";
4704 * Another bad dependency in VxWorks 5.2 <time.h>.
4706 fix = {
4707 hackname = vxworks_time;
4708 files = time.h;
4709 test = " -r vxWorks.h";
4711 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4712 c_fix = format;
4714 c_fix_arg =
4715 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4716 "#ifdef __cplusplus\n"
4717 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4718 "#else\n"
4719 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4720 "#endif\n"
4721 "#define __gcc_VOIDFUNCPTR_defined\n"
4722 "#endif\n"
4723 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4725 test_text = "`touch vxWorks.h`"
4726 "#define VOIDFUNCPTR (void(*)())";
4730 * This hack makes write const-correct on VxWorks
4732 fix = {
4733 hackname = vxworks_write_const;
4734 files = ioLib.h;
4735 mach = "*-*-vxworks*";
4737 c_fix = format;
4738 c_fix_arg = "extern int write (int, const char*, size_t);";
4739 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4740 "[\t ]*int[\t ]*,"
4741 "[\t ]*char[\t ]*\\*[\t ]*,"
4742 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4744 test_text = "extern int write ( int , char * , size_t ) ;";
4748 * There are several name conflicts with C++ reserved words in X11 header
4749 * files. These are fixed in some versions, so don't do the fixes if
4750 * we find __cplusplus in the file. These were found on the RS/6000.
4752 fix = {
4753 hackname = x11_class;
4754 files = X11/ShellP.h;
4755 bypass = __cplusplus;
4756 select = "^([ \t]*char \\*)class;(.*)";
4757 c_fix = format;
4758 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4759 "#else\n%1class;%2\n#endif";
4760 test_text =
4761 "struct {\n"
4762 " char *class;\n"
4763 "} mumble;\n";
4767 * class in Xm/BaseClassI.h
4769 fix = {
4770 hackname = x11_class_usage;
4771 files = Xm/BaseClassI.h;
4772 bypass = "__cplusplus";
4774 select = " class\\)";
4775 c_fix = format;
4776 c_fix_arg = " c_class)";
4778 test_text = "extern mumble (int class);\n";
4782 * new in Xm/Traversal.h
4784 fix = {
4785 hackname = x11_new;
4786 files = Xm/Traversal.h;
4787 bypass = __cplusplus;
4789 sed = "/Widget\told, new;/i\\\n"
4790 "#ifdef __cplusplus\\\n"
4791 "\\\tWidget\told, c_new;\\\n"
4792 "#else\n";
4794 sed = "/Widget\told, new;/a\\\n"
4795 "#endif\n";
4797 sed = "s/Widget new,/Widget c_new,/g";
4798 test_text =
4799 "struct wedge {\n"
4800 " Widget\told, new;\n"
4801 "};\nextern Wedged( Widget new, Widget old );";
4805 * Incorrect sprintf declaration in X11/Xmu.h
4807 fix = {
4808 hackname = x11_sprintf;
4809 files = X11/Xmu.h;
4810 files = X11/Xmu/Xmu.h;
4811 select = "^extern char \\*\tsprintf\\(\\);$";
4813 c_fix = format;
4814 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4816 test_text = "extern char *\tsprintf();";
4818 /*EOF*/