toplevel/
[official-gcc.git] / fixincludes / inclhack.def
blob8a26f2837ba9550c617c05caf38faa3db7791670
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
61 #endif
62 #endif
64 _EOArg_;
69 * On Mac OS 10.3.9, the 'long double' functions are available in
70 * libSystem, but are not prototyped in math.h.
72 fix = {
73 hackname = AAB_darwin7_9_long_double_funcs;
74 mach = "*-*-darwin7.9*";
75 files = architecture/ppc/math.h;
76 bypass = "powl";
77 replace = <<- _EndOfHeader_
78 /* This file prototypes the long double functions available on Mac OS
79 10.3.9. */
80 #ifndef __MATH__
81 # undef __APPLE_CC__
82 # define __APPLE_CC__ 1345
83 # include_next <architecture/ppc/math.h>
84 # undef __APPLE_CC__
85 # define __APPLE_CC__ 1
86 # ifndef __LIBMLDBL_COMPAT
87 # ifdef __LONG_DOUBLE_128__
88 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
89 # else
90 # define __LIBMLDBL_COMPAT(sym)
91 # endif /* __LONG_DOUBLE_128__ */
92 # endif /* __LIBMLDBL_COMPAT */
93 # ifdef __cplusplus
94 extern "C" {
95 # endif
96 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
97 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
98 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
99 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
100 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
101 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
102 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
103 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
104 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
105 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
106 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
107 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
108 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
109 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
110 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
111 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
112 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
113 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
114 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
115 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
116 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
117 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
118 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
119 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
120 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
121 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
122 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
123 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
124 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
125 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
126 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
127 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
128 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
129 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
130 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
131 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
132 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
133 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
134 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
135 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
136 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
137 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
138 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
139 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
140 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
141 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
142 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
143 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
144 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
145 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
146 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
147 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
148 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
149 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
150 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
151 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
152 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
153 # ifdef __cplusplus
155 # endif
156 #endif /* __MATH__ */
157 _EndOfHeader_;
162 * ... and for the previous fix to be useful, you have to not use ""
163 * includes.
165 fix = {
166 hackname = AAB_darwin7_9_long_double_funcs_2;
167 mach = "*-*-darwin7.9*";
168 files = math.h;
169 select = '#include[ \t]+\"';
170 c_fix = format;
171 c_fix_arg = "%1<%2.h>";
173 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
175 test_text = '#include "architecture/ppc/math.h"';
180 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
182 fix = {
183 hackname = AAB_fd_zero_asm_posix_types_h;
184 files = asm/posix_types.h;
185 mach = 'i[34567]86-*-linux*';
186 bypass = '} while';
187 bypass = 'x86_64';
188 bypass = 'posix_types_64';
191 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
192 * the start, so that if #include_next gets another instance of
193 * the wrapper, this will follow the #include_next chain until
194 * we arrive at the real <asm/posix_types.h>.
196 replace = <<- _EndOfHeader_
197 /* This file fixes a bug in the __FD_ZERO macro
198 for older versions of the Linux kernel. */
199 #ifndef _POSIX_TYPES_H_WRAPPER
200 #include <features.h>
201 #include_next <asm/posix_types.h>
203 #if defined(__FD_ZERO) && !defined(__GLIBC__)
204 #undef __FD_ZERO
205 #define __FD_ZERO(fdsetp) \
206 do { \
207 int __d0, __d1; \
208 __asm__ __volatile__("cld ; rep ; stosl" \
209 : "=&c" (__d0), "=&D" (__d1) \
210 : "a" (0), "0" (__FDSET_LONGS), \
211 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
212 } while (0)
213 #endif
215 #define _POSIX_TYPES_H_WRAPPER
216 #endif /* _POSIX_TYPES_H_WRAPPER */
217 _EndOfHeader_;
222 * This fixes __FD_ZERO bug for glibc-1.x
224 fix = {
225 hackname = AAB_fd_zero_gnu_types_h;
226 files = gnu/types.h;
227 mach = 'i[34567]86-*-linux*';
230 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
231 * the start, so that if #include_next gets another instance of
232 * the wrapper, this will follow the #include_next chain until
233 * we arrive at the real <gnu/types.h>.
235 replace = <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
237 #ifndef _TYPES_H_WRAPPER
238 #include <features.h>
239 #include_next <gnu/types.h>
241 #if defined(__FD_ZERO) && !defined(__GLIBC__)
242 #undef __FD_ZERO
243 # define __FD_ZERO(fdsetp) \
244 do { \
245 int __d0, __d1; \
246 __asm__ __volatile__("cld ; rep ; stosl" \
247 : "=&c" (__d0), "=&D" (__d1) \
248 : "a" (0), "0" (__FDSET_LONGS), \
249 "1" ((__fd_set *) (fdsetp)) :"memory"); \
250 } while (0)
251 #endif
253 #define _TYPES_H_WRAPPER
254 #endif /* _TYPES_H_WRAPPER */
255 _EndOfHeader_;
260 * This fixes __FD_ZERO bug for glibc-2.0.x
262 fix = {
263 hackname = AAB_fd_zero_selectbits_h;
264 files = selectbits.h;
265 mach = 'i[34567]86-*-linux*';
268 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
269 * the start, so that if #include_next gets another instance of
270 * the wrapper, this will follow the #include_next chain until
271 * we arrive at the real <selectbits.h>.
273 replace = <<- _EndOfHeader_
274 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
275 #ifndef _SELECTBITS_H_WRAPPER
276 #include <features.h>
277 #include_next <selectbits.h>
279 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
280 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
281 && __GLIBC_MINOR__ == 0
282 #undef __FD_ZERO
283 #define __FD_ZERO(fdsetp) \\
284 do { \\
285 int __d0, __d1; \\
286 __asm__ __volatile__ ("cld; rep; stosl" \\
287 : "=&c" (__d0), "=&D" (__d1) \\
288 : "a" (0), "0" (sizeof (__fd_set) \\
289 / sizeof (__fd_mask)), \\
290 "1" ((__fd_mask *) (fdsetp)) \\
291 : "memory"); \\
292 } while (0)
293 #endif
295 #define _SELECTBITS_H_WRAPPER
296 #endif /* _SELECTBITS_H_WRAPPER */
297 _EndOfHeader_;
302 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
303 * the same interface as <stdarg.h>. No idea why they couldn't have just
304 * used the standard header.
306 fix = {
307 hackname = AAB_solaris_sys_varargs_h;
308 files = "sys/varargs.h";
309 mach = '*-*-solaris*';
310 replace = <<- _EndOfHeader_
311 #ifdef __STDC__
312 #include <stdarg.h>
313 #else
314 #include <varargs.h>
315 #endif
316 _EndOfHeader_;
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
322 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
323 * many other systems have similar text but correct versions of the file.
324 * To ensure only Sun's is fixed, we grep for a likely unique string.
325 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
327 fix = {
328 hackname = AAB_sun_memcpy;
329 files = memory.h;
330 select = "/\\*\t@\\(#\\)"
331 "(head/memory.h\t50.1\t "
332 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
334 replace = <<- _EndOfHeader_
335 /* This file was generated by fixincludes */
336 #ifndef __memory_h__
337 #define __memory_h__
339 #ifdef __STDC__
340 extern void *memccpy();
341 extern void *memchr();
342 extern void *memcpy();
343 extern void *memset();
344 #else
345 extern char *memccpy();
346 extern char *memchr();
347 extern char *memcpy();
348 extern char *memset();
349 #endif /* __STDC__ */
351 extern int memcmp();
353 #endif /* __memory_h__ */
354 _EndOfHeader_;
359 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
360 * which only is provided by AIX xlc C99.
362 fix = {
363 hackname = aix_complex;
364 mach = "*-*-aix*";
365 files = complex.h;
366 select = "#define[ \t]_Complex_I[ \t]__I";
367 c_fix = format;
368 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
369 test_text = "#define _Complex_I __I\n";
373 * malloc.h on AIX6 uses XLC++ specific builtin syntax
375 fix = {
376 hackname = aix_malloc;
377 mach = "*-*-aix*";
378 files = "malloc.h";
379 select = "#ifdef __cplusplus";
380 c_fix = format;
381 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
382 test_text = "#ifdef __cplusplus";
386 * net/if_arp.h defines a variable fc_softc instead of adding a
387 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
389 fix = {
390 hackname = aix_net_if_arp;
391 mach = "*-*-aix*";
392 files = "net/if_arp.h";
393 select = "^struct fc_softc \\{";
394 c_fix = format;
395 c_fix_arg = "typedef struct _fc_softc {";
396 test_text = "struct fc_softc {\n int a;\n};";
400 * pthread.h on AIX defines PTHREAD_ONCE_INIT without enough braces.
402 fix = {
403 hackname = aix_once_init_1;
404 mach = "*-*-aix*";
405 files = "pthread.h";
406 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
407 "\\{ \\\\\n";
408 c_fix = format;
409 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
410 "{{ \\\n";
411 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
412 "{ \\\\\n";
415 fix = {
416 hackname = aix_once_init_2;
417 mach = "*-*-aix*";
418 files = "pthread.h";
419 select = "[ \t]0 \\\\\n"
420 "\\}\n";
421 c_fix = format;
422 c_fix_arg = " 0 \\\n"
423 "}}\n";
424 test_text = " 0 \\\\\n"
425 "}\n";
429 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
430 * which violates a requirement of ISO C.
432 fix = {
433 hackname = aix_pthread;
434 files = "pthread.h";
435 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
436 c_fix = format;
437 c_fix_arg = "%1 %2";
438 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
439 "{...init stuff...}";
444 * AIX stdint.h fixes.
446 fix = {
447 hackname = aix_stdint_1;
448 mach = "*-*-aix*";
449 files = stdint-aix.h, stdint.h;
450 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
451 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
452 c_fix = format;
453 c_fix_arg = "#define UINT8_MAX (255)\n"
454 "#define UINT16_MAX (65535)";
455 test_text = "#define UINT8_MAX (255U)\n"
456 "#define UINT16_MAX (65535U)";
460 fix = {
461 hackname = aix_stdint_2;
462 mach = "*-*-aix*";
463 files = stdint-aix.h, stdint.h;
464 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
465 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
466 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
467 "#else\n"
468 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
469 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
470 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
471 c_fix = format;
472 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
473 "#define INTPTR_MAX 9223372036854775807L\n"
474 "#define UINTPTR_MAX 18446744073709551615UL\n"
475 "#else\n"
476 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
477 "#define INTPTR_MAX 2147483647L\n"
478 "#define UINTPTR_MAX 4294967295UL";
479 test_text = "#define INTPTR_MIN INT64_MIN\n"
480 "#define INTPTR_MAX INT64_MAX\n"
481 "#define UINTPTR_MAX UINT64_MAX\n"
482 "#else\n"
483 "#define INTPTR_MIN INT32_MIN\n"
484 "#define INTPTR_MAX INT32_MAX\n"
485 "#define UINTPTR_MAX UINT32_MAX";
489 fix = {
490 hackname = aix_stdint_3;
491 mach = "*-*-aix*";
492 files = stdint-aix.h, stdint.h;
493 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
494 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
495 "#else\n"
496 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
497 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
498 c_fix = format;
499 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
500 "#define PTRDIFF_MAX 9223372036854775807L\n"
501 "#else\n"
502 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
503 "#define PTRDIFF_MAX 2147483647L";
504 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
505 "#define PTRDIFF_MAX INT64_MAX\n"
506 "#else\n"
507 "#define PTRDIFF_MIN INT32_MIN\n"
508 "#define PTRDIFF_MAX INT32_MAX";
512 fix = {
513 hackname = aix_stdint_4;
514 mach = "*-*-aix*";
515 files = stdint-aix.h, stdint.h;
516 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
517 "#else\n"
518 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
519 c_fix = format;
520 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
521 "#else\n"
522 "#define SIZE_MAX 4294967295UL";
523 test_text = "#define SIZE_MAX UINT64_MAX\n"
524 "#else\n"
525 "#define SIZE_MAX UINT32_MAX";
529 fix = {
530 hackname = aix_stdint_5;
531 mach = "*-*-aix*";
532 files = stdint-aix.h, stdint.h;
533 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
534 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
535 c_fix = format;
536 c_fix_arg = "#define UINT8_C(c) c\n"
537 "#define UINT16_C(c) c";
538 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
539 "#define UINT16_C(c) __CONCAT__(c,U)";
544 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
545 * in an otherwise harmless (and #ifed out) macro definition
547 fix = {
548 hackname = aix_sysmachine;
549 files = sys/machine.h;
550 select = "\\\\ +\n";
551 c_fix = format;
552 c_fix_arg = "\\\n";
553 test_text = "#define FOO \\\n"
554 " bar \\ \n baz \\ \n bat";
559 * sys/wait.h on AIX 5.2 defines macros that have both signed and
560 * unsigned types in conditional expressions.
562 fix = {
563 hackname = aix_syswait_2;
564 files = sys/wait.h;
565 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
566 c_fix = format;
567 c_fix_arg = "? (int)%1";
568 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
573 * sys/signal.h on some versions of AIX uses volatile in the typedef of
574 * sig_atomic_t, which causes gcc to generate a warning about duplicate
575 * volatile when a sig_atomic_t variable is declared volatile, as
576 * required by ANSI C.
578 fix = {
579 hackname = aix_volatile;
580 files = sys/signal.h;
581 select = "typedef volatile int sig_atomic_t";
582 c_fix = format;
583 c_fix_arg = "typedef int sig_atomic_t";
584 test_text = "typedef volatile int sig_atomic_t;";
589 * Fix __assert declaration in assert.h on Alpha OSF/1.
591 fix = {
592 hackname = alpha___assert;
593 files = "assert.h";
594 select = '__assert\(char \*, char \*, int\)';
595 c_fix = format;
596 c_fix_arg = "__assert(const char *, const char *, int)";
597 test_text = 'extern void __assert(char *, char *, int);';
602 * Fix assert macro in assert.h on Alpha OSF/1.
603 * The superfluous int cast breaks C++.
605 fix = {
606 hackname = alpha_assert;
607 files = "assert.h";
608 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
609 c_fix = format;
610 c_fix_arg = "%1(EX)";
611 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
612 ': __assert(#EX, __FILE__, __LINE__))';
617 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
619 fix = {
620 hackname = alpha_getopt;
621 files = "stdio.h";
622 files = "stdlib.h";
623 select = 'getopt\(int, char \*\[\], *char \*\)';
624 c_fix = format;
625 c_fix_arg = "getopt(int, char *const[], const char *)";
626 test_text = 'extern int getopt(int, char *[], char *);';
631 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
633 fix = {
634 hackname = alpha_if_semicolon;
635 files = net/if.h;
636 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
637 c_fix = format;
638 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
639 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
644 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
646 fix = {
647 hackname = alpha_parens;
648 files = sym.h;
649 select = '#ifndef\(__mips64\)';
650 c_fix = format;
651 c_fix_arg = "#ifndef __mips64";
652 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
657 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
658 * And OpenBSD.
660 fix = {
661 hackname = alpha_sbrk;
662 files = unistd.h;
663 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
664 c_fix = format;
665 c_fix_arg = "void *sbrk(";
666 test_text = "extern char* sbrk(ptrdiff_t increment);";
671 * For C++, avoid any typedef or macro definition of bool,
672 * and use the built in type instead.
673 * HP/UX 10.20 also has it in curses_colr/curses.h.
675 fix = {
676 hackname = avoid_bool_define;
677 files = curses.h;
678 files = curses_colr/curses.h;
679 files = term.h;
680 files = tinfo.h;
682 select = "#[ \t]*define[ \t]+bool[ \t]";
683 bypass = "__cplusplus";
685 c_fix = format;
686 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
687 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
689 test_text = "# define bool\t char \n";
693 fix = {
694 hackname = avoid_bool_type;
695 files = curses.h;
696 files = curses_colr/curses.h;
697 files = term.h;
698 files = tinfo.h;
700 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
701 bypass = "__cplusplus";
703 c_fix = format;
704 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
706 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
711 * For C++, avoid any typedef definition of wchar_t,
712 * and use the built in type instead.
713 * Don't do this for headers that are smart enough to do the right
714 * thing (recent [n]curses.h and Xlib.h).
715 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
716 * and will be broken by the edit.
719 fix = {
720 hackname = avoid_wchar_t_type;
722 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
723 bypass = "__cplusplus";
724 bypass = "_LINUX_NLS_H";
725 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
727 c_fix = format;
728 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
730 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
735 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
737 fix = {
738 hackname = bad_struct_term;
739 files = curses.h;
740 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
741 c_fix = format;
742 c_fix_arg = "struct term;";
744 test_text = 'typedef struct term;';
749 * Fix one other error in this file:
750 * a mismatched quote not inside a C comment.
752 fix = {
753 hackname = badquote;
754 files = sundev/vuid_event.h;
755 select = "doesn't";
756 c_fix = format;
757 c_fix_arg = "does not";
759 test_text = "/* doesn't have matched single quotes */";
764 * check for broken assert.h that needs stdio.h
766 fix = {
767 hackname = broken_assert_stdio;
768 files = assert.h;
769 select = stderr;
770 bypass = "include.*stdio\\.h";
771 c_fix = wrap;
772 c_fix_arg = "#include <stdio.h>\n";
773 test_text = "extern FILE* stderr;";
778 * check for broken assert.h that needs stdlib.h
780 fix = {
781 hackname = broken_assert_stdlib;
782 files = assert.h;
783 select = 'exit *\(|abort *\(';
784 bypass = "include.*stdlib\\.h";
785 c_fix = wrap;
786 c_fix_arg = "#ifdef __cplusplus\n"
787 "#include <stdlib.h>\n"
788 "#endif\n";
789 test_text = "extern void exit ( int );";
794 * Remove `extern double cabs' declarations from math.h.
795 * This conflicts with C99. Discovered on AIX.
796 * Darwin hides its broken cabs in architecture-specific subdirs.
798 fix = {
799 hackname = broken_cabs;
800 files = math.h, "architecture/*/math.h";
801 select = "^extern[ \t]+double[ \t]+cabs";
803 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
804 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
806 test_text = "#ifdef __STDC__\n"
807 "extern double cabs(struct dbl_hypot);\n"
808 "#else\n"
809 "extern double cabs();\n"
810 "#endif\n"
811 "extern double cabs ( _Complex z );";
816 * Fixup Darwin's broken check for __builtin_nanf.
818 fix = {
819 hackname = broken_nan;
821 * It is tempting to omit the first "files" entry. Do not.
822 * The testing machinery will take the first "files" entry as the name
823 * of a test file to play with. It would be a nuisance to have a directory
824 * with the name "*".
826 files = "architecture/ppc/math.h";
827 files = "architecture/*/math.h";
828 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
829 bypass = "powl";
830 c_fix = format;
831 c_fix_arg = "#if 1";
832 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
837 * Various systems derived from BSD4.4 contain a macro definition
838 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
839 * Known to be fixed in FreeBSD 5 system headers.
841 fix = {
842 hackname = bsd_stdio_attrs_conflict;
843 mach = "*-*-*bsd*";
844 mach = "*-*-*darwin*";
845 files = stdio.h;
846 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
847 c_fix = format;
848 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
849 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
850 'int vfscanf(FILE *, const char *, __builtin_va_list) '
851 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
852 test_text = '#define vfscanf __svfscanf';
856 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
857 * that it conforms to ISO/IEC 14882:2011. It currently does
858 * not support the [[noreturn]] procedure attribute.
859 * When it does, this hack should be removed.
860 * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
862 fix = {
863 hackname = cdef_cplusplus;
864 files = sys/cdefs.h;
865 select = '\[\[noreturn\]\]';
866 c_fix = format;
867 c_fix_arg = '__attribute__((__noreturn__))';
868 test_text = "#define _Noreturn [[noreturn]]";
872 * Fix various macros used to define ioctl numbers.
873 * The traditional syntax was:
875 * #define _CTRL(n, x) (('n'<<8)+x)
876 * #define TCTRLCFOO _CTRL(T, 1)
878 * but this does not work with the C standard, which disallows macro
879 * expansion inside strings. We have to rewrite it thus:
881 * #define _CTRL(n, x) ((n<<8)+x)
882 * #define TCTRLCFOO _CTRL('T', 1)
884 * The select expressions match too much, but the c_fix code is cautious.
886 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
888 fix = {
889 hackname = ctrl_quotes_def;
890 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
891 c_fix = char_macro_def;
892 c_fix_arg = "CTRL";
895 * This is two tests in order to ensure that the "CTRL(c)" can
896 * be selected in isolation from the multi-arg format
898 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
899 test_text = "#define _CTRL(c) ('c'&037)";
902 fix = {
903 hackname = ctrl_quotes_use;
904 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
905 c_fix = char_macro_use;
906 c_fix_arg = "CTRL";
907 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
912 * sys/mman.h on HP/UX is not C++ ready,
913 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
915 * rpc/types.h on OSF1/2.0 is not C++ ready,
916 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
918 * The problem is the declaration of malloc.
920 fix = {
921 hackname = cxx_unready;
922 files = sys/mman.h;
923 files = rpc/types.h;
924 select = '[^#]+malloc.*;'; /* Catch any form of declaration
925 not within a macro. */
926 bypass = '"C"|__BEGIN_DECLS';
928 c_fix = wrap;
929 c_fix_arg = "#ifdef __cplusplus\n"
930 "extern \"C\" {\n"
931 "#endif\n";
932 c_fix_arg = "#ifdef __cplusplus\n"
933 "}\n"
934 "#endif\n";
935 test_text = "extern void* malloc( size_t );";
940 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
941 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
943 fix = {
944 hackname = darwin_externc;
945 mach = "*-*-darwin*";
946 files = mach-o/swap.h;
947 files = mach/mach_time.h;
948 files = mach/mach_traps.h;
949 files = mach/message.h;
950 files = mach/mig.h;
951 files = mach/semaphore.h;
952 bypass = "extern \"C\"";
953 bypass = "__BEGIN_DECLS";
954 c_fix = wrap;
955 c_fix_arg = "#ifdef __cplusplus\n"
956 "extern \"C\" {\n"
957 "#endif\n";
958 c_fix_arg = "#ifdef __cplusplus\n"
959 "}\n"
960 "#endif\n";
961 test_text = "extern void swap_fat_header();\n";
966 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
967 * bad __GNUC__ tests.
970 fix = {
971 hackname = darwin_gcc4_breakage;
972 mach = "*-*-darwin*";
973 files = AvailabilityMacros.h;
974 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
975 c_fix = format;
976 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
977 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
978 "(__GNUC_MINOR__ >= 1)\n";
983 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
984 * why would you ever put it in a system header file?
986 fix = {
987 hackname = darwin_private_extern;
988 mach = "*-*-darwin*";
989 files = mach-o/dyld.h;
990 select = "__private_extern__ [a-z_]+ _dyld_";
991 c_fix = format;
992 c_fix_arg = "extern";
993 c_fix_arg = "__private_extern__";
994 test_text = "__private_extern__ int _dyld_func_lookup(\n"
995 "const char *dyld_func_name,\n"
996 "unsigned long *address);\n";
1001 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1002 * unsigned constants.
1004 fix = {
1005 hackname = darwin_stdint_1;
1006 mach = "*-*-darwin*";
1007 files = stdint-darwin.h, stdint.h;
1008 c_fix = format;
1009 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1010 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1011 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1012 test_text = "#define UINT8_C(v) (v ## U)\n"
1013 "#define UINT16_C(v) (v ## U)";
1018 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1019 * with wrong types.
1021 fix = {
1022 hackname = darwin_stdint_2;
1023 mach = "*-*-darwin*";
1024 files = stdint-darwin.h, stdint.h;
1025 c_fix = format;
1026 c_fix_arg = "#if __WORDSIZE == 64\n"
1027 "#define INTPTR_MAX 9223372036854775807L\n"
1028 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1029 "#else\n"
1030 "#define INTPTR_MAX 2147483647L\n"
1031 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1032 "#endif";
1033 select = "#if __WORDSIZE == 64\n"
1034 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1035 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1036 "#else\n"
1037 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1038 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1039 "#endif";
1040 test_text = "#if __WORDSIZE == 64\n"
1041 "#define INTPTR_MIN INT64_MIN\n"
1042 "#define INTPTR_MAX INT64_MAX\n"
1043 "#else\n"
1044 "#define INTPTR_MIN INT32_MIN\n"
1045 "#define INTPTR_MAX INT32_MAX\n"
1046 "#endif";
1051 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1053 fix = {
1054 hackname = darwin_stdint_3;
1055 mach = "*-*-darwin*";
1056 files = stdint-darwin.h, stdint.h;
1057 c_fix = format;
1058 c_fix_arg = "#if __WORDSIZE == 64\n"
1059 "#define UINTPTR_MAX 18446744073709551615UL\n"
1060 "#else\n"
1061 "#define UINTPTR_MAX 4294967295UL\n"
1062 "#endif";
1063 select = "#if __WORDSIZE == 64\n"
1064 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1065 "#else\n"
1066 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1067 "#endif";
1068 test_text = "#if __WORDSIZE == 64\n"
1069 "#define UINTPTR_MAX UINT64_MAX\n"
1070 "#else\n"
1071 "#define UINTPTR_MAX UINT32_MAX\n"
1072 "#endif";
1077 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1079 fix = {
1080 hackname = darwin_stdint_4;
1081 mach = "*-*-darwin*";
1082 files = stdint-darwin.h, stdint.h;
1083 c_fix = format;
1084 c_fix_arg = "#if __WORDSIZE == 64\n"
1085 "#define SIZE_MAX 18446744073709551615UL\n"
1086 "#else\n"
1087 "#define SIZE_MAX 4294967295UL\n"
1088 "#endif";
1089 select = "#if __WORDSIZE == 64\n"
1090 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1091 "#else\n"
1092 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1093 "#endif";
1094 test_text = "#if __WORDSIZE == 64\n"
1095 "#define SIZE_MAX UINT64_MAX\n"
1096 "#else\n"
1097 "#define SIZE_MAX UINT32_MAX\n"
1098 "#endif";
1103 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1104 * with a wrong type.
1106 fix = {
1107 hackname = darwin_stdint_5;
1108 mach = "*-*-darwin*";
1109 files = stdint-darwin.h, stdint.h;
1110 c_fix = format;
1111 c_fix_arg = "#if __WORDSIZE == 64\n"
1112 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1113 "#define INTMAX_MAX 9223372036854775807L\n"
1114 "#define UINTMAX_MAX 18446744073709551615UL\n"
1115 "#else\n"
1116 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1117 "#define INTMAX_MAX 9223372036854775807LL\n"
1118 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1119 "#endif";
1120 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1121 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1122 "\n"
1123 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1124 test_text = "#define INTMAX_MIN INT64_MIN\n"
1125 "#define INTMAX_MAX INT64_MAX\n"
1126 "\n"
1127 "#define UINTMAX_MAX UINT64_MAX";
1132 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1133 * with a wrong type.
1135 fix = {
1136 hackname = darwin_stdint_6;
1137 mach = "*-*-darwin*";
1138 files = stdint-darwin.h, stdint.h;
1139 c_fix = format;
1140 c_fix_arg = "#if __WORDSIZE == 64\n"
1141 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1142 "#define PTRDIFF_MAX 9223372036854775807L\n"
1143 "#else\n"
1144 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1145 "#define PTRDIFF_MAX 2147483647\n"
1146 "#endif";
1147 select = "#if __WORDSIZE == 64\n"
1148 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1149 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1150 "#else\n"
1151 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1152 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1153 "#endif";
1154 test_text = "#if __WORDSIZE == 64\n"
1155 "#define PTRDIFF_MIN INT64_MIN\n"
1156 "#define PTRDIFF_MAX INT64_MAX\n"
1157 "#else\n"
1158 "#define PTRDIFF_MIN INT32_MIN\n"
1159 "#define PTRDIFF_MAX INT32_MAX\n"
1160 "#endif";
1165 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1166 * with a wrong type.
1168 fix = {
1169 hackname = darwin_stdint_7;
1170 mach = "*-*-darwin*";
1171 files = stdint-darwin.h, stdint.h;
1172 c_fix = format;
1173 c_fix_arg = "#if __WORDSIZE == 64\n"
1174 "#define INTMAX_C(v) (v ## L)\n"
1175 "#define UINTMAX_C(v) (v ## UL)\n"
1176 "#else\n"
1177 "#define INTMAX_C(v) (v ## LL)\n"
1178 "#define UINTMAX_C(v) (v ## ULL)\n"
1179 "#endif";
1180 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1181 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1182 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1183 "#define UINTMAX_C(v) (v ## ULL)";
1188 * Fix <c_asm.h> on Digital UNIX V4.0:
1189 * It contains a prototype for a DEC C internal asm() function,
1190 * clashing with gcc's asm keyword. So protect this with __DECC.
1192 fix = {
1193 hackname = dec_intern_asm;
1194 files = c_asm.h;
1195 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1196 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1197 "#endif\n";
1198 test_text =
1199 "float fasm {\n"
1200 " ... asm stuff ...\n"
1201 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1206 * Fix typo in <wchar.h> on DJGPP 2.03.
1208 fix = {
1209 hackname = djgpp_wchar_h;
1210 file = wchar.h;
1211 select = "__DJ_wint_t";
1212 bypass = "sys/djtypes.h";
1213 c_fix = format;
1214 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1215 c_fix_arg = "#include <stddef.h>";
1216 test_text = "#include <stddef.h>\n"
1217 "extern __DJ_wint_t x;\n";
1222 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1224 fix = {
1225 hackname = ecd_cursor;
1226 files = "sunwindow/win_lock.h";
1227 files = "sunwindow/win_cursor.h";
1228 select = 'ecd\.cursor';
1229 c_fix = format;
1230 c_fix_arg = 'ecd_cursor';
1232 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1237 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1238 * neither the existence of GCC 3 nor its exact feature set yet break
1239 * (by design?) when __GNUC__ is set beyond 2.
1241 fix = {
1242 hackname = freebsd_gcc3_breakage;
1243 mach = "*-*-freebsd*";
1244 files = sys/cdefs.h;
1245 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1246 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1247 c_fix = format;
1248 c_fix_arg = '%0 || __GNUC__ >= 3';
1249 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1254 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1255 * neither the existence of GCC 4 nor its exact feature set yet break
1256 * (by design?) when __GNUC__ is set beyond 3.
1258 fix = {
1259 hackname = freebsd_gcc4_breakage;
1260 mach = "*-*-freebsd*";
1261 files = sys/cdefs.h;
1262 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1263 c_fix = format;
1264 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1265 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1270 * Some versions of glibc don't expect the C99 inline semantics.
1272 fix = {
1273 hackname = glibc_c99_inline_1;
1274 files = features.h, '*/features.h';
1275 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1276 c_fix = format;
1277 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1278 test_text = <<-EOT
1279 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1280 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1281 # define __USE_EXTERN_INLINES 1
1282 #endif
1283 EOT;
1288 * Similar, but a version that didn't have __NO_INLINE__
1290 fix = {
1291 hackname = glibc_c99_inline_1a;
1292 files = features.h, '*/features.h';
1293 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1294 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1295 c_fix = format;
1296 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1297 test_text = <<-EOT
1298 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1299 # define __USE_EXTERN_INLINES 1
1300 #endif
1301 EOT;
1306 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1307 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1308 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1310 fix = {
1311 hackname = glibc_c99_inline_2;
1312 files = sys/stat.h, '*/sys/stat.h';
1313 select = "extern __inline__ int";
1314 sed = "s/extern int \\(stat\\)/"
1315 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1316 "__inline__ int \\1/";
1317 sed = "s/extern int \\([lf]stat\\)/"
1318 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1319 "__inline__ int \\1/";
1320 sed = "s/extern int \\(mknod\\)/"
1321 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1322 "__inline__ int \\1/";
1323 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1324 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1325 "__inline__ int __REDIRECT\\1 (\\2/";
1326 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1327 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1328 "__inline__ int __REDIRECT\\1 (\\2/";
1329 sed = "s/^extern __inline__ int/"
1330 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1331 "__inline__ int/";
1332 test_text = <<-EOT
1333 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1334 extern __inline__ int
1335 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1337 EOT;
1341 fix = {
1342 hackname = glibc_c99_inline_3;
1343 files = bits/string2.h, '*/bits/string2.h';
1344 select = "extern __inline";
1345 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1346 c_fix = format;
1347 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1348 c_fix_arg = "^# ifdef __cplusplus$";
1349 test_text = <<-EOT
1350 # ifdef __cplusplus
1351 # define __STRING_INLINE inline
1352 # else
1353 # define __STRING_INLINE extern __inline
1354 # endif
1355 EOT;
1359 fix = {
1360 hackname = glibc_c99_inline_4;
1361 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1362 bypass = "__extern_inline|__gnu_inline__";
1363 select = "(^| )extern __inline";
1364 c_fix = format;
1365 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1366 test_text = <<-EOT
1367 __extension__ extern __inline unsigned int
1368 extern __inline unsigned int
1369 EOT;
1373 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1374 * so we replace them with versions that correspond to the
1375 * definition.
1377 fix = {
1378 hackname = glibc_mutex_init;
1379 files = pthread.h;
1380 select = '\{ *\{ *0, *\} *\}';
1381 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1382 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1383 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1384 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1385 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1386 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1387 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1388 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1389 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1390 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1391 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1392 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1393 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1394 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1395 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1396 "N;s/^[ \t]*#[ \t]*"
1397 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1398 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1399 "# \\1\\\n"
1400 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1401 "# else\\\n"
1402 "# \\1\\\n"
1403 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1404 "# endif/";
1405 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1406 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1407 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1408 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1410 test_text = <<- _EOText_
1411 #define PTHREAD_MUTEX_INITIALIZER \\
1412 { { 0, } }
1413 #ifdef __USE_GNU
1414 # if __WORDSIZE == 64
1415 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1416 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1417 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1418 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1419 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1420 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1421 # else
1422 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1423 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1424 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1425 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1426 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1427 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1428 # endif
1429 #endif
1430 # define PTHREAD_RWLOCK_INITIALIZER \\
1431 { { 0, } }
1432 # ifdef __USE_GNU
1433 # if __WORDSIZE == 64
1434 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1435 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1436 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1437 # else
1438 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1439 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1440 # endif
1441 # endif
1442 #define PTHREAD_COND_INITIALIZER { { 0, } }
1443 _EOText_;
1447 /* glibc versions before 2.5 have a version of stdint.h that defines
1448 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1449 versions with stdint.h based on those glibc versions. */
1450 fix = {
1451 hackname = glibc_stdint;
1452 files = stdint.h;
1453 select = "GNU C Library";
1454 c_fix = format;
1455 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1456 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1457 test_text = "/* This file is part of the GNU C Library. */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U";
1461 /* Some versions of glibc have a version of bits/string2.h that
1462 produces "value computed is not used" warnings from strncpy; fix
1463 this definition by using __builtin_strncpy instead as in newer
1464 versions. */
1465 fix = {
1466 hackname = glibc_strncpy;
1467 files = bits/string2.h;
1468 bypass = "__builtin_strncpy";
1469 c_fix = format;
1470 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1471 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1472 test_text = <<-EOT
1473 # define strncpy(dest, src, n) \
1474 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1475 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1476 ? (char *) memcpy (dest, src, n) \\
1477 : strncpy (dest, src, n)) \\
1478 : strncpy (dest, src, n)))
1479 EOT;
1483 /* glibc's tgmath.h relies on an expression that is not an integer
1484 constant expression being treated as it was by GCC 4.4 and
1485 earlier. */
1486 fix = {
1487 hackname = glibc_tgmath;
1488 files = tgmath.h;
1489 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1490 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1491 c_fix = format;
1492 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1493 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1497 * Fix these files to use the types we think they should for
1498 * ptrdiff_t, size_t, and wchar_t.
1500 * This defines the types in terms of macros predefined by our 'cpp'.
1501 * This is supposedly necessary for glibc's handling of these types.
1502 * It's probably not necessary for anyone else, but it doesn't hurt.
1504 fix = {
1505 hackname = gnu_types;
1506 files = "sys/types.h";
1507 files = "stdlib.h";
1508 files = "sys/stdtypes.h";
1509 files = "stddef.h";
1510 files = "memory.h";
1511 files = "unistd.h";
1512 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1513 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1514 c_fix = gnu_type;
1515 /* The Solaris 10 headers already define these types correctly. */
1516 mach = '*-*-solaris2.1[0-9]*';
1517 not_machine = true;
1519 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1520 "typedef uint_t size_t; /* uint_t */\n"
1521 "typedef ushort_t wchar_t; /* ushort_t */";
1526 * Fix HP & Sony's use of "../machine/xxx.h"
1527 * to refer to: <machine/xxx.h>
1529 fix = {
1530 hackname = hp_inline;
1531 files = sys/spinlock.h;
1532 files = machine/machparam.h;
1533 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1535 c_fix = format;
1536 c_fix_arg = "%1<machine/%2.h>";
1538 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1539 '([a-z]+)\.h"';
1541 test_text = ' # include "../machine/mumble.h"';
1546 * Check for (...) in C++ code in HP/UX sys/file.h.
1548 fix = {
1549 hackname = hp_sysfile;
1550 files = sys/file.h;
1551 select = "HPUX_SOURCE";
1553 c_fix = format;
1554 c_fix_arg = "(struct file *, ...)";
1555 c_fix_arg = '\(\.\.\.\)';
1557 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1562 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1563 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1565 fix = {
1566 hackname = hppa_hpux_fp_macros;
1567 mach = "hppa*-hp-hpux11*";
1568 files = math.h;
1569 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1570 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1571 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1572 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1573 "#[ \t]*define[ \t]*FP_NAN.*\n";
1574 c_fix = format;
1575 c_fix_arg = <<- _EOFix_
1576 #endif /* _INCLUDE_HPUX_SOURCE */
1578 #if defined(_INCLUDE_HPUX_SOURCE) || \
1579 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1580 %0#endif
1582 #ifdef _INCLUDE_HPUX_SOURCE
1584 _EOFix_;
1586 test_text =
1587 "# define FP_NORMAL 0\n"
1588 "# define FP_ZERO 1\n"
1589 "# define FP_INFINITE 2\n"
1590 "# define FP_SUBNORMAL 3\n"
1591 "# define FP_NAN 4\n";
1596 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1597 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1599 fix = {
1600 hackname = hpux10_cpp_pow_inline;
1601 files = fixinc-test-limits.h, math.h;
1602 select = <<- END_POW_INLINE
1603 ^# +ifdef +__cplusplus
1605 +inline +double +pow\(double +__d,int +__expon\) +\{
1606 [ ]+return +pow\(__d,\(double\)__expon\);
1608 +extern +"C" +\{
1609 #else
1610 # +endif
1611 END_POW_INLINE;
1613 c_fix = format;
1614 c_fix_arg = "";
1616 test_text =
1617 "# ifdef __cplusplus\n"
1618 " }\n"
1619 " inline double pow(double __d,int __expon) {\n"
1620 "\t return pow(__d,(double)__expon);\n"
1621 " }\n"
1622 ' extern "C"' " {\n"
1623 "#else\n"
1624 "# endif";
1627 fix = {
1628 hackname = hpux11_cpp_pow_inline;
1629 files = math.h;
1630 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1631 " +return pow\\(d, \\(double\\)expon\\);\n"
1632 " +\\}\n";
1633 c_fix = format;
1634 c_fix_arg = "";
1636 test_text =
1637 " inline double pow(double d,int expon) {\n"
1638 " return pow(d, (double)expon);\n"
1639 " }\n";
1644 * Fix hpux 10.X missing ctype declarations 1
1646 fix = {
1647 hackname = hpux10_ctype_declarations1;
1648 files = ctype.h;
1649 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1650 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1651 c_fix = format;
1652 c_fix_arg = "#ifdef _PROTOTYPES\n"
1653 "extern int __tolower(int);\n"
1654 "extern int __toupper(int);\n"
1655 "#else /* NOT _PROTOTYPES */\n"
1656 "extern int __tolower();\n"
1657 "extern int __toupper();\n"
1658 "#endif /* _PROTOTYPES */\n\n"
1659 "%0\n";
1661 test_text = "# define _toupper(__c) __toupper(__c)\n";
1666 * Fix hpux 10.X missing ctype declarations 2
1668 fix = {
1669 hackname = hpux10_ctype_declarations2;
1670 files = ctype.h;
1671 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1672 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1673 c_fix = format;
1674 c_fix_arg = "%0\n\n"
1675 "#ifdef _PROTOTYPES\n"
1676 " extern int _isalnum(int);\n"
1677 " extern int _isalpha(int);\n"
1678 " extern int _iscntrl(int);\n"
1679 " extern int _isdigit(int);\n"
1680 " extern int _isgraph(int);\n"
1681 " extern int _islower(int);\n"
1682 " extern int _isprint(int);\n"
1683 " extern int _ispunct(int);\n"
1684 " extern int _isspace(int);\n"
1685 " extern int _isupper(int);\n"
1686 " extern int _isxdigit(int);\n"
1687 "# else /* not _PROTOTYPES */\n"
1688 " extern int _isalnum();\n"
1689 " extern int _isalpha();\n"
1690 " extern int _iscntrl();\n"
1691 " extern int _isdigit();\n"
1692 " extern int _isgraph();\n"
1693 " extern int _islower();\n"
1694 " extern int _isprint();\n"
1695 " extern int _ispunct();\n"
1696 " extern int _isspace();\n"
1697 " extern int _isupper();\n"
1698 " extern int _isxdigit();\n"
1699 "#endif /* _PROTOTYPES */\n";
1701 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1702 " extern unsigned int *__SB_masks;\n";
1707 * Fix hpux 10.X missing stdio declarations
1709 fix = {
1710 hackname = hpux10_stdio_declarations;
1711 files = stdio.h;
1712 select = "^#[ \t]*define _iob[ \t]*__iob";
1713 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1714 c_fix = format;
1715 c_fix_arg = "%0\n\n"
1716 "# if defined(__STDC__) || defined(__cplusplus)\n"
1717 " extern int snprintf(char *, size_t, const char *, ...);\n"
1718 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1719 "# else /* not __STDC__) || __cplusplus */\n"
1720 " extern int snprintf();\n"
1721 " extern int vsnprintf();\n"
1722 "# endif /* __STDC__) || __cplusplus */\n";
1724 test_text = "# define _iob __iob\n";
1729 * Make sure hpux defines abs in header.
1731 fix = {
1732 hackname = hpux11_abs;
1733 mach = "*-hp-hpux11*";
1734 files = stdlib.h;
1735 select = "ifndef _MATH_INCLUDED";
1736 c_fix = format;
1737 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1738 test_text = "#ifndef _MATH_INCLUDED";
1743 * Keep HP-UX 11 from stomping on C++ math namespace
1744 * with defines for fabsf.
1746 fix = {
1747 hackname = hpux11_fabsf;
1748 files = math.h;
1749 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1750 bypass = "__cplusplus";
1752 c_fix = format;
1753 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1755 test_text =
1756 "#ifdef _PA_RISC\n"
1757 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1758 "#endif";
1763 * Fix C99 constant in __POINTER_SET define.
1765 fix = {
1766 hackname = hpux11_pthread_const;
1767 mach = "*-hp-hpux11.[0-3]*";
1768 files = sys/pthread.h;
1769 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1771 c_fix = format;
1772 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1773 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1778 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1779 * being defined by having it define _hpux_size_t instead.
1781 fix = {
1782 hackname = hpux11_size_t;
1783 mach = "*-hp-hpux11*";
1784 select = "__size_t";
1786 c_fix = format;
1787 c_fix_arg = "_hpux_size_t";
1789 test_text =
1790 "#define __size_t size_t\n"
1791 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1796 * Fix hpux 11.00 broken snprintf declaration
1797 * (third argument is char *, needs to be const char * to prevent
1798 * spurious warnings with -Wwrite-strings or in C++).
1800 fix = {
1801 hackname = hpux11_snprintf;
1802 files = stdio.h;
1803 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1804 ' *(char *\*, *\.\.\.\);)';
1805 c_fix = format;
1806 c_fix_arg = '%1 const %3';
1808 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1809 "extern int snprintf(char *, __size_t, char *, ...);\n"
1810 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1814 * Fix hpux 11.00 broken vsnprintf declaration
1816 fix = {
1817 hackname = hpux11_vsnprintf;
1818 files = stdio.h;
1819 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1820 'const char \*,) __va__list\);';
1821 c_fix = format;
1822 c_fix_arg = "%1 __va_list);";
1824 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1825 ' __va__list);';
1830 * get rid of bogus inline definitions in HP-UX 8.0
1832 fix = {
1833 hackname = hpux8_bogus_inlines;
1834 files = math.h;
1835 select = inline;
1836 bypass = "__GNUG__";
1837 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1838 "@extern \"C\" int abs(int);@";
1839 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1840 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1841 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1842 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1843 "inline double sqr(double v) { return v**0.5; }";
1848 * Fix hpux broken ctype macros
1850 fix = {
1851 hackname = hpux_ctype_macros;
1852 files = ctype.h;
1853 select = '((: |\()__SB_masks \? )'
1854 '(__SB_masks\[__(alnum|c)\] & _IS)';
1855 c_fix = format;
1856 c_fix_arg = "%1(int)%3";
1858 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1859 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1864 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1866 fix = {
1867 hackname = hpux_htonl;
1868 files = netinet/in.h;
1869 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
1870 "(/\\*\n"
1871 " \\* Macros for number representation conversion\\.\n"
1872 " \\*/\n"
1873 "#ifndef ntohl)";
1874 c_fix = format;
1875 c_fix_arg = "#if 1\n%1";
1877 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1878 "/*\n"
1879 " * Macros for number representation conversion.\n"
1880 " */\n"
1881 "#ifndef ntohl\n"
1882 "#define ntohl(x) (x)\n"
1883 "#define ntohs(x) (x)\n"
1884 "#define htonl(x) (x)\n"
1885 "#define htons(x) (x)\n"
1886 "#endif\n"
1887 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1892 * HP-UX long_double
1894 fix = {
1895 hackname = hpux_long_double;
1896 mach = "*-*-hpux10*";
1897 mach = "*-*-hpux11.[012]*";
1898 files = stdlib.h;
1899 select = "extern[ \t]long_double[ \t]strtold";
1900 bypass = "long_double_t";
1901 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1902 sed = "s/long_double/long double/g";
1904 test_text = "# ifndef _LONG_DOUBLE\n"
1905 "# define _LONG_DOUBLE\n"
1906 " typedef struct {\n"
1907 " unsigned int word1, word2, word3, word4;\n"
1908 " } long_double;\n"
1909 "# endif /* _LONG_DOUBLE */\n"
1910 "extern long_double strtold(const char *, char **);\n";
1914 * We cannot use the above rule on 11.31 because it removes the strtold
1915 * definition. ia64 is OK with no hack, PA needs some help.
1917 fix = {
1918 hackname = hpux_long_double_2;
1919 mach = "hppa*-*-hpux11.3*";
1920 files = stdlib.h;
1921 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
1922 c_fix = format;
1923 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
1925 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
1929 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1931 fix = {
1932 hackname = hpux_systime;
1933 files = sys/time.h;
1934 select = "^extern struct sigevent;";
1936 c_fix = format;
1937 c_fix_arg = "struct sigevent;";
1939 test_text = 'extern struct sigevent;';
1944 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1945 * type and mpinfou is only defined when _KERNEL is set.
1947 fix = {
1948 hackname = hpux_spu_info;
1949 mach = "*-hp-hpux*";
1951 * It is tempting to omit the first "files" entry. Do not.
1952 * The testing machinery will take the first "files" entry as the name
1953 * of a test file to play with. It would be a nuisance to have a directory
1954 * with the name "*".
1956 files = "ia64/sys/getppdp.h";
1957 files = "*/sys/getppdp.h";
1958 select = "^.*extern.*spu_info.*";
1960 c_fix = format;
1961 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
1963 test_text = "extern union mpinfou spu_info[];";
1966 fix = {
1967 hackname = hpux11_extern_sendfile;
1968 mach = "*-hp-hpux11.[12]*";
1969 files = sys/socket.h;
1970 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
1971 c_fix = format;
1972 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1973 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1976 fix = {
1977 hackname = hpux11_extern_sendpath;
1978 mach = "*-hp-hpux11.[12]*";
1979 files = sys/socket.h;
1980 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
1981 c_fix = format;
1982 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1983 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1986 fix = {
1987 hackname = hpux_extern_errno;
1988 mach = "*-hp-hpux10.*";
1989 mach = "*-hp-hpux11.[0-2]*";
1990 files = errno.h;
1991 select = "^[ \t]*extern int errno;$";
1992 c_fix = format;
1993 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
1994 test_text = " extern int errno;\n";
1999 * Add missing braces to pthread initializer defines.
2001 fix = {
2002 hackname = hpux_pthread_initializers;
2003 mach = "*-hp-hpux11.[0-3]*";
2004 files = sys/pthread.h;
2005 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2006 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2007 sed = "s@^[ \t]*1,[ \t]*\\\\"
2008 "@\t{ 1, 0 }@";
2009 sed = "/^[ \t]*0$/d";
2010 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2011 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2012 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2013 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2014 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2015 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2016 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2017 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2018 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2019 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2020 sed = "s@__PTHREAD_COND_VALID, 0"
2021 "@{ __PTHREAD_COND_VALID, 0 }@";
2022 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2023 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2024 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2025 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2026 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2027 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2028 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2029 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2030 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2031 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2032 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2033 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2034 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2035 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2036 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2037 "}\n";
2040 fix = {
2041 hackname = hpux_c99_intptr;
2042 mach = "*-hp-hpux11.3*";
2043 files = stdint-hpux11.h, stdint.h;
2044 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2045 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2046 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2047 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2048 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2049 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2050 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2051 "#define PTRDIFF_MIN INT32_MIN\n"
2052 "#define INTPTR_MAX INT32_MAX\n"
2053 "#define INTPTR_MIN INT32_MIN\n"
2054 "#define UINTPTR_MAX UINT32_MAX\n"
2055 "#define SIZE_MAX UINT32_MAX\n";
2059 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2062 fix = {
2063 hackname = hpux_c99_inttypes;
2064 mach = "*-hp-hpux11.[23]*";
2065 files = inttypes.h;
2066 files = stdint-hpux11.h, stdint.h;
2067 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2068 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2069 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2070 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2071 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2072 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2073 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2074 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2077 fix = {
2078 hackname = hpux_c99_inttypes2;
2079 mach = "*-hp-hpux11.2*";
2080 files = stdint-hpux11.h, stdint.h;
2081 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2082 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2083 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2084 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2085 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2086 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2087 "# define INT16_C(__c) ((short)(__c))\n"
2088 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2091 fix = {
2092 hackname = hpux_stdint_least_fast;
2093 mach = "*-hp-hpux11.2*";
2094 files = stdint-hpux11.h, stdint.h;
2095 select =
2096 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2097 c_fix = format;
2098 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2099 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2100 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2101 _EOFix_;
2104 fix = {
2105 hackname = hpux_inttype_int8_t;
2106 mach = "*-hp-hpux1[01].*";
2107 files = sys/_inttypes.h;
2108 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2109 c_fix = format;
2110 c_fix_arg = "typedef signed char int%18_t;";
2111 test_text = "typedef char int_least8_t;\n"
2112 "typedef char int8_t;\n";
2115 fix = {
2116 hackname = hpux_imaginary_i;
2117 mach = "ia64-hp-hpux11.*";
2118 files = complex.h;
2119 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2120 c_fix = format;
2121 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2122 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2126 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2128 fix = {
2129 hackname = huge_val_hex;
2130 files = bits/huge_val.h;
2131 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2132 bypass = "__builtin_huge_val";
2134 c_fix = format;
2135 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2137 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2142 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2144 fix = {
2145 hackname = huge_valf_hex;
2146 files = bits/huge_val.h;
2147 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2148 bypass = "__builtin_huge_valf";
2150 c_fix = format;
2151 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2153 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2158 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2160 fix = {
2161 hackname = huge_vall_hex;
2162 files = bits/huge_val.h;
2163 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2164 bypass = "__builtin_huge_vall";
2166 c_fix = format;
2167 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2169 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2174 * Fix return type of abort and free
2176 fix = {
2177 hackname = int_abort_free_and_exit;
2178 files = stdlib.h;
2179 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2180 bypass = "_CLASSIC_ANSI_TYPES";
2182 c_fix = format;
2183 c_fix_arg = "void\t%1(";
2185 test_text = "extern int abort(int);\n"
2186 "extern int free(void*);\n"
2187 "extern int exit(void*);";
2192 * Fix various macros used to define ioctl numbers.
2193 * The traditional syntax was:
2195 * #define _IO(n, x) (('n'<<8)+x)
2196 * #define TIOCFOO _IO(T, 1)
2198 * but this does not work with the C standard, which disallows macro
2199 * expansion inside strings. We have to rewrite it thus:
2201 * #define _IO(n, x) ((n<<8)+x)
2202 * #define TIOCFOO _IO('T', 1)
2204 * The select expressions match too much, but the c_fix code is cautious.
2206 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2208 fix = {
2209 hackname = io_quotes_def;
2210 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2211 c_fix = char_macro_def;
2212 c_fix_arg = "IO";
2213 test_text =
2214 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2215 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2216 "#define _IO(x,y) ('x'<<8|y)";
2217 test_text =
2218 "#define XX_IO(x) ('x'<<8|256)";
2221 fix = {
2222 hackname = io_quotes_use;
2223 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2224 "\\( *[^,']";
2225 c_fix = char_macro_use;
2226 c_fix_arg = "IO";
2227 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2228 "#define TIOCFOO \\\\\n"
2229 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2234 * Check for missing ';' in struct
2236 fix = {
2237 hackname = ip_missing_semi;
2238 files = netinet/ip.h;
2239 select = "}$";
2240 sed = "/^struct/,/^};/s/}$/};/";
2241 test_text=
2242 "struct mumble {\n"
2243 " union {\n"
2244 " int x;\n"
2245 " }\n"
2246 "}; /* mumbled struct */\n";
2251 * Non-traditional "const" declaration in Irix's limits.h.
2253 fix = {
2254 hackname = irix_limits_const;
2255 files = fixinc-test-limits.h, limits.h;
2256 select = "^extern const ";
2257 c_fix = format;
2258 c_fix_arg = "extern __const ";
2259 test_text = "extern const char limit; /* test limits */";
2264 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2265 * taking char *. However, GCC uses void * for va_list, so
2266 * calling vfprintf with a va_list fails in C++. */
2267 fix = {
2268 hackname = irix_stdio_va_list;
2269 files = stdio.h;
2271 select = '/\* va_list \*/ char \*';
2272 c_fix = format;
2273 c_fix_arg = "__gnuc_va_list";
2274 test_text =
2275 "extern int printf( const char *, /* va_list */ char * );";
2280 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2281 * use / * * / to concatenate tokens.
2283 fix = {
2284 hackname = kandr_concat;
2285 files = "sparc/asm_linkage.h";
2286 files = "sun*/asm_linkage.h";
2287 files = "arm/as_support.h";
2288 files = "arm/mc_type.h";
2289 files = "arm/xcb.h";
2290 files = "dev/chardefmac.h";
2291 files = "dev/ps_irq.h";
2292 files = "dev/screen.h";
2293 files = "dev/scsi.h";
2294 files = "sys/tty.h";
2295 files = "Xm.acorn/XmP.h";
2296 files = bsd43/bsd43_.h;
2297 select = '/\*\*/';
2298 c_fix = format;
2299 c_fix_arg = '##';
2300 test_text = "#define __CONCAT__(a,b) a/**/b";
2304 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2305 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2306 * constant on recent versions of g++.
2308 fix = {
2309 hackname = linux_ia64_ucontext;
2310 files = "sys/ucontext.h";
2311 mach = "ia64-*-linux*";
2312 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2313 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2314 c_fix = format;
2315 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2316 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2317 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2322 * Remove header file warning from sys/time.h. Autoconf's
2323 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2324 * which causes warning on LynxOS. Remove the warning.
2326 fix = {
2327 hackname = lynxos_no_warning_in_sys_time_h;
2328 files = sys/time.h;
2329 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2330 c_fix = format;
2331 c_fix_arg = "";
2332 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2337 * Add missing declaration for putenv.
2339 fix = {
2340 hackname = lynxos_missing_putenv;
2341 mach = '*-*-lynxos*';
2342 files = stdlib.h;
2343 bypass = 'putenv[ \t]*\\(';
2344 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2345 c_fix = format;
2346 c_fix_arg = "%0\n"
2347 "extern int putenv _AP((char *));";
2348 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2349 test_text = "extern char *getenv _AP((const char *));";
2354 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2356 * On NetBSD, machine is a symbolic link to an architecture specific
2357 * directory name, so we can't match a specific file name here.
2359 fix = {
2360 hackname = machine_ansi_h_va_list;
2361 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2362 bypass = '__builtin_va_list';
2364 c_fix = format;
2365 c_fix_arg = "%1__builtin_va_list";
2366 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2368 test_text = " # define _BSD_VA_LIST_\tchar**";
2373 * Fix non-ansi machine name defines
2375 fix = {
2376 hackname = machine_name;
2377 c_test = machine_name;
2378 c_fix = machine_name;
2380 test_text = "/* MACH_DIFF: */\n"
2381 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2382 "\n/* no uniform test, so be careful :-) */";
2387 * Some math.h files define struct exception (it's in the System V
2388 * Interface Definition), which conflicts with the class exception defined
2389 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2390 * This is not a great fix, but I haven't been able to think of anything
2391 * better.
2393 fix = {
2394 hackname = math_exception;
2395 files = math.h;
2396 select = "struct exception";
2398 * This should be bypassed on __cplusplus, but some supposedly C++
2399 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2400 * exception either. So currently we bypass only for glibc, based on a
2401 * comment in the fixed glibc header. Ick.
2403 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2404 '_[a-z0-9A-Z_]+_exception; for C, exception';
2405 c_fix = wrap;
2407 c_fix_arg = "#ifdef __cplusplus\n"
2408 "#define exception __math_exception\n"
2409 "#endif\n";
2411 c_fix_arg = "#ifdef __cplusplus\n"
2412 "#undef exception\n"
2413 "#endif\n";
2415 test_text = "typedef struct exception t_math_exception;";
2420 * This looks pretty broken to me. ``dbl_max_def'' will contain
2421 * "define DBL_MAX " at the start, when what we really want is just
2422 * the value portion. Can't figure out how to write a test case
2423 * for this either :-(
2425 fix = {
2426 hackname = math_huge_val_from_dbl_max;
2427 files = math.h;
2430 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2431 * in math.h, this fix applies.
2433 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2434 bypass = "define[ \t]+DBL_MAX";
2436 shell =
2438 * See if we have a definition for DBL_MAX in float.h.
2439 * If we do, we will replace the one in math.h with that one.
2442 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2443 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2445 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2446 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2447 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2448 "\telse cat\n"
2449 "\tfi";
2451 test_text =
2452 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2453 "#define HUGE_VAL DBL_MAX";
2458 * nested comment
2460 fix = {
2461 hackname = nested_auth_des;
2462 files = rpc/rpc.h;
2463 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2464 c_fix = format;
2465 c_fix_arg = "%1*/ /*";
2466 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2471 * Some versions of NetBSD don't expect the C99 inline semantics.
2473 fix = {
2474 hackname = netbsd_c99_inline_1;
2475 mach = "*-*-netbsd*";
2476 files = signal.h;
2477 select = "extern __inline int";
2479 c_fix = format;
2480 c_fix_arg = "extern\n"
2481 "#ifdef __GNUC_STDC_INLINE__\n"
2482 "__attribute__((__gnu_inline__))\n"
2483 "#endif\n"
2484 "__inline int";
2486 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2490 fix = {
2491 hackname = netbsd_c99_inline_2;
2492 mach = "*-*-netbsd*";
2493 files = signal.h;
2494 select = "#define _SIGINLINE extern __inline";
2496 c_fix = format;
2497 c_fix_arg = <<- _EOArg_
2498 #ifdef __GNUC_STDC_INLINE__
2499 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2500 #else
2502 #endif
2503 _EOArg_;
2505 test_text = "#define _SIGINLINE extern __inline";
2510 * NetBSD has a semicolon after the ending '}' for some extern "C".
2512 fix = {
2513 hackname = netbsd_extra_semicolon;
2514 mach = "*-*-netbsd*";
2515 files = sys/cdefs.h;
2516 select = "#define[ \t]*__END_DECLS[ \t]*};";
2518 c_fix = format;
2519 c_fix_arg = "#define __END_DECLS }";
2521 test_text = "#define __END_DECLS };";
2525 /* newlib's stdint.h has several failures to conform to C99. The fix
2526 for these removed a comment that can be matched to identify unfixed
2527 versions. */
2528 fix = {
2529 hackname = newlib_stdint_1;
2530 files = stdint-newlib.h, stdint.h;
2531 select = "@todo - Add support for wint_t types";
2532 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2533 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2534 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2535 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2536 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2537 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2538 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2539 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2540 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2541 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2542 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2543 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2544 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2545 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2546 test_text = "/* @todo - Add support for wint_t types. */\n"
2547 "#define INT32_MIN (-2147483647-1)\n"
2548 "#define INT32_MAX 2147483647\n"
2549 "#define UINT32_MAX 4294967295U\n"
2550 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2551 "#define INT_LEAST32_MAX 2147483647\n"
2552 "#define UINT_LEAST32_MAX 4294967295U\n"
2553 "#define INT_FAST8_MIN INT8_MIN\n"
2554 "#define INT_FAST8_MAX INT8_MAX\n"
2555 "#define UINT_FAST8_MAX UINT8_MAX\n"
2556 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2557 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2558 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2559 "#define UINT8_C(x) x##U\n"
2560 "#define UINT16_C(x) x##U";
2564 fix = {
2565 hackname = newlib_stdint_2;
2566 files = stdint-newlib.h, stdint.h;
2567 select = "@todo - Add support for wint_t types";
2568 c_fix = format;
2569 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2570 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2571 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2572 "#define WCHAR_MAX __WCHAR_MAX__\n"
2573 "#define WCHAR_MIN __WCHAR_MIN__\n"
2574 "#define WINT_MAX __WINT_MAX__\n"
2575 "#define WINT_MIN __WINT_MIN__\n\n"
2576 "%0";
2577 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2578 test_text = "/* @todo - Add support for wint_t types. */\n"
2579 "/** Macros for minimum-width integer constant expressions */";
2584 * NeXT 3.2 adds const prefix to some math functions.
2585 * These conflict with the built-in functions.
2587 fix = {
2588 hackname = next_math_prefix;
2589 files = ansi/math.h;
2590 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2592 c_fix = format;
2593 c_fix_arg = "extern double %1(";
2594 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2596 test_text = "extern\tdouble\t__const__\tmumble();";
2601 * NeXT 3.2 uses the word "template" as a parameter for some
2602 * functions. GCC reports an invalid use of a reserved key word
2603 * with the built-in functions.
2605 fix = {
2606 hackname = next_template;
2607 files = bsd/libc.h;
2608 select = "[ \t]template\\)";
2610 c_fix = format;
2611 c_fix_arg = "(%1)";
2612 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2613 test_text = "extern mumble( char * template); /* fix */";
2618 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2619 * function prototypes. That conflicts with the built-in functions.
2621 fix = {
2622 hackname = next_volitile;
2623 files = ansi/stdlib.h;
2624 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2626 c_fix = format;
2627 c_fix_arg = "extern void %1(";
2628 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2630 test_text = "extern\tvolatile\tvoid\tabort();";
2635 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2636 * Note that version 3 of the NeXT system has wait.h in a different directory,
2637 * so that this code won't do anything. But wait.h in version 3 has a
2638 * conditional, so it doesn't need this fix. So everything is okay.
2640 fix = {
2641 hackname = next_wait_union;
2642 files = sys/wait.h;
2644 select = 'wait\(union wait';
2645 c_fix = format;
2646 c_fix_arg = "wait(void";
2647 test_text = "extern pid_d wait(union wait*);";
2652 * a missing semi-colon at the end of the nodeent structure definition.
2654 fix = {
2655 hackname = nodeent_syntax;
2656 files = netdnet/dnetdb.h;
2657 select = "char[ \t]*\\*na_addr[ \t]*$";
2658 c_fix = format;
2659 c_fix_arg = "%0;";
2660 test_text = "char *na_addr\t";
2664 * Fix OpenBSD's NULL definition.
2666 fix = {
2667 hackname = openbsd_null_definition;
2668 mach = "*-*-openbsd*";
2669 files = locale.h, stddef.h, stdio.h, string.h,
2670 time.h, unistd.h, wchar.h, sys/param.h;
2671 select = "__GNUG__";
2672 c_fix = format;
2673 c_fix_arg = "#ifndef NULL\n"
2674 "#ifdef __cplusplus\n"
2675 "#ifdef __GNUG__\n"
2676 "#define NULL\t__null\n"
2677 "#else\t /* ! __GNUG__ */\n"
2678 "#define NULL\t0L\n"
2679 "#endif\t /* __GNUG__ */\n"
2680 "#else\t /* ! __cplusplus */\n"
2681 "#define NULL\t((void *)0)\n"
2682 "#endif\t /* __cplusplus */\n"
2683 "#endif\t /* !NULL */";
2685 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2686 "^#ifdef[ \t]*__GNUG__\n"
2687 "^#define[ \t]*NULL[ \t]*__null\n"
2688 "^#else\n"
2689 "^#define[ \t]*NULL[ \t]*0L\n"
2690 "^#endif\n"
2691 "^#endif";
2692 test_text =
2693 "#ifndef NULL\n"
2694 "#ifdef __GNUG__\n"
2695 "#define NULL __null\n"
2696 "#else\n"
2697 "#define NULL 0L\n"
2698 "#endif\n"
2699 "#endif\n";
2703 * obstack.h used casts as lvalues.
2705 * We need to change postincrements of casted pointers (which are
2706 * then dereferenced and assigned into) of the form
2708 * *((TYPE*)PTRVAR)++ = (VALUE)
2710 * into expressions like
2712 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2714 * which is correct for the cases used in obstack.h since PTRVAR is
2715 * of type char * and the value of the expression is not used.
2717 fix = {
2718 hackname = obstack_lvalue_cast;
2719 files = obstack.h;
2720 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2721 c_fix = format;
2722 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2723 test_text = "*((void **) (h)->next_free)++ = (aptr)";
2727 * Fix OpenBSD's va_start define.
2729 fix = {
2730 hackname = openbsd_va_start;
2731 mach = "*-*-openbsd*";
2732 files = stdarg.h;
2733 select = '__builtin_stdarg_start';
2734 c_fix = format;
2735 c_fix_arg = __builtin_va_start;
2737 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
2741 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2742 * defining regex.h related types. This causes libg++ build and usage
2743 * failures. Fixing this correctly requires checking and modifying 3 files.
2745 fix = {
2746 hackname = osf_namespace_a;
2747 files = reg_types.h;
2748 files = sys/lc_core.h;
2749 test = " -r reg_types.h";
2750 test = " -r sys/lc_core.h";
2751 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2752 test = " -z \"`grep __regex_t regex.h`\"";
2754 c_fix = format;
2755 c_fix_arg = "__%0";
2756 c_fix_arg = "reg(ex|off|match)_t";
2758 test_text = "`touch sys/lc_core.h`"
2759 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2760 "extern regex_t re;\n"
2761 "extern regoff_t ro;\n"
2762 "extern regmatch_t rm;\n";
2765 fix = {
2766 hackname = osf_namespace_c;
2767 files = regex.h;
2768 test = " -r reg_types.h";
2769 test = " -r sys/lc_core.h";
2770 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2771 test = " -z \"`grep __regex_t regex.h`\"";
2773 select = "#include <reg_types\.h>.*";
2774 c_fix = format;
2775 c_fix_arg = "%0\n"
2776 "typedef __regex_t\tregex_t;\n"
2777 "typedef __regoff_t\tregoff_t;\n"
2778 "typedef __regmatch_t\tregmatch_t;";
2780 test_text = "#include <reg_types.h>";
2785 * On broken glibc-2.3.3 systems an array of incomplete structures is
2786 * passed to __sigsetjmp. Fix that to take a pointer instead.
2788 fix = {
2789 hackname = pthread_incomplete_struct_argument;
2790 files = pthread.h;
2791 select = "struct __jmp_buf_tag";
2792 c_fix = format;
2793 c_fix_arg = "%1 *%2%3";
2794 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2795 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2799 * Fix return type of fread and fwrite on sysV68
2801 fix = {
2802 hackname = read_ret_type;
2803 files = stdio.h;
2804 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2805 c_fix = format;
2806 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2807 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2809 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2814 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2816 fix = {
2817 hackname = rpc_xdr_lvalue_cast_a;
2818 files = rpc/xdr.h;
2819 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2820 c_fix = format;
2821 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2822 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2823 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2827 fix = {
2828 hackname = rpc_xdr_lvalue_cast_b;
2829 files = rpc/xdr.h;
2830 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2831 c_fix = format;
2832 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2833 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2834 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2839 * function class(double x) conflicts with C++ keyword on rs/6000
2841 fix = {
2842 hackname = rs6000_double;
2843 files = math.h;
2844 select = '[^a-zA-Z_]class\(';
2846 c_fix = format;
2847 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2848 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2850 test_text = "extern int class();";
2855 * Wrong fchmod prototype on RS/6000.
2857 fix = {
2858 hackname = rs6000_fchmod;
2859 files = sys/stat.h;
2860 select = 'fchmod\(char \*';
2861 c_fix = format;
2862 c_fix_arg = "fchmod(int";
2863 test_text = "extern int fchmod(char *, mode_t);";
2868 * parameters conflict with C++ new on rs/6000
2870 fix = {
2871 hackname = rs6000_param;
2872 files = "stdio.h";
2873 files = "unistd.h";
2875 select = 'rename\(const char \*old, const char \*new\)';
2876 c_fix = format;
2877 c_fix_arg = 'rename(const char *_old, const char *_new)';
2879 test_text = 'extern int rename(const char *old, const char *new);';
2884 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
2885 * for C99. This is wrong for C++, which needs many C99 features, but
2886 * only supports __restrict.
2888 fix = {
2889 hackname = solaris___restrict;
2890 files = sys/feature_tests.h;
2891 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
2892 mach = "*-*-solaris2*";
2893 c_fix = format;
2894 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
2895 "#else\n%0\n#endif";
2896 test_text = "#define _RESTRICT_KYWD restrict";
2901 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
2902 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
2903 * and imaginary definitions which are not supported by GCC.
2905 fix = {
2906 hackname = solaris_complex;
2907 mach = "*-*-solaris2.*";
2908 files = complex.h;
2909 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
2910 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
2911 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
2912 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
2913 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
2914 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
2915 test_text = "#define _Complex_I _Complex_I\n"
2916 "#define complex _Complex\n"
2917 "#define _Imaginary_I _Imaginary_I\n"
2918 "#define imaginary _Imaginary\n"
2919 "#undef I\n"
2920 "#define I _Imaginary_I";
2925 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
2926 * extern "C" instead so libstdc++ can use it.
2928 fix = {
2929 hackname = solaris_complex_cxx;
2930 mach = "*-*-solaris2.*";
2931 files = complex.h;
2932 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
2933 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
2934 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
2935 "#ifdef\t__cplusplus\\\n}\\\n#endif";
2936 test_text = "#if !defined(__cplusplus)\n"
2937 "#endif /* !defined(__cplusplus) */";
2942 * g++ rejects functions declared with both C and C++ linkage.
2944 fix = {
2945 hackname = solaris_cxx_linkage;
2946 mach = '*-*-solaris2*';
2947 files = "iso/stdlib_iso.h";
2948 select = "(#if __cplusplus >= 199711L)\n"
2949 "(extern \"C\\+\\+\" \\{\n)"
2950 "(.*(bsearch|qsort).*)";
2951 c_fix = format;
2952 c_fix_arg = "%1 && !__GNUG__\n%2%3";
2954 test_text =
2955 "#if __cplusplus >= 199711L\n"
2956 "extern \"C++\" {\n"
2957 " void *bsearch(const void *, const void *, size_t, size_t,";
2962 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
2963 * _STRICT_STDC, but uses it.
2965 fix = {
2966 hackname = solaris_getc_strict_stdc;
2967 mach = "*-*-solaris2*";
2968 files = "iso/stdio_iso.h";
2969 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
2970 c_fix = format;
2971 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
2973 test_text =
2974 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
2979 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
2981 fix = {
2982 hackname = solaris_longjmp_noreturn;
2983 mach = "*-*-solaris2*";
2984 files = "iso/setjmp_iso.h";
2985 bypass = "__NORETURN";
2986 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
2987 c_fix = format;
2988 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
2990 test_text = "extern void longjmp(jmp_buf, int);";
2995 * Sun Solaris 10 defines several C99 math macros in terms of
2996 * builtins specific to the Studio compiler, in particular not
2997 * compatible with the GNU compiler.
2999 fix = {
3000 hackname = solaris_math_1;
3001 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3002 bypass = "__GNUC__";
3003 files = iso/math_c99.h;
3004 c_fix = format;
3005 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3006 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3007 test_text =
3008 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3009 "#undef HUGE_VAL\n"
3010 "#define HUGE_VAL __builtin_huge_val\n"
3011 "#undef HUGE_VALF\n"
3012 "#define HUGE_VALF __builtin_huge_valf\n"
3013 "#undef HUGE_VALL\n"
3014 "#define HUGE_VALL __builtin_huge_vall";
3017 fix = {
3018 hackname = solaris_math_2;
3019 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3020 bypass = "__GNUC__";
3021 files = iso/math_c99.h;
3022 c_fix = format;
3023 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3024 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3025 test_text =
3026 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3027 "#undef INFINITY\n"
3028 "#define INFINITY __builtin_infinity";
3031 fix = {
3032 hackname = solaris_math_3;
3033 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3034 bypass = "__GNUC__";
3035 files = iso/math_c99.h;
3036 c_fix = format;
3037 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3038 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3039 test_text =
3040 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3041 "#undef NAN\n"
3042 "#define NAN __builtin_nan";
3045 fix = {
3046 hackname = solaris_math_4;
3047 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3048 bypass = "__GNUC__";
3049 files = iso/math_c99.h;
3050 c_fix = format;
3051 c_fix_arg = "#define\tfpclassify(x) \\\n"
3052 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3053 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3054 test_text =
3055 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3056 "#undef fpclassify\n"
3057 "#define fpclassify(x) __builtin_fpclassify(x)";
3060 fix = {
3061 hackname = solaris_math_8;
3062 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3063 bypass = "__GNUC__";
3064 files = iso/math_c99.h;
3065 c_fix = format;
3066 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3067 "\t\t\t ? __builtin_signbitf(x) \\\n"
3068 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3069 "\t\t\t ? __builtin_signbitl(x) \\\n"
3070 "\t\t\t : __builtin_signbit(x))";
3071 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3072 test_text = <<- _EOText_
3073 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3074 #undef signbit
3075 #define signbit(x) __builtin_signbit(x)
3076 _EOText_;
3079 fix = {
3080 hackname = solaris_math_9;
3081 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3082 bypass = "__GNUC__";
3083 files = iso/math_c99.h;
3084 c_fix = format;
3085 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3086 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3087 test_text =
3088 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3089 "#undef isgreater\n"
3090 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3091 "#undef isgreaterequal\n"
3092 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3093 "#undef isless\n"
3094 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3095 "#undef islessequal\n"
3096 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3097 "#undef islessgreater\n"
3098 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3099 "#undef isunordered\n"
3100 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3104 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3105 * exception. Provide an alternative using GCC's builtin.
3108 fix = {
3109 hackname = solaris_math_10;
3110 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3111 files = iso/math_c99.h;
3112 c_fix = format;
3113 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3114 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3115 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3116 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3117 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3118 test_text =
3119 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3120 "#undef isinf\n"
3121 "#define isinf(x) __extension__( \\\\\n"
3122 " { __typeof(x) __x_i = (x); \\\\\n"
3123 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3124 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3128 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3129 * "0" for the last field of the pthread_mutex_t structure, which is
3130 * of type upad64_t, which itself is typedef'd to int64_t, but with
3131 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3132 * initializer to "{0}" instead
3134 fix = {
3135 hackname = solaris_mutex_init_2;
3136 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3137 files = pthread.h;
3139 * On Solaris 10, this fix is unnecessary because upad64_t is
3140 * always defined correctly regardless of the definition of the
3141 * __STDC__ macro. The first "mach" pattern matches up to
3142 * solaris9. The second "mach" pattern will not match any two (or
3143 * more) digit solaris version, but it will match e.g. 2.5.1.
3145 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3146 c_fix = format;
3147 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3148 "%0\n"
3149 "#else\n"
3150 "%1, {0}}%4\n"
3151 "#endif";
3152 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3153 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3154 ",[ \t]*0\\}" "(|[ \t].*)$";
3155 test_text =
3156 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3157 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3158 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3159 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3160 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3161 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3162 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3167 * The pow overloads with int were removed in C++ 2011.
3169 fix = {
3170 hackname = solaris_pow_int_overload;
3171 mach = '*-*-solaris2*';
3172 files = "iso/math_iso.h";
3173 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3174 " *\\{[^{}]*\n[^{}]*\\}";
3175 c_fix = format;
3176 c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif";
3178 test_text =
3179 " inline long double pow(long double __X, int __Y) { return\n"
3180 " __powl(__X, (long double) (__Y)); }";
3185 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3186 * fields of the pthread_rwlock_t structure, which are of type
3187 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3188 * defined (e.g. by -ansi) it is a union. So change the initializer
3189 * to "{0}" instead.
3191 fix = {
3192 hackname = solaris_rwlock_init_1;
3193 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3194 files = pthread.h;
3195 mach = '*-*-solaris*';
3196 c_fix = format;
3197 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3198 "%0\n"
3199 "#else\n"
3200 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3201 "#endif";
3202 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3203 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3205 test_text =
3206 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3207 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3212 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3213 * structure. As such, it need two levels of brackets, but only
3214 * contains one. Wrap the macro definition in an extra layer.
3216 fix = {
3217 hackname = solaris_once_init_1;
3218 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3219 files = pthread.h;
3220 mach = '*-*-solaris*';
3221 c_fix = format;
3222 c_fix_arg = "%1{%2}%3";
3223 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3224 test_text =
3225 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3226 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3231 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3232 * fields of the pthread_once_t structure, which are of type
3233 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3234 * defined (e.g. by -ansi) it is a union. So change the initializer
3235 * to "{0}" instead. This test relies on solaris_once_init_1.
3237 fix = {
3238 hackname = solaris_once_init_2;
3239 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3240 files = pthread.h;
3242 * On Solaris 10, this fix is unnecessary because upad64_t is
3243 * always defined correctly regardless of the definition of the
3244 * __STDC__ macro. The first "mach" pattern matches up to
3245 * solaris9. The second "mach" pattern will not match any two (or
3246 * more) digit solaris version, but it will match e.g. 2.5.1.
3248 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3249 c_fix = format;
3250 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3251 "%0\n"
3252 "#else\n"
3253 "%1{0}, {0}, {0}, {%3}%4\n"
3254 "#endif";
3255 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3256 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3257 test_text =
3258 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3259 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3264 * Sun Solaris 2 has a version of sys/int_const.h that defines
3265 * UINT8_C and UINT16_C to unsigned constants.
3267 fix = {
3268 hackname = solaris_int_const;
3269 files = sys/int_const.h;
3270 mach = '*-*-solaris2*';
3271 c_fix = format;
3272 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3273 "%1\n"
3274 "#define\tUINT16_C(c)\t(c)";
3275 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3276 "(/\*.*\*/)\n"
3277 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3278 test_text =
3279 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3280 "/* CSTYLED */\n"
3281 "#define UINT16_C(c) __CONCAT__(c,u)";
3286 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3287 * UINT8_MAX and UINT16_MAX to unsigned constants.
3289 fix = {
3290 hackname = solaris_int_limits_1;
3291 files = sys/int_limits.h;
3292 mach = '*-*-solaris2*';
3293 c_fix = format;
3294 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3295 "#define\tUINT16_MAX\t(65535)";
3296 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3297 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3298 test_text =
3299 "#define UINT8_MAX (255U)\n"
3300 "#define UINT16_MAX (65535U)";
3305 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3306 * INT_FAST16 limits to wrong values for sys/int_types.h.
3308 fix = {
3309 hackname = solaris_int_limits_2;
3310 files = sys/int_limits.h;
3311 mach = '*-*-solaris2*';
3312 c_fix = format;
3313 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3314 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3315 test_text =
3316 "#define INT_FAST16_MAX INT16_MAX\n"
3317 "#define UINT_FAST16_MAX UINT16_MAX\n"
3318 "#define INT_FAST16_MIN INT16_MIN";
3323 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3324 * SIZE_MAX as unsigned long.
3326 fix = {
3327 hackname = solaris_int_limits_3;
3328 files = sys/int_limits.h;
3329 mach = '*-*-solaris2*';
3330 c_fix = format;
3331 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3332 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3333 test_text =
3334 "#define SIZE_MAX 4294967295UL";
3339 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3340 * of Standard C99 64-bit types in 32-bit mode.
3342 fix = {
3343 hackname = solaris_int_types;
3344 select = "__STDC__ - 0 == 0";
3345 bypass = "_LONGLONG_TYPE";
3346 files = sys/int_types.h;
3347 c_fix = format;
3348 c_fix_arg =
3349 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3350 test_text =
3351 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3352 "typedef long long int64_t;\n"
3353 "#endif\n\n"
3354 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3355 "typedef int64_t intmax_t;\n"
3356 "#endif";
3361 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3362 * posix_spawn declarations, which doesn't work with C++.
3364 fix = {
3365 hackname = solaris_posix_spawn_restrict;
3366 files = spawn.h;
3367 mach = '*-*-solaris2*';
3368 c_fix = format;
3369 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3370 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3371 test_text =
3372 "char *const argv[_RESTRICT_KYWD],\n"
3373 "char *const envp[_RESTRICT_KYWD]);";
3378 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3379 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3381 fix = {
3382 hackname = solaris_std___filbuf;
3383 files = stdio.h;
3384 mach = '*-*-solaris2*';
3385 bypass = "using std::__filbuf";
3386 select = "(using std::perror;\n)(#endif)";
3387 c_fix = format;
3388 c_fix_arg = "%1#ifndef _LP64\n"
3389 "using std::__filbuf;\n"
3390 "using std::__flsbuf;\n"
3391 "#endif\n%2";
3393 test_text = "using std::perror;\n"
3394 "#endif";
3399 * Sun Solaris 8 has what appears to be some gross workaround for
3400 * some old version of their c++ compiler. G++ doesn't want it
3401 * either, but doesn't want to be tied to SunPRO version numbers.
3403 fix = {
3404 hackname = solaris_stdio_tag;
3405 files = stdio_tag.h;
3407 select = '__cplusplus < 54321L';
3408 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3409 "!defined(__GNUC__)" so we no longer need to fix it. */
3410 bypass = '__GNUC__';
3411 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3413 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3418 * On Solaris 9, __va_list needs to become a typedef for
3419 * __builtin_va_list to make -Wmissing-format-attribute work.
3421 fix = {
3422 hackname = solaris_sys_va_list;
3423 files = sys/va_list.h;
3424 mach = '*-*-solaris2.9';
3425 select = "#if.*__STDC__.*\n"
3426 "typedef void \\*__va_list;\n"
3427 "#else\n"
3428 "typedef char \\*__va_list;\n"
3429 "#endif";
3431 c_fix = format;
3432 c_fix_arg = "#ifdef __GNUC__\n"
3433 "typedef __builtin_va_list __va_list;\n"
3434 "#else\n"
3435 "%0\n"
3436 "#endif";
3437 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3438 "typedef void *__va_list;\n"
3439 "#else\n"
3440 "typedef char *__va_list;\n"
3441 "#endif";
3446 * a missing semi-colon at the end of the statsswtch structure definition.
3448 fix = {
3449 hackname = statsswtch;
3450 files = rpcsvc/rstat.h;
3451 select = "boottime$";
3452 c_fix = format;
3453 c_fix_arg = "boottime;";
3454 test_text = "struct statswtch {\n int boottime\n};";
3459 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3460 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3461 * OK too.
3463 fix = {
3464 hackname = stdio_stdarg_h;
3465 files = stdio.h;
3466 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3468 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3469 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3471 mach = '*-*-solaris2.1[0-9]*';
3472 not_machine = true;
3474 c_fix = wrap;
3476 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3478 test_text = "";
3483 * Don't use or define the name va_list in stdio.h. This is for
3484 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3485 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3486 * indicate that the header knows what it's doing -- under SUSv2,
3487 * stdio.h is required to define va_list, and we shouldn't break
3488 * that.
3490 fix = {
3491 hackname = stdio_va_list;
3492 files = stdio.h;
3493 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3495 * On Solaris 10, the definition in
3496 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3497 * there is therefore no need for this fix there.
3499 mach = '*-*-solaris2.1[0-9]*';
3500 not_machine = true;
3503 * Use __gnuc_va_list in arg types in place of va_list.
3504 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3505 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3506 * trailing parentheses and semicolon save all other systems from this.
3507 * Define __not_va_list__ (something harmless and unused)
3508 * instead of va_list.
3509 * Don't claim to have defined va_list.
3511 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3512 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3513 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3514 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3515 "s@ va_list@ __not_va_list__@\n"
3516 "s@\\*va_list@*__not_va_list__@\n"
3517 "s@ __va_list)@ __gnuc_va_list)@\n"
3518 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3519 "@typedef \\1 __not_va_list__;@\n"
3520 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3521 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3522 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3523 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3524 "s@VA_LIST@DUMMY_VA_LIST@\n"
3525 "s@_Va_LIST@_VA_LIST@";
3526 test_text = "extern void mumble( va_list);";
3531 * Fix headers that use va_list from stdio.h to use the updated
3532 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3533 * dealt with elsewhere. The presence of __gnuc_va_list,
3534 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3535 * knows what it's doing.
3537 fix = {
3538 hackname = stdio_va_list_clients;
3539 files = com_err.h;
3540 files = cps.h;
3541 files = curses.h;
3542 files = krb5.h;
3543 files = lc_core.h;
3544 files = pfmt.h;
3545 files = wchar.h;
3546 files = curses_colr/curses.h;
3547 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3548 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3549 otherwise protected. */
3550 bypass = 'include <stdarg\.h>|#ifdef va_start';
3553 * Use __gnuc_va_list in arg types in place of va_list.
3554 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3555 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3556 * trailing parentheses and semicolon save all other systems from this.
3557 * Define __not_va_list__ (something harmless and unused)
3558 * instead of va_list.
3559 * Don't claim to have defined va_list.
3561 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3562 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3563 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3564 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3565 "s@ va_list@ __not_va_list__@\n"
3566 "s@\\*va_list@*__not_va_list__@\n"
3567 "s@ __va_list)@ __gnuc_va_list)@\n"
3568 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3569 "@typedef \\1 __not_va_list__;@\n"
3570 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3571 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3572 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3573 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3574 "s@VA_LIST@DUMMY_VA_LIST@\n"
3575 "s@_Va_LIST@_VA_LIST@";
3576 test_text = "extern void mumble( va_list);";
3581 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3582 * is "!defined( __STRICT_ANSI__ )"
3584 fix = {
3585 hackname = strict_ansi_not;
3586 select = "^([ \t]*#[ \t]*if.*)"
3587 "(!__STDC__"
3588 "|__STDC__[ \t]*==[ \t]*0"
3589 "|__STDC__[ \t]*!=[ \t]*1"
3590 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3591 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3592 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3593 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3594 is not defined by GCC, so it is safe. */
3595 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3596 c_test = stdc_0_in_system_headers;
3598 c_fix = format;
3599 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3601 test_text = "#if !__STDC__ \n"
3602 "#if __STDC__ == 0\n"
3603 "#if __STDC__ != 1\n"
3604 "#if __STDC__ - 0 == 0"
3605 "/* not std C */\nint foo;\n"
3606 "\n#end-end-end-end-if :-)";
3610 * "__STDC__-0==0"
3611 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3613 fix = {
3614 hackname = strict_ansi_not_ctd;
3615 files = math.h, limits.h, stdio.h, signal.h,
3616 stdlib.h, sys/signal.h, time.h;
3618 * Starting at the beginning of a line, skip white space and
3619 * a leading "(" or "&&" or "||". One of those must be found.
3620 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3621 * expression. If these are nested, then they must accumulate
3622 * because we won't match any closing parentheses. Finally,
3623 * after skipping over all that, we must then match our suspect
3624 * phrase: "__STDC__-0==0" with or without white space.
3626 select = "^([ \t]*" '(\(|&&|\|\|)'
3627 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3628 "[ \t(]*)"
3629 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3630 c_test = stdc_0_in_system_headers;
3632 c_fix = format;
3633 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3635 test_text = "#if 1 && \\\\\n"
3636 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3637 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3638 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3639 "int foo;\n#endif";
3644 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3645 * is "defined( __STRICT_ANSI__ )"
3647 fix = {
3648 hackname = strict_ansi_only;
3649 select = "^([ \t]*#[ \t]*if.*)"
3650 "(__STDC__[ \t]*!=[ \t]*0"
3651 "|__STDC__[ \t]*==[ \t]*1"
3652 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3653 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3654 c_test = stdc_0_in_system_headers;
3656 c_fix = format;
3657 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3659 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3664 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3665 * in prototype without previous definition.
3667 fix = {
3668 hackname = struct_file;
3669 files = rpc/xdr.h;
3670 select = '^.*xdrstdio_create.*struct __file_s';
3671 c_fix = format;
3672 c_fix_arg = "struct __file_s;\n%0";
3673 test_text = "extern void xdrstdio_create( struct __file_s* );";
3678 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3679 * in prototype without previous definition.
3681 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3682 * function, and does define it.
3684 fix = {
3685 hackname = struct_sockaddr;
3686 files = rpc/auth.h;
3687 select = "^.*authdes_create.*struct sockaddr[^_]";
3688 bypass = "<sys/socket\.h>";
3689 bypass = "struct sockaddr;\n";
3690 c_fix = format;
3691 c_fix_arg = "struct sockaddr;\n%0";
3692 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3697 * Apply fix this to all OSs since this problem seems to effect
3698 * more than just SunOS.
3700 fix = {
3701 hackname = sun_auth_proto;
3702 files = rpc/auth.h;
3703 files = rpc/clnt.h;
3704 files = rpc/svc.h;
3705 files = rpc/xdr.h;
3706 bypass = "__cplusplus";
3708 * Select those files containing '(*name)()'.
3710 select = '\(\*[a-z][a-z_]*\)\(\)';
3712 c_fix = format;
3713 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3714 "#else\n%1();%2\n#endif";
3715 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3717 test_text =
3718 "struct auth_t {\n"
3719 " int (*name)(); /* C++ bad */\n"
3720 "};";
3725 * Fix bogus #ifdef on SunOS 4.1.
3727 fix = {
3728 hackname = sun_bogus_ifdef;
3729 files = "hsfs/hsfs_spec.h";
3730 files = "hsfs/iso_spec.h";
3731 select = '#ifdef(.*\|\|.*)';
3732 c_fix = format;
3733 c_fix_arg = "#if%1";
3735 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3740 * Fix the CAT macro in SunOS memvar.h.
3742 fix = {
3743 hackname = sun_catmacro;
3744 files = pixrect/memvar.h;
3745 select = "^#define[ \t]+CAT\\(a,b\\).*";
3746 c_fix = format;
3748 c_fix_arg =
3749 "#ifdef __STDC__\n"
3750 "# define CAT(a,b) a##b\n"
3751 "#else\n%0\n#endif";
3753 test_text =
3754 "#define CAT(a,b)\ta/**/b";
3759 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3760 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3762 fix = {
3763 hackname = sun_malloc;
3764 files = malloc.h;
3765 bypass = "_CLASSIC_ANSI_TYPES";
3767 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3768 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3769 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3770 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3771 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3773 test_text =
3774 "typedef char *\tmalloc_t;\n"
3775 "int \tfree();\n"
3776 "char*\tmalloc();\n"
3777 "char*\tcalloc();\n"
3778 "char*\trealloc();";
3783 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3785 fix = {
3786 hackname = sun_rusers_semi;
3787 files = rpcsvc/rusers.h;
3788 select = "_cnt$";
3789 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3790 test_text = "struct mumble\n int _cnt\n};";
3795 * signal.h on SunOS defines signal using (),
3796 * which causes trouble when compiling with g++ -pedantic.
3798 fix = {
3799 hackname = sun_signal;
3800 files = sys/signal.h;
3801 files = signal.h;
3802 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3804 c_fix = format;
3805 c_fix_arg =
3806 "#ifdef __cplusplus\n"
3807 "void\t(*signal(...))(...);\n"
3808 "#else\n%0\n#endif";
3810 test_text = "void\t(*signal())();";
3815 * Correct the return type for strlen in strings.h in SunOS 4.
3817 fix = {
3818 hackname = sunos_strlen;
3819 files = strings.h;
3820 select = "int[ \t]*strlen\\(\\);(.*)";
3821 c_fix = format;
3822 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3823 test_text = " int\tstrlen(); /* string length */";
3828 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3829 * that is visible to any ANSI compiler using this include. Simply
3830 * delete the lines that #define some string functions to internal forms.
3832 fix = {
3833 hackname = svr4_disable_opt;
3834 files = string.h;
3835 select = '#define.*__std_hdr_';
3836 sed = '/#define.*__std_hdr_/d';
3837 test_text = "#define strlen __std_hdr_strlen\n";
3842 * Fix broken decl of getcwd present on some svr4 systems.
3844 fix = {
3845 hackname = svr4_getcwd;
3846 files = stdlib.h;
3847 files = unistd.h;
3848 files = prototypes.h;
3849 select = 'getcwd\(char \*, int\)';
3851 c_fix = format;
3852 c_fix_arg = "getcwd(char *, size_t)";
3854 test_text = "extern char* getcwd(char *, int);";
3859 * Fix broken decl of profil present on some svr4 systems.
3861 fix = {
3862 hackname = svr4_profil;
3863 files = stdlib.h;
3864 files = unistd.h;
3866 select =
3867 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3868 c_fix = format;
3869 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3871 test_text =
3872 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3877 * Correct types for signal handler constants like SIG_DFL; they might be
3878 * void (*) (), and should be void (*) (int). C++ doesn't like the
3879 * old style.
3881 fix = {
3882 hackname = svr4_sighandler_type;
3883 files = sys/signal.h;
3884 select = 'void *\(\*\)\(\)';
3885 c_fix = format;
3886 c_fix_arg = "void (*)(int)";
3887 test_text = "#define SIG_DFL (void(*)())0\n"
3888 "#define SIG_IGN (void (*)())0\n";
3893 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
3894 * function 'getrnge' in <regexp.h> before they declare it. For these
3895 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
3896 * early on.
3898 * 'getrnge' traditionally manipulates a file-scope global called 'size',
3899 * so put the declaration right after the declaration of 'size'.
3901 * Don't do this if there is already a `static void getrnge' declaration
3902 * present, since this would cause a redeclaration error. Solaris 2.x has
3903 * such a declaration.
3905 fix = {
3906 hackname = svr4_undeclared_getrnge;
3907 files = regexp.h;
3908 select = "getrnge";
3909 bypass = "static void getrnge";
3910 c_fix = format;
3911 c_fix_arg = "%0\n"
3912 "static int getrnge ();";
3913 c_fix_arg = "^static int[ \t]+size;";
3914 test_text = "static int size;\n"
3915 "/* stuff which calls getrnge() */\n"
3916 "static getrnge()\n"
3917 "{}";
3922 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
3923 * in string.h on sysV68
3924 * Correct the return type for strlen in string.h on Lynx.
3925 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
3926 * Add missing const for strdup on OSF/1 V3.0.
3927 * On sysV88 layout is slightly different.
3929 fix = {
3930 hackname = sysv68_string;
3931 files = testing.h;
3932 files = string.h;
3933 bypass = "_CLASSIC_ANSI_TYPES";
3935 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
3936 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
3937 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
3939 sed = "/^extern char$/N";
3940 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3942 sed = "/^extern int$/N";
3943 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3945 sed = "/^\tstrncmp(),$/N";
3946 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3947 '\1;' "\\\nextern unsigned int\\\n\\2/";
3949 test_text =
3950 "extern int strlen();\n"
3952 "extern int ffs(long);\n"
3954 "extern char\n"
3955 "\t*memccpy(),\n"
3956 "\tmemcpy();\n"
3958 "extern int\n"
3959 "\tstrcmp(),\n"
3960 "\tstrncmp(),\n"
3961 "\tstrlen(),\n"
3962 "\tstrspn();\n"
3964 "extern int\n"
3965 "\tstrlen(), strspn();";
3970 * Fix return type of calloc, malloc, realloc, bsearch and exit
3972 fix = {
3973 hackname = sysz_stdlib_for_sun;
3974 files = stdlib.h;
3975 bypass = "_CLASSIC_ANSI_TYPES";
3977 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3978 c_fix = format;
3979 c_fix_arg = "void *\t%1(";
3981 test_text =
3982 "extern char*\tcalloc(size_t);\n"
3983 "extern char*\tmalloc(size_t);\n"
3984 "extern char*\trealloc(void*,size_t);\n"
3985 "extern char*\tbsearch(void*,size_t,size_t);\n";
3990 * __thread is now a keyword.
3992 fix = {
3993 hackname = thread_keyword;
3994 files = "pthread.h";
3995 files = "bits/sigthread.h";
3996 select = "([* ])__thread([,)])";
3997 c_fix = format;
3998 c_fix_arg = "%1__thr%2";
4000 test_text =
4001 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4002 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4003 "extern int pthread_cancel (pthread_t __thread);";
4007 * if the #if says _cplusplus, not the double underscore __cplusplus
4008 * that it should be
4010 fix = {
4011 hackname = tinfo_cplusplus;
4012 files = tinfo.h;
4013 select = "[ \t]_cplusplus";
4015 c_fix = format;
4016 c_fix_arg = " __cplusplus";
4017 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4022 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4024 fix = {
4025 hackname = ultrix_const;
4026 files = stdio.h;
4027 select = 'perror\( char \*';
4029 c_fix = format;
4030 c_fix_arg = "%1 const %3 *__";
4031 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4032 "[ \t]+(char|void) \\*__";
4034 test_text =
4035 "extern void perror( char *__s );\n"
4036 "extern int fputs( char *__s, FILE *);\n"
4037 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4038 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4039 "extern int scanf( char *__format, ...);\n";
4044 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4046 fix = {
4047 hackname = ultrix_const2;
4048 files = stdio.h;
4050 select = '\*fopen\( char \*';
4051 c_fix = format;
4052 c_fix_arg = "%1( const char *%3, const char *";
4053 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4054 "[ \t]*char[ \t]*\\*([^,]*),"
4055 "[ \t]*char[ \t]*\\*[ \t]*";
4057 test_text =
4058 "extern FILE *fopen( char *__filename, char *__type );\n"
4059 "extern int sscanf( char *__s, char *__format, ...);\n"
4060 "extern FILE *popen(char *, char *);\n"
4061 "extern char *tempnam(char*,char*);\n";
4066 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4068 fix = {
4069 hackname = va_i960_macro;
4070 files = arch/i960/archI960.h;
4071 select = "__(vsiz|vali|vpad|alignof__)";
4073 c_fix = format;
4074 c_fix_arg = "__vx%1";
4076 test_text =
4077 "extern int __vsiz vsiz;\n"
4078 "extern int __vali vali;\n"
4079 "extern int __vpad vpad;\n"
4080 "#define __alignof__(x) ...";
4085 * Define __CAN_USE_EXTERN_PREFIX on vms.
4087 fix = {
4088 hackname = vms_define_can_use_extern_prefix;
4089 files = "rtldef/decc$types.h";
4090 select = "#[ \t]*else\n"
4091 "#[ \t]*if defined\\(__DECCXX\\)\n"
4092 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4093 mach = "*-*-*vms*";
4094 c_fix = format;
4096 c_fix_arg = "%0"
4097 "# elif defined (__GNUC__)\n"
4098 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4100 test_text = "# else\n"
4101 "# if defined(__DECCXX)\n"
4102 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4103 "# endif\n"
4104 "# endif\n";
4108 * On VMS, use pragma extern_model instead of VAX-C keywords.
4110 fix = {
4111 hackname = vms_use_pragma_extern_model;
4112 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4113 "# pragma extern_model __save\n";
4114 mach = "*-*-*vms*";
4115 c_fix = format;
4117 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4118 "# pragma extern_model __save\n";
4120 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4121 "# pragma extern_model __save\n"
4122 "# pragma extern_model strict_refdef\n"
4123 " extern struct x zz$yy;\n"
4124 "# pragma extern_model __restore\n"
4125 "#endif\n";
4129 * On VMS, disable the use of dec-c string builtins
4131 fix = {
4132 hackname = vms_disable_decc_string_builtins;
4133 select = "#if !defined\\(__VAX\\)\n";
4134 mach = "*-*-*vms*";
4135 files = "rtldef/string.h";
4136 c_fix = format;
4138 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4140 test_text = "#if !defined(__VAX)\n";
4144 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4145 * conflict while building gcc. Likewise for <builtins.h>
4147 fix = {
4148 hackname = vms_use_quoted_include;
4149 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4150 mach = "*-*-*vms*";
4151 files = rtldef/wait.h, starlet_c/pthread.h;
4152 c_fix = format;
4154 c_fix_arg = '%1<sys/%2.h>';
4156 test_text = "# include <resource.h>";
4160 * On VMS, add missing braces around sigset_t constants.
4162 fix = {
4163 hackname = vms_add_missing_braces;
4164 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4165 mach = "*-*-*vms*";
4166 files = "rtldef/signal.h";
4167 c_fix = format;
4169 c_fix_arg = '%1 {%2} ';
4171 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4172 "{0x00000000, 0x00000000},\n"
4173 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4177 * On VMS, fix incompatible redeclaration of hostalias.
4179 fix = {
4180 hackname = vms_do_not_redeclare_hostalias;
4181 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4182 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4183 mach = "*-*-*vms*";
4184 files = "rtldef/resolv.h";
4185 c_fix = format;
4187 c_fix_arg = "%1\n"
4188 "/* %2 */";
4190 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4191 "__char_ptr32 hostalias (const char *);\n";
4195 * On VMS, some DEC-C builtins are directly used.
4197 fix = {
4198 hackname = vms_decc_builtin;
4199 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4200 mach = "*-*-*vms*";
4201 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4202 rtldef/socket.h;
4203 sed = "s@__MEMSET@memset@";
4204 sed = "s@__MEMMOVE@memmove@";
4205 sed = "s@__MEMCPY@memcpy@";
4206 sed = "s@__STRLEN@strlen@";
4207 sed = "s@__STRCPY@strcpy@";
4209 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4213 * On VMS, do not declare getopt and al if pointers are 64 bit.
4215 fix = {
4216 hackname = vms_no_64bit_getopt;
4217 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4218 /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
4219 mach = "*-*-*vms*";
4220 files = rtldef/stdio.h, rtldef/unistd.h;
4221 c_fix = format;
4223 c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n"
4224 "%0"
4225 "#endif\n";
4227 test_text = "int getopt (int, char * const [], const char *);";
4231 * On VMS, forward declare structure before referencing them in prototypes.
4233 fix = {
4234 hackname = vms_forward_declare_struct;
4235 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4236 "#ifdef __cplusplus\n";
4237 mach = "*-*-*vms*";
4238 files = rtldef/if.h;
4239 c_fix = format;
4241 c_fix_arg = "%1"
4242 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4244 test_text = "/* forward decls for C++ */\n"
4245 "#ifdef __cplusplus\n"
4246 "struct foo;\n"
4247 "#endif\n";
4251 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4252 * which is not yet fully supported by gcc.
4254 fix = {
4255 hackname = vms_use_fast_setjmp;
4256 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4257 mach = "*-*-*vms*";
4258 files = rtldef/setjmp.h;
4259 c_fix = format;
4261 c_fix_arg = "%0 defined (__GNUC__) ||";
4263 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4267 * AIX and Interix headers define NULL to be cast to a void pointer,
4268 * which is illegal in ANSI C++.
4270 fix = {
4271 hackname = void_null;
4272 files = curses.h;
4273 files = dbm.h;
4274 files = locale.h;
4275 files = stdio.h;
4276 files = stdlib.h;
4277 files = string.h;
4278 files = time.h;
4279 files = unistd.h;
4280 files = sys/dir.h;
4281 files = sys/param.h;
4282 files = sys/types.h;
4283 /* avoid changing C++ friendly NULL */
4284 bypass = __cplusplus;
4285 bypass = __null;
4286 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4287 c_fix = format;
4288 c_fix_arg = "#define NULL 0";
4289 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4294 * Make VxWorks header which is almost gcc ready fully gcc ready.
4296 fix = {
4297 hackname = vxworks_gcc_problem;
4298 files = types/vxTypesBase.h;
4299 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4301 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4302 "#if 1/";
4304 sed = "/[ \t]size_t/i\\\n"
4305 "#ifndef _GCC_SIZE_T\\\n"
4306 "#define _GCC_SIZE_T\n";
4308 sed = "/[ \t]size_t/a\\\n"
4309 "#endif\n";
4311 sed = "/[ \t]ptrdiff_t/i\\\n"
4312 "#ifndef _GCC_PTRDIFF_T\\\n"
4313 "#define _GCC_PTRDIFF_T\n";
4315 sed = "/[ \t]ptrdiff_t/a\\\n"
4316 "#endif\n";
4318 sed = "/[ \t]wchar_t/i\\\n"
4319 "#ifndef _GCC_WCHAR_T\\\n"
4320 "#define _GCC_WCHAR_T\n";
4322 sed = "/[ \t]wchar_t/a\\\n"
4323 "#endif\n";
4325 test_text =
4326 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4327 "typedef unsigned int size_t;\n"
4328 "typedef long ptrdiff_t;\n"
4329 "typedef unsigned short wchar_t;\n"
4330 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4335 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4337 fix = {
4338 hackname = vxworks_needs_vxtypes;
4339 files = time.h;
4340 select = "uint_t([ \t]+_clocks_per_sec)";
4341 c_fix = format;
4342 c_fix_arg = "unsigned int%1";
4343 test_text = "uint_t\t_clocks_per_sec;";
4348 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4350 fix = {
4351 hackname = vxworks_needs_vxworks;
4352 files = sys/stat.h;
4353 test = " -r types/vxTypesOld.h";
4354 test = " -n \"`egrep '#include' $file`\"";
4355 test = " -n \"`egrep ULONG $file`\"";
4356 select = "#[ \t]define[ \t]+__INCstath";
4358 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4359 "#include <types/vxTypesOld.h>\n";
4361 test_text = "`touch types/vxTypesOld.h`"
4362 "#include </dev/null> /* ULONG */\n"
4363 "# define\t__INCstath <sys/stat.h>";
4368 * Another bad dependency in VxWorks 5.2 <time.h>.
4370 fix = {
4371 hackname = vxworks_time;
4372 files = time.h;
4373 test = " -r vxWorks.h";
4375 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4376 c_fix = format;
4378 c_fix_arg =
4379 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4380 "#ifdef __cplusplus\n"
4381 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4382 "#else\n"
4383 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4384 "#endif\n"
4385 "#define __gcc_VOIDFUNCPTR_defined\n"
4386 "#endif\n"
4387 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4389 test_text = "`touch vxWorks.h`"
4390 "#define VOIDFUNCPTR (void(*)())";
4395 * There are several name conflicts with C++ reserved words in X11 header
4396 * files. These are fixed in some versions, so don't do the fixes if
4397 * we find __cplusplus in the file. These were found on the RS/6000.
4399 fix = {
4400 hackname = x11_class;
4401 files = X11/ShellP.h;
4402 bypass = __cplusplus;
4403 select = "^([ \t]*char \\*)class;(.*)";
4404 c_fix = format;
4405 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4406 "#else\n%1class;%2\n#endif";
4407 test_text =
4408 "struct {\n"
4409 " char *class;\n"
4410 "} mumble;\n";
4415 * class in Xm/BaseClassI.h
4417 fix = {
4418 hackname = x11_class_usage;
4419 files = Xm/BaseClassI.h;
4420 bypass = "__cplusplus";
4422 select = " class\\)";
4423 c_fix = format;
4424 c_fix_arg = " c_class)";
4426 test_text = "extern mumble (int class);\n";
4431 * new in Xm/Traversal.h
4433 fix = {
4434 hackname = x11_new;
4435 files = Xm/Traversal.h;
4436 bypass = __cplusplus;
4438 sed = "/Widget\told, new;/i\\\n"
4439 "#ifdef __cplusplus\\\n"
4440 "\\\tWidget\told, c_new;\\\n"
4441 "#else\n";
4443 sed = "/Widget\told, new;/a\\\n"
4444 "#endif\n";
4446 sed = "s/Widget new,/Widget c_new,/g";
4447 test_text =
4448 "struct wedge {\n"
4449 " Widget\told, new;\n"
4450 "};\nextern Wedged( Widget new, Widget old );";
4455 * Incorrect sprintf declaration in X11/Xmu.h
4457 fix = {
4458 hackname = x11_sprintf;
4459 files = X11/Xmu.h;
4460 files = X11/Xmu/Xmu.h;
4461 select = "^extern char \\*\tsprintf\\(\\);$";
4463 c_fix = format;
4464 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4466 test_text = "extern char *\tsprintf();";
4469 /*EOF*/