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