2013-12-06 Richard Biener <rguenther@suse.de>
[official-gcc.git] / fixincludes / inclhack.def
blob11ac9448c5b3878c941102133052e882606087f3
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[ ]*=[ ]*(.*);'
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 [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
731 c_fix = format;
732 c_fix_arg = "%1 %2";
733 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
734 "{...init stuff...}";
738 * AIX stdint.h fixes.
740 fix = {
741 hackname = aix_stdint_1;
742 mach = "*-*-aix*";
743 files = stdint-aix.h, stdint.h;
744 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
745 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
746 c_fix = format;
747 c_fix_arg = "#define UINT8_MAX (255)\n"
748 "#define UINT16_MAX (65535)";
749 test_text = "#define UINT8_MAX (255U)\n"
750 "#define UINT16_MAX (65535U)";
754 * aix_stdint_2
756 fix = {
757 hackname = aix_stdint_2;
758 mach = "*-*-aix*";
759 files = stdint-aix.h, stdint.h;
760 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
761 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
762 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
763 "#else\n"
764 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
765 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
766 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
767 c_fix = format;
768 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
769 "#define INTPTR_MAX 9223372036854775807L\n"
770 "#define UINTPTR_MAX 18446744073709551615UL\n"
771 "#else\n"
772 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
773 "#define INTPTR_MAX 2147483647L\n"
774 "#define UINTPTR_MAX 4294967295UL";
775 test_text = "#define INTPTR_MIN INT64_MIN\n"
776 "#define INTPTR_MAX INT64_MAX\n"
777 "#define UINTPTR_MAX UINT64_MAX\n"
778 "#else\n"
779 "#define INTPTR_MIN INT32_MIN\n"
780 "#define INTPTR_MAX INT32_MAX\n"
781 "#define UINTPTR_MAX UINT32_MAX";
785 * aix_stdint_3
787 fix = {
788 hackname = aix_stdint_3;
789 mach = "*-*-aix*";
790 files = stdint-aix.h, stdint.h;
791 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
792 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
793 "#else\n"
794 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
795 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
796 c_fix = format;
797 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
798 "#define PTRDIFF_MAX 9223372036854775807L\n"
799 "#else\n"
800 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
801 "#define PTRDIFF_MAX 2147483647L";
802 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
803 "#define PTRDIFF_MAX INT64_MAX\n"
804 "#else\n"
805 "#define PTRDIFF_MIN INT32_MIN\n"
806 "#define PTRDIFF_MAX INT32_MAX";
810 * aix_stdint_4
812 fix = {
813 hackname = aix_stdint_4;
814 mach = "*-*-aix*";
815 files = stdint-aix.h, stdint.h;
816 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
817 "#else\n"
818 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
819 c_fix = format;
820 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
821 "#else\n"
822 "#define SIZE_MAX 4294967295UL";
823 test_text = "#define SIZE_MAX UINT64_MAX\n"
824 "#else\n"
825 "#define SIZE_MAX UINT32_MAX";
829 * aix_stdint_5
831 fix = {
832 hackname = aix_stdint_5;
833 mach = "*-*-aix*";
834 files = stdint-aix.h, stdint.h;
835 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
836 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
837 c_fix = format;
838 c_fix_arg = "#define UINT8_C(c) c\n"
839 "#define UINT16_C(c) c";
840 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
841 "#define UINT16_C(c) __CONCAT__(c,U)";
845 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
846 * in an otherwise harmless (and #ifed out) macro definition
848 fix = {
849 hackname = aix_sysmachine;
850 files = sys/machine.h;
851 select = "\\\\ +\n";
852 c_fix = format;
853 c_fix_arg = "\\\n";
854 test_text = "#define FOO \\\n"
855 " bar \\ \n baz \\ \n bat";
859 * sys/wait.h on AIX 5.2 defines macros that have both signed and
860 * unsigned types in conditional expressions.
862 fix = {
863 hackname = aix_syswait_2;
864 files = sys/wait.h;
865 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
866 c_fix = format;
867 c_fix_arg = "? (int)%1";
868 test_text = "#define WSTOPSIG(__x) "
869 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
873 * sys/signal.h on some versions of AIX uses volatile in the typedef of
874 * sig_atomic_t, which causes gcc to generate a warning about duplicate
875 * volatile when a sig_atomic_t variable is declared volatile, as
876 * required by ANSI C.
878 fix = {
879 hackname = aix_volatile;
880 files = sys/signal.h;
881 select = "typedef volatile int sig_atomic_t";
882 c_fix = format;
883 c_fix_arg = "typedef int sig_atomic_t";
884 test_text = "typedef volatile int sig_atomic_t;";
888 * Fix __assert declaration in assert.h on Alpha OSF/1.
890 fix = {
891 hackname = alpha___assert;
892 files = "assert.h";
893 select = '__assert\(char \*, char \*, int\)';
894 c_fix = format;
895 c_fix_arg = "__assert(const char *, const char *, int)";
896 test_text = 'extern void __assert(char *, char *, int);';
900 * Fix assert macro in assert.h on Alpha OSF/1.
901 * The superfluous int cast breaks C++.
903 fix = {
904 hackname = alpha_assert;
905 files = "assert.h";
906 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
907 c_fix = format;
908 c_fix_arg = "%1(EX)";
909 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
910 ': __assert(#EX, __FILE__, __LINE__))';
914 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
916 fix = {
917 hackname = alpha_getopt;
918 files = "stdio.h";
919 files = "stdlib.h";
920 select = 'getopt\(int, char \*\[\], *char \*\)';
921 c_fix = format;
922 c_fix_arg = "getopt(int, char *const[], const char *)";
923 test_text = 'extern int getopt(int, char *[], char *);';
927 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
929 fix = {
930 hackname = alpha_if_semicolon;
931 files = net/if.h;
932 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
933 c_fix = format;
934 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
935 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
939 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
941 fix = {
942 hackname = alpha_parens;
943 files = sym.h;
944 select = '#ifndef\(__mips64\)';
945 c_fix = format;
946 c_fix_arg = "#ifndef __mips64";
947 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
951 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
952 * And OpenBSD.
954 fix = {
955 hackname = alpha_sbrk;
956 files = unistd.h;
957 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
958 c_fix = format;
959 c_fix_arg = "void *sbrk(";
960 test_text = "extern char* sbrk(ptrdiff_t increment);";
964 * For C++, avoid any typedef or macro definition of bool,
965 * and use the built in type instead.
966 * HP/UX 10.20 also has it in curses_colr/curses.h.
968 fix = {
969 hackname = avoid_bool_define;
970 files = curses.h;
971 files = curses_colr/curses.h;
972 files = term.h;
973 files = tinfo.h;
975 select = "#[ \t]*define[ \t]+bool[ \t]";
976 bypass = "__cplusplus";
978 c_fix = format;
979 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
980 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
982 test_text = "# define bool\t char \n";
986 * avoid_bool_type
988 fix = {
989 hackname = avoid_bool_type;
990 files = curses.h;
991 files = curses_colr/curses.h;
992 files = term.h;
993 files = tinfo.h;
995 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
996 bypass = "__cplusplus";
998 c_fix = format;
999 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1001 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1005 * For C++, avoid any typedef definition of wchar_t,
1006 * and use the built in type instead.
1007 * Don't do this for headers that are smart enough to do the right
1008 * thing (recent [n]curses.h and Xlib.h).
1009 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1010 * and will be broken by the edit.
1013 fix = {
1014 hackname = avoid_wchar_t_type;
1016 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1017 bypass = "__cplusplus";
1018 bypass = "_LINUX_NLS_H";
1019 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1021 c_fix = format;
1022 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1024 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1028 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1030 fix = {
1031 hackname = bad_struct_term;
1032 files = curses.h;
1033 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1034 c_fix = format;
1035 c_fix_arg = "struct term;";
1037 test_text = 'typedef struct term;';
1041 * Fix one other error in this file:
1042 * a mismatched quote not inside a C comment.
1044 fix = {
1045 hackname = badquote;
1046 files = sundev/vuid_event.h;
1047 select = "doesn't";
1048 c_fix = format;
1049 c_fix_arg = "does not";
1051 test_text = "/* doesn't have matched single quotes */";
1055 * check for broken assert.h that needs stdio.h
1057 fix = {
1058 hackname = broken_assert_stdio;
1059 files = assert.h;
1060 select = stderr;
1061 bypass = "include.*stdio\\.h";
1062 c_fix = wrap;
1063 c_fix_arg = "#include <stdio.h>\n";
1064 test_text = "extern FILE* stderr;";
1068 * check for broken assert.h that needs stdlib.h
1070 fix = {
1071 hackname = broken_assert_stdlib;
1072 files = assert.h;
1073 select = 'exit *\(|abort *\(';
1074 bypass = "include.*stdlib\\.h";
1075 c_fix = wrap;
1076 c_fix_arg = "#ifdef __cplusplus\n"
1077 "#include <stdlib.h>\n"
1078 "#endif\n";
1079 test_text = "extern void exit ( int );";
1083 * Remove `extern double cabs' declarations from math.h.
1084 * This conflicts with C99. Discovered on AIX.
1085 * Darwin hides its broken cabs in architecture-specific subdirs.
1087 fix = {
1088 hackname = broken_cabs;
1089 files = math.h, "architecture/*/math.h";
1090 select = "^extern[ \t]+double[ \t]+cabs";
1092 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1093 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1095 test_text = "#ifdef __STDC__\n"
1096 "extern double cabs(struct dbl_hypot);\n"
1097 "#else\n"
1098 "extern double cabs();\n"
1099 "#endif\n"
1100 "extern double cabs ( _Complex z );";
1104 * Fixup Darwin's broken check for __builtin_nanf.
1106 fix = {
1107 hackname = broken_nan;
1109 * It is tempting to omit the first "files" entry. Do not.
1110 * The testing machinery will take the first "files" entry as the name
1111 * of a test file to play with. It would be a nuisance to have a directory
1112 * with the name "*".
1114 files = "architecture/ppc/math.h";
1115 files = "architecture/*/math.h";
1116 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1117 bypass = "powl";
1118 c_fix = format;
1119 c_fix_arg = "#if 1";
1120 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1124 * Various systems derived from BSD4.4 contain a macro definition
1125 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1126 * Known to be fixed in FreeBSD 5 system headers.
1128 fix = {
1129 hackname = bsd_stdio_attrs_conflict;
1130 mach = "*-*-*bsd*";
1131 mach = "*-*-*darwin*";
1132 files = stdio.h;
1133 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1134 c_fix = format;
1135 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1136 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1137 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1138 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1139 test_text = '#define vfscanf __svfscanf';
1143 * Fix various macros used to define ioctl numbers.
1144 * The traditional syntax was:
1146 * #define _CTRL(n, x) (('n'<<8)+x)
1147 * #define TCTRLCFOO _CTRL(T, 1)
1149 * but this does not work with the C standard, which disallows macro
1150 * expansion inside strings. We have to rewrite it thus:
1152 * #define _CTRL(n, x) ((n<<8)+x)
1153 * #define TCTRLCFOO _CTRL('T', 1)
1155 * The select expressions match too much, but the c_fix code is cautious.
1157 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1159 fix = {
1160 hackname = ctrl_quotes_def;
1161 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1162 c_fix = char_macro_def;
1163 c_fix_arg = "CTRL";
1166 * This is two tests in order to ensure that the "CTRL(c)" can
1167 * be selected in isolation from the multi-arg format
1169 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1170 test_text = "#define _CTRL(c) ('c'&037)";
1174 * Fix various macros used to define ioctl numbers.
1176 fix = {
1177 hackname = ctrl_quotes_use;
1178 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1179 c_fix = char_macro_use;
1180 c_fix_arg = "CTRL";
1181 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1185 * sys/mman.h on HP/UX is not C++ ready,
1186 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1188 * rpc/types.h on OSF1/2.0 is not C++ ready,
1189 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1191 * The problem is the declaration of malloc.
1193 fix = {
1194 hackname = cxx_unready;
1195 files = sys/mman.h;
1196 files = rpc/types.h;
1197 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1198 not within a macro. */
1199 bypass = '"C"|__BEGIN_DECLS';
1201 c_fix = wrap;
1202 c_fix_arg = "#ifdef __cplusplus\n"
1203 "extern \"C\" {\n"
1204 "#endif\n";
1205 c_fix_arg = "#ifdef __cplusplus\n"
1206 "}\n"
1207 "#endif\n";
1208 test_text = "extern void* malloc( size_t );";
1212 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1213 * you have to not use "" includes.
1215 fix = {
1216 hackname = darwin_9_long_double_funcs_2;
1217 mach = "*-*-darwin7.9*";
1218 files = math.h;
1219 select = '#include[ \t]+\"';
1220 c_fix = format;
1221 c_fix_arg = "%1<%2.h>";
1223 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1225 test_text = '#include "architecture/ppc/math.h"';
1229 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1230 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1232 fix = {
1233 hackname = darwin_externc;
1234 mach = "*-*-darwin*";
1235 files = mach-o/swap.h;
1236 files = mach/mach_time.h;
1237 files = mach/mach_traps.h;
1238 files = mach/message.h;
1239 files = mach/mig.h;
1240 files = mach/semaphore.h;
1241 bypass = "extern \"C\"";
1242 bypass = "__BEGIN_DECLS";
1243 c_fix = wrap;
1244 c_fix_arg = "#ifdef __cplusplus\n"
1245 "extern \"C\" {\n"
1246 "#endif\n";
1247 c_fix_arg = "#ifdef __cplusplus\n"
1248 "}\n"
1249 "#endif\n";
1250 test_text = "extern void swap_fat_header();\n";
1254 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1255 * bad __GNUC__ tests.
1257 fix = {
1258 hackname = darwin_gcc4_breakage;
1259 mach = "*-*-darwin*";
1260 files = AvailabilityMacros.h;
1261 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1262 c_fix = format;
1263 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1264 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1265 "(__GNUC_MINOR__ >= 1)\n";
1269 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1270 * why would you ever put it in a system header file?
1272 fix = {
1273 hackname = darwin_private_extern;
1274 mach = "*-*-darwin*";
1275 files = mach-o/dyld.h;
1276 select = "__private_extern__ [a-z_]+ _dyld_";
1277 c_fix = format;
1278 c_fix_arg = "extern";
1279 c_fix_arg = "__private_extern__";
1280 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1281 "const char *dyld_func_name,\n"
1282 "unsigned long *address);\n";
1286 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1287 * unsigned constants.
1289 fix = {
1290 hackname = darwin_stdint_1;
1291 mach = "*-*-darwin*";
1292 files = stdint-darwin.h, stdint.h;
1293 c_fix = format;
1294 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1295 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1296 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1297 test_text = "#define UINT8_C(v) (v ## U)\n"
1298 "#define UINT16_C(v) (v ## U)";
1302 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1303 * with wrong types.
1305 fix = {
1306 hackname = darwin_stdint_2;
1307 mach = "*-*-darwin*";
1308 files = stdint-darwin.h, stdint.h;
1309 c_fix = format;
1310 c_fix_arg = "#if __WORDSIZE == 64\n"
1311 "#define INTPTR_MAX 9223372036854775807L\n"
1312 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1313 "#else\n"
1314 "#define INTPTR_MAX 2147483647L\n"
1315 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1316 "#endif";
1317 select = "#if __WORDSIZE == 64\n"
1318 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1319 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1320 "#else\n"
1321 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1322 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1323 "#endif";
1324 test_text = "#if __WORDSIZE == 64\n"
1325 "#define INTPTR_MIN INT64_MIN\n"
1326 "#define INTPTR_MAX INT64_MAX\n"
1327 "#else\n"
1328 "#define INTPTR_MIN INT32_MIN\n"
1329 "#define INTPTR_MAX INT32_MAX\n"
1330 "#endif";
1334 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1336 fix = {
1337 hackname = darwin_stdint_3;
1338 mach = "*-*-darwin*";
1339 files = stdint-darwin.h, stdint.h;
1340 c_fix = format;
1341 c_fix_arg = "#if __WORDSIZE == 64\n"
1342 "#define UINTPTR_MAX 18446744073709551615UL\n"
1343 "#else\n"
1344 "#define UINTPTR_MAX 4294967295UL\n"
1345 "#endif";
1346 select = "#if __WORDSIZE == 64\n"
1347 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1348 "#else\n"
1349 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1350 "#endif";
1351 test_text = "#if __WORDSIZE == 64\n"
1352 "#define UINTPTR_MAX UINT64_MAX\n"
1353 "#else\n"
1354 "#define UINTPTR_MAX UINT32_MAX\n"
1355 "#endif";
1359 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1361 fix = {
1362 hackname = darwin_stdint_4;
1363 mach = "*-*-darwin*";
1364 files = stdint-darwin.h, stdint.h;
1365 c_fix = format;
1366 c_fix_arg = "#if __WORDSIZE == 64\n"
1367 "#define SIZE_MAX 18446744073709551615UL\n"
1368 "#else\n"
1369 "#define SIZE_MAX 4294967295UL\n"
1370 "#endif";
1371 select = "#if __WORDSIZE == 64\n"
1372 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1373 "#else\n"
1374 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1375 "#endif";
1376 test_text = "#if __WORDSIZE == 64\n"
1377 "#define SIZE_MAX UINT64_MAX\n"
1378 "#else\n"
1379 "#define SIZE_MAX UINT32_MAX\n"
1380 "#endif";
1384 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1385 * with a wrong type.
1387 fix = {
1388 hackname = darwin_stdint_5;
1389 mach = "*-*-darwin*";
1390 files = stdint-darwin.h, stdint.h;
1391 c_fix = format;
1392 c_fix_arg = "#if __WORDSIZE == 64\n"
1393 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1394 "#define INTMAX_MAX 9223372036854775807L\n"
1395 "#define UINTMAX_MAX 18446744073709551615UL\n"
1396 "#else\n"
1397 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1398 "#define INTMAX_MAX 9223372036854775807LL\n"
1399 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1400 "#endif";
1401 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1402 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1403 "\n"
1404 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1405 test_text = "#define INTMAX_MIN INT64_MIN\n"
1406 "#define INTMAX_MAX INT64_MAX\n"
1407 "\n"
1408 "#define UINTMAX_MAX UINT64_MAX";
1412 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1413 * with a wrong type.
1415 fix = {
1416 hackname = darwin_stdint_6;
1417 mach = "*-*-darwin*";
1418 files = stdint-darwin.h, stdint.h;
1419 c_fix = format;
1420 c_fix_arg = "#if __WORDSIZE == 64\n"
1421 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1422 "#define PTRDIFF_MAX 9223372036854775807L\n"
1423 "#else\n"
1424 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1425 "#define PTRDIFF_MAX 2147483647\n"
1426 "#endif";
1427 select = "#if __WORDSIZE == 64\n"
1428 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1429 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1430 "#else\n"
1431 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1432 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1433 "#endif";
1434 test_text = "#if __WORDSIZE == 64\n"
1435 "#define PTRDIFF_MIN INT64_MIN\n"
1436 "#define PTRDIFF_MAX INT64_MAX\n"
1437 "#else\n"
1438 "#define PTRDIFF_MIN INT32_MIN\n"
1439 "#define PTRDIFF_MAX INT32_MAX\n"
1440 "#endif";
1444 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1445 * with a wrong type.
1447 fix = {
1448 hackname = darwin_stdint_7;
1449 mach = "*-*-darwin*";
1450 files = stdint-darwin.h, stdint.h;
1451 c_fix = format;
1452 c_fix_arg = "#if __WORDSIZE == 64\n"
1453 "#define INTMAX_C(v) (v ## L)\n"
1454 "#define UINTMAX_C(v) (v ## UL)\n"
1455 "#else\n"
1456 "#define INTMAX_C(v) (v ## LL)\n"
1457 "#define UINTMAX_C(v) (v ## ULL)\n"
1458 "#endif";
1459 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1460 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1461 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1462 "#define UINTMAX_C(v) (v ## ULL)";
1466 * Fix <c_asm.h> on Digital UNIX V4.0:
1467 * It contains a prototype for a DEC C internal asm() function,
1468 * clashing with gcc's asm keyword. So protect this with __DECC.
1470 fix = {
1471 hackname = dec_intern_asm;
1472 files = c_asm.h;
1473 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1474 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1475 "#endif\n";
1476 test_text =
1477 "float fasm {\n"
1478 " ... asm stuff ...\n"
1479 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1483 * Fix typo in <wchar.h> on DJGPP 2.03.
1485 fix = {
1486 hackname = djgpp_wchar_h;
1487 file = wchar.h;
1488 select = "__DJ_wint_t";
1489 bypass = "sys/djtypes.h";
1490 c_fix = format;
1491 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1492 c_fix_arg = "#include <stddef.h>";
1493 test_text = "#include <stddef.h>\n"
1494 "extern __DJ_wint_t x;\n";
1498 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1500 fix = {
1501 hackname = ecd_cursor;
1502 files = "sunwindow/win_lock.h";
1503 files = "sunwindow/win_cursor.h";
1504 select = 'ecd\.cursor';
1505 c_fix = format;
1506 c_fix_arg = 'ecd_cursor';
1508 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1512 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1513 * neither the existence of GCC 3 nor its exact feature set yet break
1514 * (by design?) when __GNUC__ is set beyond 2.
1516 fix = {
1517 hackname = freebsd_gcc3_breakage;
1518 mach = "*-*-freebsd*";
1519 files = sys/cdefs.h;
1520 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1521 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1522 c_fix = format;
1523 c_fix_arg = '%0 || __GNUC__ >= 3';
1524 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1528 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1529 * neither the existence of GCC 4 nor its exact feature set yet break
1530 * (by design?) when __GNUC__ is set beyond 3.
1532 fix = {
1533 hackname = freebsd_gcc4_breakage;
1534 mach = "*-*-freebsd*";
1535 files = sys/cdefs.h;
1536 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1537 c_fix = format;
1538 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1539 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1543 * Some versions of glibc don't expect the C99 inline semantics.
1545 fix = {
1546 hackname = glibc_c99_inline_1;
1547 files = features.h, '*/features.h';
1548 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1549 c_fix = format;
1550 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1551 test_text = <<-EOT
1552 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1553 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1554 # define __USE_EXTERN_INLINES 1
1555 #endif
1556 EOT;
1560 * Similar, but a version that didn't have __NO_INLINE__
1562 fix = {
1563 hackname = glibc_c99_inline_1a;
1564 files = features.h, '*/features.h';
1565 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1566 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1567 c_fix = format;
1568 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1569 test_text = <<-EOT
1570 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1571 # define __USE_EXTERN_INLINES 1
1572 #endif
1573 EOT;
1577 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1578 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1579 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1581 fix = {
1582 hackname = glibc_c99_inline_2;
1583 files = sys/stat.h, '*/sys/stat.h';
1584 select = "extern __inline__ int";
1585 sed = "s/extern int \\(stat\\)/"
1586 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1587 "__inline__ int \\1/";
1588 sed = "s/extern int \\([lf]stat\\)/"
1589 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1590 "__inline__ int \\1/";
1591 sed = "s/extern int \\(mknod\\)/"
1592 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1593 "__inline__ int \\1/";
1594 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1595 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1596 "__inline__ int __REDIRECT\\1 (\\2/";
1597 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1598 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1599 "__inline__ int __REDIRECT\\1 (\\2/";
1600 sed = "s/^extern __inline__ int/"
1601 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1602 "__inline__ int/";
1603 test_text = <<-EOT
1604 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1605 extern __inline__ int
1606 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1608 EOT;
1612 * glibc_c99_inline_3
1614 fix = {
1615 hackname = glibc_c99_inline_3;
1616 files = bits/string2.h, '*/bits/string2.h';
1617 select = "extern __inline";
1618 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1619 c_fix = format;
1620 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1621 c_fix_arg = "^# ifdef __cplusplus$";
1622 test_text = <<-EOT
1623 # ifdef __cplusplus
1624 # define __STRING_INLINE inline
1625 # else
1626 # define __STRING_INLINE extern __inline
1627 # endif
1628 EOT;
1632 * glibc_c99_inline_4
1634 fix = {
1635 hackname = glibc_c99_inline_4;
1636 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1637 bypass = "__extern_inline|__gnu_inline__";
1638 select = "(^| )extern __inline";
1639 c_fix = format;
1640 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1641 test_text = <<-EOT
1642 __extension__ extern __inline unsigned int
1643 extern __inline unsigned int
1644 EOT;
1647 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1648 * so we replace them with versions that correspond to the
1649 * definition.
1651 fix = {
1652 hackname = glibc_mutex_init;
1653 files = pthread.h;
1654 select = '\{ *\{ *0, *\} *\}';
1655 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1656 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1657 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1658 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1659 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1660 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1661 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1662 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1663 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1664 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1665 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1666 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1667 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1668 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1669 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1670 "N;s/^[ \t]*#[ \t]*"
1671 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1672 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1673 "# \\1\\\n"
1674 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1675 "# else\\\n"
1676 "# \\1\\\n"
1677 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1678 "# endif/";
1679 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1680 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1681 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1682 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1684 test_text = <<- _EOText_
1685 #define PTHREAD_MUTEX_INITIALIZER \\
1686 { { 0, } }
1687 #ifdef __USE_GNU
1688 # if __WORDSIZE == 64
1689 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1690 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1691 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1692 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1693 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1694 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1695 # else
1696 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1697 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1698 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1699 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1700 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1701 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1702 # endif
1703 #endif
1704 # define PTHREAD_RWLOCK_INITIALIZER \\
1705 { { 0, } }
1706 # ifdef __USE_GNU
1707 # if __WORDSIZE == 64
1708 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1709 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1710 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1711 # else
1712 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1713 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1714 # endif
1715 # endif
1716 #define PTHREAD_COND_INITIALIZER { { 0, } }
1717 _EOText_;
1720 /* glibc versions before 2.5 have a version of stdint.h that defines
1721 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1722 versions with stdint.h based on those glibc versions. */
1723 fix = {
1724 hackname = glibc_stdint;
1725 files = stdint.h;
1726 select = "GNU C Library";
1727 c_fix = format;
1728 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1729 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1730 test_text = "/* This file is part of the GNU C Library. */\n"
1731 "# define UINT8_C(c)\tc ## U\n"
1732 "# define UINT16_C(c)\tc ## U";
1735 /* Some versions of glibc have a version of bits/string2.h that
1736 produces "value computed is not used" warnings from strncpy; fix
1737 this definition by using __builtin_strncpy instead as in newer
1738 versions. */
1739 fix = {
1740 hackname = glibc_strncpy;
1741 files = bits/string2.h;
1742 bypass = "__builtin_strncpy";
1743 c_fix = format;
1744 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1745 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1746 test_text = <<-EOT
1747 # define strncpy(dest, src, n) \
1748 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1749 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1750 ? (char *) memcpy (dest, src, n) \\
1751 : strncpy (dest, src, n)) \\
1752 : strncpy (dest, src, n)))
1753 EOT;
1757 /* glibc's tgmath.h relies on an expression that is not an integer
1758 constant expression being treated as it was by GCC 4.4 and
1759 earlier. */
1760 fix = {
1761 hackname = glibc_tgmath;
1762 files = tgmath.h;
1763 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1764 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1765 c_fix = format;
1766 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1767 "(__builtin_classify_type ((type) 0) == 9 && "
1768 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1769 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1773 * Fix these files to use the types we think they should for
1774 * ptrdiff_t, size_t, and wchar_t.
1776 * This defines the types in terms of macros predefined by our 'cpp'.
1777 * This is supposedly necessary for glibc's handling of these types.
1778 * It's probably not necessary for anyone else, but it doesn't hurt.
1780 fix = {
1781 hackname = gnu_types;
1782 files = "sys/types.h";
1783 files = "stdlib.h";
1784 files = "sys/stdtypes.h";
1785 files = "stddef.h";
1786 files = "memory.h";
1787 files = "unistd.h";
1788 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1789 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1790 c_fix = gnu_type;
1791 /* The Solaris 10 headers already define these types correctly. */
1792 mach = '*-*-solaris2.1[0-9]*';
1793 not_machine = true;
1795 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1796 "typedef uint_t size_t; /* uint_t */\n"
1797 "typedef ushort_t wchar_t; /* ushort_t */";
1801 * Fix HP & Sony's use of "../machine/xxx.h"
1802 * to refer to: <machine/xxx.h>
1804 fix = {
1805 hackname = hp_inline;
1806 files = sys/spinlock.h;
1807 files = machine/machparam.h;
1808 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1810 c_fix = format;
1811 c_fix_arg = "%1<machine/%2.h>";
1813 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1814 '([a-z]+)\.h"';
1816 test_text = ' # include "../machine/mumble.h"';
1820 * Check for (...) in C++ code in HP/UX sys/file.h.
1822 fix = {
1823 hackname = hp_sysfile;
1824 files = sys/file.h;
1825 select = "HPUX_SOURCE";
1827 c_fix = format;
1828 c_fix_arg = "(struct file *, ...)";
1829 c_fix_arg = '\(\.\.\.\)';
1831 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1835 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1836 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1838 fix = {
1839 hackname = hppa_hpux_fp_macros;
1840 mach = "hppa*-hp-hpux11*";
1841 files = math.h;
1842 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1843 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1844 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1845 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1846 "#[ \t]*define[ \t]*FP_NAN.*\n";
1847 c_fix = format;
1848 c_fix_arg = <<- _EOFix_
1849 #endif /* _INCLUDE_HPUX_SOURCE */
1851 #if defined(_INCLUDE_HPUX_SOURCE) || \
1852 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1853 %0#endif
1855 #ifdef _INCLUDE_HPUX_SOURCE
1857 _EOFix_;
1859 test_text =
1860 "# define FP_NORMAL 0\n"
1861 "# define FP_ZERO 1\n"
1862 "# define FP_INFINITE 2\n"
1863 "# define FP_SUBNORMAL 3\n"
1864 "# define FP_NAN 4\n";
1868 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1869 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1871 fix = {
1872 hackname = hpux10_cpp_pow_inline;
1873 files = fixinc-test-limits.h, math.h;
1874 select = <<- END_POW_INLINE
1875 ^# +ifdef +__cplusplus
1877 +inline +double +pow\(double +__d,int +__expon\) +\{
1878 [ ]+return +pow\(__d,\(double\)__expon\);
1880 +extern +"C" +\{
1881 #else
1882 # +endif
1883 END_POW_INLINE;
1885 c_fix = format;
1886 c_fix_arg = "";
1888 test_text =
1889 "# ifdef __cplusplus\n"
1890 " }\n"
1891 " inline double pow(double __d,int __expon) {\n"
1892 "\t return pow(__d,(double)__expon);\n"
1893 " }\n"
1894 ' extern "C"' " {\n"
1895 "#else\n"
1896 "# endif";
1899 fix = {
1900 hackname = hpux11_cpp_pow_inline;
1901 files = math.h;
1902 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1903 " +return pow\\(d, \\(double\\)expon\\);\n"
1904 " +\\}\n";
1905 c_fix = format;
1906 c_fix_arg = "";
1908 test_text =
1909 " inline double pow(double d,int expon) {\n"
1910 " return pow(d, (double)expon);\n"
1911 " }\n";
1915 * Fix hpux 10.X missing ctype declarations 1
1917 fix = {
1918 hackname = hpux10_ctype_declarations1;
1919 files = ctype.h;
1920 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1921 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1922 c_fix = format;
1923 c_fix_arg = "#ifdef _PROTOTYPES\n"
1924 "extern int __tolower(int);\n"
1925 "extern int __toupper(int);\n"
1926 "#else /* NOT _PROTOTYPES */\n"
1927 "extern int __tolower();\n"
1928 "extern int __toupper();\n"
1929 "#endif /* _PROTOTYPES */\n\n"
1930 "%0\n";
1932 test_text = "# define _toupper(__c) __toupper(__c)\n";
1936 * Fix hpux 10.X missing ctype declarations 2
1938 fix = {
1939 hackname = hpux10_ctype_declarations2;
1940 files = ctype.h;
1941 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1942 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1943 c_fix = format;
1944 c_fix_arg = "%0\n\n"
1945 "#ifdef _PROTOTYPES\n"
1946 " extern int _isalnum(int);\n"
1947 " extern int _isalpha(int);\n"
1948 " extern int _iscntrl(int);\n"
1949 " extern int _isdigit(int);\n"
1950 " extern int _isgraph(int);\n"
1951 " extern int _islower(int);\n"
1952 " extern int _isprint(int);\n"
1953 " extern int _ispunct(int);\n"
1954 " extern int _isspace(int);\n"
1955 " extern int _isupper(int);\n"
1956 " extern int _isxdigit(int);\n"
1957 "# else /* not _PROTOTYPES */\n"
1958 " extern int _isalnum();\n"
1959 " extern int _isalpha();\n"
1960 " extern int _iscntrl();\n"
1961 " extern int _isdigit();\n"
1962 " extern int _isgraph();\n"
1963 " extern int _islower();\n"
1964 " extern int _isprint();\n"
1965 " extern int _ispunct();\n"
1966 " extern int _isspace();\n"
1967 " extern int _isupper();\n"
1968 " extern int _isxdigit();\n"
1969 "#endif /* _PROTOTYPES */\n";
1971 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1972 " extern unsigned int *__SB_masks;\n";
1976 * Fix hpux 10.X missing stdio declarations
1978 fix = {
1979 hackname = hpux10_stdio_declarations;
1980 files = stdio.h;
1981 select = "^#[ \t]*define _iob[ \t]*__iob";
1982 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1983 c_fix = format;
1984 c_fix_arg = "%0\n\n"
1985 "# if defined(__STDC__) || defined(__cplusplus)\n"
1986 " extern int snprintf(char *, size_t, const char *, ...);\n"
1987 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1988 "# else /* not __STDC__) || __cplusplus */\n"
1989 " extern int snprintf();\n"
1990 " extern int vsnprintf();\n"
1991 "# endif /* __STDC__) || __cplusplus */\n";
1993 test_text = "# define _iob __iob\n";
1997 * Make sure hpux defines abs in header.
1999 fix = {
2000 hackname = hpux11_abs;
2001 mach = "*-hp-hpux11*";
2002 files = stdlib.h;
2003 select = "ifndef _MATH_INCLUDED";
2004 c_fix = format;
2005 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2006 test_text = "#ifndef _MATH_INCLUDED";
2010 * Keep HP-UX 11 from stomping on C++ math namespace
2011 * with defines for fabsf.
2013 fix = {
2014 hackname = hpux11_fabsf;
2015 files = math.h;
2016 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2017 bypass = "__cplusplus";
2019 c_fix = format;
2020 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2022 test_text =
2023 "#ifdef _PA_RISC\n"
2024 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2025 "#endif";
2029 * Fix C99 constant in __POINTER_SET define.
2031 fix = {
2032 hackname = hpux11_pthread_const;
2033 mach = "*-hp-hpux11.[0-3]*";
2034 files = sys/pthread.h;
2035 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2037 c_fix = format;
2038 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2039 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2043 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2044 * being defined by having it define _hpux_size_t instead.
2046 fix = {
2047 hackname = hpux11_size_t;
2048 mach = "*-hp-hpux11*";
2049 select = "__size_t";
2051 c_fix = format;
2052 c_fix_arg = "_hpux_size_t";
2054 test_text =
2055 "#define __size_t size_t\n"
2056 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2060 * Fix hpux 11.00 broken snprintf declaration
2061 * (third argument is char *, needs to be const char * to prevent
2062 * spurious warnings with -Wwrite-strings or in C++).
2064 fix = {
2065 hackname = hpux11_snprintf;
2066 files = stdio.h;
2067 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2068 ' *(char *\*, *\.\.\.\);)';
2069 c_fix = format;
2070 c_fix_arg = '%1 const %3';
2072 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2073 "extern int snprintf(char *, __size_t, char *, ...);\n"
2074 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2078 * Fix hpux 11.00 broken vsnprintf declaration
2080 fix = {
2081 hackname = hpux11_vsnprintf;
2082 files = stdio.h;
2083 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2084 'const char \*,) __va__list\);';
2085 c_fix = format;
2086 c_fix_arg = "%1 __va_list);";
2088 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2089 ' __va__list);';
2093 * get rid of bogus inline definitions in HP-UX 8.0
2095 fix = {
2096 hackname = hpux8_bogus_inlines;
2097 files = math.h;
2098 select = inline;
2099 bypass = "__GNUG__";
2100 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2101 "@extern \"C\" int abs(int);@";
2102 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2103 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2104 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2105 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2106 "inline double sqr(double v) { return v**0.5; }";
2110 * Fix hpux broken ctype macros
2112 fix = {
2113 hackname = hpux_ctype_macros;
2114 files = ctype.h;
2115 select = '((: |\()__SB_masks \? )'
2116 '(__SB_masks\[__(alnum|c)\] & _IS)';
2117 c_fix = format;
2118 c_fix_arg = "%1(int)%3";
2120 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2121 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2125 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2127 fix = {
2128 hackname = hpux_htonl;
2129 files = netinet/in.h;
2130 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2131 "(/\\*\n"
2132 " \\* Macros for number representation conversion\\.\n"
2133 " \\*/\n"
2134 "#ifndef ntohl)";
2135 c_fix = format;
2136 c_fix_arg = "#if 1\n%1";
2138 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2139 "/*\n"
2140 " * Macros for number representation conversion.\n"
2141 " */\n"
2142 "#ifndef ntohl\n"
2143 "#define ntohl(x) (x)\n"
2144 "#define ntohs(x) (x)\n"
2145 "#define htonl(x) (x)\n"
2146 "#define htons(x) (x)\n"
2147 "#endif\n"
2148 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2152 * HP-UX long_double
2154 fix = {
2155 hackname = hpux_long_double;
2156 mach = "*-*-hpux10*";
2157 mach = "*-*-hpux11.[012]*";
2158 files = stdlib.h;
2159 select = "extern[ \t]long_double[ \t]strtold";
2160 bypass = "long_double_t";
2161 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2162 sed = "s/long_double/long double/g";
2164 test_text = "# ifndef _LONG_DOUBLE\n"
2165 "# define _LONG_DOUBLE\n"
2166 " typedef struct {\n"
2167 " unsigned int word1, word2, word3, word4;\n"
2168 " } long_double;\n"
2169 "# endif /* _LONG_DOUBLE */\n"
2170 "extern long_double strtold(const char *, char **);\n";
2174 * We cannot use the above rule on 11.31 because it removes the strtold
2175 * definition. ia64 is OK with no hack, PA needs some help.
2177 fix = {
2178 hackname = hpux_long_double_2;
2179 mach = "hppa*-*-hpux11.3*";
2180 files = stdlib.h;
2181 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2182 "defined\\(_PROTOTYPES\\) \\|\\| "
2183 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2184 c_fix = format;
2185 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2187 test_text = "# if !defined(__ia64) || "
2188 "!defined(_PROTOTYPES) || "
2189 "defined(_LONG_DOUBLE_STRUCT)\n";
2193 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2195 fix = {
2196 hackname = hpux_systime;
2197 files = sys/time.h;
2198 select = "^extern struct sigevent;";
2200 c_fix = format;
2201 c_fix_arg = "struct sigevent;";
2203 test_text = 'extern struct sigevent;';
2207 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2208 * type and mpinfou is only defined when _KERNEL is set.
2210 fix = {
2211 hackname = hpux_spu_info;
2212 mach = "*-hp-hpux*";
2214 * It is tempting to omit the first "files" entry. Do not.
2215 * The testing machinery will take the first "files" entry as the name
2216 * of a test file to play with. It would be a nuisance to have a directory
2217 * with the name "*".
2219 files = "ia64/sys/getppdp.h";
2220 files = "*/sys/getppdp.h";
2221 select = "^.*extern.*spu_info.*";
2223 c_fix = format;
2224 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2226 test_text = "extern union mpinfou spu_info[];";
2229 fix = {
2230 hackname = hpux11_extern_sendfile;
2231 mach = "*-hp-hpux11.[12]*";
2232 files = sys/socket.h;
2233 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2234 c_fix = format;
2235 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2236 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2237 " const struct iovec *, int));\n";
2240 fix = {
2241 hackname = hpux11_extern_sendpath;
2242 mach = "*-hp-hpux11.[12]*";
2243 files = sys/socket.h;
2244 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2245 c_fix = format;
2246 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2247 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2248 " const struct iovec *, int));\n";
2251 fix = {
2252 hackname = hpux_extern_errno;
2253 mach = "*-hp-hpux10.*";
2254 mach = "*-hp-hpux11.[0-2]*";
2255 files = errno.h;
2256 select = "^[ \t]*extern int errno;$";
2257 c_fix = format;
2258 c_fix_arg = "#ifdef __cplusplus\n"
2259 "extern \"C\" {\n"
2260 "#endif\n"
2261 "%0\n"
2262 "#ifdef __cplusplus\n"
2263 "}\n"
2264 "#endif";
2265 test_text = " extern int errno;\n";
2269 * Add missing braces to pthread initializer defines.
2271 fix = {
2272 hackname = hpux_pthread_initializers;
2273 mach = "*-hp-hpux11.[0-3]*";
2274 files = sys/pthread.h;
2275 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2276 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2277 sed = "s@^[ \t]*1,[ \t]*\\\\"
2278 "@\t{ 1, 0 }@";
2279 sed = "/^[ \t]*0$/d";
2280 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2281 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2282 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2283 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2284 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2285 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2286 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2287 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2288 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2289 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2290 sed = "s@__PTHREAD_COND_VALID, 0"
2291 "@{ __PTHREAD_COND_VALID, 0 }@";
2292 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2293 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2294 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2295 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2296 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2297 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2298 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2299 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2300 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2301 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2302 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2303 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2304 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2305 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2306 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2307 "}\n";
2310 fix = {
2311 hackname = hpux_c99_intptr;
2312 mach = "*-hp-hpux11.3*";
2313 files = stdint-hpux11.h, stdint.h;
2314 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2315 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2316 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2317 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2318 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2319 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2320 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2321 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2322 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2323 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2324 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2325 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2326 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2327 "#define PTRDIFF_MIN INT32_MIN\n"
2328 "#define INTPTR_MAX INT32_MAX\n"
2329 "#define INTPTR_MIN INT32_MIN\n"
2330 "#define UINTPTR_MAX UINT32_MAX\n"
2331 "#define SIZE_MAX UINT32_MAX\n";
2335 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2338 fix = {
2339 hackname = hpux_c99_inttypes;
2340 mach = "*-hp-hpux11.[23]*";
2341 files = inttypes.h;
2342 files = stdint-hpux11.h, stdint.h;
2343 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2344 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2345 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2346 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2347 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2348 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2349 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2350 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2351 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2352 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2353 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2354 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2357 fix = {
2358 hackname = hpux_c99_inttypes2;
2359 mach = "*-hp-hpux11.2*";
2360 files = stdint-hpux11.h, stdint.h;
2361 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2362 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2363 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2364 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2365 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2366 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2367 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2368 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2369 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2370 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2371 "# define INT16_C(__c) ((short)(__c))\n"
2372 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2375 fix = {
2376 hackname = hpux_stdint_least_fast;
2377 mach = "*-hp-hpux11.2*";
2378 files = stdint-hpux11.h, stdint.h;
2379 select =
2380 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2381 c_fix = format;
2382 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2383 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2384 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2385 _EOFix_;
2388 fix = {
2389 hackname = hpux_inttype_int8_t;
2390 mach = "*-hp-hpux1[01].*";
2391 files = sys/_inttypes.h;
2392 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2393 c_fix = format;
2394 c_fix_arg = "typedef signed char int%18_t;";
2395 test_text = "typedef char int_least8_t;\n"
2396 "typedef char int8_t;\n";
2399 fix = {
2400 hackname = hpux_imaginary_i;
2401 mach = "ia64-hp-hpux11.*";
2402 files = complex.h;
2403 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2404 c_fix = format;
2405 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2406 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2410 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2412 fix = {
2413 hackname = huge_val_hex;
2414 files = bits/huge_val.h;
2415 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2416 bypass = "__builtin_huge_val";
2418 c_fix = format;
2419 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2421 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2425 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2427 fix = {
2428 hackname = huge_valf_hex;
2429 files = bits/huge_val.h;
2430 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2431 bypass = "__builtin_huge_valf";
2433 c_fix = format;
2434 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2436 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2440 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2442 fix = {
2443 hackname = huge_vall_hex;
2444 files = bits/huge_val.h;
2445 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2446 bypass = "__builtin_huge_vall";
2448 c_fix = format;
2449 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2451 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2455 * Fix return type of abort and free
2457 fix = {
2458 hackname = int_abort_free_and_exit;
2459 files = stdlib.h;
2460 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2461 bypass = "_CLASSIC_ANSI_TYPES";
2463 c_fix = format;
2464 c_fix_arg = "void\t%1(";
2466 test_text = "extern int abort(int);\n"
2467 "extern int free(void*);\n"
2468 "extern int exit(void*);";
2472 * Fix various macros used to define ioctl numbers.
2473 * The traditional syntax was:
2475 * #define _IO(n, x) (('n'<<8)+x)
2476 * #define TIOCFOO _IO(T, 1)
2478 * but this does not work with the C standard, which disallows macro
2479 * expansion inside strings. We have to rewrite it thus:
2481 * #define _IO(n, x) ((n<<8)+x)
2482 * #define TIOCFOO _IO('T', 1)
2484 * The select expressions match too much, but the c_fix code is cautious.
2486 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2488 fix = {
2489 hackname = io_quotes_def;
2490 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2491 c_fix = char_macro_def;
2492 c_fix_arg = "IO";
2493 test_text =
2494 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2495 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2496 "#define _IO(x,y) ('x'<<8|y)";
2497 test_text =
2498 "#define XX_IO(x) ('x'<<8|256)";
2502 * Fix the usage of the ioctl macro numbers.
2504 fix = {
2505 hackname = io_quotes_use;
2506 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2507 "\\( *[^,']";
2508 c_fix = char_macro_use;
2509 c_fix_arg = "IO";
2510 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2511 "#define TIOCFOO \\\\\n"
2512 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2516 * Check for missing ';' in struct
2518 fix = {
2519 hackname = ip_missing_semi;
2520 files = netinet/ip.h;
2521 select = "}$";
2522 sed = "/^struct/,/^};/s/}$/};/";
2523 test_text=
2524 "struct mumble {\n"
2525 " union {\n"
2526 " int x;\n"
2527 " }\n"
2528 "}; /* mumbled struct */\n";
2532 * Non-traditional "const" declaration in Irix's limits.h.
2534 fix = {
2535 hackname = irix_limits_const;
2536 files = fixinc-test-limits.h, limits.h;
2537 select = "^extern const ";
2538 c_fix = format;
2539 c_fix_arg = "extern __const ";
2540 test_text = "extern const char limit; /* test limits */";
2544 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2545 * taking char *. However, GCC uses void * for va_list, so
2546 * calling vfprintf with a va_list fails in C++. */
2547 fix = {
2548 hackname = irix_stdio_va_list;
2549 files = stdio.h;
2551 select = '/\* va_list \*/ char \*';
2552 c_fix = format;
2553 c_fix_arg = "__gnuc_va_list";
2554 test_text =
2555 "extern int printf( const char *, /* va_list */ char * );";
2559 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2560 * use / * * / to concatenate tokens.
2562 fix = {
2563 hackname = kandr_concat;
2564 files = "sparc/asm_linkage.h";
2565 files = "sun*/asm_linkage.h";
2566 files = "arm/as_support.h";
2567 files = "arm/mc_type.h";
2568 files = "arm/xcb.h";
2569 files = "dev/chardefmac.h";
2570 files = "dev/ps_irq.h";
2571 files = "dev/screen.h";
2572 files = "dev/scsi.h";
2573 files = "sys/tty.h";
2574 files = "Xm.acorn/XmP.h";
2575 files = bsd43/bsd43_.h;
2576 select = '/\*\*/';
2577 c_fix = format;
2578 c_fix_arg = '##';
2579 test_text = "#define __CONCAT__(a,b) a/**/b";
2582 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2583 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2584 * constant on recent versions of g++.
2586 fix = {
2587 hackname = linux_ia64_ucontext;
2588 files = "sys/ucontext.h";
2589 mach = "ia64-*-linux*";
2590 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2591 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2592 c_fix = format;
2593 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2594 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2595 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2599 * Remove header file warning from sys/time.h. Autoconf's
2600 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2601 * which causes warning on LynxOS. Remove the warning.
2603 fix = {
2604 hackname = lynxos_no_warning_in_sys_time_h;
2605 files = sys/time.h;
2606 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2607 c_fix = format;
2608 c_fix_arg = "";
2609 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2613 * Add missing declaration for putenv.
2615 fix = {
2616 hackname = lynxos_missing_putenv;
2617 mach = '*-*-lynxos*';
2618 files = stdlib.h;
2619 bypass = 'putenv[ \t]*\\(';
2620 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2621 c_fix = format;
2622 c_fix_arg = "%0\n"
2623 "extern int putenv _AP((char *));";
2624 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2625 test_text = "extern char *getenv _AP((const char *));";
2629 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2631 * On NetBSD, machine is a symbolic link to an architecture specific
2632 * directory name, so we can't match a specific file name here.
2634 fix = {
2635 hackname = machine_ansi_h_va_list;
2636 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2637 bypass = '__builtin_va_list';
2639 c_fix = format;
2640 c_fix_arg = "%1__builtin_va_list";
2641 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2643 test_text = " # define _BSD_VA_LIST_\tchar**";
2647 * Fix non-ansi machine name defines
2649 fix = {
2650 hackname = machine_name;
2651 c_test = machine_name;
2652 c_fix = machine_name;
2654 test_text = "/* MACH_DIFF: */\n"
2655 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2656 "\n/* no uniform test, so be careful :-) */";
2660 * Some math.h files define struct exception (it's in the System V
2661 * Interface Definition), which conflicts with the class exception defined
2662 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2663 * This is not a great fix, but I haven't been able to think of anything
2664 * better.
2666 fix = {
2667 hackname = math_exception;
2668 files = math.h;
2669 select = "struct exception";
2671 * This should be bypassed on __cplusplus, but some supposedly C++
2672 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2673 * exception either. So currently we bypass only for glibc, based on a
2674 * comment in the fixed glibc header. Ick.
2676 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2677 '_[a-z0-9A-Z_]+_exception; for C, exception';
2678 c_fix = wrap;
2680 c_fix_arg = "#ifdef __cplusplus\n"
2681 "#define exception __math_exception\n"
2682 "#endif\n";
2684 c_fix_arg = "#ifdef __cplusplus\n"
2685 "#undef exception\n"
2686 "#endif\n";
2688 test_text = "typedef struct exception t_math_exception;";
2692 * This looks pretty broken to me. ``dbl_max_def'' will contain
2693 * "define DBL_MAX " at the start, when what we really want is just
2694 * the value portion. Can't figure out how to write a test case
2695 * for this either :-(
2697 fix = {
2698 hackname = math_huge_val_from_dbl_max;
2699 files = math.h;
2702 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2703 * in math.h, this fix applies.
2705 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2706 bypass = "define[ \t]+DBL_MAX";
2708 shell =
2710 * See if we have a definition for DBL_MAX in float.h.
2711 * If we do, we will replace the one in math.h with that one.
2714 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2715 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2717 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2718 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2719 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2720 "\telse cat\n"
2721 "\tfi";
2723 test_text =
2724 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2725 "#define HUGE_VAL DBL_MAX";
2729 * nested comment
2731 fix = {
2732 hackname = nested_auth_des;
2733 files = rpc/rpc.h;
2734 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2735 c_fix = format;
2736 c_fix_arg = "%1*/ /*";
2737 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2741 * Some versions of NetBSD don't expect the C99 inline semantics.
2743 fix = {
2744 hackname = netbsd_c99_inline_1;
2745 mach = "*-*-netbsd*";
2746 files = signal.h;
2747 select = "extern __inline int";
2749 c_fix = format;
2750 c_fix_arg = "extern\n"
2751 "#ifdef __GNUC_STDC_INLINE__\n"
2752 "__attribute__((__gnu_inline__))\n"
2753 "#endif\n"
2754 "__inline int";
2756 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2760 * netbsd_c99_inline_2
2762 fix = {
2763 hackname = netbsd_c99_inline_2;
2764 mach = "*-*-netbsd*";
2765 files = signal.h;
2766 select = "#define _SIGINLINE extern __inline";
2768 c_fix = format;
2769 c_fix_arg = <<- _EOArg_
2770 #ifdef __GNUC_STDC_INLINE__
2771 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2772 #else
2774 #endif
2775 _EOArg_;
2777 test_text = "#define _SIGINLINE extern __inline";
2781 * NetBSD has a semicolon after the ending '}' for some extern "C".
2783 fix = {
2784 hackname = netbsd_extra_semicolon;
2785 mach = "*-*-netbsd*";
2786 files = sys/cdefs.h;
2787 select = "#define[ \t]*__END_DECLS[ \t]*};";
2789 c_fix = format;
2790 c_fix_arg = "#define __END_DECLS }";
2792 test_text = "#define __END_DECLS };";
2795 /* newlib's stdint.h has several failures to conform to C99. The fix
2796 for these removed a comment that can be matched to identify unfixed
2797 versions. */
2798 fix = {
2799 hackname = newlib_stdint_1;
2800 files = stdint-newlib.h, stdint.h;
2801 select = "@todo - Add support for wint_t types";
2802 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2803 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2804 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2805 sed = "s@#define INT_LEAST32_MIN.*@"
2806 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2807 sed = "s@#define INT_LEAST32_MAX.*@"
2808 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2809 sed = "s@#define UINT_LEAST32_MAX.*@"
2810 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2811 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
2812 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2813 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
2814 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2815 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
2816 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2817 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2818 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2819 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2820 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2821 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2822 test_text = "/* @todo - Add support for wint_t types. */\n"
2823 "#define INT32_MIN (-2147483647-1)\n"
2824 "#define INT32_MAX 2147483647\n"
2825 "#define UINT32_MAX 4294967295U\n"
2826 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2827 "#define INT_LEAST32_MAX 2147483647\n"
2828 "#define UINT_LEAST32_MAX 4294967295U\n"
2829 "#define INT_FAST8_MIN INT8_MIN\n"
2830 "#define INT_FAST8_MAX INT8_MAX\n"
2831 "#define UINT_FAST8_MAX UINT8_MAX\n"
2832 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2833 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2834 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2835 "#define UINT8_C(x) x##U\n"
2836 "#define UINT16_C(x) x##U";
2840 * newlib_stdint_2
2842 fix = {
2843 hackname = newlib_stdint_2;
2844 files = stdint-newlib.h, stdint.h;
2845 select = "@todo - Add support for wint_t types";
2846 c_fix = format;
2847 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2848 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2849 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2850 "#define WCHAR_MAX __WCHAR_MAX__\n"
2851 "#define WCHAR_MIN __WCHAR_MIN__\n"
2852 "#define WINT_MAX __WINT_MAX__\n"
2853 "#define WINT_MIN __WINT_MIN__\n\n"
2854 "%0";
2855 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2856 test_text = "/* @todo - Add support for wint_t types. */\n"
2857 "/** Macros for minimum-width integer constant expressions */";
2861 * NeXT 3.2 adds const prefix to some math functions.
2862 * These conflict with the built-in functions.
2864 fix = {
2865 hackname = next_math_prefix;
2866 files = ansi/math.h;
2867 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2869 c_fix = format;
2870 c_fix_arg = "extern double %1(";
2871 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2873 test_text = "extern\tdouble\t__const__\tmumble();";
2877 * NeXT 3.2 uses the word "template" as a parameter for some
2878 * functions. GCC reports an invalid use of a reserved key word
2879 * with the built-in functions.
2881 fix = {
2882 hackname = next_template;
2883 files = bsd/libc.h;
2884 select = "[ \t]template\\)";
2886 c_fix = format;
2887 c_fix_arg = "(%1)";
2888 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2889 test_text = "extern mumble( char * template); /* fix */";
2893 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2894 * function prototypes. That conflicts with the built-in functions.
2896 fix = {
2897 hackname = next_volitile;
2898 files = ansi/stdlib.h;
2899 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2901 c_fix = format;
2902 c_fix_arg = "extern void %1(";
2903 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2905 test_text = "extern\tvolatile\tvoid\tabort();";
2909 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2910 * Note that version 3 of the NeXT system has wait.h in a different directory,
2911 * so that this code won't do anything. But wait.h in version 3 has a
2912 * conditional, so it doesn't need this fix. So everything is okay.
2914 fix = {
2915 hackname = next_wait_union;
2916 files = sys/wait.h;
2918 select = 'wait\(union wait';
2919 c_fix = format;
2920 c_fix_arg = "wait(void";
2921 test_text = "extern pid_d wait(union wait*);";
2925 * a missing semi-colon at the end of the nodeent structure definition.
2927 fix = {
2928 hackname = nodeent_syntax;
2929 files = netdnet/dnetdb.h;
2930 select = "char[ \t]*\\*na_addr[ \t]*$";
2931 c_fix = format;
2932 c_fix_arg = "%0;";
2933 test_text = "char *na_addr\t";
2937 * Fix OpenBSD's NULL definition.
2939 fix = {
2940 hackname = openbsd_null_definition;
2941 mach = "*-*-openbsd*";
2942 files = locale.h, stddef.h, stdio.h, string.h,
2943 time.h, unistd.h, wchar.h, sys/param.h;
2944 select = "__GNUG__";
2945 c_fix = format;
2946 c_fix_arg = "#ifndef NULL\n"
2947 "#ifdef __cplusplus\n"
2948 "#ifdef __GNUG__\n"
2949 "#define NULL\t__null\n"
2950 "#else\t /* ! __GNUG__ */\n"
2951 "#define NULL\t0L\n"
2952 "#endif\t /* __GNUG__ */\n"
2953 "#else\t /* ! __cplusplus */\n"
2954 "#define NULL\t((void *)0)\n"
2955 "#endif\t /* __cplusplus */\n"
2956 "#endif\t /* !NULL */";
2958 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2959 "^#ifdef[ \t]*__GNUG__\n"
2960 "^#define[ \t]*NULL[ \t]*__null\n"
2961 "^#else\n"
2962 "^#define[ \t]*NULL[ \t]*0L\n"
2963 "^#endif\n"
2964 "^#endif";
2965 test_text =
2966 "#ifndef NULL\n"
2967 "#ifdef __GNUG__\n"
2968 "#define NULL __null\n"
2969 "#else\n"
2970 "#define NULL 0L\n"
2971 "#endif\n"
2972 "#endif\n";
2976 * obstack.h used casts as lvalues.
2978 * We need to change postincrements of casted pointers (which are
2979 * then dereferenced and assigned into) of the form
2981 * *((TYPE*)PTRVAR)++ = (VALUE)
2983 * into expressions like
2985 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2987 * which is correct for the cases used in obstack.h since PTRVAR is
2988 * of type char * and the value of the expression is not used.
2990 fix = {
2991 hackname = obstack_lvalue_cast;
2992 files = obstack.h;
2993 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2994 c_fix = format;
2995 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2996 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3000 * Fix OpenBSD's va_start define.
3002 fix = {
3003 hackname = openbsd_va_start;
3004 mach = "*-*-openbsd*";
3005 files = stdarg.h;
3006 select = '__builtin_stdarg_start';
3007 c_fix = format;
3008 c_fix_arg = __builtin_va_start;
3010 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3014 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3015 * defining regex.h related types. This causes libg++ build and usage
3016 * failures. Fixing this correctly requires checking and modifying 3 files.
3018 fix = {
3019 hackname = osf_namespace_a;
3020 files = reg_types.h;
3021 files = sys/lc_core.h;
3022 test = " -r reg_types.h";
3023 test = " -r sys/lc_core.h";
3024 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3025 test = " -z \"`grep __regex_t regex.h`\"";
3027 c_fix = format;
3028 c_fix_arg = "__%0";
3029 c_fix_arg = "reg(ex|off|match)_t";
3031 test_text = "`touch sys/lc_core.h`"
3032 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3033 "extern regex_t re;\n"
3034 "extern regoff_t ro;\n"
3035 "extern regmatch_t rm;\n";
3038 fix = {
3039 hackname = osf_namespace_c;
3040 files = regex.h;
3041 test = " -r reg_types.h";
3042 test = " -r sys/lc_core.h";
3043 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3044 test = " -z \"`grep __regex_t regex.h`\"";
3046 select = "#include <reg_types\.h>.*";
3047 c_fix = format;
3048 c_fix_arg = "%0\n"
3049 "typedef __regex_t\tregex_t;\n"
3050 "typedef __regoff_t\tregoff_t;\n"
3051 "typedef __regmatch_t\tregmatch_t;";
3053 test_text = "#include <reg_types.h>";
3057 * On broken glibc-2.3.3 systems an array of incomplete structures is
3058 * passed to __sigsetjmp. Fix that to take a pointer instead.
3060 fix = {
3061 hackname = pthread_incomplete_struct_argument;
3062 files = pthread.h;
3063 select = "struct __jmp_buf_tag";
3064 c_fix = format;
3065 c_fix_arg = "%1 *%2%3";
3066 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3067 "(__env)\\[1\\](.*)$";
3068 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3069 "int __savemask);";
3073 * Fix return type of fread and fwrite on sysV68
3075 fix = {
3076 hackname = read_ret_type;
3077 files = stdio.h;
3078 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3079 c_fix = format;
3080 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3081 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3083 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3087 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3089 fix = {
3090 hackname = rpc_xdr_lvalue_cast_a;
3091 files = rpc/xdr.h;
3092 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3093 c_fix = format;
3094 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3095 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3096 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3100 * rpc_xdr_lvalue_cast_b
3102 fix = {
3103 hackname = rpc_xdr_lvalue_cast_b;
3104 files = rpc/xdr.h;
3105 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3106 c_fix = format;
3107 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3108 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3109 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3113 * function class(double x) conflicts with C++ keyword on rs/6000
3115 fix = {
3116 hackname = rs6000_double;
3117 files = math.h;
3118 select = '[^a-zA-Z_]class\(';
3120 c_fix = format;
3121 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3122 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3124 test_text = "extern int class();";
3128 * Wrong fchmod prototype on RS/6000.
3130 fix = {
3131 hackname = rs6000_fchmod;
3132 files = sys/stat.h;
3133 select = 'fchmod\(char \*';
3134 c_fix = format;
3135 c_fix_arg = "fchmod(int";
3136 test_text = "extern int fchmod(char *, mode_t);";
3140 * parameters conflict with C++ new on rs/6000
3142 fix = {
3143 hackname = rs6000_param;
3144 files = "stdio.h";
3145 files = "unistd.h";
3147 select = 'rename\(const char \*old, const char \*new\)';
3148 c_fix = format;
3149 c_fix_arg = 'rename(const char *_old, const char *_new)';
3151 test_text = 'extern int rename(const char *old, const char *new);';
3155 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3156 * for C99. This is wrong for C++, which needs many C99 features, but
3157 * only supports __restrict.
3159 fix = {
3160 hackname = solaris___restrict;
3161 files = sys/feature_tests.h;
3162 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3163 mach = "*-*-solaris2*";
3164 c_fix = format;
3165 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3166 "#else\n%0\n#endif";
3167 test_text = "#define _RESTRICT_KYWD restrict";
3171 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3172 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3173 * and imaginary definitions which are not supported by GCC.
3175 fix = {
3176 hackname = solaris_complex;
3177 mach = "*-*-solaris2.*";
3178 files = complex.h;
3179 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3180 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3181 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3182 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3183 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3184 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3185 test_text = "#define _Complex_I _Complex_I\n"
3186 "#define complex _Complex\n"
3187 "#define _Imaginary_I _Imaginary_I\n"
3188 "#define imaginary _Imaginary\n"
3189 "#undef I\n"
3190 "#define I _Imaginary_I";
3194 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3195 * extern "C" instead so libstdc++ can use it.
3197 fix = {
3198 hackname = solaris_complex_cxx;
3199 mach = "*-*-solaris2.*";
3200 files = complex.h;
3201 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3202 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3203 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3204 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3205 test_text = "#if !defined(__cplusplus)\n"
3206 "#endif /* !defined(__cplusplus) */";
3210 * g++ rejects functions declared with both C and C++ linkage.
3212 fix = {
3213 hackname = solaris_cxx_linkage;
3214 mach = '*-*-solaris2*';
3215 files = "iso/stdlib_iso.h";
3216 select = "(#if __cplusplus >= 199711L)\n"
3217 "(extern \"C\\+\\+\" \\{\n)"
3218 "(.*(bsearch|qsort).*)";
3219 c_fix = format;
3220 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3222 test_text =
3223 "#if __cplusplus >= 199711L\n"
3224 "extern \"C++\" {\n"
3225 " void *bsearch(const void *, const void *, size_t, size_t,";
3229 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3230 * _STRICT_STDC, but uses it.
3232 fix = {
3233 hackname = solaris_getc_strict_stdc;
3234 mach = "*-*-solaris2*";
3235 files = "iso/stdio_iso.h";
3236 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3237 c_fix = format;
3238 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3240 test_text =
3241 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3245 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
3247 fix = {
3248 hackname = solaris_longjmp_noreturn;
3249 mach = "*-*-solaris2*";
3250 files = "iso/setjmp_iso.h";
3251 bypass = "__NORETURN";
3252 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
3253 c_fix = format;
3254 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
3256 test_text = "extern void longjmp(jmp_buf, int);";
3260 * Sun Solaris 10 defines several C99 math macros in terms of
3261 * builtins specific to the Studio compiler, in particular not
3262 * compatible with the GNU compiler.
3264 fix = {
3265 hackname = solaris_math_1;
3266 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3267 bypass = "__GNUC__";
3268 files = iso/math_c99.h;
3269 c_fix = format;
3270 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3271 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3272 test_text =
3273 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3274 "#undef HUGE_VAL\n"
3275 "#define HUGE_VAL __builtin_huge_val\n"
3276 "#undef HUGE_VALF\n"
3277 "#define HUGE_VALF __builtin_huge_valf\n"
3278 "#undef HUGE_VALL\n"
3279 "#define HUGE_VALL __builtin_huge_vall";
3282 fix = {
3283 hackname = solaris_math_2;
3284 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3285 bypass = "__GNUC__";
3286 files = iso/math_c99.h;
3287 c_fix = format;
3288 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3289 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3290 test_text =
3291 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3292 "#undef INFINITY\n"
3293 "#define INFINITY __builtin_infinity";
3296 fix = {
3297 hackname = solaris_math_3;
3298 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3299 bypass = "__GNUC__";
3300 files = iso/math_c99.h;
3301 c_fix = format;
3302 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3303 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3304 test_text =
3305 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3306 "#undef NAN\n"
3307 "#define NAN __builtin_nan";
3310 fix = {
3311 hackname = solaris_math_4;
3312 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3313 bypass = "__GNUC__";
3314 files = iso/math_c99.h;
3315 c_fix = format;
3316 c_fix_arg = "#define\tfpclassify(x) \\\n"
3317 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3318 "FP_SUBNORMAL, FP_ZERO, (x))";
3319 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3320 test_text =
3321 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3322 "#undef fpclassify\n"
3323 "#define fpclassify(x) __builtin_fpclassify(x)";
3326 fix = {
3327 hackname = solaris_math_8;
3328 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3329 bypass = "__GNUC__";
3330 files = iso/math_c99.h;
3331 c_fix = format;
3332 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3333 "\t\t\t ? __builtin_signbitf(x) \\\n"
3334 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3335 "\t\t\t ? __builtin_signbitl(x) \\\n"
3336 "\t\t\t : __builtin_signbit(x))";
3337 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3338 test_text = <<- _EOText_
3339 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3340 #undef signbit
3341 #define signbit(x) __builtin_signbit(x)
3342 _EOText_;
3345 fix = {
3346 hackname = solaris_math_9;
3347 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3348 bypass = "__GNUC__";
3349 files = iso/math_c99.h;
3350 c_fix = format;
3351 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3352 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3353 "__builtin_[a-z]+\\(y\\)\\)";
3354 test_text =
3355 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3356 "#undef isgreater\n"
3357 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3358 "#undef isgreaterequal\n"
3359 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3360 "#undef isless\n"
3361 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3362 "#undef islessequal\n"
3363 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3364 "#undef islessgreater\n"
3365 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3366 "#undef isunordered\n"
3367 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3371 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3372 * exception. Provide an alternative using GCC's builtin.
3375 fix = {
3376 hackname = solaris_math_10;
3377 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3378 files = iso/math_c99.h;
3379 c_fix = format;
3380 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3381 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3382 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3383 "[ \t]*\\\\\n"
3384 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3385 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3386 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3387 "\\(-INFINITY\\);[ \t]*\\}\\)";
3388 test_text =
3389 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3390 "#undef isinf\n"
3391 "#define isinf(x) __extension__( \\\\\n"
3392 " { __typeof(x) __x_i = (x); \\\\\n"
3393 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3394 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3398 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3399 * "0" for the last field of the pthread_mutex_t structure, which is
3400 * of type upad64_t, which itself is typedef'd to int64_t, but with
3401 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3402 * initializer to "{0}" instead
3404 fix = {
3405 hackname = solaris_mutex_init_2;
3406 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3407 files = pthread.h;
3409 * On Solaris 10, this fix is unnecessary because upad64_t is
3410 * always defined correctly regardless of the definition of the
3411 * __STDC__ macro. The first "mach" pattern matches up to
3412 * solaris9. The second "mach" pattern will not match any two (or
3413 * more) digit solaris version, but it will match e.g. 2.5.1.
3415 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3416 c_fix = format;
3417 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3418 "%0\n"
3419 "#else\n"
3420 "%1, {0}}%4\n"
3421 "#endif";
3422 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3423 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3424 ",[ \t]*0\\}" "(|[ \t].*)$";
3425 test_text =
3426 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3427 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3428 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3429 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3430 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3431 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3432 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3436 * The pow overloads with int were removed in C++ 2011 DR 550.
3438 fix = {
3439 hackname = solaris_pow_int_overload;
3440 mach = '*-*-solaris2*';
3441 files = "iso/math_iso.h";
3442 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3443 " *\\{[^{}]*\n[^{}]*\\}";
3444 c_fix = format;
3445 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3447 test_text =
3448 " inline long double pow(long double __X, int __Y) { return\n"
3449 " __powl(__X, (long double) (__Y)); }";
3453 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3454 * fields of the pthread_rwlock_t structure, which are of type
3455 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3456 * defined (e.g. by -ansi) it is a union. So change the initializer
3457 * to "{0}" instead.
3459 fix = {
3460 hackname = solaris_rwlock_init_1;
3461 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3462 files = pthread.h;
3463 mach = '*-*-solaris*';
3464 c_fix = format;
3465 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3466 "%0\n"
3467 "#else\n"
3468 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3469 "#endif";
3470 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3471 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3473 test_text =
3474 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3475 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3479 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3480 * structure. As such, it need two levels of brackets, but only
3481 * contains one. Wrap the macro definition in an extra layer.
3483 fix = {
3484 hackname = solaris_once_init_1;
3485 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3486 files = pthread.h;
3487 mach = '*-*-solaris*';
3488 c_fix = format;
3489 c_fix_arg = "%1{%2}%3";
3490 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3491 test_text =
3492 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3493 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3497 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3498 * fields of the pthread_once_t structure, which are of type
3499 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3500 * defined (e.g. by -ansi) it is a union. So change the initializer
3501 * to "{0}" instead. This test relies on solaris_once_init_1.
3503 fix = {
3504 hackname = solaris_once_init_2;
3505 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3506 files = pthread.h;
3508 * On Solaris 10, this fix is unnecessary because upad64_t is
3509 * always defined correctly regardless of the definition of the
3510 * __STDC__ macro. The first "mach" pattern matches up to
3511 * solaris9. The second "mach" pattern will not match any two (or
3512 * more) digit solaris version, but it will match e.g. 2.5.1.
3514 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3515 c_fix = format;
3516 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3517 "%0\n"
3518 "#else\n"
3519 "%1{0}, {0}, {0}, {%3}%4\n"
3520 "#endif";
3521 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3522 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3523 test_text =
3524 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3525 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3529 * Sun Solaris 2 has a version of sys/int_const.h that defines
3530 * UINT8_C and UINT16_C to unsigned constants.
3532 fix = {
3533 hackname = solaris_int_const;
3534 files = sys/int_const.h;
3535 mach = '*-*-solaris2*';
3536 c_fix = format;
3537 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3538 "%1\n"
3539 "#define\tUINT16_C(c)\t(c)";
3540 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3541 "(/\*.*\*/)\n"
3542 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3543 test_text =
3544 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3545 "/* CSTYLED */\n"
3546 "#define UINT16_C(c) __CONCAT__(c,u)";
3550 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3551 * UINT8_MAX and UINT16_MAX to unsigned constants.
3553 fix = {
3554 hackname = solaris_int_limits_1;
3555 files = sys/int_limits.h;
3556 mach = '*-*-solaris2*';
3557 c_fix = format;
3558 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3559 "#define\tUINT16_MAX\t(65535)";
3560 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3561 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3562 test_text =
3563 "#define UINT8_MAX (255U)\n"
3564 "#define UINT16_MAX (65535U)";
3568 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3569 * INT_FAST16 limits to wrong values for sys/int_types.h.
3571 fix = {
3572 hackname = solaris_int_limits_2;
3573 files = sys/int_limits.h;
3574 mach = '*-*-solaris2*';
3575 c_fix = format;
3576 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3577 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3578 test_text =
3579 "#define INT_FAST16_MAX INT16_MAX\n"
3580 "#define UINT_FAST16_MAX UINT16_MAX\n"
3581 "#define INT_FAST16_MIN INT16_MIN";
3585 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3586 * SIZE_MAX as unsigned long.
3588 fix = {
3589 hackname = solaris_int_limits_3;
3590 files = sys/int_limits.h;
3591 mach = '*-*-solaris2*';
3592 c_fix = format;
3593 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3594 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3595 test_text =
3596 "#define SIZE_MAX 4294967295UL";
3600 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3601 * of Standard C99 64-bit types in 32-bit mode.
3603 fix = {
3604 hackname = solaris_int_types;
3605 select = "__STDC__ - 0 == 0";
3606 bypass = "_LONGLONG_TYPE";
3607 files = sys/int_types.h;
3608 c_fix = format;
3609 c_fix_arg =
3610 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3611 test_text =
3612 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3613 "typedef long long int64_t;\n"
3614 "#endif\n\n"
3615 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3616 "typedef int64_t intmax_t;\n"
3617 "#endif";
3621 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3622 * posix_spawn declarations, which doesn't work with C++.
3624 fix = {
3625 hackname = solaris_posix_spawn_restrict;
3626 files = spawn.h;
3627 mach = '*-*-solaris2*';
3628 c_fix = format;
3629 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3630 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3631 test_text =
3632 "char *const argv[_RESTRICT_KYWD],\n"
3633 "char *const envp[_RESTRICT_KYWD]);";
3637 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3638 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3640 fix = {
3641 hackname = solaris_std___filbuf;
3642 files = stdio.h;
3643 mach = '*-*-solaris2*';
3644 bypass = "using std::__filbuf";
3645 select = "(using std::perror;\n)(#endif)";
3646 c_fix = format;
3647 c_fix_arg = "%1#ifndef _LP64\n"
3648 "using std::__filbuf;\n"
3649 "using std::__flsbuf;\n"
3650 "#endif\n%2";
3652 test_text = "using std::perror;\n"
3653 "#endif";
3657 * Sun Solaris 8 has what appears to be some gross workaround for
3658 * some old version of their c++ compiler. G++ doesn't want it
3659 * either, but doesn't want to be tied to SunPRO version numbers.
3661 fix = {
3662 hackname = solaris_stdio_tag;
3663 files = stdio_tag.h;
3665 select = '__cplusplus < 54321L';
3666 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3667 "!defined(__GNUC__)" so we no longer need to fix it. */
3668 bypass = '__GNUC__';
3669 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3671 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3675 * On Solaris 9, __va_list needs to become a typedef for
3676 * __builtin_va_list to make -Wmissing-format-attribute work.
3678 fix = {
3679 hackname = solaris_sys_va_list;
3680 files = sys/va_list.h;
3681 mach = '*-*-solaris2.9';
3682 select = "#if.*__STDC__.*\n"
3683 "typedef void \\*__va_list;\n"
3684 "#else\n"
3685 "typedef char \\*__va_list;\n"
3686 "#endif";
3688 c_fix = format;
3689 c_fix_arg = "#ifdef __GNUC__\n"
3690 "typedef __builtin_va_list __va_list;\n"
3691 "#else\n"
3692 "%0\n"
3693 "#endif";
3694 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3695 "typedef void *__va_list;\n"
3696 "#else\n"
3697 "typedef char *__va_list;\n"
3698 "#endif";
3702 * a missing semi-colon at the end of the statsswtch structure definition.
3704 fix = {
3705 hackname = statsswtch;
3706 files = rpcsvc/rstat.h;
3707 select = "boottime$";
3708 c_fix = format;
3709 c_fix_arg = "boottime;";
3710 test_text = "struct statswtch {\n int boottime\n};";
3714 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3715 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3716 * OK too.
3718 fix = {
3719 hackname = stdio_stdarg_h;
3720 files = stdio.h;
3721 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3723 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3724 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3726 mach = '*-*-solaris2.1[0-9]*';
3727 not_machine = true;
3729 c_fix = wrap;
3731 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3733 test_text = "";
3737 * Don't use or define the name va_list in stdio.h. This is for
3738 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3739 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3740 * indicate that the header knows what it's doing -- under SUSv2,
3741 * stdio.h is required to define va_list, and we shouldn't break
3742 * that.
3744 fix = {
3745 hackname = stdio_va_list;
3746 files = stdio.h;
3747 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3749 * On Solaris 10, the definition in
3750 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3751 * there is therefore no need for this fix there.
3753 mach = '*-*-solaris2.1[0-9]*';
3754 not_machine = true;
3757 * Use __gnuc_va_list in arg types in place of va_list.
3758 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3759 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3760 * trailing parentheses and semicolon save all other systems from this.
3761 * Define __not_va_list__ (something harmless and unused)
3762 * instead of va_list.
3763 * Don't claim to have defined va_list.
3765 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3766 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3767 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3768 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3769 "s@ va_list@ __not_va_list__@\n"
3770 "s@\\*va_list@*__not_va_list__@\n"
3771 "s@ __va_list)@ __gnuc_va_list)@\n"
3772 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3773 "@typedef \\1 __not_va_list__;@\n"
3774 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3775 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3776 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3777 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3778 "s@VA_LIST@DUMMY_VA_LIST@\n"
3779 "s@_Va_LIST@_VA_LIST@";
3780 test_text = "extern void mumble( va_list);";
3784 * Fix headers that use va_list from stdio.h to use the updated
3785 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3786 * dealt with elsewhere. The presence of __gnuc_va_list,
3787 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3788 * knows what it's doing.
3790 fix = {
3791 hackname = stdio_va_list_clients;
3792 files = com_err.h;
3793 files = cps.h;
3794 files = curses.h;
3795 files = krb5.h;
3796 files = lc_core.h;
3797 files = pfmt.h;
3798 files = wchar.h;
3799 files = curses_colr/curses.h;
3800 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3801 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3802 otherwise protected. */
3803 bypass = 'include <stdarg\.h>|#ifdef va_start';
3806 * Use __gnuc_va_list in arg types in place of va_list.
3807 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3808 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3809 * trailing parentheses and semicolon save all other systems from this.
3810 * Define __not_va_list__ (something harmless and unused)
3811 * instead of va_list.
3812 * Don't claim to have defined va_list.
3814 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3815 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3816 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3817 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3818 "s@ va_list@ __not_va_list__@\n"
3819 "s@\\*va_list@*__not_va_list__@\n"
3820 "s@ __va_list)@ __gnuc_va_list)@\n"
3821 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3822 "@typedef \\1 __not_va_list__;@\n"
3823 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3824 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3825 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3826 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3827 "s@VA_LIST@DUMMY_VA_LIST@\n"
3828 "s@_Va_LIST@_VA_LIST@";
3829 test_text = "extern void mumble( va_list);";
3833 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3834 * is "!defined( __STRICT_ANSI__ )"
3836 fix = {
3837 hackname = strict_ansi_not;
3838 select = "^([ \t]*#[ \t]*if.*)"
3839 "(!__STDC__"
3840 "|__STDC__[ \t]*==[ \t]*0"
3841 "|__STDC__[ \t]*!=[ \t]*1"
3842 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3843 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3844 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3845 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3846 is not defined by GCC, so it is safe. */
3847 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3848 c_test = stdc_0_in_system_headers;
3850 c_fix = format;
3851 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3853 test_text = "#if !__STDC__ \n"
3854 "#if __STDC__ == 0\n"
3855 "#if __STDC__ != 1\n"
3856 "#if __STDC__ - 0 == 0"
3857 "/* not std C */\nint foo;\n"
3858 "\n#end-end-end-end-if :-)";
3862 * "__STDC__-0==0"
3863 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3865 fix = {
3866 hackname = strict_ansi_not_ctd;
3867 files = math.h, limits.h, stdio.h, signal.h,
3868 stdlib.h, sys/signal.h, time.h;
3870 * Starting at the beginning of a line, skip white space and
3871 * a leading "(" or "&&" or "||". One of those must be found.
3872 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3873 * expression. If these are nested, then they must accumulate
3874 * because we won't match any closing parentheses. Finally,
3875 * after skipping over all that, we must then match our suspect
3876 * phrase: "__STDC__-0==0" with or without white space.
3878 select = "^([ \t]*" '(\(|&&|\|\|)'
3879 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3880 "[ \t(]*)"
3881 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3882 c_test = stdc_0_in_system_headers;
3884 c_fix = format;
3885 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3887 test_text = "#if 1 && \\\\\n"
3888 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3889 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3890 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3891 "int foo;\n#endif";
3895 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3896 * is "defined( __STRICT_ANSI__ )"
3898 fix = {
3899 hackname = strict_ansi_only;
3900 select = "^([ \t]*#[ \t]*if.*)"
3901 "(__STDC__[ \t]*!=[ \t]*0"
3902 "|__STDC__[ \t]*==[ \t]*1"
3903 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3904 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3905 c_test = stdc_0_in_system_headers;
3907 c_fix = format;
3908 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3910 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3914 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3915 * in prototype without previous definition.
3917 fix = {
3918 hackname = struct_file;
3919 files = rpc/xdr.h;
3920 select = '^.*xdrstdio_create.*struct __file_s';
3921 c_fix = format;
3922 c_fix_arg = "struct __file_s;\n%0";
3923 test_text = "extern void xdrstdio_create( struct __file_s* );";
3927 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3928 * in prototype without previous definition.
3930 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3931 * function, and does define it.
3933 fix = {
3934 hackname = struct_sockaddr;
3935 files = rpc/auth.h;
3936 select = "^.*authdes_create.*struct sockaddr[^_]";
3937 bypass = "<sys/socket\.h>";
3938 bypass = "struct sockaddr;\n";
3939 c_fix = format;
3940 c_fix_arg = "struct sockaddr;\n%0";
3941 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3945 * Apply fix this to all OSs since this problem seems to effect
3946 * more than just SunOS.
3948 fix = {
3949 hackname = sun_auth_proto;
3950 files = rpc/auth.h;
3951 files = rpc/clnt.h;
3952 files = rpc/svc.h;
3953 files = rpc/xdr.h;
3954 bypass = "__cplusplus";
3956 * Select those files containing '(*name)()'.
3958 select = '\(\*[a-z][a-z_]*\)\(\)';
3960 c_fix = format;
3961 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3962 "#else\n%1();%2\n#endif";
3963 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3965 test_text =
3966 "struct auth_t {\n"
3967 " int (*name)(); /* C++ bad */\n"
3968 "};";
3972 * Fix bogus #ifdef on SunOS 4.1.
3974 fix = {
3975 hackname = sun_bogus_ifdef;
3976 files = "hsfs/hsfs_spec.h";
3977 files = "hsfs/iso_spec.h";
3978 select = '#ifdef(.*\|\|.*)';
3979 c_fix = format;
3980 c_fix_arg = "#if%1";
3982 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3986 * Fix the CAT macro in SunOS memvar.h.
3988 fix = {
3989 hackname = sun_catmacro;
3990 files = pixrect/memvar.h;
3991 select = "^#define[ \t]+CAT\\(a,b\\).*";
3992 c_fix = format;
3994 c_fix_arg =
3995 "#ifdef __STDC__\n"
3996 "# define CAT(a,b) a##b\n"
3997 "#else\n%0\n#endif";
3999 test_text =
4000 "#define CAT(a,b)\ta/**/b";
4004 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4005 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4007 fix = {
4008 hackname = sun_malloc;
4009 files = malloc.h;
4010 bypass = "_CLASSIC_ANSI_TYPES";
4012 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4013 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4014 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4015 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4016 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4018 test_text =
4019 "typedef char *\tmalloc_t;\n"
4020 "int \tfree();\n"
4021 "char*\tmalloc();\n"
4022 "char*\tcalloc();\n"
4023 "char*\trealloc();";
4027 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4029 fix = {
4030 hackname = sun_rusers_semi;
4031 files = rpcsvc/rusers.h;
4032 select = "_cnt$";
4033 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4034 test_text = "struct mumble\n int _cnt\n};";
4038 * signal.h on SunOS defines signal using (),
4039 * which causes trouble when compiling with g++ -pedantic.
4041 fix = {
4042 hackname = sun_signal;
4043 files = sys/signal.h;
4044 files = signal.h;
4045 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4047 c_fix = format;
4048 c_fix_arg =
4049 "#ifdef __cplusplus\n"
4050 "void\t(*signal(...))(...);\n"
4051 "#else\n%0\n#endif";
4053 test_text = "void\t(*signal())();";
4057 * Correct the return type for strlen in strings.h in SunOS 4.
4059 fix = {
4060 hackname = sunos_strlen;
4061 files = strings.h;
4062 select = "int[ \t]*strlen\\(\\);(.*)";
4063 c_fix = format;
4064 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4065 test_text = " int\tstrlen(); /* string length */";
4069 * Linux kernel's vt.h breaks C++
4071 fix = {
4072 hackname = suse_linux_vt_cxx;
4073 files = linux/vt.h;
4075 select = "^[ \t]*unsigned int new;";
4076 c_fix = format;
4077 c_fix_arg = "unsigned int newev;";
4079 test_text = " unsigned int new; /* New console (if changing) */";
4083 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4084 * that is visible to any ANSI compiler using this include. Simply
4085 * delete the lines that #define some string functions to internal forms.
4087 fix = {
4088 hackname = svr4_disable_opt;
4089 files = string.h;
4090 select = '#define.*__std_hdr_';
4091 sed = '/#define.*__std_hdr_/d';
4092 test_text = "#define strlen __std_hdr_strlen\n";
4096 * Fix broken decl of getcwd present on some svr4 systems.
4098 fix = {
4099 hackname = svr4_getcwd;
4100 files = stdlib.h;
4101 files = unistd.h;
4102 files = prototypes.h;
4103 select = 'getcwd\(char \*, int\)';
4105 c_fix = format;
4106 c_fix_arg = "getcwd(char *, size_t)";
4108 test_text = "extern char* getcwd(char *, int);";
4112 * Fix broken decl of profil present on some svr4 systems.
4114 fix = {
4115 hackname = svr4_profil;
4116 files = stdlib.h;
4117 files = unistd.h;
4119 select =
4120 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4121 c_fix = format;
4122 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4124 test_text =
4125 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4129 * Correct types for signal handler constants like SIG_DFL; they might be
4130 * void (*) (), and should be void (*) (int). C++ doesn't like the
4131 * old style.
4133 fix = {
4134 hackname = svr4_sighandler_type;
4135 files = sys/signal.h;
4136 select = 'void *\(\*\)\(\)';
4137 c_fix = format;
4138 c_fix_arg = "void (*)(int)";
4139 test_text = "#define SIG_DFL (void(*)())0\n"
4140 "#define SIG_IGN (void (*)())0\n";
4144 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4145 * function 'getrnge' in <regexp.h> before they declare it. For these
4146 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4147 * early on.
4149 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4150 * so put the declaration right after the declaration of 'size'.
4152 * Don't do this if there is already a `static void getrnge' declaration
4153 * present, since this would cause a redeclaration error. Solaris 2.x has
4154 * such a declaration.
4156 fix = {
4157 hackname = svr4_undeclared_getrnge;
4158 files = regexp.h;
4159 select = "getrnge";
4160 bypass = "static void getrnge";
4161 c_fix = format;
4162 c_fix_arg = "%0\n"
4163 "static int getrnge ();";
4164 c_fix_arg = "^static int[ \t]+size;";
4165 test_text = "static int size;\n"
4166 "/* stuff which calls getrnge() */\n"
4167 "static getrnge()\n"
4168 "{}";
4172 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4173 * in string.h on sysV68
4174 * Correct the return type for strlen in string.h on Lynx.
4175 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4176 * Add missing const for strdup on OSF/1 V3.0.
4177 * On sysV88 layout is slightly different.
4179 fix = {
4180 hackname = sysv68_string;
4181 files = testing.h;
4182 files = string.h;
4183 bypass = "_CLASSIC_ANSI_TYPES";
4185 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4186 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4187 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4189 sed = "/^extern char$/N";
4190 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4192 sed = "/^extern int$/N";
4193 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4195 sed = "/^\tstrncmp(),$/N";
4196 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4197 '\1;' "\\\nextern unsigned int\\\n\\2/";
4199 test_text =
4200 "extern int strlen();\n"
4202 "extern int ffs(long);\n"
4204 "extern char\n"
4205 "\t*memccpy(),\n"
4206 "\tmemcpy();\n"
4208 "extern int\n"
4209 "\tstrcmp(),\n"
4210 "\tstrncmp(),\n"
4211 "\tstrlen(),\n"
4212 "\tstrspn();\n"
4214 "extern int\n"
4215 "\tstrlen(), strspn();";
4219 * Fix return type of calloc, malloc, realloc, bsearch and exit
4221 fix = {
4222 hackname = sysz_stdlib_for_sun;
4223 files = stdlib.h;
4224 bypass = "_CLASSIC_ANSI_TYPES";
4226 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4227 c_fix = format;
4228 c_fix_arg = "void *\t%1(";
4230 test_text =
4231 "extern char*\tcalloc(size_t);\n"
4232 "extern char*\tmalloc(size_t);\n"
4233 "extern char*\trealloc(void*,size_t);\n"
4234 "extern char*\tbsearch(void*,size_t,size_t);\n";
4238 * __thread is now a keyword.
4240 fix = {
4241 hackname = thread_keyword;
4242 files = "pthread.h";
4243 files = "bits/sigthread.h";
4244 select = "([* ])__thread([,)])";
4245 c_fix = format;
4246 c_fix_arg = "%1__thr%2";
4248 test_text =
4249 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4250 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4251 "extern int pthread_cancel (pthread_t __thread);";
4255 * if the #if says _cplusplus, not the double underscore __cplusplus
4256 * that it should be
4258 fix = {
4259 hackname = tinfo_cplusplus;
4260 files = tinfo.h;
4261 select = "[ \t]_cplusplus";
4263 c_fix = format;
4264 c_fix_arg = " __cplusplus";
4265 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4269 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4271 fix = {
4272 hackname = ultrix_const;
4273 files = stdio.h;
4274 select = 'perror\( char \*';
4276 c_fix = format;
4277 c_fix_arg = "%1 const %3 *__";
4278 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4279 "[ \t]+(char|void) \\*__";
4281 test_text =
4282 "extern void perror( char *__s );\n"
4283 "extern int fputs( char *__s, FILE *);\n"
4284 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4285 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4286 "extern int scanf( char *__format, ...);\n";
4290 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4292 fix = {
4293 hackname = ultrix_const2;
4294 files = stdio.h;
4296 select = '\*fopen\( char \*';
4297 c_fix = format;
4298 c_fix_arg = "%1( const char *%3, const char *";
4299 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4300 "[ \t]*char[ \t]*\\*([^,]*),"
4301 "[ \t]*char[ \t]*\\*[ \t]*";
4303 test_text =
4304 "extern FILE *fopen( char *__filename, char *__type );\n"
4305 "extern int sscanf( char *__s, char *__format, ...);\n"
4306 "extern FILE *popen(char *, char *);\n"
4307 "extern char *tempnam(char*,char*);\n";
4311 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4313 fix = {
4314 hackname = va_i960_macro;
4315 files = arch/i960/archI960.h;
4316 select = "__(vsiz|vali|vpad|alignof__)";
4318 c_fix = format;
4319 c_fix_arg = "__vx%1";
4321 test_text =
4322 "extern int __vsiz vsiz;\n"
4323 "extern int __vali vali;\n"
4324 "extern int __vpad vpad;\n"
4325 "#define __alignof__(x) ...";
4329 * Define __CAN_USE_EXTERN_PREFIX on vms.
4331 fix = {
4332 hackname = vms_define_can_use_extern_prefix;
4333 files = "rtldef/decc$types.h";
4334 select = "#[ \t]*else\n"
4335 "#[ \t]*if defined\\(__DECCXX\\)\n"
4336 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4337 mach = "*-*-*vms*";
4338 c_fix = format;
4340 c_fix_arg = "%0"
4341 "# elif defined (__GNUC__)\n"
4342 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4344 test_text = "# else\n"
4345 "# if defined(__DECCXX)\n"
4346 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4347 "# endif\n"
4348 "# endif\n";
4352 * On VMS, use pragma extern_model instead of VAX-C keywords.
4354 fix = {
4355 hackname = vms_use_pragma_extern_model;
4356 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4357 "# pragma extern_model __save\n";
4358 mach = "*-*-*vms*";
4359 c_fix = format;
4361 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4362 "# pragma extern_model __save\n";
4364 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4365 "# pragma extern_model __save\n"
4366 "# pragma extern_model strict_refdef\n"
4367 " extern struct x zz$yy;\n"
4368 "# pragma extern_model __restore\n"
4369 "#endif\n";
4373 * On VMS, disable the use of dec-c string builtins
4375 fix = {
4376 hackname = vms_disable_decc_string_builtins;
4377 select = "#if !defined\\(__VAX\\)\n";
4378 mach = "*-*-*vms*";
4379 files = "rtldef/string.h";
4380 c_fix = format;
4382 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4384 test_text = "#if !defined(__VAX)\n";
4388 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4389 * conflict while building gcc. Likewise for <builtins.h>
4391 fix = {
4392 hackname = vms_use_quoted_include;
4393 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4394 mach = "*-*-*vms*";
4395 files = rtldef/wait.h, starlet_c/pthread.h;
4396 c_fix = format;
4398 c_fix_arg = '%1<sys/%2.h>';
4400 test_text = "# include <resource.h>";
4404 * On VMS, add missing braces around sigset_t constants.
4406 fix = {
4407 hackname = vms_add_missing_braces;
4408 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4409 mach = "*-*-*vms*";
4410 files = "rtldef/signal.h";
4411 c_fix = format;
4413 c_fix_arg = '%1 {%2} ';
4415 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4416 "{0x00000000, 0x00000000},\n"
4417 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4421 * On VMS, fix incompatible redeclaration of hostalias.
4423 fix = {
4424 hackname = vms_do_not_redeclare_hostalias;
4425 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4426 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4427 mach = "*-*-*vms*";
4428 files = "rtldef/resolv.h";
4429 c_fix = format;
4431 c_fix_arg = "%1\n"
4432 "/* %2 */";
4434 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4435 "__char_ptr32 hostalias (const char *);\n";
4439 * On VMS, some DEC-C builtins are directly used.
4441 fix = {
4442 hackname = vms_decc_builtin;
4443 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4444 mach = "*-*-*vms*";
4445 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4446 rtldef/socket.h;
4447 sed = "s@__MEMSET@memset@";
4448 sed = "s@__MEMMOVE@memmove@";
4449 sed = "s@__MEMCPY@memcpy@";
4450 sed = "s@__STRLEN@strlen@";
4451 sed = "s@__STRCPY@strcpy@";
4453 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4457 * On VMS, do not declare getopt and al if pointers are 64 bit.
4459 fix = {
4460 hackname = vms_no_64bit_getopt;
4461 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4462 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4463 mach = "*-*-*vms*";
4464 files = rtldef/stdio.h, rtldef/unistd.h;
4465 c_fix = format;
4467 c_fix_arg = <<- _EOArg_
4468 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4469 %0#endif
4471 _EOArg_;
4473 test_text = "int getopt (int, char * const [], const char *);";
4477 * On VMS, forward declare structure before referencing them in prototypes.
4479 fix = {
4480 hackname = vms_forward_declare_struct;
4481 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4482 "#ifdef __cplusplus\n";
4483 mach = "*-*-*vms*";
4484 files = rtldef/if.h;
4485 c_fix = format;
4487 c_fix_arg = "%1"
4488 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4490 test_text = "/* forward decls for C++ */\n"
4491 "#ifdef __cplusplus\n"
4492 "struct foo;\n"
4493 "#endif\n";
4497 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4498 * which is not yet fully supported by gcc.
4500 fix = {
4501 hackname = vms_use_fast_setjmp;
4502 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4503 mach = "*-*-*vms*";
4504 files = rtldef/setjmp.h;
4505 c_fix = format;
4507 c_fix_arg = "%0 defined (__GNUC__) ||";
4509 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4513 * AIX and Interix headers define NULL to be cast to a void pointer,
4514 * which is illegal in ANSI C++.
4516 fix = {
4517 hackname = void_null;
4518 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4519 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4520 /* avoid changing C++ friendly NULL */
4521 bypass = __cplusplus;
4522 bypass = __null;
4523 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4524 c_fix = format;
4525 c_fix_arg = <<- _EOFix_
4526 #ifndef NULL
4527 #ifdef __cplusplus
4528 #ifdef __GNUG__
4529 #define NULL __null
4530 #else /* ! __GNUG__ */
4531 #define NULL 0L
4532 #endif /* __GNUG__ */
4533 #else /* ! __cplusplus */
4534 #define NULL ((void *)0)
4535 #endif /* __cplusplus */
4536 #endif /* !NULL */
4537 _EOFix_;
4538 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4542 * Make VxWorks header which is almost gcc ready fully gcc ready.
4544 fix = {
4545 hackname = vxworks_gcc_problem;
4546 files = types/vxTypesBase.h;
4547 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4549 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4550 "#if 1/";
4552 sed = "/[ \t]size_t/i\\\n"
4553 "#ifndef _GCC_SIZE_T\\\n"
4554 "#define _GCC_SIZE_T\n";
4556 sed = "/[ \t]size_t/a\\\n"
4557 "#endif\n";
4559 sed = "/[ \t]ptrdiff_t/i\\\n"
4560 "#ifndef _GCC_PTRDIFF_T\\\n"
4561 "#define _GCC_PTRDIFF_T\n";
4563 sed = "/[ \t]ptrdiff_t/a\\\n"
4564 "#endif\n";
4566 sed = "/[ \t]wchar_t/i\\\n"
4567 "#ifndef _GCC_WCHAR_T\\\n"
4568 "#define _GCC_WCHAR_T\n";
4570 sed = "/[ \t]wchar_t/a\\\n"
4571 "#endif\n";
4573 test_text =
4574 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4575 "typedef unsigned int size_t;\n"
4576 "typedef long ptrdiff_t;\n"
4577 "typedef unsigned short wchar_t;\n"
4578 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4582 * Wrap VxWorks ioctl to keep everything pretty
4584 fix = {
4585 hackname = vxworks_ioctl_macro;
4586 files = ioLib.h;
4587 mach = "*-*-vxworks*";
4589 c_fix = format;
4590 c_fix_arg = "%0\n"
4591 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4592 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4594 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4598 * Wrap VxWorks mkdir to be posix compliant
4600 fix = {
4601 hackname = vxworks_mkdir_macro;
4602 files = sys/stat.h;
4603 mach = "*-*-vxworks*";
4605 c_fix = format;
4606 c_fix_arg = "%0\n"
4607 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4608 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4609 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4610 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4611 "\\)[\t ]*;";
4613 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4617 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4619 fix = {
4620 hackname = vxworks_needs_vxtypes;
4621 files = time.h;
4622 select = "uint_t([ \t]+_clocks_per_sec)";
4623 c_fix = format;
4624 c_fix_arg = "unsigned int%1";
4625 test_text = "uint_t\t_clocks_per_sec;";
4629 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4631 fix = {
4632 hackname = vxworks_needs_vxworks;
4633 files = sys/stat.h;
4634 test = " -r types/vxTypesOld.h";
4635 test = " -n \"`egrep '#include' $file`\"";
4636 test = " -n \"`egrep ULONG $file`\"";
4637 select = "#[ \t]define[ \t]+__INCstath";
4639 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4640 "#include <types/vxTypesOld.h>\n";
4642 test_text = "`touch types/vxTypesOld.h`"
4643 "#include </dev/null> /* ULONG */\n"
4644 "# define\t__INCstath <sys/stat.h>";
4648 * Make it so VxWorks does not include gcc/regs.h accidentally
4650 fix = {
4651 hackname = vxworks_regs;
4652 mach = "*-*-vxworks*";
4654 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4655 c_fix = format;
4656 c_fix_arg = "#include <arch/../regs.h>";
4658 test_text = "#include <regs.h>\n";
4662 * Another bad dependency in VxWorks 5.2 <time.h>.
4664 fix = {
4665 hackname = vxworks_time;
4666 files = time.h;
4667 test = " -r vxWorks.h";
4669 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4670 c_fix = format;
4672 c_fix_arg =
4673 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4674 "#ifdef __cplusplus\n"
4675 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4676 "#else\n"
4677 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4678 "#endif\n"
4679 "#define __gcc_VOIDFUNCPTR_defined\n"
4680 "#endif\n"
4681 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4683 test_text = "`touch vxWorks.h`"
4684 "#define VOIDFUNCPTR (void(*)())";
4688 * This hack makes write const-correct on VxWorks
4690 fix = {
4691 hackname = vxworks_write_const;
4692 files = ioLib.h;
4693 mach = "*-*-vxworks*";
4695 c_fix = format;
4696 c_fix_arg = "extern int write (int, const char*, size_t);";
4697 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4698 "[\t ]*int[\t ]*,"
4699 "[\t ]*char[\t ]*\\*[\t ]*,"
4700 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4702 test_text = "extern int write ( int , char * , size_t ) ;";
4706 * There are several name conflicts with C++ reserved words in X11 header
4707 * files. These are fixed in some versions, so don't do the fixes if
4708 * we find __cplusplus in the file. These were found on the RS/6000.
4710 fix = {
4711 hackname = x11_class;
4712 files = X11/ShellP.h;
4713 bypass = __cplusplus;
4714 select = "^([ \t]*char \\*)class;(.*)";
4715 c_fix = format;
4716 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4717 "#else\n%1class;%2\n#endif";
4718 test_text =
4719 "struct {\n"
4720 " char *class;\n"
4721 "} mumble;\n";
4725 * class in Xm/BaseClassI.h
4727 fix = {
4728 hackname = x11_class_usage;
4729 files = Xm/BaseClassI.h;
4730 bypass = "__cplusplus";
4732 select = " class\\)";
4733 c_fix = format;
4734 c_fix_arg = " c_class)";
4736 test_text = "extern mumble (int class);\n";
4740 * new in Xm/Traversal.h
4742 fix = {
4743 hackname = x11_new;
4744 files = Xm/Traversal.h;
4745 bypass = __cplusplus;
4747 sed = "/Widget\told, new;/i\\\n"
4748 "#ifdef __cplusplus\\\n"
4749 "\\\tWidget\told, c_new;\\\n"
4750 "#else\n";
4752 sed = "/Widget\told, new;/a\\\n"
4753 "#endif\n";
4755 sed = "s/Widget new,/Widget c_new,/g";
4756 test_text =
4757 "struct wedge {\n"
4758 " Widget\told, new;\n"
4759 "};\nextern Wedged( Widget new, Widget old );";
4763 * Incorrect sprintf declaration in X11/Xmu.h
4765 fix = {
4766 hackname = x11_sprintf;
4767 files = X11/Xmu.h;
4768 files = X11/Xmu/Xmu.h;
4769 select = "^extern char \\*\tsprintf\\(\\);$";
4771 c_fix = format;
4772 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4774 test_text = "extern char *\tsprintf();";
4778 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
4779 * that fails when compiling for SSE-less 32-bit x86.
4781 fix = {
4782 hackname = feraiseexcept_nosse_invalid;
4783 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
4784 files = bits/fenv.h;
4785 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
4786 ": \"x\" \\(__f\\)\\);$";
4787 bypass = "\"fdiv .*; fwait\"";
4789 c_fix = format;
4790 c_fix_arg = <<- _EOText_
4791 # ifdef __SSE_MATH__
4793 # else
4794 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
4795 %1 : "=t" (__f) : "0" (__f));
4796 # endif
4797 _EOText_;
4799 test_text = <<- _EOText_
4800 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
4801 _EOText_;
4805 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
4806 * that fails when compiling for SSE-less 32-bit x86.
4808 fix = {
4809 hackname = feraiseexcept_nosse_divbyzero;
4810 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
4811 files = bits/fenv.h;
4812 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
4813 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
4814 bypass = "\"fdivp .*; fwait\"";
4816 c_fix = format;
4817 c_fix_arg = <<- _EOText_
4818 # ifdef __SSE_MATH__
4820 # else
4821 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
4822 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
4823 # endif
4824 _EOText_;
4826 test_text = <<- _EOText_
4827 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
4828 _EOText_;
4832 * Old Linux kernel's <compiler.h> header breaks Traditional CPP
4834 fix = {
4835 hackname = complier_h_tradcpp;
4836 files = linux/compiler.h;
4838 select = "#define __builtin_warning\\(x, y\\.\\.\\.\\) \\(1\\)";
4839 c_fix = format;
4840 c_fix_arg = "/* __builtin_warning(x, y...) is obsolete */";
4842 test_text = "#define __builtin_warning(x, y...) (1)";
4845 /*EOF*/