* dwarf2out.c (switch_to_frame_table_section): Move
[official-gcc.git] / fixincludes / inclhack.def
blobf118260f2caeaec47a5f881af636fcf62ed7a653
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
61 #endif
62 #endif
64 _EOArg_;
69 * On Mac OS 10.3.9, the 'long double' functions are available in
70 * libSystem, but are not prototyped in math.h.
72 fix = {
73 hackname = AAB_darwin7_9_long_double_funcs;
74 mach = "*-*-darwin7.9*";
75 files = architecture/ppc/math.h;
76 bypass = "powl";
77 replace = <<- _EndOfHeader_
78 /* This file prototypes the long double functions available on Mac OS
79 10.3.9. */
80 #ifndef __MATH__
81 # undef __APPLE_CC__
82 # define __APPLE_CC__ 1345
83 # include_next <architecture/ppc/math.h>
84 # undef __APPLE_CC__
85 # define __APPLE_CC__ 1
86 # ifndef __LIBMLDBL_COMPAT
87 # ifdef __LONG_DOUBLE_128__
88 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
89 # else
90 # define __LIBMLDBL_COMPAT(sym)
91 # endif /* __LONG_DOUBLE_128__ */
92 # endif /* __LIBMLDBL_COMPAT */
93 # ifdef __cplusplus
94 extern "C" {
95 # endif
96 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
97 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
98 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
99 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
100 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
101 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
102 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
103 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
104 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
105 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
106 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
107 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
108 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
109 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
110 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
111 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
112 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
113 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
114 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
115 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
116 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
117 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
118 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
119 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
120 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
121 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
122 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
123 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
124 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
125 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
126 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
127 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
128 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
129 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
130 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
131 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
132 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
133 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
134 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
135 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
136 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
137 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
138 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
139 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
140 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
141 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
142 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
143 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
144 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
145 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
146 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
147 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
148 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
149 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
150 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
151 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
152 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
153 # ifdef __cplusplus
155 # endif
156 #endif /* __MATH__ */
157 _EndOfHeader_;
162 * ... and for the previous fix to be useful, you have to not use ""
163 * includes.
165 fix = {
166 hackname = AAB_darwin7_9_long_double_funcs_2;
167 mach = "*-*-darwin7.9*";
168 files = math.h;
169 select = '#include[ \t]+\"';
170 c_fix = format;
171 c_fix_arg = "%1<%2.h>";
173 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
175 test_text = '#include "architecture/ppc/math.h"';
180 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
182 fix = {
183 hackname = AAB_fd_zero_asm_posix_types_h;
184 files = asm/posix_types.h;
185 mach = 'i[34567]86-*-linux*';
186 bypass = '} while';
187 bypass = 'x86_64';
188 bypass = 'posix_types_64';
191 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
192 * the start, so that if #include_next gets another instance of
193 * the wrapper, this will follow the #include_next chain until
194 * we arrive at the real <asm/posix_types.h>.
196 replace = <<- _EndOfHeader_
197 /* This file fixes a bug in the __FD_ZERO macro
198 for older versions of the Linux kernel. */
199 #ifndef _POSIX_TYPES_H_WRAPPER
200 #include <features.h>
201 #include_next <asm/posix_types.h>
203 #if defined(__FD_ZERO) && !defined(__GLIBC__)
204 #undef __FD_ZERO
205 #define __FD_ZERO(fdsetp) \
206 do { \
207 int __d0, __d1; \
208 __asm__ __volatile__("cld ; rep ; stosl" \
209 : "=&c" (__d0), "=&D" (__d1) \
210 : "a" (0), "0" (__FDSET_LONGS), \
211 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
212 } while (0)
213 #endif
215 #define _POSIX_TYPES_H_WRAPPER
216 #endif /* _POSIX_TYPES_H_WRAPPER */
217 _EndOfHeader_;
222 * This fixes __FD_ZERO bug for glibc-1.x
224 fix = {
225 hackname = AAB_fd_zero_gnu_types_h;
226 files = gnu/types.h;
227 mach = 'i[34567]86-*-linux*';
230 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
231 * the start, so that if #include_next gets another instance of
232 * the wrapper, this will follow the #include_next chain until
233 * we arrive at the real <gnu/types.h>.
235 replace = <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
237 #ifndef _TYPES_H_WRAPPER
238 #include <features.h>
239 #include_next <gnu/types.h>
241 #if defined(__FD_ZERO) && !defined(__GLIBC__)
242 #undef __FD_ZERO
243 # define __FD_ZERO(fdsetp) \
244 do { \
245 int __d0, __d1; \
246 __asm__ __volatile__("cld ; rep ; stosl" \
247 : "=&c" (__d0), "=&D" (__d1) \
248 : "a" (0), "0" (__FDSET_LONGS), \
249 "1" ((__fd_set *) (fdsetp)) :"memory"); \
250 } while (0)
251 #endif
253 #define _TYPES_H_WRAPPER
254 #endif /* _TYPES_H_WRAPPER */
255 _EndOfHeader_;
260 * This fixes __FD_ZERO bug for glibc-2.0.x
262 fix = {
263 hackname = AAB_fd_zero_selectbits_h;
264 files = selectbits.h;
265 mach = 'i[34567]86-*-linux*';
268 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
269 * the start, so that if #include_next gets another instance of
270 * the wrapper, this will follow the #include_next chain until
271 * we arrive at the real <selectbits.h>.
273 replace = <<- _EndOfHeader_
274 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
275 #ifndef _SELECTBITS_H_WRAPPER
276 #include <features.h>
277 #include_next <selectbits.h>
279 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
280 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
281 && __GLIBC_MINOR__ == 0
282 #undef __FD_ZERO
283 #define __FD_ZERO(fdsetp) \\
284 do { \\
285 int __d0, __d1; \\
286 __asm__ __volatile__ ("cld; rep; stosl" \\
287 : "=&c" (__d0), "=&D" (__d1) \\
288 : "a" (0), "0" (sizeof (__fd_set) \\
289 / sizeof (__fd_mask)), \\
290 "1" ((__fd_mask *) (fdsetp)) \\
291 : "memory"); \\
292 } while (0)
293 #endif
295 #define _SELECTBITS_H_WRAPPER
296 #endif /* _SELECTBITS_H_WRAPPER */
297 _EndOfHeader_;
302 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
303 * the same interface as <stdarg.h>. No idea why they couldn't have just
304 * used the standard header.
306 fix = {
307 hackname = AAB_solaris_sys_varargs_h;
308 files = "sys/varargs.h";
309 mach = '*-*-solaris*';
310 replace = <<- _EndOfHeader_
311 #ifdef __STDC__
312 #include <stdarg.h>
313 #else
314 #include <varargs.h>
315 #endif
316 _EndOfHeader_;
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
322 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
323 * many other systems have similar text but correct versions of the file.
324 * To ensure only Sun's is fixed, we grep for a likely unique string.
325 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
327 fix = {
328 hackname = AAB_sun_memcpy;
329 files = memory.h;
330 select = "/\\*\t@\\(#\\)"
331 "(head/memory.h\t50.1\t "
332 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
334 replace = <<- _EndOfHeader_
335 /* This file was generated by fixincludes */
336 #ifndef __memory_h__
337 #define __memory_h__
339 #ifdef __STDC__
340 extern void *memccpy();
341 extern void *memchr();
342 extern void *memcpy();
343 extern void *memset();
344 #else
345 extern char *memccpy();
346 extern char *memchr();
347 extern char *memcpy();
348 extern char *memset();
349 #endif /* __STDC__ */
351 extern int memcmp();
353 #endif /* __memory_h__ */
354 _EndOfHeader_;
359 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
360 * which only is provided by AIX xlc C99.
362 fix = {
363 hackname = aix_complex;
364 mach = "*-*-aix*";
365 files = complex.h;
366 select = "#define[ \t]_Complex_I[ \t]__I";
367 c_fix = format;
368 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
369 test_text = "#define _Complex_I __I\n";
374 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
375 * which violates a requirement of ISO C.
377 fix = {
378 hackname = aix_pthread;
379 files = "pthread.h";
380 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
381 c_fix = format;
382 c_fix_arg = "%1 %2";
383 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
384 "{...init stuff...}";
389 * AIX stdint.h fixes.
391 fix = {
392 hackname = aix_stdint_1;
393 mach = "*-*-aix*";
394 files = stdint.h;
395 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
396 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
397 c_fix = format;
398 c_fix_arg = "#define UINT8_MAX (255)\n"
399 "#define UINT16_MAX (65535)";
400 test_text = "#define UINT8_MAX (255U)\n"
401 "#define UINT16_MAX (65535U)";
405 fix = {
406 hackname = aix_stdint_2;
407 mach = "*-*-aix*";
408 files = stdint.h;
409 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
410 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
411 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
412 "#else\n"
413 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
414 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
415 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
416 c_fix = format;
417 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
418 "#define INTPTR_MAX 9223372036854775807L\n"
419 "#define UINTPTR_MAX 18446744073709551615UL\n"
420 "#else\n"
421 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
422 "#define INTPTR_MAX 2147483647L\n"
423 "#define UINTPTR_MAX 4294967295UL";
424 test_text = "#define INTPTR_MIN INT64_MIN\n"
425 "#define INTPTR_MAX INT64_MAX\n"
426 "#define UINTPTR_MAX UINT64_MAX\n"
427 "#else\n"
428 "#define INTPTR_MIN INT32_MIN\n"
429 "#define INTPTR_MAX INT32_MAX\n"
430 "#define UINTPTR_MAX UINT32_MAX";
434 fix = {
435 hackname = aix_stdint_3;
436 mach = "*-*-aix*";
437 files = stdint.h;
438 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
439 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
440 "#else\n"
441 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
442 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
443 c_fix = format;
444 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
445 "#define PTRDIFF_MAX 9223372036854775807L\n"
446 "#else\n"
447 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
448 "#define PTRDIFF_MAX 2147483647L";
449 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
450 "#define PTRDIFF_MAX INT64_MAX\n"
451 "#else\n"
452 "#define PTRDIFF_MIN INT32_MIN\n"
453 "#define PTRDIFF_MAX INT32_MAX";
457 fix = {
458 hackname = aix_stdint_4;
459 mach = "*-*-aix*";
460 files = stdint.h;
461 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
462 "#else\n"
463 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
464 c_fix = format;
465 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
466 "#else\n"
467 "#define SIZE_MAX 4294967295UL";
468 test_text = "#define SIZE_MAX UINT64_MAX\n"
469 "#else\n"
470 "#define SIZE_MAX UINT32_MAX";
474 fix = {
475 hackname = aix_stdint_5;
476 mach = "*-*-aix*";
477 files = stdint.h;
478 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
479 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
480 c_fix = format;
481 c_fix_arg = "#define UINT8_C(c) c\n"
482 "#define UINT16_C(c) c";
483 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
484 "#define UINT16_C(c) __CONCAT__(c,U)";
489 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
490 * in an otherwise harmless (and #ifed out) macro definition
492 fix = {
493 hackname = aix_sysmachine;
494 files = sys/machine.h;
495 select = "\\\\ +\n";
496 c_fix = format;
497 c_fix_arg = "\\\n";
498 test_text = "#define FOO \\\n"
499 " bar \\ \n baz \\ \n bat";
504 * sys/wait.h on AIX 5.2 defines macros that have both signed and
505 * unsigned types in conditional expressions.
507 fix = {
508 hackname = aix_syswait_2;
509 files = sys/wait.h;
510 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
511 c_fix = format;
512 c_fix_arg = "? (int)%1";
513 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
518 * sys/signal.h on some versions of AIX uses volatile in the typedef of
519 * sig_atomic_t, which causes gcc to generate a warning about duplicate
520 * volatile when a sig_atomic_t variable is declared volatile, as
521 * required by ANSI C.
523 fix = {
524 hackname = aix_volatile;
525 files = sys/signal.h;
526 select = "typedef volatile int sig_atomic_t";
527 c_fix = format;
528 c_fix_arg = "typedef int sig_atomic_t";
529 test_text = "typedef volatile int sig_atomic_t;";
534 * Fix __assert declaration in assert.h on Alpha OSF/1.
536 fix = {
537 hackname = alpha___assert;
538 files = "assert.h";
539 select = '__assert\(char \*, char \*, int\)';
540 c_fix = format;
541 c_fix_arg = "__assert(const char *, const char *, int)";
542 test_text = 'extern void __assert(char *, char *, int);';
547 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
549 fix = {
550 hackname = alpha___extern_prefix;
551 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
552 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
554 mach = "alpha*-dec-osf*";
555 c_fix = format;
556 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
558 test_text = "#ifdef __DECC\n"
559 "#pragma extern_prefix \"_P\"\n"
560 "# if defined(__DECC)\n"
561 "# pragma extern_prefix \"_E\"\n"
562 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
563 "# pragma extern_prefix \"\"";
568 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
570 fix = {
571 hackname = alpha___extern_prefix_standards;
572 files = standards.h;
573 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
575 mach = "alpha*-dec-osf*";
576 c_fix = format;
577 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
579 test_text = "#if (_ISO_C_SOURCE>=19990L) "
580 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
585 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
586 * <sys/stat.h>. The tests for __DECC are special in various ways, so
587 * alpha__extern_prefix cannot be used.
589 fix = {
590 hackname = alpha___extern_prefix_sys_stat;
591 files = sys/stat.h;
592 files = sys/mount.h;
593 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
595 mach = "alpha*-dec-osf5*";
596 c_fix = format;
597 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
599 test_text = "# if defined(__DECC)";
604 * Fix assert macro in assert.h on Alpha OSF/1.
605 * The superfluous int cast breaks C++.
607 fix = {
608 hackname = alpha_assert;
609 files = "assert.h";
610 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
611 c_fix = format;
612 c_fix_arg = "%1(EX)";
613 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
614 ': __assert(#EX, __FILE__, __LINE__))';
619 * Fix #defines under Alpha OSF/1:
620 * The following files contain '#pragma extern_prefix "_FOO"' followed by
621 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
622 * statements is to reduce namespace pollution. While these macros work
623 * properly in most cases, they don't allow you to take a pointer to the
624 * "something" being modified. To get around this limitation, change these
625 * statements to be of the form '#define something _FOOsomething'.
627 * sed ain't egrep, lesson 2463: sed can use self-referential
628 * regular expressions. In the substitute expression below,
629 * "\\1" and "\\2" refer to subexpressions found earlier in the
630 * same match. So, we continue to use sed. "extern_prefix" will
631 * be a rare match anyway...
633 fix = {
634 hackname = alpha_bad_lval;
636 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
637 mach = "alpha*-dec-osf*";
639 sed =
640 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
641 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
643 test_text = '#pragma extern_prefix "_FOO"'"\n"
644 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
645 "#define mumble _FOOmumble";
650 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
652 fix = {
653 hackname = alpha_getopt;
654 files = "stdio.h";
655 files = "stdlib.h";
656 select = 'getopt\(int, char \*\[\], *char \*\)';
657 c_fix = format;
658 c_fix_arg = "getopt(int, char *const[], const char *)";
659 test_text = 'extern int getopt(int, char *[], char *);';
664 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
666 fix = {
667 hackname = alpha_if_semicolon;
668 files = net/if.h;
669 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
670 c_fix = format;
671 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
672 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
677 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
679 fix = {
680 hackname = alpha_parens;
681 files = sym.h;
682 select = '#ifndef\(__mips64\)';
683 c_fix = format;
684 c_fix_arg = "#ifndef __mips64";
685 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
690 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
692 fix = {
693 hackname = alpha_pthread;
694 files = pthread.h;
695 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
696 "|def _PTHREAD_ENV_DECC)(.*))\n"
697 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
699 mach = "alpha*-dec-osf*";
700 c_fix = format;
701 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
702 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
704 test_text = "# if defined (_PTHREAD_ENV_DECC) "
705 "|| defined (_PTHREAD_ENV_EPCC)\n"
706 "# define _PTHREAD_USE_PTDNAM_\n"
707 "# endif\n"
708 "# ifdef _PTHREAD_ENV_DECC\n"
709 "# define _PTHREAD_USE_PTDNAM_\n"
710 "# endif";
715 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
717 fix = {
718 hackname = alpha_pthread_gcc;
719 files = pthread.h;
720 select = "#else\n# error <pthread.h>: unrecognized compiler.";
722 mach = "alpha*-dec-osf*";
723 c_fix = format;
724 c_fix_arg = "#elif defined (__GNUC__)\n"
725 "# define _PTHREAD_ENV_GCC\n"
726 "%0";
728 test_text = "# define _PTHREAD_ENV_INTELC\n"
729 "#else\n"
730 "# error <pthread.h>: unrecognized compiler.\n"
731 "#endif";
736 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
737 * incorrectly, specifying less fields in the initializers than are
738 * defined in the corresponding structure types. Use of these macros
739 * in user code results in spurious warnings.
741 fix = {
742 hackname = alpha_pthread_init;
743 files = pthread.h;
744 select = ' \* @\(#\).RCSfile: pthread\.h,v \$'
745 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
746 ' .Date: 2000/08/15 15:30:13 \$';
747 mach = "alpha*-dec-osf*";
748 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
749 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
750 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
751 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
752 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
753 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
754 test_text = <<- _EOText_
756 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
758 #ifndef _PTHREAD_NOMETER_STATIC
759 # define PTHREAD_MUTEX_INITIALIZER \
760 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
761 # define PTHREAD_COND_INITIALIZER \
762 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
763 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
764 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
765 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
766 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
767 #else
768 # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
769 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
770 {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
771 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
772 {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
773 #endif
775 #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
776 #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
777 {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
778 _EOText_;
783 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
784 * And OpenBSD.
786 fix = {
787 hackname = alpha_sbrk;
788 files = unistd.h;
789 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
790 c_fix = format;
791 c_fix_arg = "void *sbrk(";
792 test_text = "extern char* sbrk(ptrdiff_t increment);";
797 * Change external names of wcstok/wcsftime via asm instead of macros on
798 * Tru64 UNIX V4.0.
800 fix = {
801 hackname = alpha_wchar;
802 files = wchar.h;
804 mach = "alpha*-dec-osf4*";
805 select = "#define wcstok wcstok_r";
806 sed = "s@#define wcstok wcstok_r@"
807 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
808 "wchar_t **)) __asm__(\"wcstok_r\");@";
809 sed = "s@#define wcsftime __wcsftime_isoc@"
810 "extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *"
811 ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
812 test_text = "#define wcstok wcstok_r\n"
813 "#define wcsftime __wcsftime_isoc";
818 * For C++, avoid any typedef or macro definition of bool,
819 * and use the built in type instead.
820 * HP/UX 10.20 also has it in curses_colr/curses.h.
822 fix = {
823 hackname = avoid_bool_define;
824 files = curses.h;
825 files = curses_colr/curses.h;
826 files = term.h;
827 files = tinfo.h;
829 select = "#[ \t]*define[ \t]+bool[ \t]";
830 bypass = "__cplusplus";
832 c_fix = format;
833 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
834 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
836 test_text = "# define bool\t char \n";
840 fix = {
841 hackname = avoid_bool_type;
842 files = curses.h;
843 files = curses_colr/curses.h;
844 files = term.h;
845 files = tinfo.h;
847 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
848 bypass = "__cplusplus";
850 c_fix = format;
851 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
853 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
858 * For C++, avoid any typedef definition of wchar_t,
859 * and use the built in type instead.
860 * Don't do this for headers that are smart enough to do the right
861 * thing (recent [n]curses.h and Xlib.h).
862 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
863 * and will be broken by the edit.
866 fix = {
867 hackname = avoid_wchar_t_type;
869 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
870 bypass = "__cplusplus";
871 bypass = "_LINUX_NLS_H";
872 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
874 c_fix = format;
875 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
877 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
882 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
884 fix = {
885 hackname = bad_struct_term;
886 files = curses.h;
887 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
888 c_fix = format;
889 c_fix_arg = "struct term;";
891 test_text = 'typedef struct term;';
896 * Fix one other error in this file:
897 * a mismatched quote not inside a C comment.
899 fix = {
900 hackname = badquote;
901 files = sundev/vuid_event.h;
902 select = "doesn't";
903 c_fix = format;
904 c_fix_arg = "does not";
906 test_text = "/* doesn't have matched single quotes */";
911 * check for broken assert.h that needs stdio.h
913 fix = {
914 hackname = broken_assert_stdio;
915 files = assert.h;
916 select = stderr;
917 bypass = "include.*stdio\\.h";
918 c_fix = wrap;
919 c_fix_arg = "#include <stdio.h>\n";
920 test_text = "extern FILE* stderr;";
925 * check for broken assert.h that needs stdlib.h
927 fix = {
928 hackname = broken_assert_stdlib;
929 files = assert.h;
930 select = 'exit *\(|abort *\(';
931 bypass = "include.*stdlib\\.h";
932 c_fix = wrap;
933 c_fix_arg = "#ifdef __cplusplus\n"
934 "#include <stdlib.h>\n"
935 "#endif\n";
936 test_text = "extern void exit ( int );";
941 * Remove `extern double cabs' declarations from math.h.
942 * This conflicts with C99. Discovered on AIX.
943 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
944 * declares cabs() to take a struct __cabs_s argument.
945 * SunOS4 has its cabs() declaration followed by a comment which
946 * terminates on the following line.
947 * Darwin hides its broken cabs in architecture-specific subdirs.
949 fix = {
950 hackname = broken_cabs;
951 files = math.h, "architecture/*/math.h";
952 select = "^extern[ \t]+double[ \t]+cabs";
954 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
955 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
957 test_text = "#ifdef __STDC__\n"
958 "extern double cabs(struct dbl_hypot);\n"
959 "#else\n"
960 "extern double cabs();\n"
961 "#endif\n"
962 "extern double cabs ( _Complex z );\n"
963 "extern double cabs(); /* This is a comment\n"
964 " and it ends here. */\n"
965 "extern double cabs(struct __cabs_s);\n"
966 "extern long double cabsl( struct __cabsl_s );";
971 * Fixup Darwin's broken check for __builtin_nanf.
973 fix = {
974 hackname = broken_nan;
976 * It is tempting to omit the first "files" entry. Do not.
977 * The testing machinery will take the first "files" entry as the name
978 * of a test file to play with. It would be a nuisance to have a directory
979 * with the name "*".
981 files = "architecture/ppc/math.h";
982 files = "architecture/*/math.h";
983 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
984 bypass = "powl";
985 c_fix = format;
986 c_fix_arg = "#if 1";
987 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
992 * Various systems derived from BSD4.4 contain a macro definition
993 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
994 * Known to be fixed in FreeBSD 5 system headers.
996 fix = {
997 hackname = bsd_stdio_attrs_conflict;
998 mach = "*-*-*bsd*";
999 mach = "*-*-*darwin*";
1000 files = stdio.h;
1001 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1002 c_fix = format;
1003 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1004 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1005 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1006 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1007 test_text = '#define vfscanf __svfscanf';
1012 * Fix various macros used to define ioctl numbers.
1013 * The traditional syntax was:
1015 * #define _CTRL(n, x) (('n'<<8)+x)
1016 * #define TCTRLCFOO _CTRL(T, 1)
1018 * but this does not work with the C standard, which disallows macro
1019 * expansion inside strings. We have to rewrite it thus:
1021 * #define _CTRL(n, x) ((n<<8)+x)
1022 * #define TCTRLCFOO _CTRL('T', 1)
1024 * The select expressions match too much, but the c_fix code is cautious.
1026 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1028 fix = {
1029 hackname = ctrl_quotes_def;
1030 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1031 c_fix = char_macro_def;
1032 c_fix_arg = "CTRL";
1035 * This is two tests in order to ensure that the "CTRL(c)" can
1036 * be selected in isolation from the multi-arg format
1038 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1039 test_text = "#define _CTRL(c) ('c'&037)";
1042 fix = {
1043 hackname = ctrl_quotes_use;
1044 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1045 c_fix = char_macro_use;
1046 c_fix_arg = "CTRL";
1047 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1052 * sys/mman.h on HP/UX is not C++ ready,
1053 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1055 * rpc/types.h on OSF1/2.0 is not C++ ready,
1056 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1058 * The problem is the declaration of malloc.
1060 fix = {
1061 hackname = cxx_unready;
1062 files = sys/mman.h;
1063 files = rpc/types.h;
1064 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1065 not within a macro. */
1066 bypass = '"C"|__BEGIN_DECLS';
1068 c_fix = wrap;
1069 c_fix_arg = "#ifdef __cplusplus\n"
1070 "extern \"C\" {\n"
1071 "#endif\n";
1072 c_fix_arg = "#ifdef __cplusplus\n"
1073 "}\n"
1074 "#endif\n";
1075 test_text = "extern void* malloc( size_t );";
1080 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1081 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1083 fix = {
1084 hackname = darwin_externc;
1085 mach = "*-*-darwin*";
1086 files = mach-o/swap.h;
1087 files = mach/mach_time.h;
1088 files = mach/mach_traps.h;
1089 files = mach/message.h;
1090 files = mach/mig.h;
1091 files = mach/semaphore.h;
1092 bypass = "extern \"C\"";
1093 bypass = "__BEGIN_DECLS";
1094 c_fix = wrap;
1095 c_fix_arg = "#ifdef __cplusplus\n"
1096 "extern \"C\" {\n"
1097 "#endif\n";
1098 c_fix_arg = "#ifdef __cplusplus\n"
1099 "}\n"
1100 "#endif\n";
1101 test_text = "extern void swap_fat_header();\n";
1106 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1107 * bad __GNUC__ tests.
1110 fix = {
1111 hackname = darwin_gcc4_breakage;
1112 mach = "*-*-darwin*";
1113 files = AvailabilityMacros.h;
1114 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1115 c_fix = format;
1116 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1117 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1118 "(__GNUC_MINOR__ >= 1)\n";
1123 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1124 * why would you ever put it in a system header file?
1126 fix = {
1127 hackname = darwin_private_extern;
1128 mach = "*-*-darwin*";
1129 files = mach-o/dyld.h;
1130 select = "__private_extern__ [a-z_]+ _dyld_";
1131 c_fix = format;
1132 c_fix_arg = "extern";
1133 c_fix_arg = "__private_extern__";
1134 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1135 "const char *dyld_func_name,\n"
1136 "unsigned long *address);\n";
1141 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1142 * unsigned constants.
1144 fix = {
1145 hackname = darwin_stdint_1;
1146 mach = "*-*-darwin*";
1147 files = stdint.h;
1148 c_fix = format;
1149 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1150 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1151 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1152 test_text = "#define UINT8_C(v) (v ## U)\n"
1153 "#define UINT16_C(v) (v ## U)";
1158 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1159 * with wrong types.
1161 fix = {
1162 hackname = darwin_stdint_2;
1163 mach = "*-*-darwin*";
1164 files = stdint.h;
1165 c_fix = format;
1166 c_fix_arg = "#if __WORDSIZE == 64\n"
1167 "#define INTPTR_MAX 9223372036854775807L\n"
1168 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1169 "#else\n"
1170 "#define INTPTR_MAX 2147483647L\n"
1171 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1172 "#endif";
1173 select = "#if __WORDSIZE == 64\n"
1174 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1175 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1176 "#else\n"
1177 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1178 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1179 "#endif";
1180 test_text = "#if __WORDSIZE == 64\n"
1181 "#define INTPTR_MIN INT64_MIN\n"
1182 "#define INTPTR_MAX INT64_MAX\n"
1183 "#else\n"
1184 "#define INTPTR_MIN INT32_MIN\n"
1185 "#define INTPTR_MAX INT32_MAX\n"
1186 "#endif";
1191 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1193 fix = {
1194 hackname = darwin_stdint_3;
1195 mach = "*-*-darwin*";
1196 files = stdint.h;
1197 c_fix = format;
1198 c_fix_arg = "#if __WORDSIZE == 64\n"
1199 "#define UINTPTR_MAX 18446744073709551615UL\n"
1200 "#else\n"
1201 "#define UINTPTR_MAX 4294967295UL\n"
1202 "#endif";
1203 select = "#if __WORDSIZE == 64\n"
1204 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1205 "#else\n"
1206 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1207 "#endif";
1208 test_text = "#if __WORDSIZE == 64\n"
1209 "#define UINTPTR_MAX UINT64_MAX\n"
1210 "#else\n"
1211 "#define UINTPTR_MAX UINT32_MAX\n"
1212 "#endif";
1217 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1219 fix = {
1220 hackname = darwin_stdint_4;
1221 mach = "*-*-darwin*";
1222 files = stdint.h;
1223 c_fix = format;
1224 c_fix_arg = "#if __WORDSIZE == 64\n"
1225 "#define SIZE_MAX 18446744073709551615UL\n"
1226 "#else\n"
1227 "#define SIZE_MAX 4294967295UL\n"
1228 "#endif";
1229 select = "#if __WORDSIZE == 64\n"
1230 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1231 "#else\n"
1232 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1233 "#endif";
1234 test_text = "#if __WORDSIZE == 64\n"
1235 "#define SIZE_MAX UINT64_MAX\n"
1236 "#else\n"
1237 "#define SIZE_MAX UINT32_MAX\n"
1238 "#endif";
1243 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1244 * with a wrong type.
1246 fix = {
1247 hackname = darwin_stdint_5;
1248 mach = "*-*-darwin*";
1249 files = stdint.h;
1250 c_fix = format;
1251 c_fix_arg = "#if __WORDSIZE == 64\n"
1252 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1253 "#define INTMAX_MAX 9223372036854775807L\n"
1254 "#define UINTMAX_MAX 18446744073709551615UL\n"
1255 "#else\n"
1256 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1257 "#define INTMAX_MAX 9223372036854775807LL\n"
1258 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1259 "#endif";
1260 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1261 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1262 "\n"
1263 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1264 test_text = "#define INTMAX_MIN INT64_MIN\n"
1265 "#define INTMAX_MAX INT64_MAX\n"
1266 "\n"
1267 "#define UINTMAX_MAX UINT64_MAX";
1272 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1273 * with a wrong type.
1275 fix = {
1276 hackname = darwin_stdint_6;
1277 mach = "*-*-darwin*";
1278 files = stdint.h;
1279 c_fix = format;
1280 c_fix_arg = "#if __WORDSIZE == 64\n"
1281 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1282 "#define PTRDIFF_MAX 9223372036854775807L\n"
1283 "#else\n"
1284 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1285 "#define PTRDIFF_MAX 2147483647\n"
1286 "#endif";
1287 select = "#if __WORDSIZE == 64\n"
1288 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1289 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1290 "#else\n"
1291 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1292 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1293 "#endif";
1294 test_text = "#if __WORDSIZE == 64\n"
1295 "#define PTRDIFF_MIN INT64_MIN\n"
1296 "#define PTRDIFF_MAX INT64_MAX\n"
1297 "#else\n"
1298 "#define PTRDIFF_MIN INT32_MIN\n"
1299 "#define PTRDIFF_MAX INT32_MAX\n"
1300 "#endif";
1305 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1306 * with a wrong type.
1308 fix = {
1309 hackname = darwin_stdint_7;
1310 mach = "*-*-darwin*";
1311 files = stdint.h;
1312 c_fix = format;
1313 c_fix_arg = "#if __WORDSIZE == 64\n"
1314 "#define INTMAX_C(v) (v ## L)\n"
1315 "#define UINTMAX_C(v) (v ## UL)\n"
1316 "#else\n"
1317 "#define INTMAX_C(v) (v ## LL)\n"
1318 "#define UINTMAX_C(v) (v ## ULL)\n"
1319 "#endif";
1320 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1321 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1322 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1323 "#define UINTMAX_C(v) (v ## ULL)";
1328 * Fix <c_asm.h> on Digital UNIX V4.0:
1329 * It contains a prototype for a DEC C internal asm() function,
1330 * clashing with gcc's asm keyword. So protect this with __DECC.
1332 fix = {
1333 hackname = dec_intern_asm;
1334 files = c_asm.h;
1335 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1336 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1337 "#endif\n";
1338 test_text =
1339 "float fasm {\n"
1340 " ... asm stuff ...\n"
1341 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1346 * Fix typo in <wchar.h> on DJGPP 2.03.
1348 fix = {
1349 hackname = djgpp_wchar_h;
1350 file = wchar.h;
1351 select = "__DJ_wint_t";
1352 bypass = "sys/djtypes.h";
1353 c_fix = format;
1354 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1355 c_fix_arg = "#include <stddef.h>";
1356 test_text = "#include <stddef.h>\n"
1357 "extern __DJ_wint_t x;\n";
1362 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1364 fix = {
1365 hackname = ecd_cursor;
1366 files = "sunwindow/win_lock.h";
1367 files = "sunwindow/win_cursor.h";
1368 select = 'ecd\.cursor';
1369 c_fix = format;
1370 c_fix_arg = 'ecd_cursor';
1372 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1377 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1378 * neither the existence of GCC 3 nor its exact feature set yet break
1379 * (by design?) when __GNUC__ is set beyond 2.
1381 fix = {
1382 hackname = freebsd_gcc3_breakage;
1383 mach = "*-*-freebsd*";
1384 files = sys/cdefs.h;
1385 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1386 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1387 c_fix = format;
1388 c_fix_arg = '%0 || __GNUC__ >= 3';
1389 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1394 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1395 * neither the existence of GCC 4 nor its exact feature set yet break
1396 * (by design?) when __GNUC__ is set beyond 3.
1398 fix = {
1399 hackname = freebsd_gcc4_breakage;
1400 mach = "*-*-freebsd*";
1401 files = sys/cdefs.h;
1402 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1403 c_fix = format;
1404 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1405 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1410 * Some versions of glibc don't expect the C99 inline semantics.
1412 fix = {
1413 hackname = glibc_c99_inline_1;
1414 files = features.h, '*/features.h';
1415 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1416 c_fix = format;
1417 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1418 test_text = <<-EOT
1419 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1420 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1421 # define __USE_EXTERN_INLINES 1
1422 #endif
1423 EOT;
1428 * Similar, but a version that didn't have __NO_INLINE__
1430 fix = {
1431 hackname = glibc_c99_inline_1a;
1432 files = features.h, '*/features.h';
1433 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1434 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1435 c_fix = format;
1436 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1437 test_text = <<-EOT
1438 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1439 # define __USE_EXTERN_INLINES 1
1440 #endif
1441 EOT;
1446 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1447 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1448 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1450 fix = {
1451 hackname = glibc_c99_inline_2;
1452 files = sys/stat.h, '*/sys/stat.h';
1453 select = "extern __inline__ int";
1454 sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
1455 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1456 "__inline__ int \\1/";
1457 sed = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
1458 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1459 "__inline__ int __REDIRECT\\1 (\\2/";
1460 sed = "s/^extern __inline__ int/"
1461 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1462 "__inline__ int/";
1463 test_text = <<-EOT
1464 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1465 extern __inline__ int
1466 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1468 EOT;
1472 fix = {
1473 hackname = glibc_c99_inline_3;
1474 files = bits/string2.h, '*/bits/string2.h';
1475 select = "extern __inline";
1476 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1477 c_fix = format;
1478 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1479 c_fix_arg = "^# ifdef __cplusplus$";
1480 test_text = <<-EOT
1481 # ifdef __cplusplus
1482 # define __STRING_INLINE inline
1483 # else
1484 # define __STRING_INLINE extern __inline
1485 # endif
1486 EOT;
1490 fix = {
1491 hackname = glibc_c99_inline_4;
1492 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1493 bypass = "__extern_inline|__gnu_inline__";
1494 select = "(^| )extern __inline";
1495 c_fix = format;
1496 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1497 test_text = <<-EOT
1498 __extension__ extern __inline unsigned int
1499 extern __inline unsigned int
1500 EOT;
1504 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1505 * so we replace them with versions that correspond to the
1506 * definition.
1508 fix = {
1509 hackname = glibc_mutex_init;
1510 files = pthread.h;
1511 select = '\{ *\{ *0, *\} *\}';
1512 sed = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1513 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1514 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1515 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1516 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1517 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1518 sed = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1519 "N;s/^[ \t]*#[ \t]*"
1520 "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1521 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
1522 "# \\1\\n"
1523 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1524 "# else\\n"
1525 "# \\1\\n"
1526 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1527 "# endif/";
1528 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1529 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1530 sed = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
1531 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1533 test_text = <<- _EOText_
1534 #define PTHREAD_MUTEX_INITIALIZER \\
1535 { { 0, } }
1536 #ifdef __USE_GNU
1537 # if __WORDSIZE == 64
1538 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1539 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1540 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1541 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1542 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1543 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1544 # else
1545 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1546 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1547 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1548 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1549 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1550 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1551 # endif
1552 #endif
1553 # define PTHREAD_RWLOCK_INITIALIZER \\
1554 { { 0, } }
1555 # ifdef __USE_GNU
1556 # if __WORDSIZE == 64
1557 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1558 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1559 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1560 # else
1561 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1562 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1563 # endif
1564 # endif
1565 #define PTHREAD_COND_INITIALIZER { { 0, } }
1566 _EOText_;
1570 /* glibc versions before 2.5 have a version of stdint.h that defines
1571 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1572 versions with stdint.h based on those glibc versions. */
1573 fix = {
1574 hackname = glibc_stdint;
1575 files = stdint.h;
1576 select = "GNU C Library";
1577 c_fix = format;
1578 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1579 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1580 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";
1584 /* glibc's tgmath.h relies on an expression that is not an integer
1585 constant expression being treated as it was by GCC 4.4 and
1586 earlier. */
1587 fix = {
1588 hackname = glibc_tgmath;
1589 files = tgmath.h;
1590 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1591 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1592 c_fix = format;
1593 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1594 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1598 * Fix these files to use the types we think they should for
1599 * ptrdiff_t, size_t, and wchar_t.
1601 * This defines the types in terms of macros predefined by our 'cpp'.
1602 * This is supposedly necessary for glibc's handling of these types.
1603 * It's probably not necessary for anyone else, but it doesn't hurt.
1605 fix = {
1606 hackname = gnu_types;
1607 files = "sys/types.h";
1608 files = "stdlib.h";
1609 files = "sys/stdtypes.h";
1610 files = "stddef.h";
1611 files = "memory.h";
1612 files = "unistd.h";
1613 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1614 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1615 c_fix = gnu_type;
1616 /* The Solaris 10 headers already define these types correctly. */
1617 mach = '*-*-solaris2.1[0-9]*';
1618 not_machine = true;
1620 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1621 "typedef uint_t size_t; /* uint_t */\n"
1622 "typedef ushort_t wchar_t; /* ushort_t */";
1627 * Fix HP & Sony's use of "../machine/xxx.h"
1628 * to refer to: <machine/xxx.h>
1630 fix = {
1631 hackname = hp_inline;
1632 files = sys/spinlock.h;
1633 files = machine/machparam.h;
1634 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1636 c_fix = format;
1637 c_fix_arg = "%1<machine/%2.h>";
1639 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1640 '([a-z]+)\.h"';
1642 test_text = ' # include "../machine/mumble.h"';
1647 * Check for (...) in C++ code in HP/UX sys/file.h.
1649 fix = {
1650 hackname = hp_sysfile;
1651 files = sys/file.h;
1652 select = "HPUX_SOURCE";
1654 c_fix = format;
1655 c_fix_arg = "(struct file *, ...)";
1656 c_fix_arg = '\(\.\.\.\)';
1658 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1663 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1664 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1666 fix = {
1667 hackname = hppa_hpux_fp_macros;
1668 mach = "hppa*-hp-hpux11*";
1669 files = math.h;
1670 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1671 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1672 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1673 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1674 "#[ \t]*define[ \t]*FP_NAN.*\n";
1675 c_fix = format;
1676 c_fix_arg = <<- _EOFix_
1677 #endif /* _INCLUDE_HPUX_SOURCE */
1679 #if defined(_INCLUDE_HPUX_SOURCE) || \
1680 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1681 %0#endif
1683 #ifdef _INCLUDE_HPUX_SOURCE
1685 _EOFix_;
1687 test_text =
1688 "# define FP_NORMAL 0\n"
1689 "# define FP_ZERO 1\n"
1690 "# define FP_INFINITE 2\n"
1691 "# define FP_SUBNORMAL 3\n"
1692 "# define FP_NAN 4\n";
1697 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1698 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1700 fix = {
1701 hackname = hpux10_cpp_pow_inline;
1702 files = fixinc-test-limits.h, math.h;
1703 select = <<- END_POW_INLINE
1704 ^# +ifdef +__cplusplus
1706 +inline +double +pow\(double +__d,int +__expon\) +\{
1707 [ ]+return +pow\(__d,\(double\)__expon\);
1709 +extern +"C" +\{
1710 #else
1711 # +endif
1712 END_POW_INLINE;
1714 c_fix = format;
1715 c_fix_arg = "";
1717 test_text =
1718 "# ifdef __cplusplus\n"
1719 " }\n"
1720 " inline double pow(double __d,int __expon) {\n"
1721 "\t return pow(__d,(double)__expon);\n"
1722 " }\n"
1723 ' extern "C"' " {\n"
1724 "#else\n"
1725 "# endif";
1728 fix = {
1729 hackname = hpux11_cpp_pow_inline;
1730 files = math.h;
1731 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1732 " +return pow\\(d, \\(double\\)expon\\);\n"
1733 " +\\}\n";
1734 c_fix = format;
1735 c_fix_arg = "";
1737 test_text =
1738 " inline double pow(double d,int expon) {\n"
1739 " return pow(d, (double)expon);\n"
1740 " }\n";
1745 * Fix hpux 10.X missing ctype declarations 1
1747 fix = {
1748 hackname = hpux10_ctype_declarations1;
1749 files = ctype.h;
1750 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1751 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1752 c_fix = format;
1753 c_fix_arg = "#ifdef _PROTOTYPES\n"
1754 "extern int __tolower(int);\n"
1755 "extern int __toupper(int);\n"
1756 "#else /* NOT _PROTOTYPES */\n"
1757 "extern int __tolower();\n"
1758 "extern int __toupper();\n"
1759 "#endif /* _PROTOTYPES */\n\n"
1760 "%0\n";
1762 test_text = "# define _toupper(__c) __toupper(__c)\n";
1767 * Fix hpux 10.X missing ctype declarations 2
1769 fix = {
1770 hackname = hpux10_ctype_declarations2;
1771 files = ctype.h;
1772 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1773 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1774 c_fix = format;
1775 c_fix_arg = "%0\n\n"
1776 "#ifdef _PROTOTYPES\n"
1777 " extern int _isalnum(int);\n"
1778 " extern int _isalpha(int);\n"
1779 " extern int _iscntrl(int);\n"
1780 " extern int _isdigit(int);\n"
1781 " extern int _isgraph(int);\n"
1782 " extern int _islower(int);\n"
1783 " extern int _isprint(int);\n"
1784 " extern int _ispunct(int);\n"
1785 " extern int _isspace(int);\n"
1786 " extern int _isupper(int);\n"
1787 " extern int _isxdigit(int);\n"
1788 "# else /* not _PROTOTYPES */\n"
1789 " extern int _isalnum();\n"
1790 " extern int _isalpha();\n"
1791 " extern int _iscntrl();\n"
1792 " extern int _isdigit();\n"
1793 " extern int _isgraph();\n"
1794 " extern int _islower();\n"
1795 " extern int _isprint();\n"
1796 " extern int _ispunct();\n"
1797 " extern int _isspace();\n"
1798 " extern int _isupper();\n"
1799 " extern int _isxdigit();\n"
1800 "#endif /* _PROTOTYPES */\n";
1802 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1803 " extern unsigned int *__SB_masks;\n";
1808 * Fix hpux 10.X missing stdio declarations
1810 fix = {
1811 hackname = hpux10_stdio_declarations;
1812 files = stdio.h;
1813 select = "^#[ \t]*define _iob[ \t]*__iob";
1814 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1815 c_fix = format;
1816 c_fix_arg = "%0\n\n"
1817 "# if defined(__STDC__) || defined(__cplusplus)\n"
1818 " extern int snprintf(char *, size_t, const char *, ...);\n"
1819 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1820 "# else /* not __STDC__) || __cplusplus */\n"
1821 " extern int snprintf();\n"
1822 " extern int vsnprintf();\n"
1823 "# endif /* __STDC__) || __cplusplus */\n";
1825 test_text = "# define _iob __iob\n";
1830 * Make sure hpux defines abs in header.
1832 fix = {
1833 hackname = hpux11_abs;
1834 mach = "ia64-hp-hpux11*";
1835 files = stdlib.h;
1836 select = "ifndef _MATH_INCLUDED";
1837 c_fix = format;
1838 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1839 test_text = "#ifndef _MATH_INCLUDED";
1844 * Keep HP-UX 11 from stomping on C++ math namespace
1845 * with defines for fabsf.
1847 fix = {
1848 hackname = hpux11_fabsf;
1849 files = math.h;
1850 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1851 bypass = "__cplusplus";
1853 c_fix = format;
1854 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1856 test_text =
1857 "#ifdef _PA_RISC\n"
1858 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1859 "#endif";
1864 * Fix C99 constant in __POINTER_SET define.
1866 fix = {
1867 hackname = hpux11_pthread_const;
1868 mach = "*-hp-hpux11.[0-3]*";
1869 files = sys/pthread.h;
1870 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1872 c_fix = format;
1873 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1874 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1879 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1880 * being defined by having it define _hpux_size_t instead.
1882 fix = {
1883 hackname = hpux11_size_t;
1884 mach = "*-hp-hpux11*";
1885 select = "__size_t";
1887 c_fix = format;
1888 c_fix_arg = "_hpux_size_t";
1890 test_text =
1891 "#define __size_t size_t\n"
1892 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1897 * Fix hpux 11.00 broken snprintf declaration
1898 * (third argument is char *, needs to be const char * to prevent
1899 * spurious warnings with -Wwrite-strings or in C++).
1901 fix = {
1902 hackname = hpux11_snprintf;
1903 files = stdio.h;
1904 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1905 ' *(char *\*, *\.\.\.\);)';
1906 c_fix = format;
1907 c_fix_arg = '%1 const %3';
1909 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1910 "extern int snprintf(char *, __size_t, char *, ...);\n"
1911 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1915 * Fix hpux 11.00 broken vsnprintf declaration
1917 fix = {
1918 hackname = hpux11_vsnprintf;
1919 files = stdio.h;
1920 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1921 'const char \*,) __va__list\);';
1922 c_fix = format;
1923 c_fix_arg = "%1 __va_list);";
1925 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1926 ' __va__list);';
1931 * get rid of bogus inline definitions in HP-UX 8.0
1933 fix = {
1934 hackname = hpux8_bogus_inlines;
1935 files = math.h;
1936 select = inline;
1937 bypass = "__GNUG__";
1938 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1939 "@extern \"C\" int abs(int);@";
1940 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1941 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1942 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1943 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1944 "inline double sqr(double v) { return v**0.5; }";
1949 * Fix hpux broken ctype macros
1951 fix = {
1952 hackname = hpux_ctype_macros;
1953 files = ctype.h;
1954 select = '((: |\()__SB_masks \? )'
1955 '(__SB_masks\[__(alnum|c)\] & _IS)';
1956 c_fix = format;
1957 c_fix_arg = "%1(int)%3";
1959 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1960 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1965 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1967 fix = {
1968 hackname = hpux_htonl;
1969 files = netinet/in.h;
1970 select = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1971 "(/\\*\n"
1972 " \\* Macros for number representation conversion\\.\n"
1973 " \\*/\n"
1974 "#ifndef ntohl)";
1975 c_fix = format;
1976 c_fix_arg = "#if 1\n%1";
1978 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1979 "/*\n"
1980 " * Macros for number representation conversion.\n"
1981 " */\n"
1982 "#ifndef ntohl\n"
1983 "#define ntohl(x) (x)\n"
1984 "#define ntohs(x) (x)\n"
1985 "#define htonl(x) (x)\n"
1986 "#define htons(x) (x)\n"
1987 "#endif\n"
1988 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1993 * HP-UX long_double
1995 fix = {
1996 hackname = hpux_long_double;
1997 mach = "*-*-hpux10*";
1998 mach = "*-*-hpux11.[012]*";
1999 files = stdlib.h;
2000 select = "extern[ \t]long_double[ \t]strtold";
2001 bypass = "long_double_t";
2002 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2003 sed = "s/long_double/long double/g";
2005 test_text = "# ifndef _LONG_DOUBLE\n"
2006 "# define _LONG_DOUBLE\n"
2007 " typedef struct {\n"
2008 " unsigned int word1, word2, word3, word4;\n"
2009 " } long_double;\n"
2010 "# endif /* _LONG_DOUBLE */\n"
2011 "extern long_double strtold(const char *, char **);\n";
2015 * We cannot use the above rule on 11.31 because it removes the strtold
2016 * definition. ia64 is OK with no hack, PA needs some help.
2018 fix = {
2019 hackname = hpux_long_double_2;
2020 mach = "hppa*-*-hpux11.3*";
2021 files = stdlib.h;
2022 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
2023 c_fix = format;
2024 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2026 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
2030 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2032 fix = {
2033 hackname = hpux_systime;
2034 files = sys/time.h;
2035 select = "^extern struct sigevent;";
2037 c_fix = format;
2038 c_fix_arg = "struct sigevent;";
2040 test_text = 'extern struct sigevent;';
2045 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2046 * type and mpinfou is only defined when _KERNEL is set.
2048 fix = {
2049 hackname = hpux_spu_info;
2050 mach = "*-hp-hpux*";
2052 * It is tempting to omit the first "files" entry. Do not.
2053 * The testing machinery will take the first "files" entry as the name
2054 * of a test file to play with. It would be a nuisance to have a directory
2055 * with the name "*".
2057 files = "ia64/sys/getppdp.h";
2058 files = "*/sys/getppdp.h";
2059 select = "^.*extern.*spu_info.*";
2061 c_fix = format;
2062 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2064 test_text = "extern union mpinfou spu_info[];";
2067 fix = {
2068 hackname = hpux11_extern_sendfile;
2069 mach = "*-hp-hpux11.[12]*";
2070 files = sys/socket.h;
2071 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2072 c_fix = format;
2073 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2074 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2077 fix = {
2078 hackname = hpux11_extern_sendpath;
2079 mach = "*-hp-hpux11.[12]*";
2080 files = sys/socket.h;
2081 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2082 c_fix = format;
2083 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2084 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2087 fix = {
2088 hackname = hpux_extern_errno;
2089 mach = "*-hp-hpux10.*";
2090 mach = "*-hp-hpux11.[0-2]*";
2091 files = errno.h;
2092 select = "^[ \t]*extern int errno;$";
2093 c_fix = format;
2094 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2095 test_text = " extern int errno;\n";
2100 * Add missing braces to pthread initializer defines.
2102 fix = {
2103 hackname = hpux_pthread_initializers;
2104 mach = "*-hp-hpux11.[0-3]*";
2105 files = sys/pthread.h;
2106 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2107 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2108 sed = "s@^[ \t]*1,[ \t]*\\\\"
2109 "@\t{ 1, 0 }@";
2110 sed = "/^[ \t]*0$/d";
2111 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2112 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2113 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2114 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2115 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2116 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2117 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2118 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2119 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2120 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2121 sed = "s@__PTHREAD_COND_VALID, 0"
2122 "@{ __PTHREAD_COND_VALID, 0 }@";
2123 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2124 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2125 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2126 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2127 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2128 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2129 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2130 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2131 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2132 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2133 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2134 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2135 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2136 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2137 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2138 "}\n";
2141 fix = {
2142 hackname = hpux_c99_intptr;
2143 mach = "*-hp-hpux11.3*";
2144 files = stdint.h;
2145 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2146 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2147 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2148 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2149 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2150 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2151 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2152 "#define PTRDIFF_MIN INT32_MIN\n"
2153 "#define INTPTR_MAX INT32_MAX\n"
2154 "#define INTPTR_MIN INT32_MIN\n"
2155 "#define UINTPTR_MAX UINT32_MAX\n"
2156 "#define SIZE_MAX UINT32_MAX\n";
2160 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2163 fix = {
2164 hackname = hpux_c99_inttypes;
2165 mach = "*-hp-hpux11.[23]*";
2166 files = inttypes.h;
2167 files = stdint.h;
2168 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2169 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2170 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2171 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2172 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2173 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2174 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2175 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2178 fix = {
2179 hackname = hpux_c99_inttypes2;
2180 mach = "*-hp-hpux11.2*";
2181 files = stdint.h;
2182 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2183 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2184 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2185 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2186 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2187 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2188 "# define INT16_C(__c) ((short)(__c))\n"
2189 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2192 fix = {
2193 hackname = hpux_stdint_least_fast;
2194 mach = "*-hp-hpux11.2*";
2195 files = stdint.h;
2196 select =
2197 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2198 c_fix = format;
2199 c-fix-arg = <<- _EOFix_
2200 #ifdef __LP64__
2201 # define UINT_%164_MAX ULONG_MAX
2202 #else
2204 #endif
2205 _EOFix_;
2206 test-text = <<- _EOFix_
2207 # define UINT_FAST64_MAX ULLONG_MAX
2208 # define UINT_LEAST64_MAX ULLONG_MAX
2209 _EOFix_;
2212 fix = {
2213 hackname = hpux_inttype_int8_t;
2214 mach = "*-hp-hpux1[01].*";
2215 files = sys/_inttypes.h;
2216 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2217 c_fix = format;
2218 c_fix_arg = "typedef signed char int%18_t;";
2219 test_text = "typedef char int_least8_t;\n"
2220 "typedef char int8_t;\n";
2223 fix = {
2224 hackname = hpux_imaginary_i;
2225 mach = "ia64-hp-hpux11.*";
2226 files = complex.h;
2227 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2228 c_fix = format;
2229 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2230 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2234 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2236 fix = {
2237 hackname = huge_val_hex;
2238 files = bits/huge_val.h;
2239 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2240 bypass = "__builtin_huge_val";
2242 c_fix = format;
2243 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2245 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2250 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2252 fix = {
2253 hackname = huge_valf_hex;
2254 files = bits/huge_val.h;
2255 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2256 bypass = "__builtin_huge_valf";
2258 c_fix = format;
2259 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2261 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2266 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2268 fix = {
2269 hackname = huge_vall_hex;
2270 files = bits/huge_val.h;
2271 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2272 bypass = "__builtin_huge_vall";
2274 c_fix = format;
2275 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2277 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2282 * Fix return type of abort and free
2284 fix = {
2285 hackname = int_abort_free_and_exit;
2286 files = stdlib.h;
2287 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2288 bypass = "_CLASSIC_ANSI_TYPES";
2290 c_fix = format;
2291 c_fix_arg = "void\t%1(";
2293 test_text = "extern int abort(int);\n"
2294 "extern int free(void*);\n"
2295 "extern int exit(void*);";
2300 * Fix various macros used to define ioctl numbers.
2301 * The traditional syntax was:
2303 * #define _IO(n, x) (('n'<<8)+x)
2304 * #define TIOCFOO _IO(T, 1)
2306 * but this does not work with the C standard, which disallows macro
2307 * expansion inside strings. We have to rewrite it thus:
2309 * #define _IO(n, x) ((n<<8)+x)
2310 * #define TIOCFOO _IO('T', 1)
2312 * The select expressions match too much, but the c_fix code is cautious.
2314 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2316 fix = {
2317 hackname = io_quotes_def;
2318 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2319 c_fix = char_macro_def;
2320 c_fix_arg = "IO";
2321 test_text =
2322 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2323 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2324 "#define _IO(x,y) ('x'<<8|y)";
2325 test_text =
2326 "#define XX_IO(x) ('x'<<8|256)";
2329 fix = {
2330 hackname = io_quotes_use;
2331 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2332 "\\( *[^,']";
2333 c_fix = char_macro_use;
2334 c_fix_arg = "IO";
2335 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2336 "#define TIOCFOO \\\\\n"
2337 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2342 * Check for missing ';' in struct
2344 fix = {
2345 hackname = ip_missing_semi;
2346 files = netinet/ip.h;
2347 select = "}$";
2348 sed = "/^struct/,/^};/s/}$/};/";
2349 test_text=
2350 "struct mumble {\n"
2351 " union {\n"
2352 " int x;\n"
2353 " }\n"
2354 "}; /* mumbled struct */\n";
2359 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
2360 * __restrict as restrict iff __c99. This is wrong for C++, which
2361 * needs many C99 features, but only supports __restrict.
2363 fix = {
2364 hackname = irix___restrict;
2365 files = internal/sgimacros.h;
2366 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
2368 mach = "mips-sgi-irix6.5";
2369 c_fix = format;
2370 c_fix_arg = "%1"
2371 "# ifndef __cplusplus\n%2\n# endif";
2373 test_text = "#ifdef __c99\n# define __restrict restrict";
2377 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
2378 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
2379 * functions.
2381 * This was probably introduced around IRIX 6.5.18
2383 fix = {
2384 hackname = irix___generic1;
2385 files = internal/math_core.h;
2386 mach = "mips-sgi-irix6.5";
2387 select = "#define ([a-z]+)\\(x\\) *__generic.*";
2389 c_fix = format;
2390 c_fix_arg = "extern int %1(double);\n"
2391 "extern int %1f(float);\n"
2392 "extern int %1l(long double);\n"
2393 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
2394 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
2395 " : _%1l(x))\n";
2397 test_text =
2398 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2402 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2403 compiler's __generic intrinsic to define isgreater, isgreaterequal,
2404 isless, islessequal, islessgreater and isunordered functions. */
2405 fix = {
2406 hackname = irix___generic2;
2407 files = internal/math_core.h;
2408 mach = "mips-sgi-irix6.5";
2409 select = "#define ([a-z]+)\\(x,y\\) *__generic.*";
2411 c_fix = format;
2412 c_fix_arg = "#define %1(x,y) \\\n"
2413 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2414 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2415 " : _%1l(x,y))\n";
2417 test_text =
2418 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2423 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2424 * that causes the assembly preprocessor to complain about an
2425 * unterminated character constant.
2427 fix = {
2428 hackname = irix_asm_apostrophe;
2429 files = sys/asm.h;
2431 select = "^[ \t]*#.*[Ww]e're";
2432 c_fix = format;
2433 c_fix_arg = "%1 are";
2434 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
2435 test_text = "\t# and we're on vacation";
2440 * Non-traditional "const" declaration in Irix's limits.h.
2442 fix = {
2443 hackname = irix_limits_const;
2444 files = fixinc-test-limits.h, limits.h;
2445 select = "^extern const ";
2446 c_fix = format;
2447 c_fix_arg = "extern __const ";
2448 test_text = "extern const char limit; /* test limits */";
2453 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2454 * Various socket function prototypes use different types instead,
2455 * depending on the API in use (BSD, XPG4/5), but the socklen_t
2456 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
2457 * IRIX 6.5.19).
2459 fix = {
2460 hackname = irix_socklen_t;
2461 files = sys/socket.h;
2462 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2464 mach = "mips-sgi-irix6.5";
2465 c_fix = format;
2466 c_fix_arg = "%1"
2467 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2468 "typedef int socklen_t;\n"
2469 "#else\n"
2470 "%2\n"
2471 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2473 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2477 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2478 * otherwise.
2480 fix = {
2481 hackname = irix_stdint_c99;
2482 files = stdint.h;
2483 select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
2485 mach = "mips-sgi-irix6.5";
2486 c_fix = format;
2487 c_fix_arg = "#if 0\n"
2488 "%2";
2489 test_text =
2490 "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
2495 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2496 * some functions that take a va_list as
2497 * taking char *. However, GCC uses void * for va_list, so
2498 * calling vfprintf with a va_list fails in C++. */
2499 fix = {
2500 hackname = irix_stdio_va_list;
2501 files = stdio.h;
2502 files = internal/stdio_core.h;
2504 select = '/\* va_list \*/ char \*';
2505 c_fix = format;
2506 c_fix_arg = "__gnuc_va_list";
2507 test_text =
2508 "extern int printf( const char *, /* va_list */ char * );";
2513 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2514 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2516 fix = {
2517 hackname = irix_wcsftime;
2518 files = internal/wchar_core.h;
2519 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2521 mach = "mips-sgi-irix6.5";
2522 c_fix = format;
2523 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2525 test_text = "#if _NO_XOPEN5\n"
2526 "extern size_t wcsftime(wchar_t *, "
2527 "__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, "
2528 "const struct tm *);";
2532 * Fixing ISC fmod declaration
2534 fix = {
2535 hackname = isc_fmod;
2536 files = math.h;
2537 select = 'fmod\(double\)';
2538 c_fix = format;
2539 c_fix_arg = "fmod(double, double)";
2540 test_text = "extern double fmod(double);";
2545 * On Interactive Unix 2.2, certain traditional Unix definitions
2546 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
2547 * defined, not just if _POSIX_SOURCE is defined. This makes it
2548 * impossible to compile any nontrivial program except with -posix.
2550 fix = {
2551 hackname = isc_omits_with_stdc;
2553 files = "stdio.h";
2554 files = "math.h";
2555 files = "ctype.h";
2556 files = "sys/limits.h";
2557 files = "sys/fcntl.h";
2558 files = "sys/dirent.h";
2560 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
2561 c_fix = format;
2562 c_fix_arg = '!defined(_POSIX_SOURCE)';
2563 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
2564 "\nint foo;\n#endif";
2569 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2570 * use / * * / to concatenate tokens.
2572 fix = {
2573 hackname = kandr_concat;
2574 files = "sparc/asm_linkage.h";
2575 files = "sun*/asm_linkage.h";
2576 files = "arm/as_support.h";
2577 files = "arm/mc_type.h";
2578 files = "arm/xcb.h";
2579 files = "dev/chardefmac.h";
2580 files = "dev/ps_irq.h";
2581 files = "dev/screen.h";
2582 files = "dev/scsi.h";
2583 files = "sys/tty.h";
2584 files = "Xm.acorn/XmP.h";
2585 files = bsd43/bsd43_.h;
2586 select = '/\*\*/';
2587 c_fix = format;
2588 c_fix_arg = '##';
2589 test_text = "#define __CONCAT__(a,b) a/**/b";
2593 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2594 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2595 * constant on recent versions of g++.
2597 fix = {
2598 hackname = linux_ia64_ucontext;
2599 files = "sys/ucontext.h";
2600 mach = "ia64-*-linux*";
2601 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2602 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2603 c_fix = format;
2604 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2605 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2606 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2611 * Remove header file warning from sys/time.h. Autoconf's
2612 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2613 * which causes warning on LynxOS. Remove the warning.
2615 fix = {
2616 hackname = lynxos_no_warning_in_sys_time_h;
2617 files = sys/time.h;
2618 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2619 c_fix = format;
2620 c_fix_arg = "";
2621 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2626 * Add missing declaration for putenv.
2628 fix = {
2629 hackname = lynxos_missing_putenv;
2630 mach = '*-*-lynxos*';
2631 files = stdlib.h;
2632 bypass = 'putenv[ \t]*\\(';
2633 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2634 c_fix = format;
2635 c_fix_arg = "%0\n"
2636 "extern int putenv _AP((char *));";
2637 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2638 test_text = "extern char *getenv _AP((const char *));";
2643 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2645 * On NetBSD, machine is a symbolic link to an architecture specific
2646 * directory name, so we can't match a specific file name here.
2648 fix = {
2649 hackname = machine_ansi_h_va_list;
2650 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2651 bypass = '__builtin_va_list';
2653 c_fix = format;
2654 c_fix_arg = "%1__builtin_va_list";
2655 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2657 test_text = " # define _BSD_VA_LIST_\tchar**";
2662 * Fix non-ansi machine name defines
2664 fix = {
2665 hackname = machine_name;
2666 c_test = machine_name;
2667 c_fix = machine_name;
2669 test_text = "/* MACH_DIFF: */\n"
2670 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2671 "\n/* no uniform test, so be careful :-) */";
2676 * Some math.h files define struct exception (it's in the System V
2677 * Interface Definition), which conflicts with the class exception defined
2678 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2679 * This is not a great fix, but I haven't been able to think of anything
2680 * better.
2682 fix = {
2683 hackname = math_exception;
2684 files = math.h;
2685 select = "struct exception";
2687 * This should be bypassed on __cplusplus, but some supposedly C++ C++
2688 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2689 * exception either. So currently we bypass only for glibc, based on a
2690 * comment in the fixed glibc header. Ick.
2692 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2693 '_[a-z0-9A-Z_]+_exception; for C, exception';
2694 c_fix = wrap;
2696 c_fix_arg = "#ifdef __cplusplus\n"
2697 "#define exception __math_exception\n"
2698 "#endif\n";
2700 c_fix_arg = "#ifdef __cplusplus\n"
2701 "#undef exception\n"
2702 "#endif\n";
2704 test_text = "typedef struct exception t_math_exception;";
2709 * This looks pretty broken to me. ``dbl_max_def'' will contain
2710 * "define DBL_MAX " at the start, when what we really want is just
2711 * the value portion. Can't figure out how to write a test case
2712 * for this either :-(
2714 fix = {
2715 hackname = math_huge_val_from_dbl_max;
2716 files = math.h;
2719 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2720 * in math.h, this fix applies.
2722 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2723 bypass = "define[ \t]+DBL_MAX";
2725 shell =
2727 * See if we have a definition for DBL_MAX in float.h.
2728 * If we do, we will replace the one in math.h with that one.
2731 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2732 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2734 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2735 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2736 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2737 "\telse cat\n"
2738 "\tfi";
2740 test_text =
2741 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2742 "#define HUGE_VAL DBL_MAX";
2747 * nested comment
2749 fix = {
2750 hackname = nested_auth_des;
2751 files = rpc/rpc.h;
2752 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2753 c_fix = format;
2754 c_fix_arg = "%1*/ /*";
2755 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2760 * Fixing nested comments in ISC <sys/limits.h>
2762 fix = {
2763 hackname = nested_sys_limits;
2764 files = sys/limits.h;
2765 select = CHILD_MAX;
2766 sed = "/CHILD_MAX/s,/\\* Max, Max,";
2767 sed = "/OPEN_MAX/s,/\\* Max, Max,";
2768 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
2769 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
2774 * Some versions of NetBSD don't expect the C99 inline semantics.
2776 fix = {
2777 hackname = netbsd_c99_inline_1;
2778 mach = "*-*-netbsd*";
2779 files = signal.h;
2780 select = "extern __inline int";
2782 c_fix = format;
2783 c_fix_arg = "extern\n"
2784 "#ifdef __GNUC_STDC_INLINE__\n"
2785 "__attribute__((__gnu_inline__))\n"
2786 "#endif\n"
2787 "__inline int";
2789 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2793 fix = {
2794 hackname = netbsd_c99_inline_2;
2795 mach = "*-*-netbsd*";
2796 files = signal.h;
2797 select = "#define _SIGINLINE extern __inline";
2799 c_fix = format;
2800 c_fix_arg = <<- _EOArg_
2801 #ifdef __GNUC_STDC_INLINE__
2802 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2803 #else
2805 #endif
2806 _EOArg_;
2808 test_text = "#define _SIGINLINE extern __inline";
2813 * NetBSD has a semicolon after the ending '}' for some extern "C".
2815 fix = {
2816 hackname = netbsd_extra_semicolon;
2817 mach = "*-*-netbsd*";
2818 files = sys/cdefs.h;
2819 select = "#define[ \t]*__END_DECLS[ \t]*};";
2821 c_fix = format;
2822 c_fix_arg = "#define __END_DECLS }";
2824 test_text = "#define __END_DECLS };";
2828 /* newlib's stdint.h has several failures to conform to C99. The fix
2829 for these removed a comment that can be matched to identify unfixed
2830 versions. */
2831 fix = {
2832 hackname = newlib_stdint_1;
2833 files = stdint.h;
2834 select = "@todo - Add support for wint_t types";
2835 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2836 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2837 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2838 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2839 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2840 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2841 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2842 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2843 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2844 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2845 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2846 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2847 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2848 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2849 test_text = "/* @todo - Add support for wint_t types. */\n"
2850 "#define INT32_MIN (-2147483647-1)\n"
2851 "#define INT32_MAX 2147483647\n"
2852 "#define UINT32_MAX 4294967295U\n"
2853 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2854 "#define INT_LEAST32_MAX 2147483647\n"
2855 "#define UINT_LEAST32_MAX 4294967295U\n"
2856 "#define INT_FAST8_MIN INT8_MIN\n"
2857 "#define INT_FAST8_MAX INT8_MAX\n"
2858 "#define UINT_FAST8_MAX UINT8_MAX\n"
2859 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2860 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2861 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2862 "#define UINT8_C(x) x##U\n"
2863 "#define UINT16_C(x) x##U";
2867 fix = {
2868 hackname = newlib_stdint_2;
2869 files = stdint.h;
2870 select = "@todo - Add support for wint_t types";
2871 c_fix = format;
2872 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2873 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2874 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2875 "#define WCHAR_MAX __WCHAR_MAX__\n"
2876 "#define WCHAR_MIN __WCHAR_MIN__\n"
2877 "#define WINT_MAX __WINT_MAX__\n"
2878 "#define WINT_MIN __WINT_MIN__\n\n"
2879 "%0";
2880 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2881 test_text = "/* @todo - Add support for wint_t types. */\n"
2882 "/** Macros for minimum-width integer constant expressions */";
2887 * NeXT 3.2 adds const prefix to some math functions.
2888 * These conflict with the built-in functions.
2890 fix = {
2891 hackname = next_math_prefix;
2892 files = ansi/math.h;
2893 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2895 c_fix = format;
2896 c_fix_arg = "extern double %1(";
2897 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2899 test_text = "extern\tdouble\t__const__\tmumble();";
2904 * NeXT 3.2 uses the word "template" as a parameter for some
2905 * functions. GCC reports an invalid use of a reserved key word
2906 * with the built-in functions.
2908 fix = {
2909 hackname = next_template;
2910 files = bsd/libc.h;
2911 select = "[ \t]template\\)";
2913 c_fix = format;
2914 c_fix_arg = "(%1)";
2915 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2916 test_text = "extern mumble( char * template); /* fix */";
2921 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2922 * function prototypes. That conflicts with the built-in functions.
2924 fix = {
2925 hackname = next_volitile;
2926 files = ansi/stdlib.h;
2927 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2929 c_fix = format;
2930 c_fix_arg = "extern void %1(";
2931 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2933 test_text = "extern\tvolatile\tvoid\tabort();";
2938 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2939 * Note that version 3 of the NeXT system has wait.h in a different directory,
2940 * so that this code won't do anything. But wait.h in version 3 has a
2941 * conditional, so it doesn't need this fix. So everything is okay.
2943 fix = {
2944 hackname = next_wait_union;
2945 files = sys/wait.h;
2947 select = 'wait\(union wait';
2948 c_fix = format;
2949 c_fix_arg = "wait(void";
2950 test_text = "extern pid_d wait(union wait*);";
2955 * a missing semi-colon at the end of the nodeent structure definition.
2957 fix = {
2958 hackname = nodeent_syntax;
2959 files = netdnet/dnetdb.h;
2960 select = "char[ \t]*\\*na_addr[ \t]*$";
2961 c_fix = format;
2962 c_fix_arg = "%0;";
2963 test_text = "char *na_addr\t";
2967 * Fix OpenBSD's NULL definition.
2969 fix = {
2970 hackname = openbsd_null_definition;
2971 mach = "*-*-openbsd*";
2972 files = locale.h, stddef.h, stdio.h, string.h,
2973 time.h, unistd.h, wchar.h, sys/param.h;
2974 select = "__GNUG__";
2975 c_fix = format;
2976 c_fix_arg = "#ifndef NULL\n"
2977 "#ifdef __cplusplus\n"
2978 "#ifdef __GNUG__\n"
2979 "#define NULL\t__null\n"
2980 "#else\t /* ! __GNUG__ */\n"
2981 "#define NULL\t0L\n"
2982 "#endif\t /* __GNUG__ */\n"
2983 "#else\t /* ! __cplusplus */\n"
2984 "#define NULL\t((void *)0)\n"
2985 "#endif\t /* __cplusplus */\n"
2986 "#endif\t /* !NULL */";
2988 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2989 "^#ifdef[ \t]*__GNUG__\n"
2990 "^#define[ \t]*NULL[ \t]*__null\n"
2991 "^#else\n"
2992 "^#define[ \t]*NULL[ \t]*0L\n"
2993 "^#endif\n"
2994 "^#endif";
2995 test_text =
2996 "#ifndef NULL\n"
2997 "#ifdef __GNUG__\n"
2998 "#define NULL __null\n"
2999 "#else\n"
3000 "#define NULL 0L\n"
3001 "#endif\n"
3002 "#endif\n";
3006 * obstack.h used casts as lvalues.
3008 * We need to change postincrements of casted pointers (which are
3009 * then dereferenced and assigned into) of the form
3011 * *((TYPE*)PTRVAR)++ = (VALUE)
3013 * into expressions like
3015 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3017 * which is correct for the cases used in obstack.h since PTRVAR is
3018 * of type char * and the value of the expression is not used.
3020 fix = {
3021 hackname = obstack_lvalue_cast;
3022 files = obstack.h;
3023 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3024 c_fix = format;
3025 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3026 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3030 * Fix OpenBSD's va_start define.
3032 fix = {
3033 hackname = openbsd_va_start;
3034 mach = "*-*-openbsd*";
3035 files = stdarg.h;
3036 select = '__builtin_stdarg_start';
3037 c_fix = format;
3038 c_fix_arg = __builtin_va_start;
3040 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3044 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3045 * defining regex.h related types. This causes libg++ build and usage
3046 * failures. Fixing this correctly requires checking and modifying 3 files.
3048 fix = {
3049 hackname = osf_namespace_a;
3050 files = reg_types.h;
3051 files = sys/lc_core.h;
3052 test = " -r reg_types.h";
3053 test = " -r sys/lc_core.h";
3054 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3055 test = " -z \"`grep __regex_t regex.h`\"";
3057 c_fix = format;
3058 c_fix_arg = "__%0";
3059 c_fix_arg = "reg(ex|off|match)_t";
3061 test_text = "`touch sys/lc_core.h`"
3062 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3063 "extern regex_t re;\n"
3064 "extern regoff_t ro;\n"
3065 "extern regmatch_t rm;\n";
3068 fix = {
3069 hackname = osf_namespace_c;
3070 files = regex.h;
3071 test = " -r reg_types.h";
3072 test = " -r sys/lc_core.h";
3073 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3074 test = " -z \"`grep __regex_t regex.h`\"";
3076 select = "#include <reg_types\.h>.*";
3077 c_fix = format;
3078 c_fix_arg = "%0\n"
3079 "typedef __regex_t\tregex_t;\n"
3080 "typedef __regoff_t\tregoff_t;\n"
3081 "typedef __regmatch_t\tregmatch_t;";
3083 test_text = "#include <reg_types.h>";
3088 * On broken glibc-2.3.3 systems an array of incomplete structures is
3089 * passed to __sigsetjmp. Fix that to take a pointer instead.
3091 fix = {
3092 hackname = pthread_incomplete_struct_argument;
3093 files = pthread.h;
3094 select = "struct __jmp_buf_tag";
3095 c_fix = format;
3096 c_fix_arg = "%1 *%2%3";
3097 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
3098 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
3102 * Fix return type of fread and fwrite on sysV68
3104 fix = {
3105 hackname = read_ret_type;
3106 files = stdio.h;
3107 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3108 c_fix = format;
3109 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3110 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3112 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3117 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3119 fix = {
3120 hackname = rpc_xdr_lvalue_cast_a;
3121 files = rpc/xdr.h;
3122 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3123 c_fix = format;
3124 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3125 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3126 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3130 fix = {
3131 hackname = rpc_xdr_lvalue_cast_b;
3132 files = rpc/xdr.h;
3133 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3134 c_fix = format;
3135 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3136 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3137 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3142 * function class(double x) conflicts with C++ keyword on rs/6000
3144 fix = {
3145 hackname = rs6000_double;
3146 files = math.h;
3147 select = '[^a-zA-Z_]class\(';
3149 c_fix = format;
3150 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3151 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3153 test_text = "extern int class();";
3158 * Wrong fchmod prototype on RS/6000.
3160 fix = {
3161 hackname = rs6000_fchmod;
3162 files = sys/stat.h;
3163 select = 'fchmod\(char \*';
3164 c_fix = format;
3165 c_fix_arg = "fchmod(int";
3166 test_text = "extern int fchmod(char *, mode_t);";
3171 * parameters conflict with C++ new on rs/6000
3173 fix = {
3174 hackname = rs6000_param;
3175 files = "stdio.h";
3176 files = "unistd.h";
3178 select = 'rename\(const char \*old, const char \*new\)';
3179 c_fix = format;
3180 c_fix_arg = 'rename(const char *_old, const char *_new)';
3182 test_text = 'extern int rename(const char *old, const char *new);';
3187 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
3188 * __builtin_generic. We fix that usage to use the GCC equivalent.
3189 * It also has a plethora of inline functions that conflict with libstdc++.
3191 fix = {
3192 hackname = sco_math;
3193 files = math.h, '*/math.h';
3194 select = "inline double abs";
3195 bypass = "__GNUG__";
3196 sed = "/#define.*__fp_class(a) \\\\/i\\\n"
3197 "#ifndef __GNUC__\n";
3198 sed =
3199 "/.*__builtin_generic/a\\\n"
3200 "#else\\\n"
3201 "#define __fp_class(a) \\\\\\\n"
3202 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
3203 " __fpclassifyl(a), \\\\\\\n"
3204 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
3205 " __fpclassifyf(a),__fpclassify(a)))\\\n"
3206 "#endif";
3208 sed = "/extern \"C\\+\\+\"/N;"
3209 "/inline double abs/i\\\n"
3210 "#ifndef __GNUC__\n";
3211 sed = "/inline long double trunc/N;"
3212 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
3213 "#endif /* ! __GNUC__ */";
3215 test_text =
3216 "#define __fp_class(a) \\\\\n"
3217 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
3223 * Sun Solaris 10 defines several C99 math macros in terms of
3224 * builtins specific to the Studio compiler, in particular not
3225 * compatible with the GNU compiler.
3227 fix = {
3228 hackname = solaris_math_1;
3229 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3230 bypass = "__GNUC__";
3231 files = iso/math_c99.h;
3232 c_fix = format;
3233 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3234 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3235 test_text =
3236 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3237 "#undef HUGE_VAL\n"
3238 "#define HUGE_VAL __builtin_huge_val\n"
3239 "#undef HUGE_VALF\n"
3240 "#define HUGE_VALF __builtin_huge_valf\n"
3241 "#undef HUGE_VALL\n"
3242 "#define HUGE_VALL __builtin_huge_vall";
3245 fix = {
3246 hackname = solaris_math_2;
3247 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3248 bypass = "__GNUC__";
3249 files = iso/math_c99.h;
3250 c_fix = format;
3251 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3252 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3253 test_text =
3254 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3255 "#undef INFINITY\n"
3256 "#define INFINITY __builtin_infinity";
3259 fix = {
3260 hackname = solaris_math_3;
3261 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3262 bypass = "__GNUC__";
3263 files = iso/math_c99.h;
3264 c_fix = format;
3265 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3266 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3267 test_text =
3268 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3269 "#undef NAN\n"
3270 "#define NAN __builtin_nan";
3273 fix = {
3274 hackname = solaris_math_4;
3275 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3276 bypass = "__GNUC__";
3277 files = iso/math_c99.h;
3278 c_fix = format;
3279 c_fix_arg = "#define\tfpclassify(x) \\\n"
3280 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3281 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3282 test_text =
3283 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3284 "#undef fpclassify\n"
3285 "#define fpclassify(x) __builtin_fpclassify(x)";
3288 fix = {
3289 hackname = solaris_math_8;
3290 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3291 bypass = "__GNUC__";
3292 files = iso/math_c99.h;
3293 c_fix = format;
3294 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3295 "\t\t\t ? __builtin_signbitf(x) \\\n"
3296 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3297 "\t\t\t ? __builtin_signbitl(x) \\\n"
3298 "\t\t\t : __builtin_signbit(x))";
3299 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3300 test_text =
3301 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3302 "#undef signbit\n"
3303 "#define signbit(x) __builtin_signbit(x)";
3306 fix = {
3307 hackname = solaris_math_9;
3308 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3309 bypass = "__GNUC__";
3310 files = iso/math_c99.h;
3311 c_fix = format;
3312 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3313 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3314 test_text =
3315 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3316 "#undef isgreater\n"
3317 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3318 "#undef isgreaterequal\n"
3319 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3320 "#undef isless\n"
3321 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3322 "#undef islessequal\n"
3323 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3324 "#undef islessgreater\n"
3325 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3326 "#undef isunordered\n"
3327 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3331 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3332 * exception. Provide an alternative using GCC's builtin.
3335 fix = {
3336 hackname = solaris_math_10;
3337 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3338 files = iso/math_c99.h;
3339 c_fix = format;
3340 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3341 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3342 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3343 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3344 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3345 test_text =
3346 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3347 "#undef isinf\n"
3348 "#define isinf(x) __extension__( \\\\\n"
3349 " { __typeof(x) __x_i = (x); \\\\\n"
3350 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3351 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3355 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3356 * "0" for the last field of the pthread_mutex_t structure, which is
3357 * of type upad64_t, which itself is typedef'd to int64_t, but with
3358 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3359 * initializer to "{0}" instead
3361 fix = {
3362 hackname = solaris_mutex_init_2;
3363 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3364 files = pthread.h;
3366 * On Solaris 10, this fix is unnecessary because upad64_t is
3367 * always defined correctly regardless of the definition of the
3368 * __STDC__ macro. The first "mach" pattern matches up to
3369 * solaris9. The second "mach" pattern will not match any two (or
3370 * more) digit solaris version, but it will match e.g. 2.5.1.
3372 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3373 c_fix = format;
3374 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3375 "%0\n"
3376 "#else\n"
3377 "%1, {0}}%4\n"
3378 "#endif";
3379 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3380 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3381 ",[ \t]*0\\}" "(|[ \t].*)$";
3382 test_text =
3383 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3384 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3385 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3386 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3387 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3388 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3389 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3394 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3395 * fields of the pthread_rwlock_t structure, which are of type
3396 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3397 * defined (e.g. by -ansi) it is a union. So change the initializer
3398 * to "{0}" instead.
3400 fix = {
3401 hackname = solaris_rwlock_init_1;
3402 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3403 files = pthread.h;
3404 mach = '*-*-solaris*';
3405 c_fix = format;
3406 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3407 "%0\n"
3408 "#else\n"
3409 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3410 "#endif";
3411 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3412 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3414 test_text =
3415 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3416 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3421 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3422 * structure. As such, it need two levels of brackets, but only
3423 * contains one. Wrap the macro definition in an extra layer.
3425 fix = {
3426 hackname = solaris_once_init_1;
3427 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3428 files = pthread.h;
3429 mach = '*-*-solaris*';
3430 c_fix = format;
3431 c_fix_arg = "%1{%2}%3";
3432 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3433 test_text =
3434 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3435 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3440 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3441 * fields of the pthread_once_t structure, which are of type
3442 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3443 * defined (e.g. by -ansi) it is a union. So change the initializer
3444 * to "{0}" instead. This test relies on solaris_once_init_1.
3446 fix = {
3447 hackname = solaris_once_init_2;
3448 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3449 files = pthread.h;
3451 * On Solaris 10, this fix is unnecessary because upad64_t is
3452 * always defined correctly regardless of the definition of the
3453 * __STDC__ macro. The first "mach" pattern matches up to
3454 * solaris9. The second "mach" pattern will not match any two (or
3455 * more) digit solaris version, but it will match e.g. 2.5.1.
3457 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3458 c_fix = format;
3459 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3460 "%0\n"
3461 "#else\n"
3462 "%1{0}, {0}, {0}, {%3}%4\n"
3463 "#endif";
3464 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3465 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3466 test_text =
3467 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3468 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3473 * Sun Solaris 10 has a version of sys/int_const.h that defines
3474 * UINT8_C and UINT16_C to unsigned constants.
3476 fix = {
3477 hackname = solaris_int_const;
3478 select = '@\(#\)int_const.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3479 files = sys/int_const.h;
3480 c_fix = format;
3481 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3482 "%1\n"
3483 "#define\tUINT16_C(c)\t(c)";
3484 c_fix_arg = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3485 "(/\*.*\*/)\n"
3486 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3487 test_text =
3488 '#pragma ident "@(#)int_const.h 1.5 04/09/28 SMI"'"\n"
3489 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3490 "/* CSTYLED */\n"
3491 "#define UINT16_C(c) __CONCAT__(c,u)";
3496 * Sun Solaris 10 has a version of sys/int_limits.h that defines
3497 * UINT8_MAX and UINT16_MAX to unsigned constants.
3499 fix = {
3500 hackname = solaris_int_limits_1;
3501 select = '@\(#\)int_limits.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3502 files = sys/int_limits.h;
3503 c_fix = format;
3504 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3505 "#define\tUINT16_MAX\t(65535)";
3506 c_fix_arg = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3507 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3508 test_text =
3509 '#pragma ident "@(#)int_limits.h 1.9 04/09/28 SMI"'"\n"
3510 "#define UINT8_MAX (255U)\n"
3511 "#define UINT16_MAX (65535U)";
3516 * Sun Solaris 10 has a version of sys/int_limits.h that defines
3517 * INT_FAST16 limits to wrong values for sys/int_types.h.
3519 fix = {
3520 hackname = solaris_int_limits_2;
3521 select = '@\(#\)int_limits.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3522 files = sys/int_limits.h;
3523 c_fix = format;
3524 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3525 c_fix_arg = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3526 test_text =
3527 '#pragma ident "@(#)int_limits.h 1.9 04/09/28 SMI"'"\n"
3528 "#define INT_FAST16_MAX INT16_MAX\n"
3529 "#define UINT_FAST16_MAX UINT16_MAX\n"
3530 "#define INT_FAST16_MIN INT16_MIN";
3535 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3536 * of Standard C99 64-bit types in 32-bit mode.
3538 fix = {
3539 hackname = solaris_int_types;
3540 select = "__STDC__ - 0 == 0";
3541 bypass = "_LONGLONG_TYPE";
3542 files = sys/int_types.h;
3543 c_fix = format;
3544 c_fix_arg =
3545 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3546 test_text =
3547 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3548 "typedef long long int64_t;\n"
3549 "#endif\n\n"
3550 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3551 "typedef int64_t intmax_t;\n"
3552 "#endif";
3557 * Sun Solaris 8 has what appears to be some gross workaround for
3558 * some old version of their c++ compiler. G++ doesn't want it
3559 * either, but doesn't want to be tied to SunPRO version numbers.
3561 fix = {
3562 hackname = solaris_stdio_tag;
3563 files = stdio_tag.h;
3565 select = '__cplusplus < 54321L';
3566 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3567 "!defined(__GNUC__)" so we no longer need to fix it. */
3568 bypass = '__GNUC__';
3569 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3571 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3576 * a missing semi-colon at the end of the statsswtch structure definition.
3578 fix = {
3579 hackname = statsswtch;
3580 files = rpcsvc/rstat.h;
3581 select = "boottime$";
3582 c_fix = format;
3583 c_fix_arg = "boottime;";
3584 test_text = "struct statswtch {\n int boottime\n};";
3589 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3590 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3591 * OK too.
3593 fix = {
3594 hackname = stdio_stdarg_h;
3595 files = stdio.h;
3596 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3598 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3599 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3601 mach = '*-*-solaris2.1[0-9]*';
3602 not_machine = true;
3604 c_fix = wrap;
3606 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3608 test_text = "";
3613 * Don't use or define the name va_list in stdio.h. This is for
3614 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3615 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3616 * indicate that the header knows what it's doing -- under SUSv2,
3617 * stdio.h is required to define va_list, and we shouldn't break
3618 * that. On IRIX 6.5, internal/wchar_core.h used to get its
3619 * definition of va_list from stdio.h. Since this doesn't happen any
3620 * longer, use __gnuc_va_list there, too.
3622 fix = {
3623 hackname = stdio_va_list;
3624 files = stdio.h;
3625 files = internal/stdio_core.h;
3626 files = internal/wchar_core.h;
3627 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3629 * On Solaris 10, the definition in
3630 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3631 * there is therefore no need for this fix there.
3633 mach = '*-*-solaris2.1[0-9]*';
3634 not_machine = true;
3637 * Use __gnuc_va_list in arg types in place of va_list.
3638 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3639 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3640 * trailing parentheses and semicolon save all other systems from this.
3641 * Define __not_va_list__ (something harmless and unused)
3642 * instead of va_list.
3643 * Don't claim to have defined va_list.
3645 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3646 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3647 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3648 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3649 "s@ va_list@ __not_va_list__@\n"
3650 "s@\\*va_list@*__not_va_list__@\n"
3651 "s@ __va_list)@ __gnuc_va_list)@\n"
3652 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3653 "@typedef \\1 __not_va_list__;@\n"
3654 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3655 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3656 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3657 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3658 "s@VA_LIST@DUMMY_VA_LIST@\n"
3659 "s@_Va_LIST@_VA_LIST@";
3660 test_text = "extern void mumble( va_list);";
3665 * Fix headers that use va_list from stdio.h to use the updated
3666 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3667 * dealt with elsewhere. The presence of __gnuc_va_list,
3668 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3669 * knows what it's doing.
3671 fix = {
3672 hackname = stdio_va_list_clients;
3673 files = com_err.h;
3674 files = cps.h;
3675 files = curses.h;
3676 files = krb5.h;
3677 files = lc_core.h;
3678 files = pfmt.h;
3679 files = wchar.h;
3680 files = curses_colr/curses.h;
3681 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3682 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3683 otherwise protected. */
3684 bypass = 'include <stdarg\.h>|#ifdef va_start';
3687 * Use __gnuc_va_list in arg types in place of va_list.
3688 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3689 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3690 * trailing parentheses and semicolon save all other systems from this.
3691 * Define __not_va_list__ (something harmless and unused)
3692 * instead of va_list.
3693 * Don't claim to have defined va_list.
3695 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3696 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3697 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3698 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3699 "s@ va_list@ __not_va_list__@\n"
3700 "s@\\*va_list@*__not_va_list__@\n"
3701 "s@ __va_list)@ __gnuc_va_list)@\n"
3702 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3703 "@typedef \\1 __not_va_list__;@\n"
3704 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3705 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3706 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3707 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3708 "s@VA_LIST@DUMMY_VA_LIST@\n"
3709 "s@_Va_LIST@_VA_LIST@";
3710 test_text = "extern void mumble( va_list);";
3715 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3716 * is "!defined( __STRICT_ANSI__ )"
3718 fix = {
3719 hackname = strict_ansi_not;
3720 select = "^([ \t]*#[ \t]*if.*)"
3721 "(!__STDC__"
3722 "|__STDC__[ \t]*==[ \t]*0"
3723 "|__STDC__[ \t]*!=[ \t]*1"
3724 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3725 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3726 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3727 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3728 is not defined by GCC, so it is safe. */
3729 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3730 c_test = stdc_0_in_system_headers;
3732 c_fix = format;
3733 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3735 test_text = "#if !__STDC__ \n"
3736 "#if __STDC__ == 0\n"
3737 "#if __STDC__ != 1\n"
3738 "#if __STDC__ - 0 == 0"
3739 "/* not std C */\nint foo;\n"
3740 "\n#end-end-end-end-if :-)";
3744 * "__STDC__-0==0"
3745 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3747 fix = {
3748 hackname = strict_ansi_not_ctd;
3749 files = math.h, limits.h, stdio.h, signal.h,
3750 stdlib.h, sys/signal.h, time.h;
3752 * Starting at the beginning of a line, skip white space and
3753 * a leading "(" or "&&" or "||". One of those must be found.
3754 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3755 * expression. If these are nested, then they must accumulate
3756 * because we won't match any closing parentheses. Finally,
3757 * after skipping over all that, we must then match our suspect
3758 * phrase: "__STDC__-0==0" with or without white space.
3760 select = "^([ \t]*" '(\(|&&|\|\|)'
3761 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3762 "[ \t(]*)"
3763 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3764 c_test = stdc_0_in_system_headers;
3766 c_fix = format;
3767 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3769 test_text = "#if 1 && \\\\\n"
3770 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3771 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3772 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3773 "int foo;\n#endif";
3778 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3779 * is "defined( __STRICT_ANSI__ )"
3781 fix = {
3782 hackname = strict_ansi_only;
3783 select = "^([ \t]*#[ \t]*if.*)"
3784 "(__STDC__[ \t]*!=[ \t]*0"
3785 "|__STDC__[ \t]*==[ \t]*1"
3786 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3787 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3788 c_test = stdc_0_in_system_headers;
3790 c_fix = format;
3791 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3793 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3798 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3799 * in prototype without previous definition.
3801 fix = {
3802 hackname = struct_file;
3803 files = rpc/xdr.h;
3804 select = '^.*xdrstdio_create.*struct __file_s';
3805 c_fix = format;
3806 c_fix_arg = "struct __file_s;\n%0";
3807 test_text = "extern void xdrstdio_create( struct __file_s* );";
3812 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3813 * in prototype without previous definition.
3815 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3816 * function, and does define it.
3818 fix = {
3819 hackname = struct_sockaddr;
3820 files = rpc/auth.h;
3821 select = "^.*authdes_create.*struct sockaddr[^_]";
3822 bypass = "<sys/socket\.h>";
3823 bypass = "struct sockaddr;\n";
3824 c_fix = format;
3825 c_fix_arg = "struct sockaddr;\n%0";
3826 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3831 * Apply fix this to all OSs since this problem seems to effect
3832 * more than just SunOS.
3834 fix = {
3835 hackname = sun_auth_proto;
3836 files = rpc/auth.h;
3837 files = rpc/clnt.h;
3838 files = rpc/svc.h;
3839 files = rpc/xdr.h;
3840 bypass = "__cplusplus";
3842 * Select those files containing '(*name)()'.
3844 select = '\(\*[a-z][a-z_]*\)\(\)';
3846 c_fix = format;
3847 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3848 "#else\n%1();%2\n#endif";
3849 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3851 test_text =
3852 "struct auth_t {\n"
3853 " int (*name)(); /* C++ bad */\n"
3854 "};";
3859 * Fix bogus #ifdef on SunOS 4.1.
3861 fix = {
3862 hackname = sun_bogus_ifdef;
3863 files = "hsfs/hsfs_spec.h";
3864 files = "hsfs/iso_spec.h";
3865 select = '#ifdef(.*\|\|.*)';
3866 c_fix = format;
3867 c_fix_arg = "#if%1";
3869 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3874 * Fix the CAT macro in SunOS memvar.h.
3876 fix = {
3877 hackname = sun_catmacro;
3878 files = pixrect/memvar.h;
3879 select = "^#define[ \t]+CAT\\(a,b\\).*";
3880 c_fix = format;
3882 c_fix_arg =
3883 "#ifdef __STDC__\n"
3884 "# define CAT(a,b) a##b\n"
3885 "#else\n%0\n#endif";
3887 test_text =
3888 "#define CAT(a,b)\ta/**/b";
3893 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3894 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3896 fix = {
3897 hackname = sun_malloc;
3898 files = malloc.h;
3899 bypass = "_CLASSIC_ANSI_TYPES";
3901 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3902 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3903 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3904 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3905 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3907 test_text =
3908 "typedef char *\tmalloc_t;\n"
3909 "int \tfree();\n"
3910 "char*\tmalloc();\n"
3911 "char*\tcalloc();\n"
3912 "char*\trealloc();";
3917 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3919 fix = {
3920 hackname = sun_rusers_semi;
3921 files = rpcsvc/rusers.h;
3922 select = "_cnt$";
3923 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3924 test_text = "struct mumble\n int _cnt\n};";
3929 * signal.h on SunOS defines signal using (),
3930 * which causes trouble when compiling with g++ -pedantic.
3932 fix = {
3933 hackname = sun_signal;
3934 files = sys/signal.h;
3935 files = signal.h;
3936 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3938 c_fix = format;
3939 c_fix_arg =
3940 "#ifdef __cplusplus\n"
3941 "void\t(*signal(...))(...);\n"
3942 "#else\n%0\n#endif";
3944 test_text = "void\t(*signal())();";
3949 * Correct the return type for strlen in strings.h in SunOS 4.
3951 fix = {
3952 hackname = sunos_strlen;
3953 files = strings.h;
3954 select = "int[ \t]*strlen\\(\\);(.*)";
3955 c_fix = format;
3956 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3957 test_text = " int\tstrlen(); /* string length */";
3962 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3963 * that is visible to any ANSI compiler using this include. Simply
3964 * delete the lines that #define some string functions to internal forms.
3966 fix = {
3967 hackname = svr4_disable_opt;
3968 files = string.h;
3969 select = '#define.*__std_hdr_';
3970 sed = '/#define.*__std_hdr_/d';
3971 test_text = "#define strlen __std_hdr_strlen\n";
3976 * Fix broken decl of getcwd present on some svr4 systems.
3978 fix = {
3979 hackname = svr4_getcwd;
3980 files = stdlib.h;
3981 files = unistd.h;
3982 files = prototypes.h;
3983 select = 'getcwd\(char \*, int\)';
3985 c_fix = format;
3986 c_fix_arg = "getcwd(char *, size_t)";
3988 test_text = "extern char* getcwd(char *, int);";
3993 * Fix broken decl of profil present on some svr4 systems.
3995 fix = {
3996 hackname = svr4_profil;
3997 files = stdlib.h;
3998 files = unistd.h;
4000 select =
4001 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4002 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
4003 prototype in <sys/profil.h>. */
4004 bypass = 'Silicon Graphics';
4005 c_fix = format;
4006 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4008 test_text =
4009 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4014 * Correct types for signal handler constants like SIG_DFL; they might be
4015 * void (*) (), and should be void (*) (int). C++ doesn't like the
4016 * old style.
4018 fix = {
4019 hackname = svr4_sighandler_type;
4020 files = sys/signal.h;
4021 select = 'void *\(\*\)\(\)';
4022 c_fix = format;
4023 c_fix_arg = "void (*)(int)";
4024 test_text = "#define SIG_DFL (void(*)())0\n"
4025 "#define SIG_IGN (void (*)())0\n";
4030 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4031 * function 'getrnge' in <regexp.h> before they declare it. For these
4032 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4033 * early on.
4035 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4036 * so put the declaration right after the declaration of 'size'.
4038 * Don't do this if there is already a `static void getrnge' declaration
4039 * present, since this would cause a redeclaration error. Solaris 2.x has
4040 * such a declaration.
4042 fix = {
4043 hackname = svr4_undeclared_getrnge;
4044 files = regexp.h;
4045 select = "getrnge";
4046 bypass = "static void getrnge";
4047 c_fix = format;
4048 c_fix_arg = "%0\n"
4049 "static int getrnge ();";
4050 c_fix_arg = "^static int[ \t]+size;";
4051 test_text = "static int size;\n"
4052 "/* stuff which calls getrnge() */\n"
4053 "static getrnge()\n"
4054 "{}";
4059 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4060 * in string.h on sysV68
4061 * Correct the return type for strlen in string.h on Lynx.
4062 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4063 * Add missing const for strdup on OSF/1 V3.0.
4064 * On sysV88 layout is slightly different.
4066 fix = {
4067 hackname = sysv68_string;
4068 files = testing.h;
4069 files = string.h;
4070 bypass = "_CLASSIC_ANSI_TYPES";
4072 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4073 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4074 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4076 sed = "/^extern char$/N";
4077 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4079 sed = "/^extern int$/N";
4080 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4082 sed = "/^\tstrncmp(),$/N";
4083 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4084 '\1;' "\\\nextern unsigned int\\\n\\2/";
4086 test_text =
4087 "extern int strlen();\n"
4089 "extern int ffs(long);\n"
4091 "extern char\n"
4092 "\t*memccpy(),\n"
4093 "\tmemcpy();\n"
4095 "extern int\n"
4096 "\tstrcmp(),\n"
4097 "\tstrncmp(),\n"
4098 "\tstrlen(),\n"
4099 "\tstrspn();\n"
4101 "extern int\n"
4102 "\tstrlen(), strspn();";
4107 * Fix return type of calloc, malloc, realloc, bsearch and exit
4109 fix = {
4110 hackname = sysz_stdlib_for_sun;
4111 files = stdlib.h;
4112 bypass = "_CLASSIC_ANSI_TYPES";
4114 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4115 c_fix = format;
4116 c_fix_arg = "void *\t%1(";
4118 test_text =
4119 "extern char*\tcalloc(size_t);\n"
4120 "extern char*\tmalloc(size_t);\n"
4121 "extern char*\trealloc(void*,size_t);\n"
4122 "extern char*\tbsearch(void*,size_t,size_t);\n";
4127 * __thread is now a keyword.
4129 fix = {
4130 hackname = thread_keyword;
4131 files = "pthread.h";
4132 files = "bits/sigthread.h";
4133 select = "([* ])__thread([,)])";
4134 c_fix = format;
4135 c_fix_arg = "%1__thr%2";
4137 test_text =
4138 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4139 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4140 "extern int pthread_cancel (pthread_t __thread);";
4144 * if the #if says _cplusplus, not the double underscore __cplusplus
4145 * that it should be
4147 fix = {
4148 hackname = tinfo_cplusplus;
4149 files = tinfo.h;
4150 select = "[ \t]_cplusplus";
4152 c_fix = format;
4153 c_fix_arg = " __cplusplus";
4154 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4159 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4161 fix = {
4162 hackname = ultrix_const;
4163 files = stdio.h;
4164 select = 'perror\( char \*';
4166 c_fix = format;
4167 c_fix_arg = "%1 const %3 *__";
4168 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4169 "[ \t]+(char|void) \\*__";
4171 test_text =
4172 "extern void perror( char *__s );\n"
4173 "extern int fputs( char *__s, FILE *);\n"
4174 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4175 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4176 "extern int scanf( char *__format, ...);\n";
4181 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4183 fix = {
4184 hackname = ultrix_const2;
4185 files = stdio.h;
4187 select = '\*fopen\( char \*';
4188 c_fix = format;
4189 c_fix_arg = "%1( const char *%3, const char *";
4190 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4191 "[ \t]*char[ \t]*\\*([^,]*),"
4192 "[ \t]*char[ \t]*\\*[ \t]*";
4194 test_text =
4195 "extern FILE *fopen( char *__filename, char *__type );\n"
4196 "extern int sscanf( char *__s, char *__format, ...);\n"
4197 "extern FILE *popen(char *, char *);\n"
4198 "extern char *tempnam(char*,char*);\n";
4203 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4205 fix = {
4206 hackname = va_i960_macro;
4207 files = arch/i960/archI960.h;
4208 select = "__(vsiz|vali|vpad|alignof__)";
4210 c_fix = format;
4211 c_fix_arg = "__vx%1";
4213 test_text =
4214 "extern int __vsiz vsiz;\n"
4215 "extern int __vali vali;\n"
4216 "extern int __vpad vpad;\n"
4217 "#define __alignof__(x) ...";
4222 * AIX and Interix headers define NULL to be cast to a void pointer,
4223 * which is illegal in ANSI C++.
4225 fix = {
4226 hackname = void_null;
4227 files = curses.h;
4228 files = dbm.h;
4229 files = locale.h;
4230 files = stdio.h;
4231 files = stdlib.h;
4232 files = string.h;
4233 files = time.h;
4234 files = unistd.h;
4235 files = sys/dir.h;
4236 files = sys/param.h;
4237 files = sys/types.h;
4238 /* avoid changing C++ friendly NULL */
4239 bypass = __cplusplus;
4240 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4241 c_fix = format;
4242 c_fix_arg = "#define NULL 0";
4243 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4248 * Make VxWorks header which is almost gcc ready fully gcc ready.
4250 fix = {
4251 hackname = vxworks_gcc_problem;
4252 files = types/vxTypesBase.h;
4253 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4255 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4256 "#if 1/";
4258 sed = "/[ \t]size_t/i\\\n"
4259 "#ifndef _GCC_SIZE_T\\\n"
4260 "#define _GCC_SIZE_T\n";
4262 sed = "/[ \t]size_t/a\\\n"
4263 "#endif\n";
4265 sed = "/[ \t]ptrdiff_t/i\\\n"
4266 "#ifndef _GCC_PTRDIFF_T\\\n"
4267 "#define _GCC_PTRDIFF_T\n";
4269 sed = "/[ \t]ptrdiff_t/a\\\n"
4270 "#endif\n";
4272 sed = "/[ \t]wchar_t/i\\\n"
4273 "#ifndef _GCC_WCHAR_T\\\n"
4274 "#define _GCC_WCHAR_T\n";
4276 sed = "/[ \t]wchar_t/a\\\n"
4277 "#endif\n";
4279 test_text =
4280 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4281 "typedef unsigned int size_t;\n"
4282 "typedef long ptrdiff_t;\n"
4283 "typedef unsigned short wchar_t;\n"
4284 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4289 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4291 fix = {
4292 hackname = vxworks_needs_vxtypes;
4293 files = time.h;
4294 select = "uint_t([ \t]+_clocks_per_sec)";
4295 c_fix = format;
4296 c_fix_arg = "unsigned int%1";
4297 test_text = "uint_t\t_clocks_per_sec;";
4302 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4304 fix = {
4305 hackname = vxworks_needs_vxworks;
4306 files = sys/stat.h;
4307 test = " -r types/vxTypesOld.h";
4308 test = " -n \"`egrep '#include' $file`\"";
4309 test = " -n \"`egrep ULONG $file`\"";
4310 select = "#[ \t]define[ \t]+__INCstath";
4312 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4313 "#include <types/vxTypesOld.h>\n";
4315 test_text = "`touch types/vxTypesOld.h`"
4316 "#include </dev/null> /* ULONG */\n"
4317 "# define\t__INCstath <sys/stat.h>";
4322 * Another bad dependency in VxWorks 5.2 <time.h>.
4324 fix = {
4325 hackname = vxworks_time;
4326 files = time.h;
4327 test = " -r vxWorks.h";
4329 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4330 c_fix = format;
4332 c_fix_arg =
4333 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4334 "#ifdef __cplusplus\n"
4335 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4336 "#else\n"
4337 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4338 "#endif\n"
4339 "#define __gcc_VOIDFUNCPTR_defined\n"
4340 "#endif\n"
4341 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4343 test_text = "`touch vxWorks.h`"
4344 "#define VOIDFUNCPTR (void(*)())";
4349 * There are several name conflicts with C++ reserved words in X11 header
4350 * files. These are fixed in some versions, so don't do the fixes if
4351 * we find __cplusplus in the file. These were found on the RS/6000.
4353 fix = {
4354 hackname = x11_class;
4355 files = X11/ShellP.h;
4356 bypass = __cplusplus;
4357 select = "^([ \t]*char \\*)class;(.*)";
4358 c_fix = format;
4359 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4360 "#else\n%1class;%2\n#endif";
4361 test_text =
4362 "struct {\n"
4363 " char *class;\n"
4364 "} mumble;\n";
4369 * class in Xm/BaseClassI.h
4371 fix = {
4372 hackname = x11_class_usage;
4373 files = Xm/BaseClassI.h;
4374 bypass = "__cplusplus";
4376 select = " class\\)";
4377 c_fix = format;
4378 c_fix_arg = " c_class)";
4380 test_text = "extern mumble (int class);\n";
4385 * new in Xm/Traversal.h
4387 fix = {
4388 hackname = x11_new;
4389 files = Xm/Traversal.h;
4390 bypass = __cplusplus;
4392 sed = "/Widget\told, new;/i\\\n"
4393 "#ifdef __cplusplus\\\n"
4394 "\tWidget\told, c_new;\\\n"
4395 "#else\n";
4397 sed = "/Widget\told, new;/a\\\n"
4398 "#endif\n";
4400 sed = "s/Widget new,/Widget c_new,/g";
4401 test_text =
4402 "struct wedge {\n"
4403 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
4404 "};\nextern Wedged( Widget new, Widget old );";
4409 * Incorrect sprintf declaration in X11/Xmu.h
4411 fix = {
4412 hackname = x11_sprintf;
4413 files = X11/Xmu.h;
4414 files = X11/Xmu/Xmu.h;
4415 select = "^extern char \\*\tsprintf\\(\\);$";
4417 c_fix = format;
4418 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4420 test_text = "extern char *\tsprintf();";
4423 /*EOF*/