* Make-lang.in (cp/class.o): Depend upon gt-cp-class.h.
[official-gcc.git] / fixincludes / inclhack.def
blobf9845cc74f501ed9060e2e6e7d30642ca733d675
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 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
360 * which violates a requirement of ISO C.
362 fix = {
363 hackname = aix_pthread;
364 files = "pthread.h";
365 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
366 c_fix = format;
367 c_fix_arg = "%1 %2";
368 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
369 "{...init stuff...}";
374 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
375 * in an otherwise harmless (and #ifed out) macro definition
377 fix = {
378 hackname = aix_sysmachine;
379 files = sys/machine.h;
380 select = "\\\\ +\n";
381 c_fix = format;
382 c_fix_arg = "\\\n";
383 test_text = "#define FOO \\\n"
384 " bar \\ \n baz \\ \n bat";
389 * sys/wait.h on AIX 5.2 defines macros that have both signed and
390 * unsigned types in conditional expressions.
392 fix = {
393 hackname = aix_syswait_2;
394 files = sys/wait.h;
395 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
396 c_fix = format;
397 c_fix_arg = "? (int)%1";
398 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
403 * sys/signal.h on some versions of AIX uses volatile in the typedef of
404 * sig_atomic_t, which causes gcc to generate a warning about duplicate
405 * volatile when a sig_atomic_t variable is declared volatile, as
406 * required by ANSI C.
408 fix = {
409 hackname = aix_volatile;
410 files = sys/signal.h;
411 select = "typedef volatile int sig_atomic_t";
412 c_fix = format;
413 c_fix_arg = "typedef int sig_atomic_t";
414 test_text = "typedef volatile int sig_atomic_t;";
419 * Fix __assert declaration in assert.h on Alpha OSF/1.
421 fix = {
422 hackname = alpha___assert;
423 files = "assert.h";
424 select = '__assert\(char \*, char \*, int\)';
425 c_fix = format;
426 c_fix_arg = "__assert(const char *, const char *, int)";
427 test_text = 'extern void __assert(char *, char *, int);';
432 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
434 fix = {
435 hackname = alpha___extern_prefix;
436 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
437 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
439 mach = "alpha*-dec-osf*";
440 c_fix = format;
441 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
443 test_text = "#ifdef __DECC\n"
444 "#pragma extern_prefix \"_P\"\n"
445 "# if defined(__DECC)\n"
446 "# pragma extern_prefix \"_E\"\n"
447 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
448 "# pragma extern_prefix \"\"";
453 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
455 fix = {
456 hackname = alpha___extern_prefix_standards;
457 files = standards.h;
458 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
460 mach = "alpha*-dec-osf*";
461 c_fix = format;
462 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
464 test_text = "#if (_ISO_C_SOURCE>=19990L) "
465 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
470 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
471 * <sys/stat.h>. The tests for __DECC are special in various ways, so
472 * alpha__extern_prefix cannot be used.
474 fix = {
475 hackname = alpha___extern_prefix_sys_stat;
476 files = sys/stat.h;
477 files = sys/mount.h;
478 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
480 mach = "alpha*-dec-osf5*";
481 c_fix = format;
482 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
484 test_text = "# if defined(__DECC)";
489 * Fix assert macro in assert.h on Alpha OSF/1.
490 * The superfluous int cast breaks C++.
492 fix = {
493 hackname = alpha_assert;
494 files = "assert.h";
495 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
496 c_fix = format;
497 c_fix_arg = "%1(EX)";
498 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
499 ': __assert(#EX, __FILE__, __LINE__))';
504 * Fix #defines under Alpha OSF/1:
505 * The following files contain '#pragma extern_prefix "_FOO"' followed by
506 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
507 * statements is to reduce namespace pollution. While these macros work
508 * properly in most cases, they don't allow you to take a pointer to the
509 * "something" being modified. To get around this limitation, change these
510 * statements to be of the form '#define something _FOOsomething'.
512 * sed ain't egrep, lesson 2463: sed can use self-referential
513 * regular expressions. In the substitute expression below,
514 * "\\1" and "\\2" refer to subexpressions found earlier in the
515 * same match. So, we continue to use sed. "extern_prefix" will
516 * be a rare match anyway...
518 fix = {
519 hackname = alpha_bad_lval;
521 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
522 mach = "alpha*-dec-osf*";
524 sed =
525 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
526 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
528 test_text = '#pragma extern_prefix "_FOO"'"\n"
529 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
530 "#define mumble _FOOmumble";
535 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
537 fix = {
538 hackname = alpha_getopt;
539 files = "stdio.h";
540 files = "stdlib.h";
541 select = 'getopt\(int, char \*\[\], *char \*\)';
542 c_fix = format;
543 c_fix_arg = "getopt(int, char *const[], const char *)";
544 test_text = 'extern int getopt(int, char *[], char *);';
549 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
551 fix = {
552 hackname = alpha_if_semicolon;
553 files = net/if.h;
554 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
555 c_fix = format;
556 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
557 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
562 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
564 fix = {
565 hackname = alpha_parens;
566 files = sym.h;
567 select = '#ifndef\(__mips64\)';
568 c_fix = format;
569 c_fix_arg = "#ifndef __mips64";
570 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
575 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
577 fix = {
578 hackname = alpha_pthread;
579 files = pthread.h;
580 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
581 "|def _PTHREAD_ENV_DECC)(.*))\n"
582 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
584 mach = "alpha*-dec-osf*";
585 c_fix = format;
586 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
587 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
589 test_text = "# if defined (_PTHREAD_ENV_DECC) "
590 "|| defined (_PTHREAD_ENV_EPCC)\n"
591 "# define _PTHREAD_USE_PTDNAM_\n"
592 "# endif\n"
593 "# ifdef _PTHREAD_ENV_DECC\n"
594 "# define _PTHREAD_USE_PTDNAM_\n"
595 "# endif";
600 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
602 fix = {
603 hackname = alpha_pthread_gcc;
604 files = pthread.h;
605 select = "#else\n# error <pthread.h>: unrecognized compiler.";
607 mach = "alpha*-dec-osf*";
608 c_fix = format;
609 c_fix_arg = "#elif defined (__GNUC__)\n"
610 "# define _PTHREAD_ENV_GCC\n"
611 "%0";
613 test_text = "# define _PTHREAD_ENV_INTELC\n"
614 "#else\n"
615 "# error <pthread.h>: unrecognized compiler.\n"
616 "#endif";
621 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
622 * incorrectly, specifying less fields in the initializers than are
623 * defined in the corresponding structure types. Use of these macros
624 * in user code results in spurious warnings.
626 fix = {
627 hackname = alpha_pthread_init;
628 files = pthread.h;
629 select = ' \* @\(#\).RCSfile: pthread\.h,v \$'
630 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
631 ' .Date: 2000/08/15 15:30:13 \$';
632 mach = "alpha*-dec-osf*";
633 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
634 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
635 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
636 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
637 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
638 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
639 test_text = <<- _EOText_
641 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
643 #ifndef _PTHREAD_NOMETER_STATIC
644 # define PTHREAD_MUTEX_INITIALIZER \
645 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
646 # define PTHREAD_COND_INITIALIZER \
647 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
648 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
649 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
650 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
651 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
652 #else
653 # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
654 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
655 {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
656 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
657 {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
658 #endif
660 #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
661 #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
662 {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
663 _EOText_;
668 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
669 * And OpenBSD.
671 fix = {
672 hackname = alpha_sbrk;
673 files = unistd.h;
674 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
675 c_fix = format;
676 c_fix_arg = "void *sbrk(";
677 test_text = "extern char* sbrk(ptrdiff_t increment);";
682 * Change external names of wcstok/wcsftime via asm instead of macros on
683 * Tru64 UNIX V4.0.
685 fix = {
686 hackname = alpha_wchar;
687 files = wchar.h;
689 mach = "alpha*-dec-osf4*";
690 select = "#define wcstok wcstok_r";
691 sed = "s@#define wcstok wcstok_r@"
692 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
693 "wchar_t **)) __asm__(\"wcstok_r\");@";
694 sed = "s@#define wcsftime __wcsftime_isoc@"
695 "extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *"
696 ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
697 test_text = "#define wcstok wcstok_r\n"
698 "#define wcsftime __wcsftime_isoc";
703 * For C++, avoid any typedef or macro definition of bool,
704 * and use the built in type instead.
705 * HP/UX 10.20 also has it in curses_colr/curses.h.
707 fix = {
708 hackname = avoid_bool_define;
709 files = curses.h;
710 files = curses_colr/curses.h;
711 files = term.h;
712 files = tinfo.h;
714 select = "#[ \t]*define[ \t]+bool[ \t]";
715 bypass = "__cplusplus";
717 c_fix = format;
718 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
719 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
721 test_text = "# define bool\t char \n";
725 fix = {
726 hackname = avoid_bool_type;
727 files = curses.h;
728 files = curses_colr/curses.h;
729 files = term.h;
730 files = tinfo.h;
732 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
733 bypass = "__cplusplus";
735 c_fix = format;
736 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
738 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
743 * For C++, avoid any typedef definition of wchar_t,
744 * and use the built in type instead.
745 * Don't do this for headers that are smart enough to do the right
746 * thing (recent [n]curses.h and Xlib.h).
747 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
748 * and will be broken by the edit.
751 fix = {
752 hackname = avoid_wchar_t_type;
754 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
755 bypass = "__cplusplus";
756 bypass = "_LINUX_NLS_H";
757 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
759 c_fix = format;
760 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
762 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
767 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
769 fix = {
770 hackname = bad_struct_term;
771 files = curses.h;
772 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
773 c_fix = format;
774 c_fix_arg = "struct term;";
776 test_text = 'typedef struct term;';
781 * Fix one other error in this file:
782 * a mismatched quote not inside a C comment.
784 fix = {
785 hackname = badquote;
786 files = sundev/vuid_event.h;
787 select = "doesn't";
788 c_fix = format;
789 c_fix_arg = "does not";
791 test_text = "/* doesn't have matched single quotes */";
796 * check for broken assert.h that needs stdio.h
798 fix = {
799 hackname = broken_assert_stdio;
800 files = assert.h;
801 select = stderr;
802 bypass = "include.*stdio\\.h";
803 c_fix = wrap;
804 c_fix_arg = "#include <stdio.h>\n";
805 test_text = "extern FILE* stderr;";
810 * check for broken assert.h that needs stdlib.h
812 fix = {
813 hackname = broken_assert_stdlib;
814 files = assert.h;
815 select = 'exit *\(|abort *\(';
816 bypass = "include.*stdlib\\.h";
817 c_fix = wrap;
818 c_fix_arg = "#ifdef __cplusplus\n"
819 "#include <stdlib.h>\n"
820 "#endif\n";
821 test_text = "extern void exit ( int );";
826 * Remove `extern double cabs' declarations from math.h.
827 * This conflicts with C99. Discovered on AIX.
828 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
829 * declares cabs() to take a struct __cabs_s argument.
830 * SunOS4 has its cabs() declaration followed by a comment which
831 * terminates on the following line.
832 * Darwin hides its broken cabs in architecture-specific subdirs.
834 fix = {
835 hackname = broken_cabs;
836 files = math.h, "architecture/*/math.h";
837 select = "^extern[ \t]+double[ \t]+cabs";
839 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
840 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
842 test_text = "#ifdef __STDC__\n"
843 "extern double cabs(struct dbl_hypot);\n"
844 "#else\n"
845 "extern double cabs();\n"
846 "#endif\n"
847 "extern double cabs ( _Complex z );\n"
848 "extern double cabs(); /* This is a comment\n"
849 " and it ends here. */\n"
850 "extern double cabs(struct __cabs_s);\n"
851 "extern long double cabsl( struct __cabsl_s );";
856 * Fixup Darwin's broken check for __builtin_nanf.
858 fix = {
859 hackname = broken_nan;
861 * It is tempting to omit the first "files" entry. Do not.
862 * The testing machinery will take the first "files" entry as the name
863 * of a test file to play with. It would be a nuisance to have a directory
864 * with the name "*".
866 files = "architecture/ppc/math.h";
867 files = "architecture/*/math.h";
868 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
869 bypass = "powl";
870 c_fix = format;
871 c_fix_arg = "#if 1";
872 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
877 * Various systems derived from BSD4.4 contain a macro definition
878 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
879 * Known to be fixed in FreeBSD 5 system headers.
881 fix = {
882 hackname = bsd_stdio_attrs_conflict;
883 mach = "*-*-*bsd*";
884 mach = "*-*-*darwin*";
885 files = stdio.h;
886 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
887 c_fix = format;
888 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
889 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
890 'int vfscanf(FILE *, const char *, __builtin_va_list) '
891 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
892 test_text = '#define vfscanf __svfscanf';
897 * Fix various macros used to define ioctl numbers.
898 * The traditional syntax was:
900 * #define _CTRL(n, x) (('n'<<8)+x)
901 * #define TCTRLCFOO _CTRL(T, 1)
903 * but this does not work with the C standard, which disallows macro
904 * expansion inside strings. We have to rewrite it thus:
906 * #define _CTRL(n, x) ((n<<8)+x)
907 * #define TCTRLCFOO _CTRL('T', 1)
909 * The select expressions match too much, but the c_fix code is cautious.
911 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
913 fix = {
914 hackname = ctrl_quotes_def;
915 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
916 c_fix = char_macro_def;
917 c_fix_arg = "CTRL";
920 * This is two tests in order to ensure that the "CTRL(c)" can
921 * be selected in isolation from the multi-arg format
923 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
924 test_text = "#define _CTRL(c) ('c'&037)";
927 fix = {
928 hackname = ctrl_quotes_use;
929 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
930 c_fix = char_macro_use;
931 c_fix_arg = "CTRL";
932 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
937 * sys/mman.h on HP/UX is not C++ ready,
938 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
940 * rpc/types.h on OSF1/2.0 is not C++ ready,
941 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
943 * The problem is the declaration of malloc.
945 fix = {
946 hackname = cxx_unready;
947 files = sys/mman.h;
948 files = rpc/types.h;
949 select = '[^#]+malloc.*;'; /* Catch any form of declaration
950 not within a macro. */
951 bypass = '"C"|__BEGIN_DECLS';
953 c_fix = wrap;
954 c_fix_arg = "#ifdef __cplusplus\n"
955 "extern \"C\" {\n"
956 "#endif\n";
957 c_fix_arg = "#ifdef __cplusplus\n"
958 "}\n"
959 "#endif\n";
960 test_text = "extern void* malloc( size_t );";
965 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
966 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
968 fix = {
969 hackname = darwin_externc;
970 mach = "*-*-darwin*";
971 files = mach-o/swap.h;
972 files = mach/mach_time.h;
973 files = mach/mach_traps.h;
974 files = mach/message.h;
975 files = mach/mig.h;
976 files = mach/semaphore.h;
977 bypass = "extern \"C\"";
978 bypass = "__BEGIN_DECLS";
979 c_fix = wrap;
980 c_fix_arg = "#ifdef __cplusplus\n"
981 "extern \"C\" {\n"
982 "#endif\n";
983 c_fix_arg = "#ifdef __cplusplus\n"
984 "}\n"
985 "#endif\n";
986 test_text = "extern void swap_fat_header();\n";
991 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
992 * bad __GNUC__ tests.
995 fix = {
996 hackname = darwin_gcc4_breakage;
997 mach = "*-*-darwin*";
998 files = AvailabilityMacros.h;
999 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1000 c_fix = format;
1001 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1002 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1003 "(__GNUC_MINOR__ >= 1)\n";
1008 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1009 * why would you ever put it in a system header file?
1011 fix = {
1012 hackname = darwin_private_extern;
1013 mach = "*-*-darwin*";
1014 files = mach-o/dyld.h;
1015 select = "__private_extern__ [a-z_]+ _dyld_";
1016 c_fix = format;
1017 c_fix_arg = "extern";
1018 c_fix_arg = "__private_extern__";
1019 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1020 "const char *dyld_func_name,\n"
1021 "unsigned long *address);\n";
1026 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1027 * unsigned constants.
1029 fix = {
1030 hackname = darwin_stdint_1;
1031 mach = "*-*-darwin*";
1032 files = stdint.h;
1033 c_fix = format;
1034 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1035 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1036 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1037 test_text = "#define UINT8_C(v) (v ## U)\n"
1038 "#define UINT16_C(v) (v ## U)";
1043 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1044 * with wrong types.
1046 fix = {
1047 hackname = darwin_stdint_2;
1048 mach = "*-*-darwin*";
1049 files = stdint.h;
1050 c_fix = format;
1051 c_fix_arg = "#if __WORDSIZE == 64\n"
1052 "#define INTPTR_MAX 9223372036854775807L\n"
1053 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1054 "#else\n"
1055 "#define INTPTR_MAX 2147483647L\n"
1056 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1057 "#endif";
1058 select = "#if __WORDSIZE == 64\n"
1059 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1060 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1061 "#else\n"
1062 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1063 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1064 "#endif";
1065 test_text = "#if __WORDSIZE == 64\n"
1066 "#define INTPTR_MIN INT64_MIN\n"
1067 "#define INTPTR_MAX INT64_MAX\n"
1068 "#else\n"
1069 "#define INTPTR_MIN INT32_MIN\n"
1070 "#define INTPTR_MAX INT32_MAX\n"
1071 "#endif";
1076 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1078 fix = {
1079 hackname = darwin_stdint_3;
1080 mach = "*-*-darwin*";
1081 files = stdint.h;
1082 c_fix = format;
1083 c_fix_arg = "#if __WORDSIZE == 64\n"
1084 "#define UINTPTR_MAX 18446744073709551615UL\n"
1085 "#else\n"
1086 "#define UINTPTR_MAX 4294967295UL\n"
1087 "#endif";
1088 select = "#if __WORDSIZE == 64\n"
1089 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1090 "#else\n"
1091 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1092 "#endif";
1093 test_text = "#if __WORDSIZE == 64\n"
1094 "#define UINTPTR_MAX UINT64_MAX\n"
1095 "#else\n"
1096 "#define UINTPTR_MAX UINT32_MAX\n"
1097 "#endif";
1102 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1104 fix = {
1105 hackname = darwin_stdint_4;
1106 mach = "*-*-darwin*";
1107 files = stdint.h;
1108 c_fix = format;
1109 c_fix_arg = "#if __WORDSIZE == 64\n"
1110 "#define SIZE_MAX 18446744073709551615UL\n"
1111 "#else\n"
1112 "#define SIZE_MAX 4294967295UL\n"
1113 "#endif";
1114 select = "#if __WORDSIZE == 64\n"
1115 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1116 "#else\n"
1117 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1118 "#endif";
1119 test_text = "#if __WORDSIZE == 64\n"
1120 "#define SIZE_MAX UINT64_MAX\n"
1121 "#else\n"
1122 "#define SIZE_MAX UINT32_MAX\n"
1123 "#endif";
1128 * Fix <c_asm.h> on Digital UNIX V4.0:
1129 * It contains a prototype for a DEC C internal asm() function,
1130 * clashing with gcc's asm keyword. So protect this with __DECC.
1132 fix = {
1133 hackname = dec_intern_asm;
1134 files = c_asm.h;
1135 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1136 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1137 "#endif\n";
1138 test_text =
1139 "float fasm {\n"
1140 " ... asm stuff ...\n"
1141 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1146 * Fix typo in <wchar.h> on DJGPP 2.03.
1148 fix = {
1149 hackname = djgpp_wchar_h;
1150 file = wchar.h;
1151 select = "__DJ_wint_t";
1152 bypass = "sys/djtypes.h";
1153 c_fix = format;
1154 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1155 c_fix_arg = "#include <stddef.h>";
1156 test_text = "#include <stddef.h>\n"
1157 "extern __DJ_wint_t x;\n";
1162 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1164 fix = {
1165 hackname = ecd_cursor;
1166 files = "sunwindow/win_lock.h";
1167 files = "sunwindow/win_cursor.h";
1168 select = 'ecd\.cursor';
1169 c_fix = format;
1170 c_fix_arg = 'ecd_cursor';
1172 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1177 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1178 * neither the existence of GCC 3 nor its exact feature set yet break
1179 * (by design?) when __GNUC__ is set beyond 2.
1181 fix = {
1182 hackname = freebsd_gcc3_breakage;
1183 mach = "*-*-freebsd*";
1184 files = sys/cdefs.h;
1185 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1186 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1187 c_fix = format;
1188 c_fix_arg = '%0 || __GNUC__ >= 3';
1189 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1194 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1195 * neither the existence of GCC 4 nor its exact feature set yet break
1196 * (by design?) when __GNUC__ is set beyond 3.
1198 fix = {
1199 hackname = freebsd_gcc4_breakage;
1200 mach = "*-*-freebsd*";
1201 files = sys/cdefs.h;
1202 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1203 c_fix = format;
1204 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1205 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1210 * Some versions of glibc don't expect the C99 inline semantics.
1212 fix = {
1213 hackname = glibc_c99_inline_1;
1214 files = features.h, '*/features.h';
1215 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1216 c_fix = format;
1217 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1218 test_text = <<-EOT
1219 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1220 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1221 # define __USE_EXTERN_INLINES 1
1222 #endif
1223 EOT;
1228 * Similar, but a version that didn't have __NO_INLINE__
1230 fix = {
1231 hackname = glibc_c99_inline_1a;
1232 files = features.h, '*/features.h';
1233 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1234 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1235 c_fix = format;
1236 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1237 test_text = <<-EOT
1238 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1239 # define __USE_EXTERN_INLINES 1
1240 #endif
1241 EOT;
1246 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1247 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1248 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1250 fix = {
1251 hackname = glibc_c99_inline_2;
1252 files = sys/stat.h, '*/sys/stat.h';
1253 select = "extern __inline__ int";
1254 sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
1255 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1256 "__inline__ int \\1/";
1257 sed = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
1258 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1259 "__inline__ int __REDIRECT\\1 (\\2/";
1260 sed = "s/^extern __inline__ int/"
1261 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1262 "__inline__ int/";
1263 test_text = <<-EOT
1264 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1265 extern __inline__ int
1266 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1268 EOT;
1272 fix = {
1273 hackname = glibc_c99_inline_3;
1274 files = bits/string2.h, '*/bits/string2.h';
1275 select = "extern __inline";
1276 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1277 c_fix = format;
1278 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1279 c_fix_arg = "^# ifdef __cplusplus$";
1280 test_text = <<-EOT
1281 # ifdef __cplusplus
1282 # define __STRING_INLINE inline
1283 # else
1284 # define __STRING_INLINE extern __inline
1285 # endif
1286 EOT;
1290 fix = {
1291 hackname = glibc_c99_inline_4;
1292 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1293 bypass = "__extern_inline|__gnu_inline__";
1294 select = "(^| )extern __inline";
1295 c_fix = format;
1296 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1297 test_text = <<-EOT
1298 __extension__ extern __inline unsigned int
1299 extern __inline unsigned int
1300 EOT;
1304 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1305 * so we replace them with versions that correspond to the
1306 * definition.
1308 fix = {
1309 hackname = glibc_mutex_init;
1310 files = pthread.h;
1311 select = '\{ *\{ *0, *\} *\}';
1312 sed = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1313 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1314 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1315 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1316 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1317 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1318 sed = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1319 "N;s/^[ \t]*#[ \t]*"
1320 "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1321 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
1322 "# \\1\\n"
1323 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1324 "# else\\n"
1325 "# \\1\\n"
1326 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1327 "# endif/";
1328 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1329 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1330 sed = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
1331 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1333 test_text = <<- _EOText_
1334 #define PTHREAD_MUTEX_INITIALIZER \\
1335 { { 0, } }
1336 #ifdef __USE_GNU
1337 # if __WORDSIZE == 64
1338 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1339 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1340 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1341 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1342 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1343 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1344 # else
1345 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1346 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1347 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1348 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1349 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1350 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1351 # endif
1352 #endif
1353 # define PTHREAD_RWLOCK_INITIALIZER \\
1354 { { 0, } }
1355 # ifdef __USE_GNU
1356 # if __WORDSIZE == 64
1357 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1358 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1359 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1360 # else
1361 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1362 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1363 # endif
1364 # endif
1365 #define PTHREAD_COND_INITIALIZER { { 0, } }
1366 _EOText_;
1370 /* glibc versions before 2.5 have a version of stdint.h that defines
1371 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1372 versions with stdint.h based on those glibc versions. */
1373 fix = {
1374 hackname = glibc_stdint;
1375 files = stdint.h;
1376 select = "GNU C Library";
1377 c_fix = format;
1378 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1379 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1380 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";
1384 /* glibc's tgmath.h relies on an expression that is not an integer
1385 constant expression being treated as it was by GCC 4.4 and
1386 earlier. */
1387 fix = {
1388 hackname = glibc_tgmath;
1389 files = tgmath.h;
1390 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1391 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1392 c_fix = format;
1393 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1394 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1398 * Fix these files to use the types we think they should for
1399 * ptrdiff_t, size_t, and wchar_t.
1401 * This defines the types in terms of macros predefined by our 'cpp'.
1402 * This is supposedly necessary for glibc's handling of these types.
1403 * It's probably not necessary for anyone else, but it doesn't hurt.
1405 fix = {
1406 hackname = gnu_types;
1407 files = "sys/types.h";
1408 files = "stdlib.h";
1409 files = "sys/stdtypes.h";
1410 files = "stddef.h";
1411 files = "memory.h";
1412 files = "unistd.h";
1413 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1414 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1415 c_fix = gnu_type;
1416 /* The Solaris 10 headers already define these types correctly. */
1417 mach = '*-*-solaris2.1[0-9]*';
1418 not_machine = true;
1420 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1421 "typedef uint_t size_t; /* uint_t */\n"
1422 "typedef ushort_t wchar_t; /* ushort_t */";
1427 * Fix HP & Sony's use of "../machine/xxx.h"
1428 * to refer to: <machine/xxx.h>
1430 fix = {
1431 hackname = hp_inline;
1432 files = sys/spinlock.h;
1433 files = machine/machparam.h;
1434 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1436 c_fix = format;
1437 c_fix_arg = "%1<machine/%2.h>";
1439 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1440 '([a-z]+)\.h"';
1442 test_text = ' # include "../machine/mumble.h"';
1447 * Check for (...) in C++ code in HP/UX sys/file.h.
1449 fix = {
1450 hackname = hp_sysfile;
1451 files = sys/file.h;
1452 select = "HPUX_SOURCE";
1454 c_fix = format;
1455 c_fix_arg = "(struct file *, ...)";
1456 c_fix_arg = '\(\.\.\.\)';
1458 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1463 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1464 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1466 fix = {
1467 hackname = hppa_hpux_fp_macros;
1468 mach = "hppa*-hp-hpux11*";
1469 files = math.h;
1470 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1471 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1472 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1473 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1474 "#[ \t]*define[ \t]*FP_NAN.*\n";
1475 c_fix = format;
1476 c_fix_arg = <<- _EOFix_
1477 #endif /* _INCLUDE_HPUX_SOURCE */
1479 #if defined(_INCLUDE_HPUX_SOURCE) || \
1480 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1481 %0#endif
1483 #ifdef _INCLUDE_HPUX_SOURCE
1485 _EOFix_;
1487 test_text =
1488 "# define FP_NORMAL 0\n"
1489 "# define FP_ZERO 1\n"
1490 "# define FP_INFINITE 2\n"
1491 "# define FP_SUBNORMAL 3\n"
1492 "# define FP_NAN 4\n";
1497 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1498 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1500 fix = {
1501 hackname = hpux10_cpp_pow_inline;
1502 files = fixinc-test-limits.h, math.h;
1503 select = <<- END_POW_INLINE
1504 ^# +ifdef +__cplusplus
1506 +inline +double +pow\(double +__d,int +__expon\) +\{
1507 [ ]+return +pow\(__d,\(double\)__expon\);
1509 +extern +"C" +\{
1510 #else
1511 # +endif
1512 END_POW_INLINE;
1514 c_fix = format;
1515 c_fix_arg = "";
1517 test_text =
1518 "# ifdef __cplusplus\n"
1519 " }\n"
1520 " inline double pow(double __d,int __expon) {\n"
1521 "\t return pow(__d,(double)__expon);\n"
1522 " }\n"
1523 ' extern "C"' " {\n"
1524 "#else\n"
1525 "# endif";
1528 fix = {
1529 hackname = hpux11_cpp_pow_inline;
1530 files = math.h;
1531 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1532 " +return pow\\(d, \\(double\\)expon\\);\n"
1533 " +\\}\n";
1534 c_fix = format;
1535 c_fix_arg = "";
1537 test_text =
1538 " inline double pow(double d,int expon) {\n"
1539 " return pow(d, (double)expon);\n"
1540 " }\n";
1545 * Fix hpux 10.X missing ctype declarations 1
1547 fix = {
1548 hackname = hpux10_ctype_declarations1;
1549 files = ctype.h;
1550 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1551 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1552 c_fix = format;
1553 c_fix_arg = "#ifdef _PROTOTYPES\n"
1554 "extern int __tolower(int);\n"
1555 "extern int __toupper(int);\n"
1556 "#else /* NOT _PROTOTYPES */\n"
1557 "extern int __tolower();\n"
1558 "extern int __toupper();\n"
1559 "#endif /* _PROTOTYPES */\n\n"
1560 "%0\n";
1562 test_text = "# define _toupper(__c) __toupper(__c)\n";
1567 * Fix hpux 10.X missing ctype declarations 2
1569 fix = {
1570 hackname = hpux10_ctype_declarations2;
1571 files = ctype.h;
1572 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1573 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1574 c_fix = format;
1575 c_fix_arg = "%0\n\n"
1576 "#ifdef _PROTOTYPES\n"
1577 " extern int _isalnum(int);\n"
1578 " extern int _isalpha(int);\n"
1579 " extern int _iscntrl(int);\n"
1580 " extern int _isdigit(int);\n"
1581 " extern int _isgraph(int);\n"
1582 " extern int _islower(int);\n"
1583 " extern int _isprint(int);\n"
1584 " extern int _ispunct(int);\n"
1585 " extern int _isspace(int);\n"
1586 " extern int _isupper(int);\n"
1587 " extern int _isxdigit(int);\n"
1588 "# else /* not _PROTOTYPES */\n"
1589 " extern int _isalnum();\n"
1590 " extern int _isalpha();\n"
1591 " extern int _iscntrl();\n"
1592 " extern int _isdigit();\n"
1593 " extern int _isgraph();\n"
1594 " extern int _islower();\n"
1595 " extern int _isprint();\n"
1596 " extern int _ispunct();\n"
1597 " extern int _isspace();\n"
1598 " extern int _isupper();\n"
1599 " extern int _isxdigit();\n"
1600 "#endif /* _PROTOTYPES */\n";
1602 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1603 " extern unsigned int *__SB_masks;\n";
1608 * Fix hpux 10.X missing stdio declarations
1610 fix = {
1611 hackname = hpux10_stdio_declarations;
1612 files = stdio.h;
1613 select = "^#[ \t]*define _iob[ \t]*__iob";
1614 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1615 c_fix = format;
1616 c_fix_arg = "%0\n\n"
1617 "# if defined(__STDC__) || defined(__cplusplus)\n"
1618 " extern int snprintf(char *, size_t, const char *, ...);\n"
1619 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1620 "# else /* not __STDC__) || __cplusplus */\n"
1621 " extern int snprintf();\n"
1622 " extern int vsnprintf();\n"
1623 "# endif /* __STDC__) || __cplusplus */\n";
1625 test_text = "# define _iob __iob\n";
1630 * Make sure hpux defines abs in header.
1632 fix = {
1633 hackname = hpux11_abs;
1634 mach = "ia64-hp-hpux11*";
1635 files = stdlib.h;
1636 select = "ifndef _MATH_INCLUDED";
1637 c_fix = format;
1638 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1639 test_text = "#ifndef _MATH_INCLUDED";
1644 * Keep HP-UX 11 from stomping on C++ math namespace
1645 * with defines for fabsf.
1647 fix = {
1648 hackname = hpux11_fabsf;
1649 files = math.h;
1650 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1651 bypass = "__cplusplus";
1653 c_fix = format;
1654 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1656 test_text =
1657 "#ifdef _PA_RISC\n"
1658 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1659 "#endif";
1664 * Fix C99 constant in __POINTER_SET define.
1666 fix = {
1667 hackname = hpux11_pthread_const;
1668 mach = "*-hp-hpux11.[0-3]*";
1669 files = sys/pthread.h;
1670 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1672 c_fix = format;
1673 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1674 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1679 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1680 * being defined by having it define _hpux_size_t instead.
1682 fix = {
1683 hackname = hpux11_size_t;
1684 mach = "*-hp-hpux11*";
1685 select = "__size_t";
1687 c_fix = format;
1688 c_fix_arg = "_hpux_size_t";
1690 test_text =
1691 "#define __size_t size_t\n"
1692 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1697 * Fix hpux 11.00 broken snprintf declaration
1698 * (third argument is char *, needs to be const char * to prevent
1699 * spurious warnings with -Wwrite-strings or in C++).
1701 fix = {
1702 hackname = hpux11_snprintf;
1703 files = stdio.h;
1704 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1705 ' *(char *\*, *\.\.\.\);)';
1706 c_fix = format;
1707 c_fix_arg = '%1 const %3';
1709 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1710 "extern int snprintf(char *, __size_t, char *, ...);\n"
1711 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1715 * Fix hpux 11.00 broken vsnprintf declaration
1717 fix = {
1718 hackname = hpux11_vsnprintf;
1719 files = stdio.h;
1720 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1721 'const char \*,) __va__list\);';
1722 c_fix = format;
1723 c_fix_arg = "%1 __va_list);";
1725 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1726 ' __va__list);';
1731 * get rid of bogus inline definitions in HP-UX 8.0
1733 fix = {
1734 hackname = hpux8_bogus_inlines;
1735 files = math.h;
1736 select = inline;
1737 bypass = "__GNUG__";
1738 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1739 "@extern \"C\" int abs(int);@";
1740 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1741 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1742 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1743 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1744 "inline double sqr(double v) { return v**0.5; }";
1749 * Fix hpux broken ctype macros
1751 fix = {
1752 hackname = hpux_ctype_macros;
1753 files = ctype.h;
1754 select = '((: |\()__SB_masks \? )'
1755 '(__SB_masks\[__(alnum|c)\] & _IS)';
1756 c_fix = format;
1757 c_fix_arg = "%1(int)%3";
1759 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1760 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1765 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1767 fix = {
1768 hackname = hpux_htonl;
1769 files = netinet/in.h;
1770 select = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1771 "(/\\*\n"
1772 " \\* Macros for number representation conversion\\.\n"
1773 " \\*/\n"
1774 "#ifndef ntohl)";
1775 c_fix = format;
1776 c_fix_arg = "#if 1\n%1";
1778 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1779 "/*\n"
1780 " * Macros for number representation conversion.\n"
1781 " */\n"
1782 "#ifndef ntohl\n"
1783 "#define ntohl(x) (x)\n"
1784 "#define ntohs(x) (x)\n"
1785 "#define htonl(x) (x)\n"
1786 "#define htons(x) (x)\n"
1787 "#endif\n"
1788 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1793 * HP-UX long_double
1795 fix = {
1796 hackname = hpux_long_double;
1797 mach = "*-*-hpux10*";
1798 mach = "*-*-hpux11.[012]*";
1799 files = stdlib.h;
1800 select = "extern[ \t]long_double[ \t]strtold";
1801 bypass = "long_double_t";
1802 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1803 sed = "s/long_double/long double/g";
1805 test_text = "# ifndef _LONG_DOUBLE\n"
1806 "# define _LONG_DOUBLE\n"
1807 " typedef struct {\n"
1808 " unsigned int word1, word2, word3, word4;\n"
1809 " } long_double;\n"
1810 "# endif /* _LONG_DOUBLE */\n"
1811 "extern long_double strtold(const char *, char **);\n";
1815 * We cannot use the above rule on 11.31 because it removes the strtold
1816 * definition. ia64 is OK with no hack, PA needs some help.
1818 fix = {
1819 hackname = hpux_long_double_2;
1820 mach = "hppa*-*-hpux11.3*";
1821 files = stdlib.h;
1822 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
1823 c_fix = format;
1824 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
1826 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
1830 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1832 fix = {
1833 hackname = hpux_systime;
1834 files = sys/time.h;
1835 select = "^extern struct sigevent;";
1837 c_fix = format;
1838 c_fix_arg = "struct sigevent;";
1840 test_text = 'extern struct sigevent;';
1845 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1846 * type and mpinfou is only defined when _KERNEL is set.
1848 fix = {
1849 hackname = hpux_spu_info;
1850 mach = "*-hp-hpux*";
1852 * It is tempting to omit the first "files" entry. Do not.
1853 * The testing machinery will take the first "files" entry as the name
1854 * of a test file to play with. It would be a nuisance to have a directory
1855 * with the name "*".
1857 files = "ia64/sys/getppdp.h";
1858 files = "*/sys/getppdp.h";
1859 select = "^.*extern.*spu_info.*";
1861 c_fix = format;
1862 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
1864 test_text = "extern union mpinfou spu_info[];";
1867 fix = {
1868 hackname = hpux11_extern_sendfile;
1869 mach = "*-hp-hpux11.[12]*";
1870 files = sys/socket.h;
1871 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
1872 c_fix = format;
1873 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1874 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1877 fix = {
1878 hackname = hpux11_extern_sendpath;
1879 mach = "*-hp-hpux11.[12]*";
1880 files = sys/socket.h;
1881 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
1882 c_fix = format;
1883 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1884 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1887 fix = {
1888 hackname = hpux_extern_errno;
1889 mach = "*-hp-hpux10.*";
1890 mach = "*-hp-hpux11.[0-2]*";
1891 files = errno.h;
1892 select = "^[ \t]*extern int errno;$";
1893 c_fix = format;
1894 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
1895 test_text = " extern int errno;\n";
1900 * Add missing braces to pthread initializer defines.
1902 fix = {
1903 hackname = hpux_pthread_initializers;
1904 mach = "*-hp-hpux11.[0-3]*";
1905 files = sys/pthread.h;
1906 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
1907 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
1908 sed = "s@^[ \t]*1,[ \t]*\\\\"
1909 "@\t{ 1, 0 }@";
1910 sed = "/^[ \t]*0$/d";
1911 sed = "s@__PTHREAD_MUTEX_VALID, 0"
1912 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
1913 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
1914 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
1915 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1916 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1917 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1918 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1919 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
1920 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
1921 sed = "s@__PTHREAD_COND_VALID, 0"
1922 "@{ __PTHREAD_COND_VALID, 0 }@";
1923 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
1924 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
1925 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
1926 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
1927 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
1928 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
1929 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
1930 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
1931 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
1932 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
1933 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
1934 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
1935 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
1936 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
1937 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
1938 "}\n";
1941 fix = {
1942 hackname = hpux_c99_intptr;
1943 mach = "*-hp-hpux11.3*";
1944 files = stdint.h;
1945 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
1946 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
1947 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
1948 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
1949 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
1950 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
1951 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
1952 "#define PTRDIFF_MIN INT32_MIN\n"
1953 "#define INTPTR_MAX INT32_MAX\n"
1954 "#define INTPTR_MIN INT32_MIN\n"
1955 "#define UINTPTR_MAX UINT32_MAX\n"
1956 "#define SIZE_MAX UINT32_MAX\n";
1960 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
1963 fix = {
1964 hackname = hpux_c99_inttypes;
1965 mach = "*-hp-hpux11.[23]*";
1966 files = inttypes.h;
1967 files = stdint.h;
1968 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
1969 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
1970 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
1971 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
1972 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
1973 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
1974 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
1975 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
1978 fix = {
1979 hackname = hpux_c99_inttypes2;
1980 mach = "*-hp-hpux11.2*";
1981 files = stdint.h;
1982 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
1983 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
1984 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
1985 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
1986 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
1987 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
1988 "# define INT16_C(__c) ((short)(__c))\n"
1989 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
1992 fix = {
1993 hackname = hpux_stdint_least;
1994 mach = "*-hp-hpux11.2*";
1995 files = stdint.h;
1996 select = "^[ \t]*#[ \t]*define[ \t]*UINT_LEAST64_MAX[ \t]*ULLONG_MAX";
1997 c_fix = format;
1998 c_fix_arg = "#ifdef __LP64__\n# define UINT_LEAST64_MAX ULONG_MAX\n#else\n%0\n#endif\n";
1999 test_text ="# define UINT_LEAST64_MAX ULLONG_MAX\n";
2002 fix = {
2003 hackname = hpux_stdint_fast;
2004 mach = "*-hp-hpux11.2*";
2005 files = stdint.h;
2006 select = "^[ \t]*#[ \t]*define[ \t]*UINT_FAST64_MAX[ \t]*ULLONG_MAX";
2007 c_fix = format;
2008 c_fix_arg = "#ifdef __LP64__\n# define UINT_FAST64_MAX ULONG_MAX\n#else\n%0\n#endif\n";
2009 test_text ="# define UINT_FAST64_MAX ULLONG_MAX\n";
2012 fix = {
2013 hackname = hpux_inttype_int_least8_t;
2014 mach = "*-hp-hpux11.*";
2015 files = sys/_inttypes.h;
2016 select = "^[ \t]*typedef[ \t]*char[ \t]*int_least8_t.*";
2017 c_fix = format;
2018 c_fix_arg = "typedef signed char int_least8_t;";
2019 test_text ="typedef char int_least8_t;\n";
2022 fix = {
2023 hackname = hpux_inttype_int8_t;
2024 mach = "*-hp-hpux11.*";
2025 files = sys/_inttypes.h;
2026 select = "^[ \t]*typedef[ \t]*char[ \t]*int8_t.*";
2027 c_fix = format;
2028 c_fix_arg = "typedef signed char int8_t;";
2029 test_text ="typedef char int8_t;\n";
2033 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2035 fix = {
2036 hackname = huge_val_hex;
2037 files = bits/huge_val.h;
2038 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2039 bypass = "__builtin_huge_val";
2041 c_fix = format;
2042 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2044 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2049 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2051 fix = {
2052 hackname = huge_valf_hex;
2053 files = bits/huge_val.h;
2054 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2055 bypass = "__builtin_huge_valf";
2057 c_fix = format;
2058 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2060 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2065 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2067 fix = {
2068 hackname = huge_vall_hex;
2069 files = bits/huge_val.h;
2070 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2071 bypass = "__builtin_huge_vall";
2073 c_fix = format;
2074 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2076 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2081 * Fix return type of abort and free
2083 fix = {
2084 hackname = int_abort_free_and_exit;
2085 files = stdlib.h;
2086 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2087 bypass = "_CLASSIC_ANSI_TYPES";
2089 c_fix = format;
2090 c_fix_arg = "void\t%1(";
2092 test_text = "extern int abort(int);\n"
2093 "extern int free(void*);\n"
2094 "extern int exit(void*);";
2099 * Fix various macros used to define ioctl numbers.
2100 * The traditional syntax was:
2102 * #define _IO(n, x) (('n'<<8)+x)
2103 * #define TIOCFOO _IO(T, 1)
2105 * but this does not work with the C standard, which disallows macro
2106 * expansion inside strings. We have to rewrite it thus:
2108 * #define _IO(n, x) ((n<<8)+x)
2109 * #define TIOCFOO _IO('T', 1)
2111 * The select expressions match too much, but the c_fix code is cautious.
2113 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2115 fix = {
2116 hackname = io_quotes_def;
2117 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2118 c_fix = char_macro_def;
2119 c_fix_arg = "IO";
2120 test_text =
2121 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2122 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2123 "#define _IO(x,y) ('x'<<8|y)";
2124 test_text =
2125 "#define XX_IO(x) ('x'<<8|256)";
2128 fix = {
2129 hackname = io_quotes_use;
2130 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2131 "\\( *[^,']";
2132 c_fix = char_macro_use;
2133 c_fix_arg = "IO";
2134 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2135 "#define TIOCFOO \\\\\n"
2136 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2141 * Check for missing ';' in struct
2143 fix = {
2144 hackname = ip_missing_semi;
2145 files = netinet/ip.h;
2146 select = "}$";
2147 sed = "/^struct/,/^};/s/}$/};/";
2148 test_text=
2149 "struct mumble {\n"
2150 " union {\n"
2151 " int x;\n"
2152 " }\n"
2153 "}; /* mumbled struct */\n";
2158 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
2159 * __restrict as restrict iff __c99. This is wrong for C++, which
2160 * needs many C99 features, but only supports __restrict.
2162 fix = {
2163 hackname = irix___restrict;
2164 files = internal/sgimacros.h;
2165 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
2167 mach = "mips-sgi-irix6.5";
2168 c_fix = format;
2169 c_fix_arg = "%1"
2170 "# ifndef __cplusplus\n%2\n# endif";
2172 test_text = "#ifdef __c99\n# define __restrict restrict";
2176 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
2177 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
2178 * functions.
2180 * This was probably introduced around IRIX 6.5.18
2182 fix = {
2183 hackname = irix___generic1;
2184 files = internal/math_core.h;
2185 mach = "mips-sgi-irix6.5";
2186 select = "#define ([a-z]+)\\(x\\) *__generic.*";
2188 c_fix = format;
2189 c_fix_arg = "extern int %1(double);\n"
2190 "extern int %1f(float);\n"
2191 "extern int %1l(long double);\n"
2192 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
2193 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
2194 " : _%1l(x))\n";
2196 test_text =
2197 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2201 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2202 compiler's __generic intrinsic to define isgreater, isgreaterequal,
2203 isless, islessequal, islessgreater and isunordered functions. */
2204 fix = {
2205 hackname = irix___generic2;
2206 files = internal/math_core.h;
2207 mach = "mips-sgi-irix6.5";
2208 select = "#define ([a-z]+)\\(x,y\\) *__generic.*";
2210 c_fix = format;
2211 c_fix_arg = "#define %1(x,y) \\\n"
2212 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2213 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2214 " : _%1l(x,y))\n";
2216 test_text =
2217 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2222 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2223 * that causes the assembly preprocessor to complain about an
2224 * unterminated character constant.
2226 fix = {
2227 hackname = irix_asm_apostrophe;
2228 files = sys/asm.h;
2230 select = "^[ \t]*#.*[Ww]e're";
2231 c_fix = format;
2232 c_fix_arg = "%1 are";
2233 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
2234 test_text = "\t# and we're on vacation";
2239 * Non-traditional "const" declaration in Irix's limits.h.
2241 fix = {
2242 hackname = irix_limits_const;
2243 files = fixinc-test-limits.h, limits.h;
2244 select = "^extern const ";
2245 c_fix = format;
2246 c_fix_arg = "extern __const ";
2247 test_text = "extern const char limit; /* test limits */";
2252 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2253 * Various socket function prototypes use different types instead,
2254 * depending on the API in use (BSD, XPG4/5), but the socklen_t
2255 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
2256 * IRIX 6.5.19).
2258 fix = {
2259 hackname = irix_socklen_t;
2260 files = sys/socket.h;
2261 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2263 mach = "mips-sgi-irix6.5";
2264 c_fix = format;
2265 c_fix_arg = "%1"
2266 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2267 "typedef int socklen_t;\n"
2268 "#else\n"
2269 "%2\n"
2270 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2272 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2276 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2277 * otherwise.
2279 fix = {
2280 hackname = irix_stdint_c99;
2281 files = stdint.h;
2282 select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
2284 mach = "mips-sgi-irix6.5";
2285 c_fix = format;
2286 c_fix_arg = "#if 0\n"
2287 "%2";
2288 test_text =
2289 "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
2294 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2295 * some functions that take a va_list as
2296 * taking char *. However, GCC uses void * for va_list, so
2297 * calling vfprintf with a va_list fails in C++. */
2298 fix = {
2299 hackname = irix_stdio_va_list;
2300 files = stdio.h;
2301 files = internal/stdio_core.h;
2303 select = '/\* va_list \*/ char \*';
2304 c_fix = format;
2305 c_fix_arg = "__gnuc_va_list";
2306 test_text =
2307 "extern int printf( const char *, /* va_list */ char * );";
2312 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2313 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2315 fix = {
2316 hackname = irix_wcsftime;
2317 files = internal/wchar_core.h;
2318 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2320 mach = "mips-sgi-irix6.5";
2321 c_fix = format;
2322 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2324 test_text = "#if _NO_XOPEN5\n"
2325 "extern size_t wcsftime(wchar_t *, "
2326 "__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, "
2327 "const struct tm *);";
2331 * Fixing ISC fmod declaration
2333 fix = {
2334 hackname = isc_fmod;
2335 files = math.h;
2336 select = 'fmod\(double\)';
2337 c_fix = format;
2338 c_fix_arg = "fmod(double, double)";
2339 test_text = "extern double fmod(double);";
2344 * On Interactive Unix 2.2, certain traditional Unix definitions
2345 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
2346 * defined, not just if _POSIX_SOURCE is defined. This makes it
2347 * impossible to compile any nontrivial program except with -posix.
2349 fix = {
2350 hackname = isc_omits_with_stdc;
2352 files = "stdio.h";
2353 files = "math.h";
2354 files = "ctype.h";
2355 files = "sys/limits.h";
2356 files = "sys/fcntl.h";
2357 files = "sys/dirent.h";
2359 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
2360 c_fix = format;
2361 c_fix_arg = '!defined(_POSIX_SOURCE)';
2362 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
2363 "\nint foo;\n#endif";
2368 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2369 * use / * * / to concatenate tokens.
2371 fix = {
2372 hackname = kandr_concat;
2373 files = "sparc/asm_linkage.h";
2374 files = "sun*/asm_linkage.h";
2375 files = "arm/as_support.h";
2376 files = "arm/mc_type.h";
2377 files = "arm/xcb.h";
2378 files = "dev/chardefmac.h";
2379 files = "dev/ps_irq.h";
2380 files = "dev/screen.h";
2381 files = "dev/scsi.h";
2382 files = "sys/tty.h";
2383 files = "Xm.acorn/XmP.h";
2384 files = bsd43/bsd43_.h;
2385 select = '/\*\*/';
2386 c_fix = format;
2387 c_fix_arg = '##';
2388 test_text = "#define __CONCAT__(a,b) a/**/b";
2392 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2393 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2394 * constant on recent versions of g++.
2396 fix = {
2397 hackname = linux_ia64_ucontext;
2398 files = "sys/ucontext.h";
2399 mach = "ia64-*-linux*";
2400 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2401 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2402 c_fix = format;
2403 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2404 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2405 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2410 * Remove header file warning from sys/time.h. Autoconf's
2411 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2412 * which causes warning on LynxOS. Remove the warning.
2414 fix = {
2415 hackname = lynxos_no_warning_in_sys_time_h;
2416 files = sys/time.h;
2417 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2418 c_fix = format;
2419 c_fix_arg = "";
2420 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2425 * Add missing declaration for putenv.
2427 fix = {
2428 hackname = lynxos_missing_putenv;
2429 mach = '*-*-lynxos*';
2430 files = stdlib.h;
2431 bypass = 'putenv[ \t]*\\(';
2432 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2433 c_fix = format;
2434 c_fix_arg = "%0\n"
2435 "extern int putenv _AP((char *));";
2436 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2437 test_text = "extern char *getenv _AP((const char *));";
2442 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2444 * On NetBSD, machine is a symbolic link to an architecture specific
2445 * directory name, so we can't match a specific file name here.
2447 fix = {
2448 hackname = machine_ansi_h_va_list;
2449 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2450 bypass = '__builtin_va_list';
2452 c_fix = format;
2453 c_fix_arg = "%1__builtin_va_list";
2454 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2456 test_text = " # define _BSD_VA_LIST_\tchar**";
2461 * Fix non-ansi machine name defines
2463 fix = {
2464 hackname = machine_name;
2465 c_test = machine_name;
2466 c_fix = machine_name;
2468 test_text = "/* MACH_DIFF: */\n"
2469 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2470 "\n/* no uniform test, so be careful :-) */";
2475 * Some math.h files define struct exception (it's in the System V
2476 * Interface Definition), which conflicts with the class exception defined
2477 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2478 * This is not a great fix, but I haven't been able to think of anything
2479 * better.
2481 fix = {
2482 hackname = math_exception;
2483 files = math.h;
2484 select = "struct exception";
2486 * This should be bypassed on __cplusplus, but some supposedly C++ C++
2487 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2488 * exception either. So currently we bypass only for glibc, based on a
2489 * comment in the fixed glibc header. Ick.
2491 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2492 '_[a-z0-9A-Z_]+_exception; for C, exception';
2493 c_fix = wrap;
2495 c_fix_arg = "#ifdef __cplusplus\n"
2496 "#define exception __math_exception\n"
2497 "#endif\n";
2499 c_fix_arg = "#ifdef __cplusplus\n"
2500 "#undef exception\n"
2501 "#endif\n";
2503 test_text = "typedef struct exception t_math_exception;";
2508 * This looks pretty broken to me. ``dbl_max_def'' will contain
2509 * "define DBL_MAX " at the start, when what we really want is just
2510 * the value portion. Can't figure out how to write a test case
2511 * for this either :-(
2513 fix = {
2514 hackname = math_huge_val_from_dbl_max;
2515 files = math.h;
2518 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2519 * in math.h, this fix applies.
2521 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2522 bypass = "define[ \t]+DBL_MAX";
2524 shell =
2526 * See if we have a definition for DBL_MAX in float.h.
2527 * If we do, we will replace the one in math.h with that one.
2530 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2531 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2533 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2534 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2535 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2536 "\telse cat\n"
2537 "\tfi";
2539 test_text =
2540 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2541 "#define HUGE_VAL DBL_MAX";
2546 * nested comment
2548 fix = {
2549 hackname = nested_auth_des;
2550 files = rpc/rpc.h;
2551 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2552 c_fix = format;
2553 c_fix_arg = "%1*/ /*";
2554 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2559 * Fixing nested comments in ISC <sys/limits.h>
2561 fix = {
2562 hackname = nested_sys_limits;
2563 files = sys/limits.h;
2564 select = CHILD_MAX;
2565 sed = "/CHILD_MAX/s,/\\* Max, Max,";
2566 sed = "/OPEN_MAX/s,/\\* Max, Max,";
2567 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
2568 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
2573 * Some versions of NetBSD don't expect the C99 inline semantics.
2575 fix = {
2576 hackname = netbsd_c99_inline_1;
2577 mach = "*-*-netbsd*";
2578 files = signal.h;
2579 select = "extern __inline int";
2581 c_fix = format;
2582 c_fix_arg = "extern\n"
2583 "#ifdef __GNUC_STDC_INLINE__\n"
2584 "__attribute__((__gnu_inline__))\n"
2585 "#endif\n"
2586 "__inline int";
2588 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2592 fix = {
2593 hackname = netbsd_c99_inline_2;
2594 mach = "*-*-netbsd*";
2595 files = signal.h;
2596 select = "#define _SIGINLINE extern __inline";
2598 c_fix = format;
2599 c_fix_arg = <<- _EOArg_
2600 #ifdef __GNUC_STDC_INLINE__
2601 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2602 #else
2604 #endif
2605 _EOArg_;
2607 test_text = "#define _SIGINLINE extern __inline";
2612 * NetBSD has a semicolon after the ending '}' for some extern "C".
2614 fix = {
2615 hackname = netbsd_extra_semicolon;
2616 mach = "*-*-netbsd*";
2617 files = sys/cdefs.h;
2618 select = "#define[ \t]*__END_DECLS[ \t]*};";
2620 c_fix = format;
2621 c_fix_arg = "#define __END_DECLS }";
2623 test_text = "#define __END_DECLS };";
2627 /* newlib's stdint.h has several failures to conform to C99. The fix
2628 for these removed a comment that can be matched to identify unfixed
2629 versions. */
2630 fix = {
2631 hackname = newlib_stdint_1;
2632 files = stdint.h;
2633 select = "@todo - Add support for wint_t types";
2634 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2635 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2636 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2637 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2638 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2639 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2640 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2641 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2642 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2643 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2644 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2645 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2646 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2647 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2648 test_text = "/* @todo - Add support for wint_t types. */\n"
2649 "#define INT32_MIN (-2147483647-1)\n"
2650 "#define INT32_MAX 2147483647\n"
2651 "#define UINT32_MAX 4294967295U\n"
2652 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2653 "#define INT_LEAST32_MAX 2147483647\n"
2654 "#define UINT_LEAST32_MAX 4294967295U\n"
2655 "#define INT_FAST8_MIN INT8_MIN\n"
2656 "#define INT_FAST8_MAX INT8_MAX\n"
2657 "#define UINT_FAST8_MAX UINT8_MAX\n"
2658 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2659 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2660 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2661 "#define UINT8_C(x) x##U\n"
2662 "#define UINT16_C(x) x##U";
2666 fix = {
2667 hackname = newlib_stdint_2;
2668 files = stdint.h;
2669 select = "@todo - Add support for wint_t types";
2670 c_fix = format;
2671 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2672 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2673 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2674 "#define WCHAR_MAX __WCHAR_MAX__\n"
2675 "#define WCHAR_MIN __WCHAR_MIN__\n"
2676 "#define WINT_MAX __WINT_MAX__\n"
2677 "#define WINT_MIN __WINT_MIN__\n\n"
2678 "%0";
2679 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2680 test_text = "/* @todo - Add support for wint_t types. */\n"
2681 "/** Macros for minimum-width integer constant expressions */";
2686 * NeXT 3.2 adds const prefix to some math functions.
2687 * These conflict with the built-in functions.
2689 fix = {
2690 hackname = next_math_prefix;
2691 files = ansi/math.h;
2692 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2694 c_fix = format;
2695 c_fix_arg = "extern double %1(";
2696 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2698 test_text = "extern\tdouble\t__const__\tmumble();";
2703 * NeXT 3.2 uses the word "template" as a parameter for some
2704 * functions. GCC reports an invalid use of a reserved key word
2705 * with the built-in functions.
2707 fix = {
2708 hackname = next_template;
2709 files = bsd/libc.h;
2710 select = "[ \t]template\\)";
2712 c_fix = format;
2713 c_fix_arg = "(%1)";
2714 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2715 test_text = "extern mumble( char * template); /* fix */";
2720 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2721 * function prototypes. That conflicts with the built-in functions.
2723 fix = {
2724 hackname = next_volitile;
2725 files = ansi/stdlib.h;
2726 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2728 c_fix = format;
2729 c_fix_arg = "extern void %1(";
2730 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2732 test_text = "extern\tvolatile\tvoid\tabort();";
2737 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2738 * Note that version 3 of the NeXT system has wait.h in a different directory,
2739 * so that this code won't do anything. But wait.h in version 3 has a
2740 * conditional, so it doesn't need this fix. So everything is okay.
2742 fix = {
2743 hackname = next_wait_union;
2744 files = sys/wait.h;
2746 select = 'wait\(union wait';
2747 c_fix = format;
2748 c_fix_arg = "wait(void";
2749 test_text = "extern pid_d wait(union wait*);";
2754 * a missing semi-colon at the end of the nodeent structure definition.
2756 fix = {
2757 hackname = nodeent_syntax;
2758 files = netdnet/dnetdb.h;
2759 select = "char[ \t]*\\*na_addr[ \t]*$";
2760 c_fix = format;
2761 c_fix_arg = "%0;";
2762 test_text = "char *na_addr\t";
2766 * Fix OpenBSD's NULL definition.
2768 fix = {
2769 hackname = openbsd_null_definition;
2770 mach = "*-*-openbsd*";
2771 files = locale.h, stddef.h, stdio.h, string.h,
2772 time.h, unistd.h, wchar.h, sys/param.h;
2773 select = "__GNUG__";
2774 c_fix = format;
2775 c_fix_arg = "#ifndef NULL\n"
2776 "#ifdef __cplusplus\n"
2777 "#ifdef __GNUG__\n"
2778 "#define NULL\t__null\n"
2779 "#else\t /* ! __GNUG__ */\n"
2780 "#define NULL\t0L\n"
2781 "#endif\t /* __GNUG__ */\n"
2782 "#else\t /* ! __cplusplus */\n"
2783 "#define NULL\t((void *)0)\n"
2784 "#endif\t /* __cplusplus */\n"
2785 "#endif\t /* !NULL */";
2787 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2788 "^#ifdef[ \t]*__GNUG__\n"
2789 "^#define[ \t]*NULL[ \t]*__null\n"
2790 "^#else\n"
2791 "^#define[ \t]*NULL[ \t]*0L\n"
2792 "^#endif\n"
2793 "^#endif";
2794 test_text =
2795 "#ifndef NULL\n"
2796 "#ifdef __GNUG__\n"
2797 "#define NULL __null\n"
2798 "#else\n"
2799 "#define NULL 0L\n"
2800 "#endif\n"
2801 "#endif\n";
2805 * obstack.h used casts as lvalues.
2807 * We need to change postincrements of casted pointers (which are
2808 * then dereferenced and assigned into) of the form
2810 * *((TYPE*)PTRVAR)++ = (VALUE)
2812 * into expressions like
2814 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2816 * which is correct for the cases used in obstack.h since PTRVAR is
2817 * of type char * and the value of the expression is not used.
2819 fix = {
2820 hackname = obstack_lvalue_cast;
2821 files = obstack.h;
2822 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2823 c_fix = format;
2824 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2825 test_text = "*((void **) (h)->next_free)++ = (aptr)";
2829 * Fix OpenBSD's va_start define.
2831 fix = {
2832 hackname = openbsd_va_start;
2833 mach = "*-*-openbsd*";
2834 files = stdarg.h;
2835 select = '__builtin_stdarg_start';
2836 c_fix = format;
2837 c_fix_arg = __builtin_va_start;
2839 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
2843 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2844 * defining regex.h related types. This causes libg++ build and usage
2845 * failures. Fixing this correctly requires checking and modifying 3 files.
2847 fix = {
2848 hackname = osf_namespace_a;
2849 files = reg_types.h;
2850 files = sys/lc_core.h;
2851 test = " -r reg_types.h";
2852 test = " -r sys/lc_core.h";
2853 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2854 test = " -z \"`grep __regex_t regex.h`\"";
2856 c_fix = format;
2857 c_fix_arg = "__%0";
2858 c_fix_arg = "reg(ex|off|match)_t";
2860 test_text = "`touch sys/lc_core.h`"
2861 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2862 "extern regex_t re;\n"
2863 "extern regoff_t ro;\n"
2864 "extern regmatch_t rm;\n";
2867 fix = {
2868 hackname = osf_namespace_c;
2869 files = regex.h;
2870 test = " -r reg_types.h";
2871 test = " -r sys/lc_core.h";
2872 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2873 test = " -z \"`grep __regex_t regex.h`\"";
2875 select = "#include <reg_types\.h>.*";
2876 c_fix = format;
2877 c_fix_arg = "%0\n"
2878 "typedef __regex_t\tregex_t;\n"
2879 "typedef __regoff_t\tregoff_t;\n"
2880 "typedef __regmatch_t\tregmatch_t;";
2882 test_text = "#include <reg_types.h>";
2887 * On broken glibc-2.3.3 systems an array of incomplete structures is
2888 * passed to __sigsetjmp. Fix that to take a pointer instead.
2890 fix = {
2891 hackname = pthread_incomplete_struct_argument;
2892 files = pthread.h;
2893 select = "struct __jmp_buf_tag";
2894 c_fix = format;
2895 c_fix_arg = "%1 *%2%3";
2896 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2897 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2901 * Fix return type of fread and fwrite on sysV68
2903 fix = {
2904 hackname = read_ret_type;
2905 files = stdio.h;
2906 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2907 c_fix = format;
2908 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2909 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2911 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2916 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2918 fix = {
2919 hackname = rpc_xdr_lvalue_cast_a;
2920 files = rpc/xdr.h;
2921 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2922 c_fix = format;
2923 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2924 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2925 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2929 fix = {
2930 hackname = rpc_xdr_lvalue_cast_b;
2931 files = rpc/xdr.h;
2932 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2933 c_fix = format;
2934 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2935 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2936 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2941 * function class(double x) conflicts with C++ keyword on rs/6000
2943 fix = {
2944 hackname = rs6000_double;
2945 files = math.h;
2946 select = '[^a-zA-Z_]class\(';
2948 c_fix = format;
2949 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2950 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2952 test_text = "extern int class();";
2957 * Wrong fchmod prototype on RS/6000.
2959 fix = {
2960 hackname = rs6000_fchmod;
2961 files = sys/stat.h;
2962 select = 'fchmod\(char \*';
2963 c_fix = format;
2964 c_fix_arg = "fchmod(int";
2965 test_text = "extern int fchmod(char *, mode_t);";
2970 * parameters conflict with C++ new on rs/6000
2972 fix = {
2973 hackname = rs6000_param;
2974 files = "stdio.h";
2975 files = "unistd.h";
2977 select = 'rename\(const char \*old, const char \*new\)';
2978 c_fix = format;
2979 c_fix_arg = 'rename(const char *_old, const char *_new)';
2981 test_text = 'extern int rename(const char *old, const char *new);';
2986 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2987 * __builtin_generic. We fix that usage to use the GCC equivalent.
2988 * It also has a plethora of inline functions that conflict with libstdc++.
2990 fix = {
2991 hackname = sco_math;
2992 files = math.h, '*/math.h';
2993 select = "inline double abs";
2994 bypass = "__GNUG__";
2995 sed = "/#define.*__fp_class(a) \\\\/i\\\n"
2996 "#ifndef __GNUC__\n";
2997 sed =
2998 "/.*__builtin_generic/a\\\n"
2999 "#else\\\n"
3000 "#define __fp_class(a) \\\\\\\n"
3001 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
3002 " __fpclassifyl(a), \\\\\\\n"
3003 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
3004 " __fpclassifyf(a),__fpclassify(a)))\\\n"
3005 "#endif";
3007 sed = "/extern \"C\\+\\+\"/N;"
3008 "/inline double abs/i\\\n"
3009 "#ifndef __GNUC__\n";
3010 sed = "/inline long double trunc/N;"
3011 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
3012 "#endif /* ! __GNUC__ */";
3014 test_text =
3015 "#define __fp_class(a) \\\\\n"
3016 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
3022 * Sun Solaris 10 defines several C99 math macros in terms of
3023 * builtins specific to the Studio compiler, in particular not
3024 * compatible with the GNU compiler.
3026 fix = {
3027 hackname = solaris_math_1;
3028 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3029 bypass = "__GNUC__";
3030 files = iso/math_c99.h;
3031 c_fix = format;
3032 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3033 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3034 test_text =
3035 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3036 "#undef HUGE_VAL\n"
3037 "#define HUGE_VAL __builtin_huge_val\n"
3038 "#undef HUGE_VALF\n"
3039 "#define HUGE_VALF __builtin_huge_valf\n"
3040 "#undef HUGE_VALL\n"
3041 "#define HUGE_VALL __builtin_huge_vall";
3044 fix = {
3045 hackname = solaris_math_2;
3046 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3047 bypass = "__GNUC__";
3048 files = iso/math_c99.h;
3049 c_fix = format;
3050 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3051 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3052 test_text =
3053 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3054 "#undef INFINITY\n"
3055 "#define INFINITY __builtin_infinity";
3058 fix = {
3059 hackname = solaris_math_3;
3060 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3061 bypass = "__GNUC__";
3062 files = iso/math_c99.h;
3063 c_fix = format;
3064 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3065 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3066 test_text =
3067 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3068 "#undef NAN\n"
3069 "#define NAN __builtin_nan";
3072 fix = {
3073 hackname = solaris_math_4;
3074 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3075 bypass = "__GNUC__";
3076 files = iso/math_c99.h;
3077 c_fix = format;
3078 c_fix_arg = "#define\tfpclassify(x) \\\n"
3079 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3080 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3081 test_text =
3082 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3083 "#undef fpclassify\n"
3084 "#define fpclassify(x) __builtin_fpclassify(x)";
3087 fix = {
3088 hackname = solaris_math_8;
3089 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3090 bypass = "__GNUC__";
3091 files = iso/math_c99.h;
3092 c_fix = format;
3093 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3094 "\t\t\t ? __builtin_signbitf(x) \\\n"
3095 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3096 "\t\t\t ? __builtin_signbitl(x) \\\n"
3097 "\t\t\t : __builtin_signbit(x))";
3098 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3099 test_text =
3100 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3101 "#undef signbit\n"
3102 "#define signbit(x) __builtin_signbit(x)";
3105 fix = {
3106 hackname = solaris_math_9;
3107 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3108 bypass = "__GNUC__";
3109 files = iso/math_c99.h;
3110 c_fix = format;
3111 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3112 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3113 test_text =
3114 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3115 "#undef isgreater\n"
3116 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3117 "#undef isgreaterequal\n"
3118 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3119 "#undef isless\n"
3120 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3121 "#undef islessequal\n"
3122 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3123 "#undef islessgreater\n"
3124 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3125 "#undef isunordered\n"
3126 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3130 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3131 * exception. Provide an alternative using GCC's builtin.
3134 fix = {
3135 hackname = solaris_math_10;
3136 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3137 files = iso/math_c99.h;
3138 c_fix = format;
3139 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3140 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3141 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3142 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3143 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3144 test_text =
3145 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3146 "#undef isinf\n"
3147 "#define isinf(x) __extension__( \\\\\n"
3148 " { __typeof(x) __x_i = (x); \\\\\n"
3149 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3150 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3154 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3155 * "0" for the last field of the pthread_mutex_t structure, which is
3156 * of type upad64_t, which itself is typedef'd to int64_t, but with
3157 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3158 * initializer to "{0}" instead
3160 fix = {
3161 hackname = solaris_mutex_init_2;
3162 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3163 files = pthread.h;
3165 * On Solaris 10, this fix is unnecessary because upad64_t is
3166 * always defined correctly regardless of the definition of the
3167 * __STDC__ macro. The first "mach" pattern matches up to
3168 * solaris9. The second "mach" pattern will not match any two (or
3169 * more) digit solaris version, but it will match e.g. 2.5.1.
3171 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3172 c_fix = format;
3173 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3174 "%0\n"
3175 "#else\n"
3176 "%1, {0}}%4\n"
3177 "#endif";
3178 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3179 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3180 ",[ \t]*0\\}" "(|[ \t].*)$";
3181 test_text =
3182 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3183 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3184 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3185 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3186 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3187 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3188 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3193 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3194 * fields of the pthread_rwlock_t structure, which are of type
3195 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3196 * defined (e.g. by -ansi) it is a union. So change the initializer
3197 * to "{0}" instead.
3199 fix = {
3200 hackname = solaris_rwlock_init_1;
3201 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3202 files = pthread.h;
3203 mach = '*-*-solaris*';
3204 c_fix = format;
3205 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3206 "%0\n"
3207 "#else\n"
3208 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3209 "#endif";
3210 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3211 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3213 test_text =
3214 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3215 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3220 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3221 * structure. As such, it need two levels of brackets, but only
3222 * contains one. Wrap the macro definition in an extra layer.
3224 fix = {
3225 hackname = solaris_once_init_1;
3226 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3227 files = pthread.h;
3228 mach = '*-*-solaris*';
3229 c_fix = format;
3230 c_fix_arg = "%1{%2}%3";
3231 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3232 test_text =
3233 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3234 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3239 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3240 * fields of the pthread_once_t structure, which are of type
3241 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3242 * defined (e.g. by -ansi) it is a union. So change the initializer
3243 * to "{0}" instead. This test relies on solaris_once_init_1.
3245 fix = {
3246 hackname = solaris_once_init_2;
3247 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3248 files = pthread.h;
3250 * On Solaris 10, this fix is unnecessary because upad64_t is
3251 * always defined correctly regardless of the definition of the
3252 * __STDC__ macro. The first "mach" pattern matches up to
3253 * solaris9. The second "mach" pattern will not match any two (or
3254 * more) digit solaris version, but it will match e.g. 2.5.1.
3256 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3257 c_fix = format;
3258 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3259 "%0\n"
3260 "#else\n"
3261 "%1{0}, {0}, {0}, {%3}%4\n"
3262 "#endif";
3263 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3264 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3265 test_text =
3266 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3267 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3272 * Sun Solaris 10 has a version of sys/int_const.h that defines
3273 * UINT8_C and UINT16_C to unsigned constants.
3275 fix = {
3276 hackname = solaris_int_const;
3277 select = '@\(#\)int_const.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3278 files = sys/int_const.h;
3279 c_fix = format;
3280 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3281 "%1\n"
3282 "#define\tUINT16_C(c)\t(c)";
3283 c_fix_arg = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3284 "(/\*.*\*/)\n"
3285 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3286 test_text =
3287 '#pragma ident "@(#)int_const.h 1.5 04/09/28 SMI"'"\n"
3288 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3289 "/* CSTYLED */\n"
3290 "#define UINT16_C(c) __CONCAT__(c,u)";
3295 * Sun Solaris 10 has a version of sys/int_limits.h that defines
3296 * UINT8_MAX and UINT16_MAX to unsigned constants.
3298 fix = {
3299 hackname = solaris_int_limits_1;
3300 select = '@\(#\)int_limits.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3301 files = sys/int_limits.h;
3302 c_fix = format;
3303 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3304 "#define\tUINT16_MAX\t(65535)";
3305 c_fix_arg = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3306 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3307 test_text =
3308 '#pragma ident "@(#)int_limits.h 1.9 04/09/28 SMI"'"\n"
3309 "#define UINT8_MAX (255U)\n"
3310 "#define UINT16_MAX (65535U)";
3315 * Sun Solaris 10 has a version of sys/int_limits.h that defines
3316 * INT_FAST16 limits to wrong values for sys/int_types.h.
3318 fix = {
3319 hackname = solaris_int_limits_2;
3320 select = '@\(#\)int_limits.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3321 files = sys/int_limits.h;
3322 c_fix = format;
3323 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3324 c_fix_arg = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3325 test_text =
3326 '#pragma ident "@(#)int_limits.h 1.9 04/09/28 SMI"'"\n"
3327 "#define INT_FAST16_MAX INT16_MAX\n"
3328 "#define UINT_FAST16_MAX UINT16_MAX\n"
3329 "#define INT_FAST16_MIN INT16_MIN";
3334 * Solaris 2.8 has what appears to be some gross workaround for
3335 * some old version of their c++ compiler. G++ doesn't want it
3336 * either, but doesn't want to be tied to SunPRO version numbers.
3338 fix = {
3339 hackname = solaris_stdio_tag;
3340 files = stdio_tag.h;
3342 select = '__cplusplus < 54321L';
3343 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3344 "!defined(__GNUC__)" so we no longer need to fix it. */
3345 bypass = '__GNUC__';
3346 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3348 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3353 * a missing semi-colon at the end of the statsswtch structure definition.
3355 fix = {
3356 hackname = statsswtch;
3357 files = rpcsvc/rstat.h;
3358 select = "boottime$";
3359 c_fix = format;
3360 c_fix_arg = "boottime;";
3361 test_text = "struct statswtch {\n int boottime\n};";
3366 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3367 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3368 * OK too.
3370 fix = {
3371 hackname = stdio_stdarg_h;
3372 files = stdio.h;
3373 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3375 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3376 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3378 mach = '*-*-solaris2.1[0-9]*';
3379 not_machine = true;
3381 c_fix = wrap;
3383 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3385 test_text = "";
3390 * Don't use or define the name va_list in stdio.h. This is for
3391 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3392 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3393 * indicate that the header knows what it's doing -- under SUSv2,
3394 * stdio.h is required to define va_list, and we shouldn't break
3395 * that. On IRIX 6.5, internal/wchar_core.h used to get its
3396 * definition of va_list from stdio.h. Since this doesn't happen any
3397 * longer, use __gnuc_va_list there, too.
3399 fix = {
3400 hackname = stdio_va_list;
3401 files = stdio.h;
3402 files = internal/stdio_core.h;
3403 files = internal/wchar_core.h;
3404 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3406 * On Solaris 10, the definition in
3407 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3408 * there is therefore no need for this fix there.
3410 mach = '*-*-solaris2.1[0-9]*';
3411 not_machine = true;
3414 * Use __gnuc_va_list in arg types in place of va_list.
3415 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3416 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3417 * trailing parentheses and semicolon save all other systems from this.
3418 * Define __not_va_list__ (something harmless and unused)
3419 * instead of va_list.
3420 * Don't claim to have defined va_list.
3422 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3423 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3424 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3425 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3426 "s@ va_list@ __not_va_list__@\n"
3427 "s@\\*va_list@*__not_va_list__@\n"
3428 "s@ __va_list)@ __gnuc_va_list)@\n"
3429 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3430 "@typedef \\1 __not_va_list__;@\n"
3431 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3432 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3433 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3434 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3435 "s@VA_LIST@DUMMY_VA_LIST@\n"
3436 "s@_Va_LIST@_VA_LIST@";
3437 test_text = "extern void mumble( va_list);";
3442 * Fix headers that use va_list from stdio.h to use the updated
3443 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3444 * dealt with elsewhere. The presence of __gnuc_va_list,
3445 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3446 * knows what it's doing.
3448 fix = {
3449 hackname = stdio_va_list_clients;
3450 files = com_err.h;
3451 files = cps.h;
3452 files = curses.h;
3453 files = krb5.h;
3454 files = lc_core.h;
3455 files = pfmt.h;
3456 files = wchar.h;
3457 files = curses_colr/curses.h;
3458 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3459 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3460 otherwise protected. */
3461 bypass = 'include <stdarg\.h>|#ifdef va_start';
3464 * Use __gnuc_va_list in arg types in place of va_list.
3465 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3466 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3467 * trailing parentheses and semicolon save all other systems from this.
3468 * Define __not_va_list__ (something harmless and unused)
3469 * instead of va_list.
3470 * Don't claim to have defined va_list.
3472 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3473 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3474 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3475 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3476 "s@ va_list@ __not_va_list__@\n"
3477 "s@\\*va_list@*__not_va_list__@\n"
3478 "s@ __va_list)@ __gnuc_va_list)@\n"
3479 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3480 "@typedef \\1 __not_va_list__;@\n"
3481 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3482 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3483 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3484 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3485 "s@VA_LIST@DUMMY_VA_LIST@\n"
3486 "s@_Va_LIST@_VA_LIST@";
3487 test_text = "extern void mumble( va_list);";
3492 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3493 * is "!defined( __STRICT_ANSI__ )"
3495 fix = {
3496 hackname = strict_ansi_not;
3497 select = "^([ \t]*#[ \t]*if.*)"
3498 "(!__STDC__"
3499 "|__STDC__[ \t]*==[ \t]*0"
3500 "|__STDC__[ \t]*!=[ \t]*1"
3501 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3502 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3503 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3504 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3505 is not defined by GCC, so it is safe. */
3506 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3507 c_test = stdc_0_in_system_headers;
3509 c_fix = format;
3510 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3512 test_text = "#if !__STDC__ \n"
3513 "#if __STDC__ == 0\n"
3514 "#if __STDC__ != 1\n"
3515 "#if __STDC__ - 0 == 0"
3516 "/* not std C */\nint foo;\n"
3517 "\n#end-end-end-end-if :-)";
3521 * "__STDC__-0==0"
3522 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3524 fix = {
3525 hackname = strict_ansi_not_ctd;
3526 files = math.h, limits.h, stdio.h, signal.h,
3527 stdlib.h, sys/signal.h, time.h;
3529 * Starting at the beginning of a line, skip white space and
3530 * a leading "(" or "&&" or "||". One of those must be found.
3531 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3532 * expression. If these are nested, then they must accumulate
3533 * because we won't match any closing parentheses. Finally,
3534 * after skipping over all that, we must then match our suspect
3535 * phrase: "__STDC__-0==0" with or without white space.
3537 select = "^([ \t]*" '(\(|&&|\|\|)'
3538 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3539 "[ \t(]*)"
3540 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3541 c_test = stdc_0_in_system_headers;
3543 c_fix = format;
3544 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3546 test_text = "#if 1 && \\\\\n"
3547 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3548 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3549 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3550 "int foo;\n#endif";
3555 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3556 * is "defined( __STRICT_ANSI__ )"
3558 fix = {
3559 hackname = strict_ansi_only;
3560 select = "^([ \t]*#[ \t]*if.*)"
3561 "(__STDC__[ \t]*!=[ \t]*0"
3562 "|__STDC__[ \t]*==[ \t]*1"
3563 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3564 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3565 c_test = stdc_0_in_system_headers;
3567 c_fix = format;
3568 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3570 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3575 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3576 * in prototype without previous definition.
3578 fix = {
3579 hackname = struct_file;
3580 files = rpc/xdr.h;
3581 select = '^.*xdrstdio_create.*struct __file_s';
3582 c_fix = format;
3583 c_fix_arg = "struct __file_s;\n%0";
3584 test_text = "extern void xdrstdio_create( struct __file_s* );";
3589 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3590 * in prototype without previous definition.
3592 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3593 * function, and does define it.
3595 fix = {
3596 hackname = struct_sockaddr;
3597 files = rpc/auth.h;
3598 select = "^.*authdes_create.*struct sockaddr[^_]";
3599 bypass = "<sys/socket\.h>";
3600 bypass = "struct sockaddr;\n";
3601 c_fix = format;
3602 c_fix_arg = "struct sockaddr;\n%0";
3603 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3608 * Apply fix this to all OSs since this problem seems to effect
3609 * more than just SunOS.
3611 fix = {
3612 hackname = sun_auth_proto;
3613 files = rpc/auth.h;
3614 files = rpc/clnt.h;
3615 files = rpc/svc.h;
3616 files = rpc/xdr.h;
3617 bypass = "__cplusplus";
3619 * Select those files containing '(*name)()'.
3621 select = '\(\*[a-z][a-z_]*\)\(\)';
3623 c_fix = format;
3624 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3625 "#else\n%1();%2\n#endif";
3626 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3628 test_text =
3629 "struct auth_t {\n"
3630 " int (*name)(); /* C++ bad */\n"
3631 "};";
3636 * Fix bogus #ifdef on SunOS 4.1.
3638 fix = {
3639 hackname = sun_bogus_ifdef;
3640 files = "hsfs/hsfs_spec.h";
3641 files = "hsfs/iso_spec.h";
3642 select = '#ifdef(.*\|\|.*)';
3643 c_fix = format;
3644 c_fix_arg = "#if%1";
3646 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3651 * Fix the CAT macro in SunOS memvar.h.
3653 fix = {
3654 hackname = sun_catmacro;
3655 files = pixrect/memvar.h;
3656 select = "^#define[ \t]+CAT\\(a,b\\).*";
3657 c_fix = format;
3659 c_fix_arg =
3660 "#ifdef __STDC__\n"
3661 "# define CAT(a,b) a##b\n"
3662 "#else\n%0\n#endif";
3664 test_text =
3665 "#define CAT(a,b)\ta/**/b";
3670 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3671 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3673 fix = {
3674 hackname = sun_malloc;
3675 files = malloc.h;
3676 bypass = "_CLASSIC_ANSI_TYPES";
3678 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3679 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3680 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3681 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3682 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3684 test_text =
3685 "typedef char *\tmalloc_t;\n"
3686 "int \tfree();\n"
3687 "char*\tmalloc();\n"
3688 "char*\tcalloc();\n"
3689 "char*\trealloc();";
3694 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3696 fix = {
3697 hackname = sun_rusers_semi;
3698 files = rpcsvc/rusers.h;
3699 select = "_cnt$";
3700 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3701 test_text = "struct mumble\n int _cnt\n};";
3706 * signal.h on SunOS defines signal using (),
3707 * which causes trouble when compiling with g++ -pedantic.
3709 fix = {
3710 hackname = sun_signal;
3711 files = sys/signal.h;
3712 files = signal.h;
3713 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3715 c_fix = format;
3716 c_fix_arg =
3717 "#ifdef __cplusplus\n"
3718 "void\t(*signal(...))(...);\n"
3719 "#else\n%0\n#endif";
3721 test_text = "void\t(*signal())();";
3726 * Correct the return type for strlen in strings.h in SunOS 4.
3728 fix = {
3729 hackname = sunos_strlen;
3730 files = strings.h;
3731 select = "int[ \t]*strlen\\(\\);(.*)";
3732 c_fix = format;
3733 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3734 test_text = " int\tstrlen(); /* string length */";
3739 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3740 * that is visible to any ANSI compiler using this include. Simply
3741 * delete the lines that #define some string functions to internal forms.
3743 fix = {
3744 hackname = svr4_disable_opt;
3745 files = string.h;
3746 select = '#define.*__std_hdr_';
3747 sed = '/#define.*__std_hdr_/d';
3748 test_text = "#define strlen __std_hdr_strlen\n";
3753 * Fix broken decl of getcwd present on some svr4 systems.
3755 fix = {
3756 hackname = svr4_getcwd;
3757 files = stdlib.h;
3758 files = unistd.h;
3759 files = prototypes.h;
3760 select = 'getcwd\(char \*, int\)';
3762 c_fix = format;
3763 c_fix_arg = "getcwd(char *, size_t)";
3765 test_text = "extern char* getcwd(char *, int);";
3770 * Fix broken decl of profil present on some svr4 systems.
3772 fix = {
3773 hackname = svr4_profil;
3774 files = stdlib.h;
3775 files = unistd.h;
3777 select =
3778 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3779 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
3780 prototype in <sys/profil.h>. */
3781 bypass = 'Silicon Graphics';
3782 c_fix = format;
3783 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3785 test_text =
3786 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3791 * Correct types for signal handler constants like SIG_DFL; they might be
3792 * void (*) (), and should be void (*) (int). C++ doesn't like the
3793 * old style.
3795 fix = {
3796 hackname = svr4_sighandler_type;
3797 files = sys/signal.h;
3798 select = 'void *\(\*\)\(\)';
3799 c_fix = format;
3800 c_fix_arg = "void (*)(int)";
3801 test_text = "#define SIG_DFL (void(*)())0\n"
3802 "#define SIG_IGN (void (*)())0\n";
3807 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
3808 * function 'getrnge' in <regexp.h> before they declare it. For these
3809 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
3810 * early on.
3812 * 'getrnge' traditionally manipulates a file-scope global called 'size',
3813 * so put the declaration right after the declaration of 'size'.
3815 * Don't do this if there is already a `static void getrnge' declaration
3816 * present, since this would cause a redeclaration error. Solaris 2.x has
3817 * such a declaration.
3819 fix = {
3820 hackname = svr4_undeclared_getrnge;
3821 files = regexp.h;
3822 select = "getrnge";
3823 bypass = "static void getrnge";
3824 c_fix = format;
3825 c_fix_arg = "%0\n"
3826 "static int getrnge ();";
3827 c_fix_arg = "^static int[ \t]+size;";
3828 test_text = "static int size;\n"
3829 "/* stuff which calls getrnge() */\n"
3830 "static getrnge()\n"
3831 "{}";
3836 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
3837 * in string.h on sysV68
3838 * Correct the return type for strlen in string.h on Lynx.
3839 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
3840 * Add missing const for strdup on OSF/1 V3.0.
3841 * On sysV88 layout is slightly different.
3843 fix = {
3844 hackname = sysv68_string;
3845 files = testing.h;
3846 files = string.h;
3847 bypass = "_CLASSIC_ANSI_TYPES";
3849 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
3850 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
3851 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
3853 sed = "/^extern char$/N";
3854 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3856 sed = "/^extern int$/N";
3857 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3859 sed = "/^\tstrncmp(),$/N";
3860 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3861 '\1;' "\\\nextern unsigned int\\\n\\2/";
3863 test_text =
3864 "extern int strlen();\n"
3866 "extern int ffs(long);\n"
3868 "extern char\n"
3869 "\t*memccpy(),\n"
3870 "\tmemcpy();\n"
3872 "extern int\n"
3873 "\tstrcmp(),\n"
3874 "\tstrncmp(),\n"
3875 "\tstrlen(),\n"
3876 "\tstrspn();\n"
3878 "extern int\n"
3879 "\tstrlen(), strspn();";
3884 * Fix return type of calloc, malloc, realloc, bsearch and exit
3886 fix = {
3887 hackname = sysz_stdlib_for_sun;
3888 files = stdlib.h;
3889 bypass = "_CLASSIC_ANSI_TYPES";
3891 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3892 c_fix = format;
3893 c_fix_arg = "void *\t%1(";
3895 test_text =
3896 "extern char*\tcalloc(size_t);\n"
3897 "extern char*\tmalloc(size_t);\n"
3898 "extern char*\trealloc(void*,size_t);\n"
3899 "extern char*\tbsearch(void*,size_t,size_t);\n";
3904 * __thread is now a keyword.
3906 fix = {
3907 hackname = thread_keyword;
3908 files = "pthread.h";
3909 files = "bits/sigthread.h";
3910 select = "([* ])__thread([,)])";
3911 c_fix = format;
3912 c_fix_arg = "%1__thr%2";
3914 test_text =
3915 "extern int pthread_create (pthread_t *__restrict __thread,\n"
3916 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
3917 "extern int pthread_cancel (pthread_t __thread);";
3921 * if the #if says _cplusplus, not the double underscore __cplusplus
3922 * that it should be
3924 fix = {
3925 hackname = tinfo_cplusplus;
3926 files = tinfo.h;
3927 select = "[ \t]_cplusplus";
3929 c_fix = format;
3930 c_fix_arg = " __cplusplus";
3931 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
3936 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3938 fix = {
3939 hackname = ultrix_const;
3940 files = stdio.h;
3941 select = 'perror\( char \*';
3943 c_fix = format;
3944 c_fix_arg = "%1 const %3 *__";
3945 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3946 "[ \t]+(char|void) \\*__";
3948 test_text =
3949 "extern void perror( char *__s );\n"
3950 "extern int fputs( char *__s, FILE *);\n"
3951 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3952 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3953 "extern int scanf( char *__format, ...);\n";
3958 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3960 fix = {
3961 hackname = ultrix_const2;
3962 files = stdio.h;
3964 select = '\*fopen\( char \*';
3965 c_fix = format;
3966 c_fix_arg = "%1( const char *%3, const char *";
3967 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3968 "[ \t]*char[ \t]*\\*([^,]*),"
3969 "[ \t]*char[ \t]*\\*[ \t]*";
3971 test_text =
3972 "extern FILE *fopen( char *__filename, char *__type );\n"
3973 "extern int sscanf( char *__s, char *__format, ...);\n"
3974 "extern FILE *popen(char *, char *);\n"
3975 "extern char *tempnam(char*,char*);\n";
3980 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3982 fix = {
3983 hackname = va_i960_macro;
3984 files = arch/i960/archI960.h;
3985 select = "__(vsiz|vali|vpad|alignof__)";
3987 c_fix = format;
3988 c_fix_arg = "__vx%1";
3990 test_text =
3991 "extern int __vsiz vsiz;\n"
3992 "extern int __vali vali;\n"
3993 "extern int __vpad vpad;\n"
3994 "#define __alignof__(x) ...";
3999 * AIX and Interix headers define NULL to be cast to a void pointer,
4000 * which is illegal in ANSI C++.
4002 fix = {
4003 hackname = void_null;
4004 files = curses.h;
4005 files = dbm.h;
4006 files = locale.h;
4007 files = stdio.h;
4008 files = stdlib.h;
4009 files = string.h;
4010 files = time.h;
4011 files = unistd.h;
4012 files = sys/dir.h;
4013 files = sys/param.h;
4014 files = sys/types.h;
4015 /* avoid changing C++ friendly NULL */
4016 bypass = __cplusplus;
4017 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4018 c_fix = format;
4019 c_fix_arg = "#define NULL 0";
4020 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4025 * Make VxWorks header which is almost gcc ready fully gcc ready.
4027 fix = {
4028 hackname = vxworks_gcc_problem;
4029 files = types/vxTypesBase.h;
4030 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4032 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4033 "#if 1/";
4035 sed = "/[ \t]size_t/i\\\n"
4036 "#ifndef _GCC_SIZE_T\\\n"
4037 "#define _GCC_SIZE_T\n";
4039 sed = "/[ \t]size_t/a\\\n"
4040 "#endif\n";
4042 sed = "/[ \t]ptrdiff_t/i\\\n"
4043 "#ifndef _GCC_PTRDIFF_T\\\n"
4044 "#define _GCC_PTRDIFF_T\n";
4046 sed = "/[ \t]ptrdiff_t/a\\\n"
4047 "#endif\n";
4049 sed = "/[ \t]wchar_t/i\\\n"
4050 "#ifndef _GCC_WCHAR_T\\\n"
4051 "#define _GCC_WCHAR_T\n";
4053 sed = "/[ \t]wchar_t/a\\\n"
4054 "#endif\n";
4056 test_text =
4057 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4058 "typedef unsigned int size_t;\n"
4059 "typedef long ptrdiff_t;\n"
4060 "typedef unsigned short wchar_t;\n"
4061 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4066 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4068 fix = {
4069 hackname = vxworks_needs_vxtypes;
4070 files = time.h;
4071 select = "uint_t([ \t]+_clocks_per_sec)";
4072 c_fix = format;
4073 c_fix_arg = "unsigned int%1";
4074 test_text = "uint_t\t_clocks_per_sec;";
4079 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4081 fix = {
4082 hackname = vxworks_needs_vxworks;
4083 files = sys/stat.h;
4084 test = " -r types/vxTypesOld.h";
4085 test = " -n \"`egrep '#include' $file`\"";
4086 test = " -n \"`egrep ULONG $file`\"";
4087 select = "#[ \t]define[ \t]+__INCstath";
4089 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4090 "#include <types/vxTypesOld.h>\n";
4092 test_text = "`touch types/vxTypesOld.h`"
4093 "#include </dev/null> /* ULONG */\n"
4094 "# define\t__INCstath <sys/stat.h>";
4099 * Another bad dependency in VxWorks 5.2 <time.h>.
4101 fix = {
4102 hackname = vxworks_time;
4103 files = time.h;
4104 test = " -r vxWorks.h";
4106 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4107 c_fix = format;
4109 c_fix_arg =
4110 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4111 "#ifdef __cplusplus\n"
4112 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4113 "#else\n"
4114 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4115 "#endif\n"
4116 "#define __gcc_VOIDFUNCPTR_defined\n"
4117 "#endif\n"
4118 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4120 test_text = "`touch vxWorks.h`"
4121 "#define VOIDFUNCPTR (void(*)())";
4126 * There are several name conflicts with C++ reserved words in X11 header
4127 * files. These are fixed in some versions, so don't do the fixes if
4128 * we find __cplusplus in the file. These were found on the RS/6000.
4130 fix = {
4131 hackname = x11_class;
4132 files = X11/ShellP.h;
4133 bypass = __cplusplus;
4134 select = "^([ \t]*char \\*)class;(.*)";
4135 c_fix = format;
4136 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4137 "#else\n%1class;%2\n#endif";
4138 test_text =
4139 "struct {\n"
4140 " char *class;\n"
4141 "} mumble;\n";
4146 * class in Xm/BaseClassI.h
4148 fix = {
4149 hackname = x11_class_usage;
4150 files = Xm/BaseClassI.h;
4151 bypass = "__cplusplus";
4153 select = " class\\)";
4154 c_fix = format;
4155 c_fix_arg = " c_class)";
4157 test_text = "extern mumble (int class);\n";
4162 * new in Xm/Traversal.h
4164 fix = {
4165 hackname = x11_new;
4166 files = Xm/Traversal.h;
4167 bypass = __cplusplus;
4169 sed = "/Widget\told, new;/i\\\n"
4170 "#ifdef __cplusplus\\\n"
4171 "\tWidget\told, c_new;\\\n"
4172 "#else\n";
4174 sed = "/Widget\told, new;/a\\\n"
4175 "#endif\n";
4177 sed = "s/Widget new,/Widget c_new,/g";
4178 test_text =
4179 "struct wedge {\n"
4180 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
4181 "};\nextern Wedged( Widget new, Widget old );";
4186 * Incorrect sprintf declaration in X11/Xmu.h
4188 fix = {
4189 hackname = x11_sprintf;
4190 files = X11/Xmu.h;
4191 files = X11/Xmu/Xmu.h;
4192 select = "^extern char \\*\tsprintf\\(\\);$";
4194 c_fix = format;
4195 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4197 test_text = "extern char *\tsprintf();";
4200 /*EOF*/