re PR c++/57979 (G++ accepts constant expression defined using floating point non...
[official-gcc.git] / fixincludes / inclhack.def
blobb27f1636bc3eac9de86c6a891b629f6d6e6b199b
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 pthread.h, '*/pthread.h';
1692 bypass = "__extern_inline|__gnu_inline__";
1693 select = "(^| )extern __inline";
1694 c_fix = format;
1695 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1696 test_text = <<-EOT
1697 __extension__ extern __inline unsigned int
1698 extern __inline unsigned int
1699 EOT;
1702 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1703 * so we replace them with versions that correspond to the
1704 * definition.
1706 fix = {
1707 hackname = glibc_mutex_init;
1708 files = pthread.h;
1709 select = '\{ *\{ *0, *\} *\}';
1710 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1711 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1712 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1713 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1714 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1715 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1716 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1717 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1718 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1719 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1720 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1721 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1722 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1723 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1724 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1725 "N;s/^[ \t]*#[ \t]*"
1726 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1727 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1728 "# \\1\\\n"
1729 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1730 "# else\\\n"
1731 "# \\1\\\n"
1732 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1733 "# endif/";
1734 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1735 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1736 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1737 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1739 test_text = <<- _EOText_
1740 #define PTHREAD_MUTEX_INITIALIZER \\
1741 { { 0, } }
1742 #ifdef __USE_GNU
1743 # if __WORDSIZE == 64
1744 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1745 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1746 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1747 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1748 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1749 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1750 # else
1751 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1752 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1753 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1754 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1755 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1756 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1757 # endif
1758 #endif
1759 # define PTHREAD_RWLOCK_INITIALIZER \\
1760 { { 0, } }
1761 # ifdef __USE_GNU
1762 # if __WORDSIZE == 64
1763 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1764 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1765 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1766 # else
1767 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1768 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1769 # endif
1770 # endif
1771 #define PTHREAD_COND_INITIALIZER { { 0, } }
1772 _EOText_;
1775 /* glibc versions before 2.5 have a version of stdint.h that defines
1776 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1777 versions with stdint.h based on those glibc versions. */
1778 fix = {
1779 hackname = glibc_stdint;
1780 files = stdint.h;
1781 select = "GNU C Library";
1782 c_fix = format;
1783 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1784 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1785 test_text = "/* This file is part of the GNU C Library. */\n"
1786 "# define UINT8_C(c)\tc ## U\n"
1787 "# define UINT16_C(c)\tc ## U";
1790 /* Some versions of glibc have a version of bits/string2.h that
1791 produces "value computed is not used" warnings from strncpy; fix
1792 this definition by using __builtin_strncpy instead as in newer
1793 versions. */
1794 fix = {
1795 hackname = glibc_strncpy;
1796 files = bits/string2.h, '*/bits/string2.h';
1797 bypass = "__builtin_strncpy";
1798 c_fix = format;
1799 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1800 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1801 test_text = <<-EOT
1802 # define strncpy(dest, src, n) \
1803 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1804 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1805 ? (char *) memcpy (dest, src, n) \\
1806 : strncpy (dest, src, n)) \\
1807 : strncpy (dest, src, n)))
1808 EOT;
1812 /* glibc's tgmath.h relies on an expression that is not an integer
1813 constant expression being treated as it was by GCC 4.4 and
1814 earlier. */
1815 fix = {
1816 hackname = glibc_tgmath;
1817 files = tgmath.h;
1818 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1819 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1820 c_fix = format;
1821 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1822 "(__builtin_classify_type ((type) 0) == 9 && "
1823 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1824 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1828 * Fix these files to use the types we think they should for
1829 * ptrdiff_t, size_t, and wchar_t.
1831 * This defines the types in terms of macros predefined by our 'cpp'.
1832 * This is supposedly necessary for glibc's handling of these types.
1833 * It's probably not necessary for anyone else, but it doesn't hurt.
1835 fix = {
1836 hackname = gnu_types;
1837 files = "sys/types.h";
1838 files = "stdlib.h";
1839 files = "sys/stdtypes.h";
1840 files = "stddef.h";
1841 files = "memory.h";
1842 files = "unistd.h";
1843 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1844 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1845 c_fix = gnu_type;
1846 /* The Solaris 10 headers already define these types correctly. */
1847 mach = '*-*-solaris2.1[0-9]*';
1848 not_machine = true;
1850 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1851 "typedef uint_t size_t; /* uint_t */\n"
1852 "typedef ushort_t wchar_t; /* ushort_t */";
1856 * Fix HP & Sony's use of "../machine/xxx.h"
1857 * to refer to: <machine/xxx.h>
1859 fix = {
1860 hackname = hp_inline;
1861 files = sys/spinlock.h;
1862 files = machine/machparam.h;
1863 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1865 c_fix = format;
1866 c_fix_arg = "%1<machine/%2.h>";
1868 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1869 '([a-z]+)\.h"';
1871 test_text = ' # include "../machine/mumble.h"';
1875 * Check for (...) in C++ code in HP/UX sys/file.h.
1877 fix = {
1878 hackname = hp_sysfile;
1879 files = sys/file.h;
1880 select = "HPUX_SOURCE";
1882 c_fix = format;
1883 c_fix_arg = "(struct file *, ...)";
1884 c_fix_arg = '\(\.\.\.\)';
1886 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1890 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1891 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1893 fix = {
1894 hackname = hppa_hpux_fp_macros;
1895 mach = "hppa*-hp-hpux11*";
1896 files = math.h;
1897 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1898 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1899 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1900 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1901 "#[ \t]*define[ \t]*FP_NAN.*\n";
1902 c_fix = format;
1903 c_fix_arg = <<- _EOFix_
1904 #endif /* _INCLUDE_HPUX_SOURCE */
1906 #if defined(_INCLUDE_HPUX_SOURCE) || \
1907 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1908 %0#endif
1910 #ifdef _INCLUDE_HPUX_SOURCE
1912 _EOFix_;
1914 test_text =
1915 "# define FP_NORMAL 0\n"
1916 "# define FP_ZERO 1\n"
1917 "# define FP_INFINITE 2\n"
1918 "# define FP_SUBNORMAL 3\n"
1919 "# define FP_NAN 4\n";
1923 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1924 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1926 fix = {
1927 hackname = hpux10_cpp_pow_inline;
1928 files = fixinc-test-limits.h, math.h;
1929 select = <<- END_POW_INLINE
1930 ^# +ifdef +__cplusplus
1932 +inline +double +pow\(double +__d,int +__expon\) +\{
1933 [ ]+return +pow\(__d,\(double\)__expon\);
1935 +extern +"C" +\{
1936 #else
1937 # +endif
1938 END_POW_INLINE;
1940 c_fix = format;
1941 c_fix_arg = "";
1943 test_text =
1944 "# ifdef __cplusplus\n"
1945 " }\n"
1946 " inline double pow(double __d,int __expon) {\n"
1947 "\t return pow(__d,(double)__expon);\n"
1948 " }\n"
1949 ' extern "C"' " {\n"
1950 "#else\n"
1951 "# endif";
1954 fix = {
1955 hackname = hpux11_cpp_pow_inline;
1956 files = math.h;
1957 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1958 " +return pow\\(d, \\(double\\)expon\\);\n"
1959 " +\\}\n";
1960 c_fix = format;
1961 c_fix_arg = "";
1963 test_text =
1964 " inline double pow(double d,int expon) {\n"
1965 " return pow(d, (double)expon);\n"
1966 " }\n";
1970 * Fix hpux 10.X missing ctype declarations 1
1972 fix = {
1973 hackname = hpux10_ctype_declarations1;
1974 files = ctype.h;
1975 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1976 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1977 c_fix = format;
1978 c_fix_arg = "#ifdef _PROTOTYPES\n"
1979 "extern int __tolower(int);\n"
1980 "extern int __toupper(int);\n"
1981 "#else /* NOT _PROTOTYPES */\n"
1982 "extern int __tolower();\n"
1983 "extern int __toupper();\n"
1984 "#endif /* _PROTOTYPES */\n\n"
1985 "%0\n";
1987 test_text = "# define _toupper(__c) __toupper(__c)\n";
1991 * Fix hpux 10.X missing ctype declarations 2
1993 fix = {
1994 hackname = hpux10_ctype_declarations2;
1995 files = ctype.h;
1996 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1997 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1998 c_fix = format;
1999 c_fix_arg = "%0\n\n"
2000 "#ifdef _PROTOTYPES\n"
2001 " extern int _isalnum(int);\n"
2002 " extern int _isalpha(int);\n"
2003 " extern int _iscntrl(int);\n"
2004 " extern int _isdigit(int);\n"
2005 " extern int _isgraph(int);\n"
2006 " extern int _islower(int);\n"
2007 " extern int _isprint(int);\n"
2008 " extern int _ispunct(int);\n"
2009 " extern int _isspace(int);\n"
2010 " extern int _isupper(int);\n"
2011 " extern int _isxdigit(int);\n"
2012 "# else /* not _PROTOTYPES */\n"
2013 " extern int _isalnum();\n"
2014 " extern int _isalpha();\n"
2015 " extern int _iscntrl();\n"
2016 " extern int _isdigit();\n"
2017 " extern int _isgraph();\n"
2018 " extern int _islower();\n"
2019 " extern int _isprint();\n"
2020 " extern int _ispunct();\n"
2021 " extern int _isspace();\n"
2022 " extern int _isupper();\n"
2023 " extern int _isxdigit();\n"
2024 "#endif /* _PROTOTYPES */\n";
2026 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2027 " extern unsigned int *__SB_masks;\n";
2031 * Fix hpux 10.X missing stdio declarations
2033 fix = {
2034 hackname = hpux10_stdio_declarations;
2035 files = stdio.h;
2036 select = "^#[ \t]*define _iob[ \t]*__iob";
2037 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2038 c_fix = format;
2039 c_fix_arg = "%0\n\n"
2040 "# if defined(__STDC__) || defined(__cplusplus)\n"
2041 " extern int snprintf(char *, size_t, const char *, ...);\n"
2042 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2043 "# else /* not __STDC__) || __cplusplus */\n"
2044 " extern int snprintf();\n"
2045 " extern int vsnprintf();\n"
2046 "# endif /* __STDC__) || __cplusplus */\n";
2048 test_text = "# define _iob __iob\n";
2052 * Make sure hpux defines abs in header.
2054 fix = {
2055 hackname = hpux11_abs;
2056 mach = "*-hp-hpux11*";
2057 files = stdlib.h;
2058 select = "ifndef _MATH_INCLUDED";
2059 c_fix = format;
2060 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2061 test_text = "#ifndef _MATH_INCLUDED";
2065 * hpux sendfile()
2067 fix = {
2068 hackname = hpux11_extern_sendfile;
2069 mach = "*-hp-hpux11.[12]*";
2070 files = sys/socket.h;
2071 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2072 c_fix = format;
2073 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2074 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2075 " const struct iovec *, int));\n";
2079 * hpux sendpath()
2081 fix = {
2082 hackname = hpux11_extern_sendpath;
2083 mach = "*-hp-hpux11.[12]*";
2084 files = sys/socket.h;
2085 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2086 c_fix = format;
2087 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2088 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2089 " const struct iovec *, int));\n";
2093 * Keep HP-UX 11 from stomping on C++ math namespace
2094 * with defines for fabsf.
2096 fix = {
2097 hackname = hpux11_fabsf;
2098 files = math.h;
2099 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2100 bypass = "__cplusplus";
2102 c_fix = format;
2103 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2105 test_text =
2106 "#ifdef _PA_RISC\n"
2107 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2108 "#endif";
2112 * Fix C99 constant in __POINTER_SET define.
2114 fix = {
2115 hackname = hpux11_pthread_const;
2116 mach = "*-hp-hpux11.[0-3]*";
2117 files = sys/pthread.h;
2118 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2120 c_fix = format;
2121 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2122 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2126 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2127 * being defined by having it define _hpux_size_t instead.
2129 fix = {
2130 hackname = hpux11_size_t;
2131 mach = "*-hp-hpux11*";
2132 select = "__size_t";
2134 c_fix = format;
2135 c_fix_arg = "_hpux_size_t";
2137 test_text =
2138 "#define __size_t size_t\n"
2139 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2143 * Fix hpux 11.00 broken snprintf declaration
2144 * (third argument is char *, needs to be const char * to prevent
2145 * spurious warnings with -Wwrite-strings or in C++).
2147 fix = {
2148 hackname = hpux11_snprintf;
2149 files = stdio.h;
2150 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2151 ' *(char *\*, *\.\.\.\);)';
2152 c_fix = format;
2153 c_fix_arg = '%1 const %3';
2155 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2156 "extern int snprintf(char *, __size_t, char *, ...);\n"
2157 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2161 * Fix hpux 11.00 broken vsnprintf declaration
2163 fix = {
2164 hackname = hpux11_vsnprintf;
2165 files = stdio.h;
2166 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2167 'const char \*,) __va__list\);';
2168 c_fix = format;
2169 c_fix_arg = "%1 __va_list);";
2171 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2172 ' __va__list);';
2176 * get rid of bogus inline definitions in HP-UX 8.0
2178 fix = {
2179 hackname = hpux8_bogus_inlines;
2180 files = math.h;
2181 select = inline;
2182 bypass = "__GNUG__";
2183 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2184 "@extern \"C\" int abs(int);@";
2185 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2186 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2187 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2188 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2189 "inline double sqr(double v) { return v**0.5; }";
2193 * hpux intptr
2195 fix = {
2196 hackname = hpux_c99_intptr;
2197 mach = "*-hp-hpux11.3*";
2198 files = stdint-hpux11.h, stdint.h;
2199 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2200 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2201 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2202 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2203 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2204 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2205 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2206 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2207 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2208 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2209 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2210 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2211 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2212 "#define PTRDIFF_MIN INT32_MIN\n"
2213 "#define INTPTR_MAX INT32_MAX\n"
2214 "#define INTPTR_MIN INT32_MIN\n"
2215 "#define UINTPTR_MAX UINT32_MAX\n"
2216 "#define SIZE_MAX UINT32_MAX\n";
2220 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2222 fix = {
2223 hackname = hpux_c99_inttypes;
2224 mach = "*-hp-hpux11.[23]*";
2225 files = inttypes.h;
2226 files = stdint-hpux11.h, stdint.h;
2227 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2228 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2229 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2230 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2231 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2232 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2233 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2234 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2235 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2236 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2237 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2238 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2242 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2244 fix = {
2245 hackname = hpux_c99_inttypes2;
2246 mach = "*-hp-hpux11.2*";
2247 files = stdint-hpux11.h, stdint.h;
2248 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2249 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2250 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2251 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2252 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2253 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2254 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2255 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2256 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2257 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2258 "# define INT16_C(__c) ((short)(__c))\n"
2259 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2263 * Fix hpux broken ctype macros
2265 fix = {
2266 hackname = hpux_ctype_macros;
2267 files = ctype.h;
2268 select = '((: |\()__SB_masks \? )'
2269 '(__SB_masks\[__(alnum|c)\] & _IS)';
2270 c_fix = format;
2271 c_fix_arg = "%1(int)%3";
2273 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2274 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2278 * hpux errno()
2280 fix = {
2281 hackname = hpux_extern_errno;
2282 mach = "*-hp-hpux10.*";
2283 mach = "*-hp-hpux11.[0-2]*";
2284 files = errno.h;
2285 select = "^[ \t]*extern int errno;$";
2286 c_fix = format;
2287 c_fix_arg = "#ifdef __cplusplus\n"
2288 "extern \"C\" {\n"
2289 "#endif\n"
2290 "%0\n"
2291 "#ifdef __cplusplus\n"
2292 "}\n"
2293 "#endif";
2294 test_text = " extern int errno;\n";
2298 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2300 fix = {
2301 hackname = hpux_htonl;
2302 files = netinet/in.h;
2303 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2304 "(/\\*\n"
2305 " \\* Macros for number representation conversion\\.\n"
2306 " \\*/\n"
2307 "#ifndef ntohl)";
2308 c_fix = format;
2309 c_fix_arg = "#if 1\n%1";
2311 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2312 "/*\n"
2313 " * Macros for number representation conversion.\n"
2314 " */\n"
2315 "#ifndef ntohl\n"
2316 "#define ntohl(x) (x)\n"
2317 "#define ntohs(x) (x)\n"
2318 "#define htonl(x) (x)\n"
2319 "#define htons(x) (x)\n"
2320 "#endif\n"
2321 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2325 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2327 fix = {
2328 hackname = hpux_imaginary_i;
2329 mach = "ia64-hp-hpux11.*";
2330 files = complex.h;
2331 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2332 c_fix = format;
2333 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2334 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2338 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2340 fix = {
2341 hackname = hpux_inttype_int8_t;
2342 mach = "*-hp-hpux1[01].*";
2343 files = sys/_inttypes.h;
2344 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2345 c_fix = format;
2346 c_fix_arg = "typedef signed char int%18_t;";
2347 test_text = "typedef char int_least8_t;\n"
2348 "typedef char int8_t;\n";
2352 * HP-UX long_double
2354 fix = {
2355 hackname = hpux_long_double;
2356 mach = "*-*-hpux10*";
2357 mach = "*-*-hpux11.[012]*";
2358 files = stdlib.h;
2359 select = "extern[ \t]long_double[ \t]strtold";
2360 bypass = "long_double_t";
2361 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2362 sed = "s/long_double/long double/g";
2364 test_text = "# ifndef _LONG_DOUBLE\n"
2365 "# define _LONG_DOUBLE\n"
2366 " typedef struct {\n"
2367 " unsigned int word1, word2, word3, word4;\n"
2368 " } long_double;\n"
2369 "# endif /* _LONG_DOUBLE */\n"
2370 "extern long_double strtold(const char *, char **);\n";
2374 * We cannot use the above rule on 11.31 because it removes the strtold
2375 * definition. ia64 is OK with no hack, PA needs some help.
2377 fix = {
2378 hackname = hpux_long_double_2;
2379 mach = "hppa*-*-hpux11.3*";
2380 files = stdlib.h;
2381 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2382 "defined\\(_PROTOTYPES\\) \\|\\| "
2383 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2384 c_fix = format;
2385 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2387 test_text = "# if !defined(__ia64) || "
2388 "!defined(_PROTOTYPES) || "
2389 "defined(_LONG_DOUBLE_STRUCT)\n";
2393 * Add missing braces to pthread initializer defines.
2395 fix = {
2396 hackname = hpux_pthread_initializers;
2397 mach = "*-hp-hpux11.[0-3]*";
2398 files = sys/pthread.h;
2399 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2400 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2401 sed = "s@^[ \t]*1,[ \t]*\\\\"
2402 "@\t{ 1, 0 }@";
2403 sed = "/^[ \t]*0$/d";
2404 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2405 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2406 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2407 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2408 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2409 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2410 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2411 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2412 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2413 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2414 sed = "s@__PTHREAD_COND_VALID, 0"
2415 "@{ __PTHREAD_COND_VALID, 0 }@";
2416 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2417 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2418 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2419 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2420 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2421 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2422 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2423 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2424 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2425 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2426 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2427 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2428 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2429 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2430 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2431 "}\n";
2435 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2436 * type and mpinfou is only defined when _KERNEL is set.
2438 fix = {
2439 hackname = hpux_spu_info;
2440 mach = "*-hp-hpux*";
2442 * It is tempting to omit the first "files" entry. Do not.
2443 * The testing machinery will take the first "files" entry as the name
2444 * of a test file to play with. It would be a nuisance to have a directory
2445 * with the name "*".
2447 files = "ia64/sys/getppdp.h";
2448 files = "*/sys/getppdp.h";
2449 select = "^.*extern.*spu_info.*";
2451 c_fix = format;
2452 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2454 test_text = "extern union mpinfou spu_info[];";
2458 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2460 fix = {
2461 hackname = hpux_stdint_least_fast;
2462 mach = "*-hp-hpux11.2*";
2463 files = stdint-hpux11.h, stdint.h;
2464 select =
2465 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2466 c_fix = format;
2467 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2468 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2469 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2470 _EOFix_;
2474 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2476 fix = {
2477 hackname = hpux_systime;
2478 files = sys/time.h;
2479 select = "^extern struct sigevent;";
2481 c_fix = format;
2482 c_fix_arg = "struct sigevent;";
2484 test_text = 'extern struct sigevent;';
2488 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2490 fix = {
2491 hackname = huge_val_hex;
2492 files = bits/huge_val.h, '*/bits/huge_val.h';
2493 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2494 bypass = "__builtin_huge_val";
2496 c_fix = format;
2497 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2499 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2503 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2505 fix = {
2506 hackname = huge_valf_hex;
2507 files = bits/huge_val.h, '*/bits/huge_val.h';
2508 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2509 bypass = "__builtin_huge_valf";
2511 c_fix = format;
2512 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2514 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2518 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2520 fix = {
2521 hackname = huge_vall_hex;
2522 files = bits/huge_val.h, '*/bits/huge_val.h';
2523 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2524 bypass = "__builtin_huge_vall";
2526 c_fix = format;
2527 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2529 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2533 * Fix return type of abort and free
2535 fix = {
2536 hackname = int_abort_free_and_exit;
2537 files = stdlib.h;
2538 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2539 bypass = "_CLASSIC_ANSI_TYPES";
2541 c_fix = format;
2542 c_fix_arg = "void\t%1(";
2544 test_text = "extern int abort(int);\n"
2545 "extern int free(void*);\n"
2546 "extern int exit(void*);";
2550 * Fix various macros used to define ioctl numbers.
2551 * The traditional syntax was:
2553 * #define _IO(n, x) (('n'<<8)+x)
2554 * #define TIOCFOO _IO(T, 1)
2556 * but this does not work with the C standard, which disallows macro
2557 * expansion inside strings. We have to rewrite it thus:
2559 * #define _IO(n, x) ((n<<8)+x)
2560 * #define TIOCFOO _IO('T', 1)
2562 * The select expressions match too much, but the c_fix code is cautious.
2564 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2566 fix = {
2567 hackname = io_quotes_def;
2568 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2569 c_fix = char_macro_def;
2570 c_fix_arg = "IO";
2571 test_text =
2572 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2573 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2574 "#define _IO(x,y) ('x'<<8|y)";
2575 test_text =
2576 "#define XX_IO(x) ('x'<<8|256)";
2580 * Fix the usage of the ioctl macro numbers.
2582 fix = {
2583 hackname = io_quotes_use;
2584 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2585 "\\( *[^,']";
2586 c_fix = char_macro_use;
2587 c_fix_arg = "IO";
2588 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2589 "#define TIOCFOO \\\\\n"
2590 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2594 * Check for missing ';' in struct
2596 fix = {
2597 hackname = ip_missing_semi;
2598 files = netinet/ip.h;
2599 select = "}$";
2600 sed = "/^struct/,/^};/s/}$/};/";
2601 test_text=
2602 "struct mumble {\n"
2603 " union {\n"
2604 " int x;\n"
2605 " }\n"
2606 "}; /* mumbled struct */\n";
2610 * Non-traditional "const" declaration in Irix's limits.h.
2612 fix = {
2613 hackname = irix_limits_const;
2614 files = fixinc-test-limits.h, limits.h;
2615 select = "^extern const ";
2616 c_fix = format;
2617 c_fix_arg = "extern __const ";
2618 test_text = "extern const char limit; /* test limits */";
2622 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2623 * taking char *. However, GCC uses void * for va_list, so
2624 * calling vfprintf with a va_list fails in C++. */
2625 fix = {
2626 hackname = irix_stdio_va_list;
2627 files = stdio.h;
2629 select = '/\* va_list \*/ char \*';
2630 c_fix = format;
2631 c_fix_arg = "__gnuc_va_list";
2632 test_text =
2633 "extern int printf( const char *, /* va_list */ char * );";
2637 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2638 * use / * * / to concatenate tokens.
2640 fix = {
2641 hackname = kandr_concat;
2642 files = "sparc/asm_linkage.h";
2643 files = "sun*/asm_linkage.h";
2644 files = "arm/as_support.h";
2645 files = "arm/mc_type.h";
2646 files = "arm/xcb.h";
2647 files = "dev/chardefmac.h";
2648 files = "dev/ps_irq.h";
2649 files = "dev/screen.h";
2650 files = "dev/scsi.h";
2651 files = "sys/tty.h";
2652 files = "Xm.acorn/XmP.h";
2653 files = bsd43/bsd43_.h;
2654 select = '/\*\*/';
2655 c_fix = format;
2656 c_fix_arg = '##';
2657 test_text = "#define __CONCAT__(a,b) a/**/b";
2661 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2662 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2663 * constant on recent versions of g++.
2665 fix = {
2666 hackname = linux_ia64_ucontext;
2667 files = "sys/ucontext.h";
2668 mach = "ia64-*-linux*";
2669 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2670 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2671 c_fix = format;
2672 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2673 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2674 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2678 * Remove header file warning from sys/time.h. Autoconf's
2679 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2680 * which causes warning on LynxOS. Remove the warning.
2682 fix = {
2683 hackname = lynxos_no_warning_in_sys_time_h;
2684 files = sys/time.h;
2685 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2686 c_fix = format;
2687 c_fix_arg = "";
2688 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2692 * Add missing declaration for putenv.
2694 fix = {
2695 hackname = lynxos_missing_putenv;
2696 mach = '*-*-lynxos*';
2697 files = stdlib.h;
2698 bypass = 'putenv[ \t]*\\(';
2699 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2700 c_fix = format;
2701 c_fix_arg = "%0\n"
2702 "extern int putenv _AP((char *));";
2703 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2704 test_text = "extern char *getenv _AP((const char *));";
2708 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2710 * On NetBSD, machine is a symbolic link to an architecture specific
2711 * directory name, so we can't match a specific file name here.
2713 fix = {
2714 hackname = machine_ansi_h_va_list;
2715 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2716 bypass = '__builtin_va_list';
2718 c_fix = format;
2719 c_fix_arg = "%1__builtin_va_list";
2720 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2722 test_text = " # define _BSD_VA_LIST_\tchar**";
2726 * Fix non-ansi machine name defines
2728 fix = {
2729 hackname = machine_name;
2730 c_test = machine_name;
2731 c_fix = machine_name;
2733 test_text = "/* MACH_DIFF: */\n"
2734 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2735 "\n/* no uniform test, so be careful :-) */";
2739 * Some math.h files define struct exception (it's in the System V
2740 * Interface Definition), which conflicts with the class exception defined
2741 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2742 * This is not a great fix, but I haven't been able to think of anything
2743 * better.
2745 fix = {
2746 hackname = math_exception;
2747 files = math.h;
2748 select = "struct exception";
2750 * This should be bypassed on __cplusplus, but some supposedly C++
2751 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2752 * exception either. So currently we bypass only for glibc, based on a
2753 * comment in the fixed glibc header. Ick.
2755 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2756 '_[a-z0-9A-Z_]+_exception; for C, exception';
2757 /* The Solaris 10 headers already get this right. */
2758 mach = '*-*-solaris2.1[0-9]*';
2759 not_machine = true;
2760 c_fix = wrap;
2762 c_fix_arg = "#ifdef __cplusplus\n"
2763 "#define exception __math_exception\n"
2764 "#endif\n";
2766 c_fix_arg = "#ifdef __cplusplus\n"
2767 "#undef exception\n"
2768 "#endif\n";
2770 test_text = "typedef struct exception t_math_exception;";
2774 * This looks pretty broken to me. ``dbl_max_def'' will contain
2775 * "define DBL_MAX " at the start, when what we really want is just
2776 * the value portion. Can't figure out how to write a test case
2777 * for this either :-(
2779 fix = {
2780 hackname = math_huge_val_from_dbl_max;
2781 files = math.h;
2784 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2785 * in math.h, this fix applies.
2787 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2788 bypass = "define[ \t]+DBL_MAX";
2790 shell =
2792 * See if we have a definition for DBL_MAX in float.h.
2793 * If we do, we will replace the one in math.h with that one.
2796 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2797 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2799 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2800 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2801 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2802 "\telse cat\n"
2803 "\tfi";
2805 test_text =
2806 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2807 "#define HUGE_VAL DBL_MAX";
2811 * nested comment
2813 fix = {
2814 hackname = nested_auth_des;
2815 files = rpc/rpc.h;
2816 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2817 c_fix = format;
2818 c_fix_arg = "%1*/ /*";
2819 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2823 * Some versions of NetBSD don't expect the C99 inline semantics.
2825 fix = {
2826 hackname = netbsd_c99_inline_1;
2827 mach = "*-*-netbsd*";
2828 files = signal.h;
2829 select = "extern __inline int";
2831 c_fix = format;
2832 c_fix_arg = "extern\n"
2833 "#ifdef __GNUC_STDC_INLINE__\n"
2834 "__attribute__((__gnu_inline__))\n"
2835 "#endif\n"
2836 "__inline int";
2838 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2842 * netbsd_c99_inline_2
2844 fix = {
2845 hackname = netbsd_c99_inline_2;
2846 mach = "*-*-netbsd*";
2847 files = signal.h;
2848 select = "#define _SIGINLINE extern __inline";
2850 c_fix = format;
2851 c_fix_arg = <<- _EOArg_
2852 #ifdef __GNUC_STDC_INLINE__
2853 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2854 #else
2856 #endif
2857 _EOArg_;
2859 test_text = "#define _SIGINLINE extern __inline";
2863 * NetBSD has a semicolon after the ending '}' for some extern "C".
2865 fix = {
2866 hackname = netbsd_extra_semicolon;
2867 mach = "*-*-netbsd*";
2868 files = sys/cdefs.h;
2869 select = "#define[ \t]*__END_DECLS[ \t]*};";
2871 c_fix = format;
2872 c_fix_arg = "#define __END_DECLS }";
2874 test_text = "#define __END_DECLS };";
2878 * newlib's stdint.h has several failures to conform to C99. The fix
2879 * for these removed a comment that can be matched to identify unfixed
2880 * versions.
2882 fix = {
2883 hackname = newlib_stdint_1;
2884 files = stdint-newlib.h, stdint.h;
2885 select = "@todo - Add support for wint_t types";
2886 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2887 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2888 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2889 sed = "s@#define INT_LEAST32_MIN.*@"
2890 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2891 sed = "s@#define INT_LEAST32_MAX.*@"
2892 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2893 sed = "s@#define UINT_LEAST32_MAX.*@"
2894 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2895 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
2896 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2897 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
2898 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2899 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
2900 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2901 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2902 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2903 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2904 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2905 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2906 test_text = "/* @todo - Add support for wint_t types. */\n"
2907 "#define INT32_MIN (-2147483647-1)\n"
2908 "#define INT32_MAX 2147483647\n"
2909 "#define UINT32_MAX 4294967295U\n"
2910 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2911 "#define INT_LEAST32_MAX 2147483647\n"
2912 "#define UINT_LEAST32_MAX 4294967295U\n"
2913 "#define INT_FAST8_MIN INT8_MIN\n"
2914 "#define INT_FAST8_MAX INT8_MAX\n"
2915 "#define UINT_FAST8_MAX UINT8_MAX\n"
2916 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2917 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2918 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2919 "#define UINT8_C(x) x##U\n"
2920 "#define UINT16_C(x) x##U";
2924 * newlib_stdint_2
2926 fix = {
2927 hackname = newlib_stdint_2;
2928 files = stdint-newlib.h, stdint.h;
2929 select = "@todo - Add support for wint_t types";
2930 c_fix = format;
2931 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2932 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2933 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2934 "#define WCHAR_MAX __WCHAR_MAX__\n"
2935 "#define WCHAR_MIN __WCHAR_MIN__\n"
2936 "#define WINT_MAX __WINT_MAX__\n"
2937 "#define WINT_MIN __WINT_MIN__\n\n"
2938 "%0";
2939 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2940 test_text = "/* @todo - Add support for wint_t types. */\n"
2941 "/** Macros for minimum-width integer constant expressions */";
2945 * NeXT 3.2 adds const prefix to some math functions.
2946 * These conflict with the built-in functions.
2948 fix = {
2949 hackname = next_math_prefix;
2950 files = ansi/math.h;
2951 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2953 c_fix = format;
2954 c_fix_arg = "extern double %1(";
2955 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2957 test_text = "extern\tdouble\t__const__\tmumble();";
2961 * NeXT 3.2 uses the word "template" as a parameter for some
2962 * functions. GCC reports an invalid use of a reserved key word
2963 * with the built-in functions.
2965 fix = {
2966 hackname = next_template;
2967 files = bsd/libc.h;
2968 select = "[ \t]template\\)";
2970 c_fix = format;
2971 c_fix_arg = "(%1)";
2972 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2973 test_text = "extern mumble( char * template); /* fix */";
2977 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2978 * function prototypes. That conflicts with the built-in functions.
2980 fix = {
2981 hackname = next_volitile;
2982 files = ansi/stdlib.h;
2983 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2985 c_fix = format;
2986 c_fix_arg = "extern void %1(";
2987 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2989 test_text = "extern\tvolatile\tvoid\tabort();";
2993 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2994 * Note that version 3 of the NeXT system has wait.h in a different directory,
2995 * so that this code won't do anything. But wait.h in version 3 has a
2996 * conditional, so it doesn't need this fix. So everything is okay.
2998 fix = {
2999 hackname = next_wait_union;
3000 files = sys/wait.h;
3002 select = 'wait\(union wait';
3003 c_fix = format;
3004 c_fix_arg = "wait(void";
3005 test_text = "extern pid_d wait(union wait*);";
3009 * a missing semi-colon at the end of the nodeent structure definition.
3011 fix = {
3012 hackname = nodeent_syntax;
3013 files = netdnet/dnetdb.h;
3014 select = "char[ \t]*\\*na_addr[ \t]*$";
3015 c_fix = format;
3016 c_fix_arg = "%0;";
3017 test_text = "char *na_addr\t";
3021 * Fix OpenBSD's NULL definition.
3023 fix = {
3024 hackname = openbsd_null_definition;
3025 mach = "*-*-openbsd*";
3026 files = locale.h, stddef.h, stdio.h, string.h,
3027 time.h, unistd.h, wchar.h, sys/param.h;
3028 select = "__GNUG__";
3029 c_fix = format;
3030 c_fix_arg = "#ifndef NULL\n"
3031 "#ifdef __cplusplus\n"
3032 "#ifdef __GNUG__\n"
3033 "#define NULL\t__null\n"
3034 "#else\t /* ! __GNUG__ */\n"
3035 "#define NULL\t0L\n"
3036 "#endif\t /* __GNUG__ */\n"
3037 "#else\t /* ! __cplusplus */\n"
3038 "#define NULL\t((void *)0)\n"
3039 "#endif\t /* __cplusplus */\n"
3040 "#endif\t /* !NULL */";
3042 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3043 "^#ifdef[ \t]*__GNUG__\n"
3044 "^#define[ \t]*NULL[ \t]*__null\n"
3045 "^#else\n"
3046 "^#define[ \t]*NULL[ \t]*0L\n"
3047 "^#endif\n"
3048 "^#endif";
3049 test_text =
3050 "#ifndef NULL\n"
3051 "#ifdef __GNUG__\n"
3052 "#define NULL __null\n"
3053 "#else\n"
3054 "#define NULL 0L\n"
3055 "#endif\n"
3056 "#endif\n";
3060 * obstack.h used casts as lvalues.
3062 * We need to change postincrements of casted pointers (which are
3063 * then dereferenced and assigned into) of the form
3065 * *((TYPE*)PTRVAR)++ = (VALUE)
3067 * into expressions like
3069 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3071 * which is correct for the cases used in obstack.h since PTRVAR is
3072 * of type char * and the value of the expression is not used.
3074 fix = {
3075 hackname = obstack_lvalue_cast;
3076 files = obstack.h;
3077 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3078 c_fix = format;
3079 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3080 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3084 * Fix OpenBSD's va_start define.
3086 fix = {
3087 hackname = openbsd_va_start;
3088 mach = "*-*-openbsd*";
3089 files = stdarg.h;
3090 select = '__builtin_stdarg_start';
3091 c_fix = format;
3092 c_fix_arg = __builtin_va_start;
3094 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3098 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3099 * defining regex.h related types. This causes libg++ build and usage
3100 * failures. Fixing this correctly requires checking and modifying 3 files.
3102 fix = {
3103 hackname = osf_namespace_a;
3104 files = reg_types.h;
3105 files = sys/lc_core.h;
3106 test = " -r reg_types.h";
3107 test = " -r sys/lc_core.h";
3108 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3109 test = " -z \"`grep __regex_t regex.h`\"";
3111 c_fix = format;
3112 c_fix_arg = "__%0";
3113 c_fix_arg = "reg(ex|off|match)_t";
3115 test_text = "`touch sys/lc_core.h`"
3116 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3117 "extern regex_t re;\n"
3118 "extern regoff_t ro;\n"
3119 "extern regmatch_t rm;\n";
3122 fix = {
3123 hackname = osf_namespace_c;
3124 files = regex.h;
3125 test = " -r reg_types.h";
3126 test = " -r sys/lc_core.h";
3127 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3128 test = " -z \"`grep __regex_t regex.h`\"";
3130 select = "#include <reg_types\.h>.*";
3131 c_fix = format;
3132 c_fix_arg = "%0\n"
3133 "typedef __regex_t\tregex_t;\n"
3134 "typedef __regoff_t\tregoff_t;\n"
3135 "typedef __regmatch_t\tregmatch_t;";
3137 test_text = "#include <reg_types.h>";
3141 * On broken glibc-2.3.3 systems an array of incomplete structures is
3142 * passed to __sigsetjmp. Fix that to take a pointer instead.
3144 fix = {
3145 hackname = pthread_incomplete_struct_argument;
3146 files = pthread.h;
3147 select = "struct __jmp_buf_tag";
3148 c_fix = format;
3149 c_fix_arg = "%1 *%2%3";
3150 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3151 "(__env)\\[1\\](.*)$";
3152 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3153 "int __savemask);";
3157 * Fix return type of fread and fwrite on sysV68
3159 fix = {
3160 hackname = read_ret_type;
3161 files = stdio.h;
3162 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3163 c_fix = format;
3164 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3165 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3167 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3171 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3173 fix = {
3174 hackname = rpc_xdr_lvalue_cast_a;
3175 files = rpc/xdr.h;
3176 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3177 c_fix = format;
3178 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3179 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3180 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3184 * rpc_xdr_lvalue_cast_b
3186 fix = {
3187 hackname = rpc_xdr_lvalue_cast_b;
3188 files = rpc/xdr.h;
3189 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3190 c_fix = format;
3191 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3192 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3193 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3197 * function class(double x) conflicts with C++ keyword on rs/6000
3199 fix = {
3200 hackname = rs6000_double;
3201 files = math.h;
3202 select = '[^a-zA-Z_]class\(';
3204 c_fix = format;
3205 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3206 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3208 test_text = "extern int class();";
3212 * Wrong fchmod prototype on RS/6000.
3214 fix = {
3215 hackname = rs6000_fchmod;
3216 files = sys/stat.h;
3217 select = 'fchmod\(char \*';
3218 c_fix = format;
3219 c_fix_arg = "fchmod(int";
3220 test_text = "extern int fchmod(char *, mode_t);";
3224 * parameters conflict with C++ new on rs/6000
3226 fix = {
3227 hackname = rs6000_param;
3228 files = "stdio.h";
3229 files = "unistd.h";
3231 select = 'rename\(const char \*old, const char \*new\)';
3232 c_fix = format;
3233 c_fix_arg = 'rename(const char *_old, const char *_new)';
3235 test_text = 'extern int rename(const char *old, const char *new);';
3239 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3240 * for C99. This is wrong for C++, which needs many C99 features, but
3241 * only supports __restrict.
3243 fix = {
3244 hackname = solaris___restrict;
3245 files = sys/feature_tests.h;
3246 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3247 mach = "*-*-solaris2*";
3248 c_fix = format;
3249 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3250 "#else\n%0\n#endif";
3251 test_text = "#define _RESTRICT_KYWD restrict";
3255 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3256 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3257 * and imaginary definitions which are not supported by GCC.
3259 fix = {
3260 hackname = solaris_complex;
3261 mach = "*-*-solaris2.*";
3262 files = complex.h;
3263 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3264 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3265 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3266 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3267 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3268 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3269 test_text = "#define _Complex_I _Complex_I\n"
3270 "#define complex _Complex\n"
3271 "#define _Imaginary_I _Imaginary_I\n"
3272 "#define imaginary _Imaginary\n"
3273 "#undef I\n"
3274 "#define I _Imaginary_I";
3278 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3279 * extern "C" instead so libstdc++ can use it.
3281 fix = {
3282 hackname = solaris_complex_cxx;
3283 mach = "*-*-solaris2.*";
3284 files = complex.h;
3285 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3286 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3287 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3288 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3289 test_text = "#if !defined(__cplusplus)\n"
3290 "#endif /* !defined(__cplusplus) */";
3294 * g++ rejects functions declared with both C and C++ linkage.
3296 fix = {
3297 hackname = solaris_cxx_linkage;
3298 mach = '*-*-solaris2*';
3299 files = "iso/stdlib_iso.h";
3300 select = "(#if __cplusplus >= 199711L)\n"
3301 "(extern \"C\\+\\+\" \\{\n)"
3302 "(.*(bsearch|qsort).*)";
3303 c_fix = format;
3304 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3306 test_text =
3307 "#if __cplusplus >= 199711L\n"
3308 "extern \"C++\" {\n"
3309 " void *bsearch(const void *, const void *, size_t, size_t,";
3313 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3314 * _STRICT_STDC, but uses it.
3316 fix = {
3317 hackname = solaris_getc_strict_stdc;
3318 mach = "*-*-solaris2*";
3319 files = "iso/stdio_iso.h";
3320 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3321 c_fix = format;
3322 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3324 test_text =
3325 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3329 * Sun Solaris 2 has a version of sys/int_const.h that defines
3330 * UINT8_C and UINT16_C to unsigned constants.
3332 fix = {
3333 hackname = solaris_int_const;
3334 files = sys/int_const.h;
3335 mach = '*-*-solaris2*';
3336 c_fix = format;
3337 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3338 "%1\n"
3339 "#define\tUINT16_C(c)\t(c)";
3340 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3341 "(/\*.*\*/)\n"
3342 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3343 test_text =
3344 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3345 "/* CSTYLED */\n"
3346 "#define UINT16_C(c) __CONCAT__(c,u)";
3350 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3351 * UINT8_MAX and UINT16_MAX to unsigned constants.
3353 fix = {
3354 hackname = solaris_int_limits_1;
3355 files = sys/int_limits.h;
3356 mach = '*-*-solaris2*';
3357 c_fix = format;
3358 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3359 "#define\tUINT16_MAX\t(65535)";
3360 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3361 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3362 test_text =
3363 "#define UINT8_MAX (255U)\n"
3364 "#define UINT16_MAX (65535U)";
3368 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3369 * INT_FAST16 limits to wrong values for sys/int_types.h.
3371 fix = {
3372 hackname = solaris_int_limits_2;
3373 files = sys/int_limits.h;
3374 mach = '*-*-solaris2*';
3375 c_fix = format;
3376 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3377 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3378 test_text =
3379 "#define INT_FAST16_MAX INT16_MAX\n"
3380 "#define UINT_FAST16_MAX UINT16_MAX\n"
3381 "#define INT_FAST16_MIN INT16_MIN";
3385 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3386 * SIZE_MAX as unsigned long.
3388 fix = {
3389 hackname = solaris_int_limits_3;
3390 files = sys/int_limits.h;
3391 mach = '*-*-solaris2*';
3392 c_fix = format;
3393 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3394 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3395 test_text =
3396 "#define SIZE_MAX 4294967295UL";
3400 * Sun Solaris 10 defines several C99 math macros in terms of
3401 * builtins specific to the Studio compiler, in particular not
3402 * compatible with the GNU compiler.
3404 fix = {
3405 hackname = solaris_math_1;
3406 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3407 bypass = "__GNUC__";
3408 files = iso/math_c99.h;
3409 c_fix = format;
3410 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3411 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3412 test_text =
3413 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3414 "#undef HUGE_VAL\n"
3415 "#define HUGE_VAL __builtin_huge_val\n"
3416 "#undef HUGE_VALF\n"
3417 "#define HUGE_VALF __builtin_huge_valf\n"
3418 "#undef HUGE_VALL\n"
3419 "#define HUGE_VALL __builtin_huge_vall";
3423 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3424 * exception. Provide an alternative using GCC's builtin.
3426 fix = {
3427 hackname = solaris_math_10;
3428 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3429 files = iso/math_c99.h;
3430 c_fix = format;
3431 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3432 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3433 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3434 "[ \t]*\\\\\n"
3435 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3436 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3437 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3438 "\\(-INFINITY\\);[ \t]*\\}\\)";
3439 test_text =
3440 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3441 "#undef isinf\n"
3442 "#define isinf(x) __extension__( \\\\\n"
3443 " { __typeof(x) __x_i = (x); \\\\\n"
3444 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3445 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3449 * Solaris math INFINITY
3451 fix = {
3452 hackname = solaris_math_2;
3453 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3454 bypass = "__GNUC__";
3455 files = iso/math_c99.h;
3456 c_fix = format;
3457 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3458 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3459 test_text =
3460 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3461 "#undef INFINITY\n"
3462 "#define INFINITY __builtin_infinity";
3466 * Solaris math NAN
3468 fix = {
3469 hackname = solaris_math_3;
3470 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3471 bypass = "__GNUC__";
3472 files = iso/math_c99.h;
3473 c_fix = format;
3474 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3475 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3476 test_text =
3477 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3478 "#undef NAN\n"
3479 "#define NAN __builtin_nan";
3483 * Solaris math fpclassify
3485 fix = {
3486 hackname = solaris_math_4;
3487 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3488 bypass = "__GNUC__";
3489 files = iso/math_c99.h;
3490 c_fix = format;
3491 c_fix_arg = "#define\tfpclassify(x) \\\n"
3492 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3493 "FP_SUBNORMAL, FP_ZERO, (x))";
3494 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3495 test_text =
3496 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3497 "#undef fpclassify\n"
3498 "#define fpclassify(x) __builtin_fpclassify(x)";
3502 * Solaris math signbit
3504 fix = {
3505 hackname = solaris_math_8;
3506 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3507 bypass = "__GNUC__";
3508 files = iso/math_c99.h;
3509 c_fix = format;
3510 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3511 "\t\t\t ? __builtin_signbitf(x) \\\n"
3512 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3513 "\t\t\t ? __builtin_signbitl(x) \\\n"
3514 "\t\t\t : __builtin_signbit(x))";
3515 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3516 test_text = <<- _EOText_
3517 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3518 #undef signbit
3519 #define signbit(x) __builtin_signbit(x)
3520 _EOText_;
3524 * Solaris math comparison macros
3526 fix = {
3527 hackname = solaris_math_9;
3528 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3529 bypass = "__GNUC__";
3530 files = iso/math_c99.h;
3531 c_fix = format;
3532 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3533 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3534 "__builtin_[a-z]+\\(y\\)\\)";
3535 test_text =
3536 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3537 "#undef isgreater\n"
3538 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3539 "#undef isgreaterequal\n"
3540 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3541 "#undef isless\n"
3542 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3543 "#undef islessequal\n"
3544 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3545 "#undef islessgreater\n"
3546 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3547 "#undef isunordered\n"
3548 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3552 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3553 * structure. As such, it need two levels of brackets, but only
3554 * contains one. Wrap the macro definition in an extra layer.
3556 fix = {
3557 hackname = solaris_once_init_1;
3558 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3559 files = pthread.h;
3560 mach = '*-*-solaris*';
3561 c_fix = format;
3562 c_fix_arg = "%1{%2}%3";
3563 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3564 test_text =
3565 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3566 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3570 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3571 * posix_spawn declarations, which doesn't work with C++.
3573 fix = {
3574 hackname = solaris_posix_spawn_restrict;
3575 files = spawn.h;
3576 mach = '*-*-solaris2*';
3577 c_fix = format;
3578 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3579 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3580 test_text =
3581 "char *const argv[_RESTRICT_KYWD],\n"
3582 "char *const envp[_RESTRICT_KYWD]);";
3586 * The pow overloads with int were removed in C++ 2011 DR 550.
3588 fix = {
3589 hackname = solaris_pow_int_overload;
3590 mach = '*-*-solaris2*';
3591 files = "iso/math_iso.h";
3592 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3593 " *\\{[^{}]*\n[^{}]*\\}";
3594 c_fix = format;
3595 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3597 test_text =
3598 " inline long double pow(long double __X, int __Y) { return\n"
3599 " __powl(__X, (long double) (__Y)); }";
3603 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3604 * fields of the pthread_rwlock_t structure, which are of type
3605 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3606 * defined (e.g. by -ansi) it is a union. So change the initializer
3607 * to "{0}" instead.
3609 fix = {
3610 hackname = solaris_rwlock_init_1;
3611 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3612 files = pthread.h;
3613 mach = '*-*-solaris*';
3614 c_fix = format;
3615 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3616 "%0\n"
3617 "#else\n"
3618 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3619 "#endif";
3620 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3621 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3623 test_text =
3624 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3625 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3629 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3630 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3632 fix = {
3633 hackname = solaris_std___filbuf;
3634 files = stdio.h;
3635 mach = '*-*-solaris2*';
3636 bypass = "using std::__filbuf";
3637 select = "(using std::perror;\n)(#endif)";
3638 c_fix = format;
3639 c_fix_arg = "%1#ifndef _LP64\n"
3640 "using std::__filbuf;\n"
3641 "using std::__flsbuf;\n"
3642 "#endif\n%2";
3644 test_text = "using std::perror;\n"
3645 "#endif";
3649 * Sun Solaris 8 has what appears to be some gross workaround for
3650 * some old version of their c++ compiler. G++ doesn't want it
3651 * either, but doesn't want to be tied to SunPRO version numbers.
3653 fix = {
3654 hackname = solaris_stdio_tag;
3655 files = stdio_tag.h;
3657 select = '__cplusplus < 54321L';
3658 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3659 "!defined(__GNUC__)" so we no longer need to fix it. */
3660 bypass = '__GNUC__';
3661 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3663 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3667 * a missing semi-colon at the end of the statsswtch structure definition.
3669 fix = {
3670 hackname = statsswtch;
3671 files = rpcsvc/rstat.h;
3672 select = "boottime$";
3673 c_fix = format;
3674 c_fix_arg = "boottime;";
3675 test_text = "struct statswtch {\n int boottime\n};";
3679 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3680 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3681 * OK too.
3683 fix = {
3684 hackname = stdio_stdarg_h;
3685 files = stdio.h;
3686 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3688 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3689 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3691 mach = '*-*-solaris2.1[0-9]*';
3692 not_machine = true;
3694 c_fix = wrap;
3696 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3698 test_text = "";
3702 * Don't use or define the name va_list in stdio.h. This is for
3703 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3704 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3705 * indicate that the header knows what it's doing -- under SUSv2,
3706 * stdio.h is required to define va_list, and we shouldn't break
3707 * that.
3709 fix = {
3710 hackname = stdio_va_list;
3711 files = stdio.h;
3712 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3714 * On Solaris 10, the definition in
3715 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3716 * there is therefore no need for this fix there.
3718 mach = '*-*-solaris2.1[0-9]*';
3719 not_machine = true;
3722 * Use __gnuc_va_list in arg types in place of va_list.
3723 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3724 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3725 * trailing parentheses and semicolon save all other systems from this.
3726 * Define __not_va_list__ (something harmless and unused)
3727 * instead of va_list.
3728 * Don't claim to have defined va_list.
3730 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3731 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3732 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3733 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3734 "s@ va_list@ __not_va_list__@\n"
3735 "s@\\*va_list@*__not_va_list__@\n"
3736 "s@ __va_list)@ __gnuc_va_list)@\n"
3737 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3738 "@typedef \\1 __not_va_list__;@\n"
3739 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3740 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3741 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3742 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3743 "s@VA_LIST@DUMMY_VA_LIST@\n"
3744 "s@_Va_LIST@_VA_LIST@";
3745 test_text = "extern void mumble( va_list);";
3749 * Fix headers that use va_list from stdio.h to use the updated
3750 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3751 * dealt with elsewhere. The presence of __gnuc_va_list,
3752 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3753 * knows what it's doing.
3755 fix = {
3756 hackname = stdio_va_list_clients;
3757 files = com_err.h;
3758 files = cps.h;
3759 files = curses.h;
3760 files = krb5.h;
3761 files = lc_core.h;
3762 files = pfmt.h;
3763 files = wchar.h;
3764 files = curses_colr/curses.h;
3765 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3766 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3767 otherwise protected. */
3768 bypass = 'include <stdarg\.h>|#ifdef va_start';
3771 * Use __gnuc_va_list in arg types in place of va_list.
3772 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3773 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3774 * trailing parentheses and semicolon save all other systems from this.
3775 * Define __not_va_list__ (something harmless and unused)
3776 * instead of va_list.
3777 * Don't claim to have defined va_list.
3779 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3780 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3781 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3782 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3783 "s@ va_list@ __not_va_list__@\n"
3784 "s@\\*va_list@*__not_va_list__@\n"
3785 "s@ __va_list)@ __gnuc_va_list)@\n"
3786 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3787 "@typedef \\1 __not_va_list__;@\n"
3788 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3789 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3790 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3791 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3792 "s@VA_LIST@DUMMY_VA_LIST@\n"
3793 "s@_Va_LIST@_VA_LIST@";
3794 test_text = "extern void mumble( va_list);";
3798 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3799 * is "!defined( __STRICT_ANSI__ )"
3801 fix = {
3802 hackname = strict_ansi_not;
3803 select = "^([ \t]*#[ \t]*if.*)"
3804 "(!__STDC__"
3805 "|__STDC__[ \t]*==[ \t]*0"
3806 "|__STDC__[ \t]*!=[ \t]*1"
3807 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3808 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3809 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3810 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3811 is not defined by GCC, so it is safe. */
3812 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3813 c_test = stdc_0_in_system_headers;
3815 c_fix = format;
3816 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3818 test_text = "#if !__STDC__ \n"
3819 "#if __STDC__ == 0\n"
3820 "#if __STDC__ != 1\n"
3821 "#if __STDC__ - 0 == 0"
3822 "/* not std C */\nint foo;\n"
3823 "\n#end-end-end-end-if :-)";
3827 * "__STDC__-0==0"
3828 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3830 fix = {
3831 hackname = strict_ansi_not_ctd;
3832 files = math.h, limits.h, stdio.h, signal.h,
3833 stdlib.h, sys/signal.h, time.h;
3835 * Starting at the beginning of a line, skip white space and
3836 * a leading "(" or "&&" or "||". One of those must be found.
3837 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3838 * expression. If these are nested, then they must accumulate
3839 * because we won't match any closing parentheses. Finally,
3840 * after skipping over all that, we must then match our suspect
3841 * phrase: "__STDC__-0==0" with or without white space.
3843 select = "^([ \t]*" '(\(|&&|\|\|)'
3844 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3845 "[ \t(]*)"
3846 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3847 c_test = stdc_0_in_system_headers;
3849 c_fix = format;
3850 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3852 test_text = "#if 1 && \\\\\n"
3853 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3854 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3855 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3856 "int foo;\n#endif";
3860 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3861 * is "defined( __STRICT_ANSI__ )"
3863 fix = {
3864 hackname = strict_ansi_only;
3865 select = "^([ \t]*#[ \t]*if.*)"
3866 "(__STDC__[ \t]*!=[ \t]*0"
3867 "|__STDC__[ \t]*==[ \t]*1"
3868 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3869 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3870 c_test = stdc_0_in_system_headers;
3872 c_fix = format;
3873 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3875 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3879 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3880 * in prototype without previous definition.
3882 fix = {
3883 hackname = struct_file;
3884 files = rpc/xdr.h;
3885 select = '^.*xdrstdio_create.*struct __file_s';
3886 c_fix = format;
3887 c_fix_arg = "struct __file_s;\n%0";
3888 test_text = "extern void xdrstdio_create( struct __file_s* );";
3892 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3893 * in prototype without previous definition.
3895 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3896 * function, and does define it.
3898 fix = {
3899 hackname = struct_sockaddr;
3900 files = rpc/auth.h;
3901 select = "^.*authdes_create.*struct sockaddr[^_]";
3902 bypass = "<sys/socket\.h>";
3903 bypass = "struct sockaddr;\n";
3904 c_fix = format;
3905 c_fix_arg = "struct sockaddr;\n%0";
3906 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3910 * Apply fix this to all OSs since this problem seems to effect
3911 * more than just SunOS.
3913 fix = {
3914 hackname = sun_auth_proto;
3915 files = rpc/auth.h;
3916 files = rpc/clnt.h;
3917 files = rpc/svc.h;
3918 files = rpc/xdr.h;
3919 bypass = "__cplusplus";
3921 * Select those files containing '(*name)()'.
3923 select = '\(\*[a-z][a-z_]*\)\(\)';
3925 c_fix = format;
3926 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3927 "#else\n%1();%2\n#endif";
3928 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3930 test_text =
3931 "struct auth_t {\n"
3932 " int (*name)(); /* C++ bad */\n"
3933 "};";
3937 * Fix bogus #ifdef on SunOS 4.1.
3939 fix = {
3940 hackname = sun_bogus_ifdef;
3941 files = "hsfs/hsfs_spec.h";
3942 files = "hsfs/iso_spec.h";
3943 select = '#ifdef(.*\|\|.*)';
3944 c_fix = format;
3945 c_fix_arg = "#if%1";
3947 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3951 * Fix the CAT macro in SunOS memvar.h.
3953 fix = {
3954 hackname = sun_catmacro;
3955 files = pixrect/memvar.h;
3956 select = "^#define[ \t]+CAT\\(a,b\\).*";
3957 c_fix = format;
3959 c_fix_arg =
3960 "#ifdef __STDC__\n"
3961 "# define CAT(a,b) a##b\n"
3962 "#else\n%0\n#endif";
3964 test_text =
3965 "#define CAT(a,b)\ta/**/b";
3969 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3970 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3972 fix = {
3973 hackname = sun_malloc;
3974 files = malloc.h;
3975 bypass = "_CLASSIC_ANSI_TYPES";
3977 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3978 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3979 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3980 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3981 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3983 test_text =
3984 "typedef char *\tmalloc_t;\n"
3985 "int \tfree();\n"
3986 "char*\tmalloc();\n"
3987 "char*\tcalloc();\n"
3988 "char*\trealloc();";
3992 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3994 fix = {
3995 hackname = sun_rusers_semi;
3996 files = rpcsvc/rusers.h;
3997 select = "_cnt$";
3998 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3999 test_text = "struct mumble\n int _cnt\n};";
4003 * signal.h on SunOS defines signal using (),
4004 * which causes trouble when compiling with g++ -pedantic.
4006 fix = {
4007 hackname = sun_signal;
4008 files = sys/signal.h;
4009 files = signal.h;
4010 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4012 c_fix = format;
4013 c_fix_arg =
4014 "#ifdef __cplusplus\n"
4015 "void\t(*signal(...))(...);\n"
4016 "#else\n%0\n#endif";
4018 test_text = "void\t(*signal())();";
4022 * Correct the return type for strlen in strings.h in SunOS 4.
4024 fix = {
4025 hackname = sunos_strlen;
4026 files = strings.h;
4027 select = "int[ \t]*strlen\\(\\);(.*)";
4028 c_fix = format;
4029 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4030 test_text = " int\tstrlen(); /* string length */";
4034 * Linux kernel's vt.h breaks C++
4036 fix = {
4037 hackname = suse_linux_vt_cxx;
4038 files = linux/vt.h;
4040 select = "^[ \t]*unsigned int new;";
4041 c_fix = format;
4042 c_fix_arg = "unsigned int newev;";
4044 test_text = " unsigned int new; /* New console (if changing) */";
4048 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4049 * that is visible to any ANSI compiler using this include. Simply
4050 * delete the lines that #define some string functions to internal forms.
4052 fix = {
4053 hackname = svr4_disable_opt;
4054 files = string.h;
4055 select = '#define.*__std_hdr_';
4056 sed = '/#define.*__std_hdr_/d';
4057 test_text = "#define strlen __std_hdr_strlen\n";
4061 * Fix broken decl of getcwd present on some svr4 systems.
4063 fix = {
4064 hackname = svr4_getcwd;
4065 files = stdlib.h;
4066 files = unistd.h;
4067 files = prototypes.h;
4068 select = 'getcwd\(char \*, int\)';
4070 c_fix = format;
4071 c_fix_arg = "getcwd(char *, size_t)";
4073 test_text = "extern char* getcwd(char *, int);";
4077 * Fix broken decl of profil present on some svr4 systems.
4079 fix = {
4080 hackname = svr4_profil;
4081 files = stdlib.h;
4082 files = unistd.h;
4084 select =
4085 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4086 c_fix = format;
4087 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4089 test_text =
4090 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4094 * Correct types for signal handler constants like SIG_DFL; they might be
4095 * void (*) (), and should be void (*) (int). C++ doesn't like the
4096 * old style.
4098 fix = {
4099 hackname = svr4_sighandler_type;
4100 files = sys/signal.h;
4101 select = 'void *\(\*\)\(\)';
4102 c_fix = format;
4103 c_fix_arg = "void (*)(int)";
4104 test_text = "#define SIG_DFL (void(*)())0\n"
4105 "#define SIG_IGN (void (*)())0\n";
4109 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4110 * function 'getrnge' in <regexp.h> before they declare it. For these
4111 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4112 * early on.
4114 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4115 * so put the declaration right after the declaration of 'size'.
4117 * Don't do this if there is already a `static void getrnge' declaration
4118 * present, since this would cause a redeclaration error. Solaris 2.x has
4119 * such a declaration.
4121 fix = {
4122 hackname = svr4_undeclared_getrnge;
4123 files = regexp.h;
4124 select = "getrnge";
4125 bypass = "static void getrnge";
4126 c_fix = format;
4127 c_fix_arg = "%0\n"
4128 "static int getrnge ();";
4129 c_fix_arg = "^static int[ \t]+size;";
4130 test_text = "static int size;\n"
4131 "/* stuff which calls getrnge() */\n"
4132 "static getrnge()\n"
4133 "{}";
4137 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4138 * in string.h on sysV68
4139 * Correct the return type for strlen in string.h on Lynx.
4140 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4141 * Add missing const for strdup on OSF/1 V3.0.
4142 * On sysV88 layout is slightly different.
4144 fix = {
4145 hackname = sysv68_string;
4146 files = testing.h;
4147 files = string.h;
4148 bypass = "_CLASSIC_ANSI_TYPES";
4150 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4151 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4152 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4154 sed = "/^extern char$/N";
4155 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4157 sed = "/^extern int$/N";
4158 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4160 sed = "/^\tstrncmp(),$/N";
4161 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4162 '\1;' "\\\nextern unsigned int\\\n\\2/";
4164 test_text =
4165 "extern int strlen();\n"
4167 "extern int ffs(long);\n"
4169 "extern char\n"
4170 "\t*memccpy(),\n"
4171 "\tmemcpy();\n"
4173 "extern int\n"
4174 "\tstrcmp(),\n"
4175 "\tstrncmp(),\n"
4176 "\tstrlen(),\n"
4177 "\tstrspn();\n"
4179 "extern int\n"
4180 "\tstrlen(), strspn();";
4184 * Fix return type of calloc, malloc, realloc, bsearch and exit
4186 fix = {
4187 hackname = sysz_stdlib_for_sun;
4188 files = stdlib.h;
4189 bypass = "_CLASSIC_ANSI_TYPES";
4191 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4192 c_fix = format;
4193 c_fix_arg = "void *\t%1(";
4195 test_text =
4196 "extern char*\tcalloc(size_t);\n"
4197 "extern char*\tmalloc(size_t);\n"
4198 "extern char*\trealloc(void*,size_t);\n"
4199 "extern char*\tbsearch(void*,size_t,size_t);\n";
4203 * __thread is now a keyword.
4205 fix = {
4206 hackname = thread_keyword;
4207 files = "pthread.h";
4208 files = bits/sigthread.h, '*/bits/sigthread.h';
4209 select = "([* ])__thread([,)])";
4210 c_fix = format;
4211 c_fix_arg = "%1__thr%2";
4213 test_text =
4214 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4215 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4216 "extern int pthread_cancel (pthread_t __thread);";
4220 * if the #if says _cplusplus, not the double underscore __cplusplus
4221 * that it should be
4223 fix = {
4224 hackname = tinfo_cplusplus;
4225 files = tinfo.h;
4226 select = "[ \t]_cplusplus";
4228 c_fix = format;
4229 c_fix_arg = " __cplusplus";
4230 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4234 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4236 fix = {
4237 hackname = ultrix_const;
4238 files = stdio.h;
4239 select = 'perror\( char \*';
4241 c_fix = format;
4242 c_fix_arg = "%1 const %3 *__";
4243 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4244 "[ \t]+(char|void) \\*__";
4246 test_text =
4247 "extern void perror( char *__s );\n"
4248 "extern int fputs( char *__s, FILE *);\n"
4249 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4250 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4251 "extern int scanf( char *__format, ...);\n";
4255 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4257 fix = {
4258 hackname = ultrix_const2;
4259 files = stdio.h;
4261 select = '\*fopen\( char \*';
4262 c_fix = format;
4263 c_fix_arg = "%1( const char *%3, const char *";
4264 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4265 "[ \t]*char[ \t]*\\*([^,]*),"
4266 "[ \t]*char[ \t]*\\*[ \t]*";
4268 test_text =
4269 "extern FILE *fopen( char *__filename, char *__type );\n"
4270 "extern int sscanf( char *__s, char *__format, ...);\n"
4271 "extern FILE *popen(char *, char *);\n"
4272 "extern char *tempnam(char*,char*);\n";
4276 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4278 fix = {
4279 hackname = va_i960_macro;
4280 files = arch/i960/archI960.h;
4281 select = "__(vsiz|vali|vpad|alignof__)";
4283 c_fix = format;
4284 c_fix_arg = "__vx%1";
4286 test_text =
4287 "extern int __vsiz vsiz;\n"
4288 "extern int __vali vali;\n"
4289 "extern int __vpad vpad;\n"
4290 "#define __alignof__(x) ...";
4294 * On VMS, add missing braces around sigset_t constants.
4296 fix = {
4297 hackname = vms_add_missing_braces;
4298 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4299 mach = "*-*-*vms*";
4300 files = "rtldef/signal.h";
4301 c_fix = format;
4303 c_fix_arg = '%1 {%2} ';
4305 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4306 "{0x00000000, 0x00000000},\n"
4307 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4311 * On VMS, some DEC-C builtins are directly used.
4313 fix = {
4314 hackname = vms_decc_builtin;
4315 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4316 mach = "*-*-*vms*";
4317 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4318 rtldef/socket.h;
4319 sed = "s@__MEMSET@memset@";
4320 sed = "s@__MEMMOVE@memmove@";
4321 sed = "s@__MEMCPY@memcpy@";
4322 sed = "s@__STRLEN@strlen@";
4323 sed = "s@__STRCPY@strcpy@";
4325 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4329 * Define __CAN_USE_EXTERN_PREFIX on vms.
4331 fix = {
4332 hackname = vms_define_can_use_extern_prefix;
4333 files = "rtldef/decc$types.h";
4334 select = "#[ \t]*else\n"
4335 "#[ \t]*if defined\\(__DECCXX\\)\n"
4336 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4337 mach = "*-*-*vms*";
4338 c_fix = format;
4340 c_fix_arg = "%0"
4341 "# elif defined (__GNUC__)\n"
4342 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4344 test_text = "# else\n"
4345 "# if defined(__DECCXX)\n"
4346 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4347 "# endif\n"
4348 "# endif\n";
4352 * On VMS, disable the use of dec-c string builtins
4354 fix = {
4355 hackname = vms_disable_decc_string_builtins;
4356 select = "#if !defined\\(__VAX\\)\n";
4357 mach = "*-*-*vms*";
4358 files = "rtldef/string.h";
4359 c_fix = format;
4361 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4363 test_text = "#if !defined(__VAX)\n";
4367 * On VMS, fix incompatible redeclaration of hostalias.
4369 fix = {
4370 hackname = vms_do_not_redeclare_hostalias;
4371 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4372 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4373 mach = "*-*-*vms*";
4374 files = "rtldef/resolv.h";
4375 c_fix = format;
4377 c_fix_arg = "%1\n"
4378 "/* %2 */";
4380 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4381 "__char_ptr32 hostalias (const char *);\n";
4385 * On VMS, forward declare structure before referencing them in prototypes.
4387 fix = {
4388 hackname = vms_forward_declare_struct;
4389 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4390 "#ifdef __cplusplus\n";
4391 mach = "*-*-*vms*";
4392 files = rtldef/if.h;
4393 c_fix = format;
4395 c_fix_arg = "%1"
4396 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4398 test_text = "/* forward decls for C++ */\n"
4399 "#ifdef __cplusplus\n"
4400 "struct foo;\n"
4401 "#endif\n";
4405 * On VMS, do not declare getopt and al if pointers are 64 bit.
4407 fix = {
4408 hackname = vms_no_64bit_getopt;
4409 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4410 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4411 mach = "*-*-*vms*";
4412 files = rtldef/stdio.h, rtldef/unistd.h;
4413 c_fix = format;
4415 c_fix_arg = <<- _EOArg_
4416 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4417 %0#endif
4419 _EOArg_;
4421 test_text = "int getopt (int, char * const [], const char *);";
4425 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4426 * which is not yet fully supported by gcc.
4428 fix = {
4429 hackname = vms_use_fast_setjmp;
4430 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4431 mach = "*-*-*vms*";
4432 files = rtldef/setjmp.h;
4433 c_fix = format;
4435 c_fix_arg = "%0 defined (__GNUC__) ||";
4437 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4441 * On VMS, use pragma extern_model instead of VAX-C keywords.
4443 fix = {
4444 hackname = vms_use_pragma_extern_model;
4445 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4446 "# pragma extern_model __save\n";
4447 mach = "*-*-*vms*";
4448 c_fix = format;
4450 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4451 "# pragma extern_model __save\n";
4453 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4454 "# pragma extern_model __save\n"
4455 "# pragma extern_model strict_refdef\n"
4456 " extern struct x zz$yy;\n"
4457 "# pragma extern_model __restore\n"
4458 "#endif\n";
4462 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4463 * conflict while building gcc. Likewise for <builtins.h>
4465 fix = {
4466 hackname = vms_use_quoted_include;
4467 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4468 mach = "*-*-*vms*";
4469 files = rtldef/wait.h, starlet_c/pthread.h;
4470 c_fix = format;
4472 c_fix_arg = '%1<sys/%2.h>';
4474 test_text = "# include <resource.h>";
4478 * AIX and Interix headers define NULL to be cast to a void pointer,
4479 * which is illegal in ANSI C++.
4481 fix = {
4482 hackname = void_null;
4483 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4484 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4485 /* avoid changing C++ friendly NULL */
4486 bypass = __cplusplus;
4487 bypass = __null;
4488 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4489 c_fix = format;
4490 c_fix_arg = <<- _EOFix_
4491 #ifndef NULL
4492 #ifdef __cplusplus
4493 #ifdef __GNUG__
4494 #define NULL __null
4495 #else /* ! __GNUG__ */
4496 #define NULL 0L
4497 #endif /* __GNUG__ */
4498 #else /* ! __cplusplus */
4499 #define NULL ((void *)0)
4500 #endif /* __cplusplus */
4501 #endif /* !NULL */
4502 _EOFix_;
4503 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4507 * Make VxWorks header which is almost gcc ready fully gcc ready.
4509 fix = {
4510 hackname = vxworks_gcc_problem;
4511 files = types/vxTypesBase.h;
4512 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4514 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4515 "#if 1/";
4517 sed = "/[ \t]size_t/i\\\n"
4518 "#ifndef _GCC_SIZE_T\\\n"
4519 "#define _GCC_SIZE_T\n";
4521 sed = "/[ \t]size_t/a\\\n"
4522 "#endif\n";
4524 sed = "/[ \t]ptrdiff_t/i\\\n"
4525 "#ifndef _GCC_PTRDIFF_T\\\n"
4526 "#define _GCC_PTRDIFF_T\n";
4528 sed = "/[ \t]ptrdiff_t/a\\\n"
4529 "#endif\n";
4531 sed = "/[ \t]wchar_t/i\\\n"
4532 "#ifndef _GCC_WCHAR_T\\\n"
4533 "#define _GCC_WCHAR_T\n";
4535 sed = "/[ \t]wchar_t/a\\\n"
4536 "#endif\n";
4538 test_text =
4539 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4540 "typedef unsigned int size_t;\n"
4541 "typedef long ptrdiff_t;\n"
4542 "typedef unsigned short wchar_t;\n"
4543 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4547 * Wrap VxWorks ioctl to keep everything pretty
4549 fix = {
4550 hackname = vxworks_ioctl_macro;
4551 files = ioLib.h;
4552 mach = "*-*-vxworks*";
4554 c_fix = format;
4555 c_fix_arg = "%0\n"
4556 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4557 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4559 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4563 * Wrap VxWorks mkdir to be posix compliant
4565 fix = {
4566 hackname = vxworks_mkdir_macro;
4567 files = sys/stat.h;
4568 mach = "*-*-vxworks*";
4570 c_fix = format;
4571 c_fix_arg = "%0\n"
4572 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4573 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4574 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4575 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4576 "\\)[\t ]*;";
4578 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4582 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4584 fix = {
4585 hackname = vxworks_needs_vxtypes;
4586 files = time.h;
4587 select = "uint_t([ \t]+_clocks_per_sec)";
4588 c_fix = format;
4589 c_fix_arg = "unsigned int%1";
4590 test_text = "uint_t\t_clocks_per_sec;";
4594 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4596 fix = {
4597 hackname = vxworks_needs_vxworks;
4598 files = sys/stat.h;
4599 test = " -r types/vxTypesOld.h";
4600 test = " -n \"`egrep '#include' $file`\"";
4601 test = " -n \"`egrep ULONG $file`\"";
4602 select = "#[ \t]define[ \t]+__INCstath";
4604 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4605 "#include <types/vxTypesOld.h>\n";
4607 test_text = "`touch types/vxTypesOld.h`"
4608 "#include </dev/null> /* ULONG */\n"
4609 "# define\t__INCstath <sys/stat.h>";
4613 * Make it so VxWorks does not include gcc/regs.h accidentally
4615 fix = {
4616 hackname = vxworks_regs;
4617 mach = "*-*-vxworks*";
4619 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4620 c_fix = format;
4621 c_fix_arg = "#include <arch/../regs.h>";
4623 test_text = "#include <regs.h>\n";
4627 * Another bad dependency in VxWorks 5.2 <time.h>.
4629 fix = {
4630 hackname = vxworks_time;
4631 files = time.h;
4632 test = " -r vxWorks.h";
4634 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4635 c_fix = format;
4637 c_fix_arg =
4638 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4639 "#ifdef __cplusplus\n"
4640 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4641 "#else\n"
4642 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4643 "#endif\n"
4644 "#define __gcc_VOIDFUNCPTR_defined\n"
4645 "#endif\n"
4646 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4648 test_text = "`touch vxWorks.h`"
4649 "#define VOIDFUNCPTR (void(*)())";
4653 * This hack makes write const-correct on VxWorks
4655 fix = {
4656 hackname = vxworks_write_const;
4657 files = ioLib.h;
4658 mach = "*-*-vxworks*";
4660 c_fix = format;
4661 c_fix_arg = "extern int write (int, const char*, size_t);";
4662 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4663 "[\t ]*int[\t ]*,"
4664 "[\t ]*char[\t ]*\\*[\t ]*,"
4665 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4667 test_text = "extern int write ( int , char * , size_t ) ;";
4671 * There are several name conflicts with C++ reserved words in X11 header
4672 * files. These are fixed in some versions, so don't do the fixes if
4673 * we find __cplusplus in the file. These were found on the RS/6000.
4675 fix = {
4676 hackname = x11_class;
4677 files = X11/ShellP.h;
4678 bypass = __cplusplus;
4679 select = "^([ \t]*char \\*)class;(.*)";
4680 c_fix = format;
4681 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4682 "#else\n%1class;%2\n#endif";
4683 test_text =
4684 "struct {\n"
4685 " char *class;\n"
4686 "} mumble;\n";
4690 * class in Xm/BaseClassI.h
4692 fix = {
4693 hackname = x11_class_usage;
4694 files = Xm/BaseClassI.h;
4695 bypass = "__cplusplus";
4697 select = " class\\)";
4698 c_fix = format;
4699 c_fix_arg = " c_class)";
4701 test_text = "extern mumble (int class);\n";
4705 * new in Xm/Traversal.h
4707 fix = {
4708 hackname = x11_new;
4709 files = Xm/Traversal.h;
4710 bypass = __cplusplus;
4712 sed = "/Widget\told, new;/i\\\n"
4713 "#ifdef __cplusplus\\\n"
4714 "\\\tWidget\told, c_new;\\\n"
4715 "#else\n";
4717 sed = "/Widget\told, new;/a\\\n"
4718 "#endif\n";
4720 sed = "s/Widget new,/Widget c_new,/g";
4721 test_text =
4722 "struct wedge {\n"
4723 " Widget\told, new;\n"
4724 "};\nextern Wedged( Widget new, Widget old );";
4728 * Incorrect sprintf declaration in X11/Xmu.h
4730 fix = {
4731 hackname = x11_sprintf;
4732 files = X11/Xmu.h;
4733 files = X11/Xmu/Xmu.h;
4734 select = "^extern char \\*\tsprintf\\(\\);$";
4736 c_fix = format;
4737 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4739 test_text = "extern char *\tsprintf();";
4741 /*EOF*/