PR tree-optimization/54321
[official-gcc.git] / fixincludes / inclhack.def
blob82792afdbe37e9e99726415816b2d1e3ccf8ef74
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
61 #endif
62 #endif
64 _EOArg_;
69 * On Mac OS 10.3.9, the 'long double' functions are available in
70 * libSystem, but are not prototyped in math.h.
72 fix = {
73 hackname = AAB_darwin7_9_long_double_funcs;
74 mach = "*-*-darwin7.9*";
75 files = architecture/ppc/math.h;
76 bypass = "powl";
77 replace = <<- _EndOfHeader_
78 /* This file prototypes the long double functions available on Mac OS
79 10.3.9. */
80 #ifndef __MATH__
81 # undef __APPLE_CC__
82 # define __APPLE_CC__ 1345
83 # include_next <architecture/ppc/math.h>
84 # undef __APPLE_CC__
85 # define __APPLE_CC__ 1
86 # ifndef __LIBMLDBL_COMPAT
87 # ifdef __LONG_DOUBLE_128__
88 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
89 # else
90 # define __LIBMLDBL_COMPAT(sym)
91 # endif /* __LONG_DOUBLE_128__ */
92 # endif /* __LIBMLDBL_COMPAT */
93 # ifdef __cplusplus
94 extern "C" {
95 # endif
96 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
97 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
98 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
99 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
100 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
101 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
102 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
103 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
104 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
105 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
106 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
107 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
108 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
109 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
110 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
111 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
112 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
113 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
114 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
115 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
116 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
117 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
118 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
119 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
120 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
121 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
122 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
123 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
124 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
125 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
126 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
127 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
128 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
129 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
130 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
131 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
132 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
133 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
134 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
135 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
136 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
137 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
138 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
139 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
140 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
141 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
142 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
143 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
144 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
145 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
146 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
147 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
148 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
149 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
150 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
151 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
152 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
153 # ifdef __cplusplus
155 # endif
156 #endif /* __MATH__ */
157 _EndOfHeader_;
162 * ... and for the previous fix to be useful, you have to not use ""
163 * includes.
165 fix = {
166 hackname = AAB_darwin7_9_long_double_funcs_2;
167 mach = "*-*-darwin7.9*";
168 files = math.h;
169 select = '#include[ \t]+\"';
170 c_fix = format;
171 c_fix_arg = "%1<%2.h>";
173 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
175 test_text = '#include "architecture/ppc/math.h"';
180 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
182 fix = {
183 hackname = AAB_fd_zero_asm_posix_types_h;
184 files = asm/posix_types.h;
185 mach = 'i[34567]86-*-linux*';
186 bypass = '} while';
187 bypass = 'x86_64';
188 bypass = 'posix_types_64';
191 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
192 * the start, so that if #include_next gets another instance of
193 * the wrapper, this will follow the #include_next chain until
194 * we arrive at the real <asm/posix_types.h>.
196 replace = <<- _EndOfHeader_
197 /* This file fixes a bug in the __FD_ZERO macro
198 for older versions of the Linux kernel. */
199 #ifndef _POSIX_TYPES_H_WRAPPER
200 #include <features.h>
201 #include_next <asm/posix_types.h>
203 #if defined(__FD_ZERO) && !defined(__GLIBC__)
204 #undef __FD_ZERO
205 #define __FD_ZERO(fdsetp) \
206 do { \
207 int __d0, __d1; \
208 __asm__ __volatile__("cld ; rep ; stosl" \
209 : "=&c" (__d0), "=&D" (__d1) \
210 : "a" (0), "0" (__FDSET_LONGS), \
211 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
212 } while (0)
213 #endif
215 #define _POSIX_TYPES_H_WRAPPER
216 #endif /* _POSIX_TYPES_H_WRAPPER */
217 _EndOfHeader_;
222 * This fixes __FD_ZERO bug for glibc-1.x
224 fix = {
225 hackname = AAB_fd_zero_gnu_types_h;
226 files = gnu/types.h;
227 mach = 'i[34567]86-*-linux*';
230 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
231 * the start, so that if #include_next gets another instance of
232 * the wrapper, this will follow the #include_next chain until
233 * we arrive at the real <gnu/types.h>.
235 replace = <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
237 #ifndef _TYPES_H_WRAPPER
238 #include <features.h>
239 #include_next <gnu/types.h>
241 #if defined(__FD_ZERO) && !defined(__GLIBC__)
242 #undef __FD_ZERO
243 # define __FD_ZERO(fdsetp) \
244 do { \
245 int __d0, __d1; \
246 __asm__ __volatile__("cld ; rep ; stosl" \
247 : "=&c" (__d0), "=&D" (__d1) \
248 : "a" (0), "0" (__FDSET_LONGS), \
249 "1" ((__fd_set *) (fdsetp)) :"memory"); \
250 } while (0)
251 #endif
253 #define _TYPES_H_WRAPPER
254 #endif /* _TYPES_H_WRAPPER */
255 _EndOfHeader_;
260 * This fixes __FD_ZERO bug for glibc-2.0.x
262 fix = {
263 hackname = AAB_fd_zero_selectbits_h;
264 files = selectbits.h;
265 mach = 'i[34567]86-*-linux*';
268 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
269 * the start, so that if #include_next gets another instance of
270 * the wrapper, this will follow the #include_next chain until
271 * we arrive at the real <selectbits.h>.
273 replace = <<- _EndOfHeader_
274 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
275 #ifndef _SELECTBITS_H_WRAPPER
276 #include <features.h>
277 #include_next <selectbits.h>
279 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
280 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
281 && __GLIBC_MINOR__ == 0
282 #undef __FD_ZERO
283 #define __FD_ZERO(fdsetp) \\
284 do { \\
285 int __d0, __d1; \\
286 __asm__ __volatile__ ("cld; rep; stosl" \\
287 : "=&c" (__d0), "=&D" (__d1) \\
288 : "a" (0), "0" (sizeof (__fd_set) \\
289 / sizeof (__fd_mask)), \\
290 "1" ((__fd_mask *) (fdsetp)) \\
291 : "memory"); \\
292 } while (0)
293 #endif
295 #define _SELECTBITS_H_WRAPPER
296 #endif /* _SELECTBITS_H_WRAPPER */
297 _EndOfHeader_;
302 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
303 * the same interface as <stdarg.h>. No idea why they couldn't have just
304 * used the standard header.
306 fix = {
307 hackname = AAB_solaris_sys_varargs_h;
308 files = "sys/varargs.h";
309 mach = '*-*-solaris*';
310 replace = <<- _EndOfHeader_
311 #ifdef __STDC__
312 #include <stdarg.h>
313 #else
314 #include <varargs.h>
315 #endif
316 _EndOfHeader_;
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
322 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
323 * many other systems have similar text but correct versions of the file.
324 * To ensure only Sun's is fixed, we grep for a likely unique string.
325 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
327 fix = {
328 hackname = AAB_sun_memcpy;
329 files = memory.h;
330 select = "/\\*\t@\\(#\\)"
331 "(head/memory.h\t50.1\t "
332 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
334 replace = <<- _EndOfHeader_
335 /* This file was generated by fixincludes */
336 #ifndef __memory_h__
337 #define __memory_h__
339 #ifdef __STDC__
340 extern void *memccpy();
341 extern void *memchr();
342 extern void *memcpy();
343 extern void *memset();
344 #else
345 extern char *memccpy();
346 extern char *memchr();
347 extern char *memcpy();
348 extern char *memset();
349 #endif /* __STDC__ */
351 extern int memcmp();
353 #endif /* __memory_h__ */
354 _EndOfHeader_;
359 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
360 * which only is provided by AIX xlc C99.
362 fix = {
363 hackname = aix_complex;
364 mach = "*-*-aix*";
365 files = complex.h;
366 select = "#define[ \t]_Complex_I[ \t]__I";
367 c_fix = format;
368 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
369 test_text = "#define _Complex_I __I\n";
373 * malloc.h on AIX6 uses XLC++ specific builtin syntax
375 fix = {
376 hackname = aix_malloc;
377 mach = "*-*-aix*";
378 files = "malloc.h";
379 select = "#ifdef __cplusplus";
380 c_fix = format;
381 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
382 test_text = "#ifdef __cplusplus";
386 * net/if_arp.h defines a variable fc_softc instead of adding a
387 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
389 fix = {
390 hackname = aix_net_if_arp;
391 mach = "*-*-aix*";
392 files = "net/if_arp.h";
393 select = "^struct fc_softc \\{";
394 c_fix = format;
395 c_fix_arg = "typedef struct _fc_softc {";
396 test_text = "struct fc_softc {\n int a;\n};";
400 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
401 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
402 * braces.
404 fix = {
405 hackname = aix_once_init_1;
406 mach = "*-*-aix*";
407 files = "pthread.h";
408 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
409 "\\{ \\\\\n";
410 c_fix = format;
411 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
412 "{{ \\\n";
413 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
414 "{ \\\\\n";
417 fix = {
418 hackname = aix_once_init_2;
419 mach = "*-*-aix*";
420 files = "pthread.h";
421 select = "[ \t]0 \\\\\n"
422 "\\}\n";
423 c_fix = format;
424 c_fix_arg = " 0 \\\n"
425 "}}\n";
426 test_text = " 0 \\\\\n"
427 "}\n";
430 fix = {
431 hackname = aix_mutex_initializer_1;
432 mach = "*-*-aix*";
433 files = "pthread.h";
434 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
435 "\\{ \\\\\n";
436 c_fix = format;
437 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
438 "{{ \\\n";
439 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
440 "{ \\\\\n";
443 fix = {
444 hackname = aix_cond_initializer_1;
445 mach = "*-*-aix*";
446 files = "pthread.h";
447 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
448 "\\{ \\\\\n";
449 c_fix = format;
450 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
451 "{{ \\\n";
452 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
453 "{ \\\\\n";
456 fix = {
457 hackname = aix_rwlock_initializer_1;
458 mach = "*-*-aix*";
459 files = "pthread.h";
460 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
461 "\\{ \\\\\n";
462 c_fix = format;
463 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
464 "{{ \\\n";
465 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
466 "{ \\\\\n";
470 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
471 * which violates a requirement of ISO C.
473 fix = {
474 hackname = aix_pthread;
475 files = "pthread.h";
476 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
477 c_fix = format;
478 c_fix_arg = "%1 %2";
479 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
480 "{...init stuff...}";
485 * AIX stdint.h fixes.
487 fix = {
488 hackname = aix_stdint_1;
489 mach = "*-*-aix*";
490 files = stdint-aix.h, stdint.h;
491 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
492 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
493 c_fix = format;
494 c_fix_arg = "#define UINT8_MAX (255)\n"
495 "#define UINT16_MAX (65535)";
496 test_text = "#define UINT8_MAX (255U)\n"
497 "#define UINT16_MAX (65535U)";
501 fix = {
502 hackname = aix_stdint_2;
503 mach = "*-*-aix*";
504 files = stdint-aix.h, stdint.h;
505 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
506 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
507 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
508 "#else\n"
509 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
510 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
511 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
512 c_fix = format;
513 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
514 "#define INTPTR_MAX 9223372036854775807L\n"
515 "#define UINTPTR_MAX 18446744073709551615UL\n"
516 "#else\n"
517 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
518 "#define INTPTR_MAX 2147483647L\n"
519 "#define UINTPTR_MAX 4294967295UL";
520 test_text = "#define INTPTR_MIN INT64_MIN\n"
521 "#define INTPTR_MAX INT64_MAX\n"
522 "#define UINTPTR_MAX UINT64_MAX\n"
523 "#else\n"
524 "#define INTPTR_MIN INT32_MIN\n"
525 "#define INTPTR_MAX INT32_MAX\n"
526 "#define UINTPTR_MAX UINT32_MAX";
530 fix = {
531 hackname = aix_stdint_3;
532 mach = "*-*-aix*";
533 files = stdint-aix.h, stdint.h;
534 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
535 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
536 "#else\n"
537 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
538 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
539 c_fix = format;
540 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
541 "#define PTRDIFF_MAX 9223372036854775807L\n"
542 "#else\n"
543 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
544 "#define PTRDIFF_MAX 2147483647L";
545 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
546 "#define PTRDIFF_MAX INT64_MAX\n"
547 "#else\n"
548 "#define PTRDIFF_MIN INT32_MIN\n"
549 "#define PTRDIFF_MAX INT32_MAX";
553 fix = {
554 hackname = aix_stdint_4;
555 mach = "*-*-aix*";
556 files = stdint-aix.h, stdint.h;
557 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
558 "#else\n"
559 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
560 c_fix = format;
561 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
562 "#else\n"
563 "#define SIZE_MAX 4294967295UL";
564 test_text = "#define SIZE_MAX UINT64_MAX\n"
565 "#else\n"
566 "#define SIZE_MAX UINT32_MAX";
570 fix = {
571 hackname = aix_stdint_5;
572 mach = "*-*-aix*";
573 files = stdint-aix.h, stdint.h;
574 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
575 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
576 c_fix = format;
577 c_fix_arg = "#define UINT8_C(c) c\n"
578 "#define UINT16_C(c) c";
579 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
580 "#define UINT16_C(c) __CONCAT__(c,U)";
585 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
586 * in an otherwise harmless (and #ifed out) macro definition
588 fix = {
589 hackname = aix_sysmachine;
590 files = sys/machine.h;
591 select = "\\\\ +\n";
592 c_fix = format;
593 c_fix_arg = "\\\n";
594 test_text = "#define FOO \\\n"
595 " bar \\ \n baz \\ \n bat";
600 * sys/wait.h on AIX 5.2 defines macros that have both signed and
601 * unsigned types in conditional expressions.
603 fix = {
604 hackname = aix_syswait_2;
605 files = sys/wait.h;
606 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
607 c_fix = format;
608 c_fix_arg = "? (int)%1";
609 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
614 * sys/signal.h on some versions of AIX uses volatile in the typedef of
615 * sig_atomic_t, which causes gcc to generate a warning about duplicate
616 * volatile when a sig_atomic_t variable is declared volatile, as
617 * required by ANSI C.
619 fix = {
620 hackname = aix_volatile;
621 files = sys/signal.h;
622 select = "typedef volatile int sig_atomic_t";
623 c_fix = format;
624 c_fix_arg = "typedef int sig_atomic_t";
625 test_text = "typedef volatile int sig_atomic_t;";
630 * Fix __assert declaration in assert.h on Alpha OSF/1.
632 fix = {
633 hackname = alpha___assert;
634 files = "assert.h";
635 select = '__assert\(char \*, char \*, int\)';
636 c_fix = format;
637 c_fix_arg = "__assert(const char *, const char *, int)";
638 test_text = 'extern void __assert(char *, char *, int);';
643 * Fix assert macro in assert.h on Alpha OSF/1.
644 * The superfluous int cast breaks C++.
646 fix = {
647 hackname = alpha_assert;
648 files = "assert.h";
649 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
650 c_fix = format;
651 c_fix_arg = "%1(EX)";
652 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
653 ': __assert(#EX, __FILE__, __LINE__))';
658 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
660 fix = {
661 hackname = alpha_getopt;
662 files = "stdio.h";
663 files = "stdlib.h";
664 select = 'getopt\(int, char \*\[\], *char \*\)';
665 c_fix = format;
666 c_fix_arg = "getopt(int, char *const[], const char *)";
667 test_text = 'extern int getopt(int, char *[], char *);';
672 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
674 fix = {
675 hackname = alpha_if_semicolon;
676 files = net/if.h;
677 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
678 c_fix = format;
679 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
680 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
685 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
687 fix = {
688 hackname = alpha_parens;
689 files = sym.h;
690 select = '#ifndef\(__mips64\)';
691 c_fix = format;
692 c_fix_arg = "#ifndef __mips64";
693 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
698 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
699 * And OpenBSD.
701 fix = {
702 hackname = alpha_sbrk;
703 files = unistd.h;
704 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
705 c_fix = format;
706 c_fix_arg = "void *sbrk(";
707 test_text = "extern char* sbrk(ptrdiff_t increment);";
712 * For C++, avoid any typedef or macro definition of bool,
713 * and use the built in type instead.
714 * HP/UX 10.20 also has it in curses_colr/curses.h.
716 fix = {
717 hackname = avoid_bool_define;
718 files = curses.h;
719 files = curses_colr/curses.h;
720 files = term.h;
721 files = tinfo.h;
723 select = "#[ \t]*define[ \t]+bool[ \t]";
724 bypass = "__cplusplus";
726 c_fix = format;
727 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
728 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
730 test_text = "# define bool\t char \n";
734 fix = {
735 hackname = avoid_bool_type;
736 files = curses.h;
737 files = curses_colr/curses.h;
738 files = term.h;
739 files = tinfo.h;
741 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
742 bypass = "__cplusplus";
744 c_fix = format;
745 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
747 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
752 * For C++, avoid any typedef definition of wchar_t,
753 * and use the built in type instead.
754 * Don't do this for headers that are smart enough to do the right
755 * thing (recent [n]curses.h and Xlib.h).
756 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
757 * and will be broken by the edit.
760 fix = {
761 hackname = avoid_wchar_t_type;
763 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
764 bypass = "__cplusplus";
765 bypass = "_LINUX_NLS_H";
766 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
768 c_fix = format;
769 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
771 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
776 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
778 fix = {
779 hackname = bad_struct_term;
780 files = curses.h;
781 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
782 c_fix = format;
783 c_fix_arg = "struct term;";
785 test_text = 'typedef struct term;';
790 * Fix one other error in this file:
791 * a mismatched quote not inside a C comment.
793 fix = {
794 hackname = badquote;
795 files = sundev/vuid_event.h;
796 select = "doesn't";
797 c_fix = format;
798 c_fix_arg = "does not";
800 test_text = "/* doesn't have matched single quotes */";
805 * check for broken assert.h that needs stdio.h
807 fix = {
808 hackname = broken_assert_stdio;
809 files = assert.h;
810 select = stderr;
811 bypass = "include.*stdio\\.h";
812 c_fix = wrap;
813 c_fix_arg = "#include <stdio.h>\n";
814 test_text = "extern FILE* stderr;";
819 * check for broken assert.h that needs stdlib.h
821 fix = {
822 hackname = broken_assert_stdlib;
823 files = assert.h;
824 select = 'exit *\(|abort *\(';
825 bypass = "include.*stdlib\\.h";
826 c_fix = wrap;
827 c_fix_arg = "#ifdef __cplusplus\n"
828 "#include <stdlib.h>\n"
829 "#endif\n";
830 test_text = "extern void exit ( int );";
835 * Remove `extern double cabs' declarations from math.h.
836 * This conflicts with C99. Discovered on AIX.
837 * Darwin hides its broken cabs in architecture-specific subdirs.
839 fix = {
840 hackname = broken_cabs;
841 files = math.h, "architecture/*/math.h";
842 select = "^extern[ \t]+double[ \t]+cabs";
844 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
845 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
847 test_text = "#ifdef __STDC__\n"
848 "extern double cabs(struct dbl_hypot);\n"
849 "#else\n"
850 "extern double cabs();\n"
851 "#endif\n"
852 "extern double cabs ( _Complex z );";
857 * Fixup Darwin's broken check for __builtin_nanf.
859 fix = {
860 hackname = broken_nan;
862 * It is tempting to omit the first "files" entry. Do not.
863 * The testing machinery will take the first "files" entry as the name
864 * of a test file to play with. It would be a nuisance to have a directory
865 * with the name "*".
867 files = "architecture/ppc/math.h";
868 files = "architecture/*/math.h";
869 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
870 bypass = "powl";
871 c_fix = format;
872 c_fix_arg = "#if 1";
873 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
878 * Various systems derived from BSD4.4 contain a macro definition
879 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
880 * Known to be fixed in FreeBSD 5 system headers.
882 fix = {
883 hackname = bsd_stdio_attrs_conflict;
884 mach = "*-*-*bsd*";
885 mach = "*-*-*darwin*";
886 files = stdio.h;
887 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
888 c_fix = format;
889 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
890 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
891 'int vfscanf(FILE *, const char *, __builtin_va_list) '
892 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
893 test_text = '#define vfscanf __svfscanf';
897 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
898 * that it conforms to ISO/IEC 14882:2011. It currently does
899 * not support the [[noreturn]] procedure attribute.
900 * When it does, this hack should be removed.
901 * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
903 fix = {
904 hackname = cdef_cplusplus;
905 files = sys/cdefs.h;
906 select = '\[\[noreturn\]\]';
907 c_fix = format;
908 c_fix_arg = '__attribute__((__noreturn__))';
909 test_text = "#define _Noreturn [[noreturn]]";
913 * Fix various macros used to define ioctl numbers.
914 * The traditional syntax was:
916 * #define _CTRL(n, x) (('n'<<8)+x)
917 * #define TCTRLCFOO _CTRL(T, 1)
919 * but this does not work with the C standard, which disallows macro
920 * expansion inside strings. We have to rewrite it thus:
922 * #define _CTRL(n, x) ((n<<8)+x)
923 * #define TCTRLCFOO _CTRL('T', 1)
925 * The select expressions match too much, but the c_fix code is cautious.
927 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
929 fix = {
930 hackname = ctrl_quotes_def;
931 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
932 c_fix = char_macro_def;
933 c_fix_arg = "CTRL";
936 * This is two tests in order to ensure that the "CTRL(c)" can
937 * be selected in isolation from the multi-arg format
939 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
940 test_text = "#define _CTRL(c) ('c'&037)";
943 fix = {
944 hackname = ctrl_quotes_use;
945 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
946 c_fix = char_macro_use;
947 c_fix_arg = "CTRL";
948 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
953 * sys/mman.h on HP/UX is not C++ ready,
954 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
956 * rpc/types.h on OSF1/2.0 is not C++ ready,
957 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
959 * The problem is the declaration of malloc.
961 fix = {
962 hackname = cxx_unready;
963 files = sys/mman.h;
964 files = rpc/types.h;
965 select = '[^#]+malloc.*;'; /* Catch any form of declaration
966 not within a macro. */
967 bypass = '"C"|__BEGIN_DECLS';
969 c_fix = wrap;
970 c_fix_arg = "#ifdef __cplusplus\n"
971 "extern \"C\" {\n"
972 "#endif\n";
973 c_fix_arg = "#ifdef __cplusplus\n"
974 "}\n"
975 "#endif\n";
976 test_text = "extern void* malloc( size_t );";
981 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
982 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
984 fix = {
985 hackname = darwin_externc;
986 mach = "*-*-darwin*";
987 files = mach-o/swap.h;
988 files = mach/mach_time.h;
989 files = mach/mach_traps.h;
990 files = mach/message.h;
991 files = mach/mig.h;
992 files = mach/semaphore.h;
993 bypass = "extern \"C\"";
994 bypass = "__BEGIN_DECLS";
995 c_fix = wrap;
996 c_fix_arg = "#ifdef __cplusplus\n"
997 "extern \"C\" {\n"
998 "#endif\n";
999 c_fix_arg = "#ifdef __cplusplus\n"
1000 "}\n"
1001 "#endif\n";
1002 test_text = "extern void swap_fat_header();\n";
1007 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1008 * bad __GNUC__ tests.
1011 fix = {
1012 hackname = darwin_gcc4_breakage;
1013 mach = "*-*-darwin*";
1014 files = AvailabilityMacros.h;
1015 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1016 c_fix = format;
1017 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1018 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1019 "(__GNUC_MINOR__ >= 1)\n";
1024 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1025 * why would you ever put it in a system header file?
1027 fix = {
1028 hackname = darwin_private_extern;
1029 mach = "*-*-darwin*";
1030 files = mach-o/dyld.h;
1031 select = "__private_extern__ [a-z_]+ _dyld_";
1032 c_fix = format;
1033 c_fix_arg = "extern";
1034 c_fix_arg = "__private_extern__";
1035 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1036 "const char *dyld_func_name,\n"
1037 "unsigned long *address);\n";
1042 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1043 * unsigned constants.
1045 fix = {
1046 hackname = darwin_stdint_1;
1047 mach = "*-*-darwin*";
1048 files = stdint-darwin.h, stdint.h;
1049 c_fix = format;
1050 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1051 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1052 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1053 test_text = "#define UINT8_C(v) (v ## U)\n"
1054 "#define UINT16_C(v) (v ## U)";
1059 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1060 * with wrong types.
1062 fix = {
1063 hackname = darwin_stdint_2;
1064 mach = "*-*-darwin*";
1065 files = stdint-darwin.h, stdint.h;
1066 c_fix = format;
1067 c_fix_arg = "#if __WORDSIZE == 64\n"
1068 "#define INTPTR_MAX 9223372036854775807L\n"
1069 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1070 "#else\n"
1071 "#define INTPTR_MAX 2147483647L\n"
1072 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1073 "#endif";
1074 select = "#if __WORDSIZE == 64\n"
1075 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1076 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1077 "#else\n"
1078 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1079 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1080 "#endif";
1081 test_text = "#if __WORDSIZE == 64\n"
1082 "#define INTPTR_MIN INT64_MIN\n"
1083 "#define INTPTR_MAX INT64_MAX\n"
1084 "#else\n"
1085 "#define INTPTR_MIN INT32_MIN\n"
1086 "#define INTPTR_MAX INT32_MAX\n"
1087 "#endif";
1092 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1094 fix = {
1095 hackname = darwin_stdint_3;
1096 mach = "*-*-darwin*";
1097 files = stdint-darwin.h, stdint.h;
1098 c_fix = format;
1099 c_fix_arg = "#if __WORDSIZE == 64\n"
1100 "#define UINTPTR_MAX 18446744073709551615UL\n"
1101 "#else\n"
1102 "#define UINTPTR_MAX 4294967295UL\n"
1103 "#endif";
1104 select = "#if __WORDSIZE == 64\n"
1105 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1106 "#else\n"
1107 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1108 "#endif";
1109 test_text = "#if __WORDSIZE == 64\n"
1110 "#define UINTPTR_MAX UINT64_MAX\n"
1111 "#else\n"
1112 "#define UINTPTR_MAX UINT32_MAX\n"
1113 "#endif";
1118 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1120 fix = {
1121 hackname = darwin_stdint_4;
1122 mach = "*-*-darwin*";
1123 files = stdint-darwin.h, stdint.h;
1124 c_fix = format;
1125 c_fix_arg = "#if __WORDSIZE == 64\n"
1126 "#define SIZE_MAX 18446744073709551615UL\n"
1127 "#else\n"
1128 "#define SIZE_MAX 4294967295UL\n"
1129 "#endif";
1130 select = "#if __WORDSIZE == 64\n"
1131 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1132 "#else\n"
1133 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1134 "#endif";
1135 test_text = "#if __WORDSIZE == 64\n"
1136 "#define SIZE_MAX UINT64_MAX\n"
1137 "#else\n"
1138 "#define SIZE_MAX UINT32_MAX\n"
1139 "#endif";
1144 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1145 * with a wrong type.
1147 fix = {
1148 hackname = darwin_stdint_5;
1149 mach = "*-*-darwin*";
1150 files = stdint-darwin.h, stdint.h;
1151 c_fix = format;
1152 c_fix_arg = "#if __WORDSIZE == 64\n"
1153 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1154 "#define INTMAX_MAX 9223372036854775807L\n"
1155 "#define UINTMAX_MAX 18446744073709551615UL\n"
1156 "#else\n"
1157 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1158 "#define INTMAX_MAX 9223372036854775807LL\n"
1159 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1160 "#endif";
1161 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1162 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1163 "\n"
1164 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1165 test_text = "#define INTMAX_MIN INT64_MIN\n"
1166 "#define INTMAX_MAX INT64_MAX\n"
1167 "\n"
1168 "#define UINTMAX_MAX UINT64_MAX";
1173 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1174 * with a wrong type.
1176 fix = {
1177 hackname = darwin_stdint_6;
1178 mach = "*-*-darwin*";
1179 files = stdint-darwin.h, stdint.h;
1180 c_fix = format;
1181 c_fix_arg = "#if __WORDSIZE == 64\n"
1182 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1183 "#define PTRDIFF_MAX 9223372036854775807L\n"
1184 "#else\n"
1185 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1186 "#define PTRDIFF_MAX 2147483647\n"
1187 "#endif";
1188 select = "#if __WORDSIZE == 64\n"
1189 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1190 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1191 "#else\n"
1192 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1193 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1194 "#endif";
1195 test_text = "#if __WORDSIZE == 64\n"
1196 "#define PTRDIFF_MIN INT64_MIN\n"
1197 "#define PTRDIFF_MAX INT64_MAX\n"
1198 "#else\n"
1199 "#define PTRDIFF_MIN INT32_MIN\n"
1200 "#define PTRDIFF_MAX INT32_MAX\n"
1201 "#endif";
1206 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1207 * with a wrong type.
1209 fix = {
1210 hackname = darwin_stdint_7;
1211 mach = "*-*-darwin*";
1212 files = stdint-darwin.h, stdint.h;
1213 c_fix = format;
1214 c_fix_arg = "#if __WORDSIZE == 64\n"
1215 "#define INTMAX_C(v) (v ## L)\n"
1216 "#define UINTMAX_C(v) (v ## UL)\n"
1217 "#else\n"
1218 "#define INTMAX_C(v) (v ## LL)\n"
1219 "#define UINTMAX_C(v) (v ## ULL)\n"
1220 "#endif";
1221 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1222 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1223 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1224 "#define UINTMAX_C(v) (v ## ULL)";
1229 * Fix <c_asm.h> on Digital UNIX V4.0:
1230 * It contains a prototype for a DEC C internal asm() function,
1231 * clashing with gcc's asm keyword. So protect this with __DECC.
1233 fix = {
1234 hackname = dec_intern_asm;
1235 files = c_asm.h;
1236 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1237 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1238 "#endif\n";
1239 test_text =
1240 "float fasm {\n"
1241 " ... asm stuff ...\n"
1242 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1247 * Fix typo in <wchar.h> on DJGPP 2.03.
1249 fix = {
1250 hackname = djgpp_wchar_h;
1251 file = wchar.h;
1252 select = "__DJ_wint_t";
1253 bypass = "sys/djtypes.h";
1254 c_fix = format;
1255 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1256 c_fix_arg = "#include <stddef.h>";
1257 test_text = "#include <stddef.h>\n"
1258 "extern __DJ_wint_t x;\n";
1263 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1265 fix = {
1266 hackname = ecd_cursor;
1267 files = "sunwindow/win_lock.h";
1268 files = "sunwindow/win_cursor.h";
1269 select = 'ecd\.cursor';
1270 c_fix = format;
1271 c_fix_arg = 'ecd_cursor';
1273 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1278 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1279 * neither the existence of GCC 3 nor its exact feature set yet break
1280 * (by design?) when __GNUC__ is set beyond 2.
1282 fix = {
1283 hackname = freebsd_gcc3_breakage;
1284 mach = "*-*-freebsd*";
1285 files = sys/cdefs.h;
1286 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1287 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1288 c_fix = format;
1289 c_fix_arg = '%0 || __GNUC__ >= 3';
1290 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1295 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1296 * neither the existence of GCC 4 nor its exact feature set yet break
1297 * (by design?) when __GNUC__ is set beyond 3.
1299 fix = {
1300 hackname = freebsd_gcc4_breakage;
1301 mach = "*-*-freebsd*";
1302 files = sys/cdefs.h;
1303 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1304 c_fix = format;
1305 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1306 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1311 * Some versions of glibc don't expect the C99 inline semantics.
1313 fix = {
1314 hackname = glibc_c99_inline_1;
1315 files = features.h, '*/features.h';
1316 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1317 c_fix = format;
1318 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1319 test_text = <<-EOT
1320 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1321 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1322 # define __USE_EXTERN_INLINES 1
1323 #endif
1324 EOT;
1329 * Similar, but a version that didn't have __NO_INLINE__
1331 fix = {
1332 hackname = glibc_c99_inline_1a;
1333 files = features.h, '*/features.h';
1334 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1335 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1336 c_fix = format;
1337 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1338 test_text = <<-EOT
1339 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1340 # define __USE_EXTERN_INLINES 1
1341 #endif
1342 EOT;
1347 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1348 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1349 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1351 fix = {
1352 hackname = glibc_c99_inline_2;
1353 files = sys/stat.h, '*/sys/stat.h';
1354 select = "extern __inline__ int";
1355 sed = "s/extern int \\(stat\\)/"
1356 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1357 "__inline__ int \\1/";
1358 sed = "s/extern int \\([lf]stat\\)/"
1359 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1360 "__inline__ int \\1/";
1361 sed = "s/extern int \\(mknod\\)/"
1362 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1363 "__inline__ int \\1/";
1364 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1365 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1366 "__inline__ int __REDIRECT\\1 (\\2/";
1367 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1368 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1369 "__inline__ int __REDIRECT\\1 (\\2/";
1370 sed = "s/^extern __inline__ int/"
1371 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1372 "__inline__ int/";
1373 test_text = <<-EOT
1374 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1375 extern __inline__ int
1376 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1378 EOT;
1382 fix = {
1383 hackname = glibc_c99_inline_3;
1384 files = bits/string2.h, '*/bits/string2.h';
1385 select = "extern __inline";
1386 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1387 c_fix = format;
1388 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1389 c_fix_arg = "^# ifdef __cplusplus$";
1390 test_text = <<-EOT
1391 # ifdef __cplusplus
1392 # define __STRING_INLINE inline
1393 # else
1394 # define __STRING_INLINE extern __inline
1395 # endif
1396 EOT;
1400 fix = {
1401 hackname = glibc_c99_inline_4;
1402 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1403 bypass = "__extern_inline|__gnu_inline__";
1404 select = "(^| )extern __inline";
1405 c_fix = format;
1406 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1407 test_text = <<-EOT
1408 __extension__ extern __inline unsigned int
1409 extern __inline unsigned int
1410 EOT;
1414 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1415 * so we replace them with versions that correspond to the
1416 * definition.
1418 fix = {
1419 hackname = glibc_mutex_init;
1420 files = pthread.h;
1421 select = '\{ *\{ *0, *\} *\}';
1422 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1423 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1424 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1425 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1426 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1427 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1428 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1429 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1430 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1431 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1432 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1433 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1434 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1435 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1436 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1437 "N;s/^[ \t]*#[ \t]*"
1438 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1439 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1440 "# \\1\\\n"
1441 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1442 "# else\\\n"
1443 "# \\1\\\n"
1444 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1445 "# endif/";
1446 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1447 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1448 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1449 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1451 test_text = <<- _EOText_
1452 #define PTHREAD_MUTEX_INITIALIZER \\
1453 { { 0, } }
1454 #ifdef __USE_GNU
1455 # if __WORDSIZE == 64
1456 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1457 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1458 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1459 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1460 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1461 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1462 # else
1463 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1464 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1465 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1466 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1467 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1468 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1469 # endif
1470 #endif
1471 # define PTHREAD_RWLOCK_INITIALIZER \\
1472 { { 0, } }
1473 # ifdef __USE_GNU
1474 # if __WORDSIZE == 64
1475 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1476 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1477 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1478 # else
1479 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1480 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1481 # endif
1482 # endif
1483 #define PTHREAD_COND_INITIALIZER { { 0, } }
1484 _EOText_;
1488 /* glibc versions before 2.5 have a version of stdint.h that defines
1489 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1490 versions with stdint.h based on those glibc versions. */
1491 fix = {
1492 hackname = glibc_stdint;
1493 files = stdint.h;
1494 select = "GNU C Library";
1495 c_fix = format;
1496 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1497 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1498 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";
1502 /* Some versions of glibc have a version of bits/string2.h that
1503 produces "value computed is not used" warnings from strncpy; fix
1504 this definition by using __builtin_strncpy instead as in newer
1505 versions. */
1506 fix = {
1507 hackname = glibc_strncpy;
1508 files = bits/string2.h;
1509 bypass = "__builtin_strncpy";
1510 c_fix = format;
1511 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1512 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1513 test_text = <<-EOT
1514 # define strncpy(dest, src, n) \
1515 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1516 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1517 ? (char *) memcpy (dest, src, n) \\
1518 : strncpy (dest, src, n)) \\
1519 : strncpy (dest, src, n)))
1520 EOT;
1524 /* glibc's tgmath.h relies on an expression that is not an integer
1525 constant expression being treated as it was by GCC 4.4 and
1526 earlier. */
1527 fix = {
1528 hackname = glibc_tgmath;
1529 files = tgmath.h;
1530 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1531 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1532 c_fix = format;
1533 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1534 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1538 * Fix these files to use the types we think they should for
1539 * ptrdiff_t, size_t, and wchar_t.
1541 * This defines the types in terms of macros predefined by our 'cpp'.
1542 * This is supposedly necessary for glibc's handling of these types.
1543 * It's probably not necessary for anyone else, but it doesn't hurt.
1545 fix = {
1546 hackname = gnu_types;
1547 files = "sys/types.h";
1548 files = "stdlib.h";
1549 files = "sys/stdtypes.h";
1550 files = "stddef.h";
1551 files = "memory.h";
1552 files = "unistd.h";
1553 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1554 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1555 c_fix = gnu_type;
1556 /* The Solaris 10 headers already define these types correctly. */
1557 mach = '*-*-solaris2.1[0-9]*';
1558 not_machine = true;
1560 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1561 "typedef uint_t size_t; /* uint_t */\n"
1562 "typedef ushort_t wchar_t; /* ushort_t */";
1567 * Fix HP & Sony's use of "../machine/xxx.h"
1568 * to refer to: <machine/xxx.h>
1570 fix = {
1571 hackname = hp_inline;
1572 files = sys/spinlock.h;
1573 files = machine/machparam.h;
1574 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1576 c_fix = format;
1577 c_fix_arg = "%1<machine/%2.h>";
1579 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1580 '([a-z]+)\.h"';
1582 test_text = ' # include "../machine/mumble.h"';
1587 * Check for (...) in C++ code in HP/UX sys/file.h.
1589 fix = {
1590 hackname = hp_sysfile;
1591 files = sys/file.h;
1592 select = "HPUX_SOURCE";
1594 c_fix = format;
1595 c_fix_arg = "(struct file *, ...)";
1596 c_fix_arg = '\(\.\.\.\)';
1598 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1603 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1604 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1606 fix = {
1607 hackname = hppa_hpux_fp_macros;
1608 mach = "hppa*-hp-hpux11*";
1609 files = math.h;
1610 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1611 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1612 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1613 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1614 "#[ \t]*define[ \t]*FP_NAN.*\n";
1615 c_fix = format;
1616 c_fix_arg = <<- _EOFix_
1617 #endif /* _INCLUDE_HPUX_SOURCE */
1619 #if defined(_INCLUDE_HPUX_SOURCE) || \
1620 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1621 %0#endif
1623 #ifdef _INCLUDE_HPUX_SOURCE
1625 _EOFix_;
1627 test_text =
1628 "# define FP_NORMAL 0\n"
1629 "# define FP_ZERO 1\n"
1630 "# define FP_INFINITE 2\n"
1631 "# define FP_SUBNORMAL 3\n"
1632 "# define FP_NAN 4\n";
1637 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1638 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1640 fix = {
1641 hackname = hpux10_cpp_pow_inline;
1642 files = fixinc-test-limits.h, math.h;
1643 select = <<- END_POW_INLINE
1644 ^# +ifdef +__cplusplus
1646 +inline +double +pow\(double +__d,int +__expon\) +\{
1647 [ ]+return +pow\(__d,\(double\)__expon\);
1649 +extern +"C" +\{
1650 #else
1651 # +endif
1652 END_POW_INLINE;
1654 c_fix = format;
1655 c_fix_arg = "";
1657 test_text =
1658 "# ifdef __cplusplus\n"
1659 " }\n"
1660 " inline double pow(double __d,int __expon) {\n"
1661 "\t return pow(__d,(double)__expon);\n"
1662 " }\n"
1663 ' extern "C"' " {\n"
1664 "#else\n"
1665 "# endif";
1668 fix = {
1669 hackname = hpux11_cpp_pow_inline;
1670 files = math.h;
1671 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1672 " +return pow\\(d, \\(double\\)expon\\);\n"
1673 " +\\}\n";
1674 c_fix = format;
1675 c_fix_arg = "";
1677 test_text =
1678 " inline double pow(double d,int expon) {\n"
1679 " return pow(d, (double)expon);\n"
1680 " }\n";
1685 * Fix hpux 10.X missing ctype declarations 1
1687 fix = {
1688 hackname = hpux10_ctype_declarations1;
1689 files = ctype.h;
1690 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1691 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1692 c_fix = format;
1693 c_fix_arg = "#ifdef _PROTOTYPES\n"
1694 "extern int __tolower(int);\n"
1695 "extern int __toupper(int);\n"
1696 "#else /* NOT _PROTOTYPES */\n"
1697 "extern int __tolower();\n"
1698 "extern int __toupper();\n"
1699 "#endif /* _PROTOTYPES */\n\n"
1700 "%0\n";
1702 test_text = "# define _toupper(__c) __toupper(__c)\n";
1707 * Fix hpux 10.X missing ctype declarations 2
1709 fix = {
1710 hackname = hpux10_ctype_declarations2;
1711 files = ctype.h;
1712 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1713 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1714 c_fix = format;
1715 c_fix_arg = "%0\n\n"
1716 "#ifdef _PROTOTYPES\n"
1717 " extern int _isalnum(int);\n"
1718 " extern int _isalpha(int);\n"
1719 " extern int _iscntrl(int);\n"
1720 " extern int _isdigit(int);\n"
1721 " extern int _isgraph(int);\n"
1722 " extern int _islower(int);\n"
1723 " extern int _isprint(int);\n"
1724 " extern int _ispunct(int);\n"
1725 " extern int _isspace(int);\n"
1726 " extern int _isupper(int);\n"
1727 " extern int _isxdigit(int);\n"
1728 "# else /* not _PROTOTYPES */\n"
1729 " extern int _isalnum();\n"
1730 " extern int _isalpha();\n"
1731 " extern int _iscntrl();\n"
1732 " extern int _isdigit();\n"
1733 " extern int _isgraph();\n"
1734 " extern int _islower();\n"
1735 " extern int _isprint();\n"
1736 " extern int _ispunct();\n"
1737 " extern int _isspace();\n"
1738 " extern int _isupper();\n"
1739 " extern int _isxdigit();\n"
1740 "#endif /* _PROTOTYPES */\n";
1742 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1743 " extern unsigned int *__SB_masks;\n";
1748 * Fix hpux 10.X missing stdio declarations
1750 fix = {
1751 hackname = hpux10_stdio_declarations;
1752 files = stdio.h;
1753 select = "^#[ \t]*define _iob[ \t]*__iob";
1754 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1755 c_fix = format;
1756 c_fix_arg = "%0\n\n"
1757 "# if defined(__STDC__) || defined(__cplusplus)\n"
1758 " extern int snprintf(char *, size_t, const char *, ...);\n"
1759 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1760 "# else /* not __STDC__) || __cplusplus */\n"
1761 " extern int snprintf();\n"
1762 " extern int vsnprintf();\n"
1763 "# endif /* __STDC__) || __cplusplus */\n";
1765 test_text = "# define _iob __iob\n";
1770 * Make sure hpux defines abs in header.
1772 fix = {
1773 hackname = hpux11_abs;
1774 mach = "*-hp-hpux11*";
1775 files = stdlib.h;
1776 select = "ifndef _MATH_INCLUDED";
1777 c_fix = format;
1778 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1779 test_text = "#ifndef _MATH_INCLUDED";
1784 * Keep HP-UX 11 from stomping on C++ math namespace
1785 * with defines for fabsf.
1787 fix = {
1788 hackname = hpux11_fabsf;
1789 files = math.h;
1790 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1791 bypass = "__cplusplus";
1793 c_fix = format;
1794 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1796 test_text =
1797 "#ifdef _PA_RISC\n"
1798 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1799 "#endif";
1804 * Fix C99 constant in __POINTER_SET define.
1806 fix = {
1807 hackname = hpux11_pthread_const;
1808 mach = "*-hp-hpux11.[0-3]*";
1809 files = sys/pthread.h;
1810 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1812 c_fix = format;
1813 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1814 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1819 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1820 * being defined by having it define _hpux_size_t instead.
1822 fix = {
1823 hackname = hpux11_size_t;
1824 mach = "*-hp-hpux11*";
1825 select = "__size_t";
1827 c_fix = format;
1828 c_fix_arg = "_hpux_size_t";
1830 test_text =
1831 "#define __size_t size_t\n"
1832 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1837 * Fix hpux 11.00 broken snprintf declaration
1838 * (third argument is char *, needs to be const char * to prevent
1839 * spurious warnings with -Wwrite-strings or in C++).
1841 fix = {
1842 hackname = hpux11_snprintf;
1843 files = stdio.h;
1844 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1845 ' *(char *\*, *\.\.\.\);)';
1846 c_fix = format;
1847 c_fix_arg = '%1 const %3';
1849 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1850 "extern int snprintf(char *, __size_t, char *, ...);\n"
1851 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1855 * Fix hpux 11.00 broken vsnprintf declaration
1857 fix = {
1858 hackname = hpux11_vsnprintf;
1859 files = stdio.h;
1860 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1861 'const char \*,) __va__list\);';
1862 c_fix = format;
1863 c_fix_arg = "%1 __va_list);";
1865 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1866 ' __va__list);';
1871 * get rid of bogus inline definitions in HP-UX 8.0
1873 fix = {
1874 hackname = hpux8_bogus_inlines;
1875 files = math.h;
1876 select = inline;
1877 bypass = "__GNUG__";
1878 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1879 "@extern \"C\" int abs(int);@";
1880 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1881 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1882 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1883 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1884 "inline double sqr(double v) { return v**0.5; }";
1889 * Fix hpux broken ctype macros
1891 fix = {
1892 hackname = hpux_ctype_macros;
1893 files = ctype.h;
1894 select = '((: |\()__SB_masks \? )'
1895 '(__SB_masks\[__(alnum|c)\] & _IS)';
1896 c_fix = format;
1897 c_fix_arg = "%1(int)%3";
1899 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1900 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1905 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1907 fix = {
1908 hackname = hpux_htonl;
1909 files = netinet/in.h;
1910 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
1911 "(/\\*\n"
1912 " \\* Macros for number representation conversion\\.\n"
1913 " \\*/\n"
1914 "#ifndef ntohl)";
1915 c_fix = format;
1916 c_fix_arg = "#if 1\n%1";
1918 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1919 "/*\n"
1920 " * Macros for number representation conversion.\n"
1921 " */\n"
1922 "#ifndef ntohl\n"
1923 "#define ntohl(x) (x)\n"
1924 "#define ntohs(x) (x)\n"
1925 "#define htonl(x) (x)\n"
1926 "#define htons(x) (x)\n"
1927 "#endif\n"
1928 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1933 * HP-UX long_double
1935 fix = {
1936 hackname = hpux_long_double;
1937 mach = "*-*-hpux10*";
1938 mach = "*-*-hpux11.[012]*";
1939 files = stdlib.h;
1940 select = "extern[ \t]long_double[ \t]strtold";
1941 bypass = "long_double_t";
1942 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1943 sed = "s/long_double/long double/g";
1945 test_text = "# ifndef _LONG_DOUBLE\n"
1946 "# define _LONG_DOUBLE\n"
1947 " typedef struct {\n"
1948 " unsigned int word1, word2, word3, word4;\n"
1949 " } long_double;\n"
1950 "# endif /* _LONG_DOUBLE */\n"
1951 "extern long_double strtold(const char *, char **);\n";
1955 * We cannot use the above rule on 11.31 because it removes the strtold
1956 * definition. ia64 is OK with no hack, PA needs some help.
1958 fix = {
1959 hackname = hpux_long_double_2;
1960 mach = "hppa*-*-hpux11.3*";
1961 files = stdlib.h;
1962 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
1963 c_fix = format;
1964 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
1966 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
1970 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1972 fix = {
1973 hackname = hpux_systime;
1974 files = sys/time.h;
1975 select = "^extern struct sigevent;";
1977 c_fix = format;
1978 c_fix_arg = "struct sigevent;";
1980 test_text = 'extern struct sigevent;';
1985 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1986 * type and mpinfou is only defined when _KERNEL is set.
1988 fix = {
1989 hackname = hpux_spu_info;
1990 mach = "*-hp-hpux*";
1992 * It is tempting to omit the first "files" entry. Do not.
1993 * The testing machinery will take the first "files" entry as the name
1994 * of a test file to play with. It would be a nuisance to have a directory
1995 * with the name "*".
1997 files = "ia64/sys/getppdp.h";
1998 files = "*/sys/getppdp.h";
1999 select = "^.*extern.*spu_info.*";
2001 c_fix = format;
2002 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2004 test_text = "extern union mpinfou spu_info[];";
2007 fix = {
2008 hackname = hpux11_extern_sendfile;
2009 mach = "*-hp-hpux11.[12]*";
2010 files = sys/socket.h;
2011 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2012 c_fix = format;
2013 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2014 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2017 fix = {
2018 hackname = hpux11_extern_sendpath;
2019 mach = "*-hp-hpux11.[12]*";
2020 files = sys/socket.h;
2021 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2022 c_fix = format;
2023 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2024 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2027 fix = {
2028 hackname = hpux_extern_errno;
2029 mach = "*-hp-hpux10.*";
2030 mach = "*-hp-hpux11.[0-2]*";
2031 files = errno.h;
2032 select = "^[ \t]*extern int errno;$";
2033 c_fix = format;
2034 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2035 test_text = " extern int errno;\n";
2040 * Add missing braces to pthread initializer defines.
2042 fix = {
2043 hackname = hpux_pthread_initializers;
2044 mach = "*-hp-hpux11.[0-3]*";
2045 files = sys/pthread.h;
2046 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2047 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2048 sed = "s@^[ \t]*1,[ \t]*\\\\"
2049 "@\t{ 1, 0 }@";
2050 sed = "/^[ \t]*0$/d";
2051 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2052 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2053 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2054 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2055 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2056 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2057 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2058 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2059 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2060 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2061 sed = "s@__PTHREAD_COND_VALID, 0"
2062 "@{ __PTHREAD_COND_VALID, 0 }@";
2063 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2064 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2065 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2066 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2067 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2068 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2069 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2070 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2071 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2072 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2073 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2074 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2075 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2076 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2077 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2078 "}\n";
2081 fix = {
2082 hackname = hpux_c99_intptr;
2083 mach = "*-hp-hpux11.3*";
2084 files = stdint-hpux11.h, stdint.h;
2085 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2086 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2087 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2088 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2089 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2090 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2091 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2092 "#define PTRDIFF_MIN INT32_MIN\n"
2093 "#define INTPTR_MAX INT32_MAX\n"
2094 "#define INTPTR_MIN INT32_MIN\n"
2095 "#define UINTPTR_MAX UINT32_MAX\n"
2096 "#define SIZE_MAX UINT32_MAX\n";
2100 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2103 fix = {
2104 hackname = hpux_c99_inttypes;
2105 mach = "*-hp-hpux11.[23]*";
2106 files = inttypes.h;
2107 files = stdint-hpux11.h, stdint.h;
2108 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2109 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2110 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2111 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2112 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2113 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2114 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2115 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2118 fix = {
2119 hackname = hpux_c99_inttypes2;
2120 mach = "*-hp-hpux11.2*";
2121 files = stdint-hpux11.h, stdint.h;
2122 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2123 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2124 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2125 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2126 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2127 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2128 "# define INT16_C(__c) ((short)(__c))\n"
2129 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2132 fix = {
2133 hackname = hpux_stdint_least_fast;
2134 mach = "*-hp-hpux11.2*";
2135 files = stdint-hpux11.h, stdint.h;
2136 select =
2137 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2138 c_fix = format;
2139 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2140 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2141 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2142 _EOFix_;
2145 fix = {
2146 hackname = hpux_inttype_int8_t;
2147 mach = "*-hp-hpux1[01].*";
2148 files = sys/_inttypes.h;
2149 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2150 c_fix = format;
2151 c_fix_arg = "typedef signed char int%18_t;";
2152 test_text = "typedef char int_least8_t;\n"
2153 "typedef char int8_t;\n";
2156 fix = {
2157 hackname = hpux_imaginary_i;
2158 mach = "ia64-hp-hpux11.*";
2159 files = complex.h;
2160 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2161 c_fix = format;
2162 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2163 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2167 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2169 fix = {
2170 hackname = huge_val_hex;
2171 files = bits/huge_val.h;
2172 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2173 bypass = "__builtin_huge_val";
2175 c_fix = format;
2176 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2178 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2183 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2185 fix = {
2186 hackname = huge_valf_hex;
2187 files = bits/huge_val.h;
2188 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2189 bypass = "__builtin_huge_valf";
2191 c_fix = format;
2192 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2194 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2199 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2201 fix = {
2202 hackname = huge_vall_hex;
2203 files = bits/huge_val.h;
2204 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2205 bypass = "__builtin_huge_vall";
2207 c_fix = format;
2208 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2210 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2215 * Fix return type of abort and free
2217 fix = {
2218 hackname = int_abort_free_and_exit;
2219 files = stdlib.h;
2220 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2221 bypass = "_CLASSIC_ANSI_TYPES";
2223 c_fix = format;
2224 c_fix_arg = "void\t%1(";
2226 test_text = "extern int abort(int);\n"
2227 "extern int free(void*);\n"
2228 "extern int exit(void*);";
2233 * Fix various macros used to define ioctl numbers.
2234 * The traditional syntax was:
2236 * #define _IO(n, x) (('n'<<8)+x)
2237 * #define TIOCFOO _IO(T, 1)
2239 * but this does not work with the C standard, which disallows macro
2240 * expansion inside strings. We have to rewrite it thus:
2242 * #define _IO(n, x) ((n<<8)+x)
2243 * #define TIOCFOO _IO('T', 1)
2245 * The select expressions match too much, but the c_fix code is cautious.
2247 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2249 fix = {
2250 hackname = io_quotes_def;
2251 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2252 c_fix = char_macro_def;
2253 c_fix_arg = "IO";
2254 test_text =
2255 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2256 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2257 "#define _IO(x,y) ('x'<<8|y)";
2258 test_text =
2259 "#define XX_IO(x) ('x'<<8|256)";
2262 fix = {
2263 hackname = io_quotes_use;
2264 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2265 "\\( *[^,']";
2266 c_fix = char_macro_use;
2267 c_fix_arg = "IO";
2268 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2269 "#define TIOCFOO \\\\\n"
2270 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2275 * Check for missing ';' in struct
2277 fix = {
2278 hackname = ip_missing_semi;
2279 files = netinet/ip.h;
2280 select = "}$";
2281 sed = "/^struct/,/^};/s/}$/};/";
2282 test_text=
2283 "struct mumble {\n"
2284 " union {\n"
2285 " int x;\n"
2286 " }\n"
2287 "}; /* mumbled struct */\n";
2292 * Non-traditional "const" declaration in Irix's limits.h.
2294 fix = {
2295 hackname = irix_limits_const;
2296 files = fixinc-test-limits.h, limits.h;
2297 select = "^extern const ";
2298 c_fix = format;
2299 c_fix_arg = "extern __const ";
2300 test_text = "extern const char limit; /* test limits */";
2305 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2306 * taking char *. However, GCC uses void * for va_list, so
2307 * calling vfprintf with a va_list fails in C++. */
2308 fix = {
2309 hackname = irix_stdio_va_list;
2310 files = stdio.h;
2312 select = '/\* va_list \*/ char \*';
2313 c_fix = format;
2314 c_fix_arg = "__gnuc_va_list";
2315 test_text =
2316 "extern int printf( const char *, /* va_list */ char * );";
2321 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2322 * use / * * / to concatenate tokens.
2324 fix = {
2325 hackname = kandr_concat;
2326 files = "sparc/asm_linkage.h";
2327 files = "sun*/asm_linkage.h";
2328 files = "arm/as_support.h";
2329 files = "arm/mc_type.h";
2330 files = "arm/xcb.h";
2331 files = "dev/chardefmac.h";
2332 files = "dev/ps_irq.h";
2333 files = "dev/screen.h";
2334 files = "dev/scsi.h";
2335 files = "sys/tty.h";
2336 files = "Xm.acorn/XmP.h";
2337 files = bsd43/bsd43_.h;
2338 select = '/\*\*/';
2339 c_fix = format;
2340 c_fix_arg = '##';
2341 test_text = "#define __CONCAT__(a,b) a/**/b";
2345 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2346 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2347 * constant on recent versions of g++.
2349 fix = {
2350 hackname = linux_ia64_ucontext;
2351 files = "sys/ucontext.h";
2352 mach = "ia64-*-linux*";
2353 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2354 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2355 c_fix = format;
2356 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2357 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2358 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2363 * Remove header file warning from sys/time.h. Autoconf's
2364 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2365 * which causes warning on LynxOS. Remove the warning.
2367 fix = {
2368 hackname = lynxos_no_warning_in_sys_time_h;
2369 files = sys/time.h;
2370 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2371 c_fix = format;
2372 c_fix_arg = "";
2373 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2378 * Add missing declaration for putenv.
2380 fix = {
2381 hackname = lynxos_missing_putenv;
2382 mach = '*-*-lynxos*';
2383 files = stdlib.h;
2384 bypass = 'putenv[ \t]*\\(';
2385 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2386 c_fix = format;
2387 c_fix_arg = "%0\n"
2388 "extern int putenv _AP((char *));";
2389 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2390 test_text = "extern char *getenv _AP((const char *));";
2395 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2397 * On NetBSD, machine is a symbolic link to an architecture specific
2398 * directory name, so we can't match a specific file name here.
2400 fix = {
2401 hackname = machine_ansi_h_va_list;
2402 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2403 bypass = '__builtin_va_list';
2405 c_fix = format;
2406 c_fix_arg = "%1__builtin_va_list";
2407 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2409 test_text = " # define _BSD_VA_LIST_\tchar**";
2414 * Fix non-ansi machine name defines
2416 fix = {
2417 hackname = machine_name;
2418 c_test = machine_name;
2419 c_fix = machine_name;
2421 test_text = "/* MACH_DIFF: */\n"
2422 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2423 "\n/* no uniform test, so be careful :-) */";
2428 * Some math.h files define struct exception (it's in the System V
2429 * Interface Definition), which conflicts with the class exception defined
2430 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2431 * This is not a great fix, but I haven't been able to think of anything
2432 * better.
2434 fix = {
2435 hackname = math_exception;
2436 files = math.h;
2437 select = "struct exception";
2439 * This should be bypassed on __cplusplus, but some supposedly C++
2440 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2441 * exception either. So currently we bypass only for glibc, based on a
2442 * comment in the fixed glibc header. Ick.
2444 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2445 '_[a-z0-9A-Z_]+_exception; for C, exception';
2446 c_fix = wrap;
2448 c_fix_arg = "#ifdef __cplusplus\n"
2449 "#define exception __math_exception\n"
2450 "#endif\n";
2452 c_fix_arg = "#ifdef __cplusplus\n"
2453 "#undef exception\n"
2454 "#endif\n";
2456 test_text = "typedef struct exception t_math_exception;";
2461 * This looks pretty broken to me. ``dbl_max_def'' will contain
2462 * "define DBL_MAX " at the start, when what we really want is just
2463 * the value portion. Can't figure out how to write a test case
2464 * for this either :-(
2466 fix = {
2467 hackname = math_huge_val_from_dbl_max;
2468 files = math.h;
2471 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2472 * in math.h, this fix applies.
2474 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2475 bypass = "define[ \t]+DBL_MAX";
2477 shell =
2479 * See if we have a definition for DBL_MAX in float.h.
2480 * If we do, we will replace the one in math.h with that one.
2483 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2484 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2486 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2487 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2488 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2489 "\telse cat\n"
2490 "\tfi";
2492 test_text =
2493 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2494 "#define HUGE_VAL DBL_MAX";
2499 * nested comment
2501 fix = {
2502 hackname = nested_auth_des;
2503 files = rpc/rpc.h;
2504 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2505 c_fix = format;
2506 c_fix_arg = "%1*/ /*";
2507 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2512 * Some versions of NetBSD don't expect the C99 inline semantics.
2514 fix = {
2515 hackname = netbsd_c99_inline_1;
2516 mach = "*-*-netbsd*";
2517 files = signal.h;
2518 select = "extern __inline int";
2520 c_fix = format;
2521 c_fix_arg = "extern\n"
2522 "#ifdef __GNUC_STDC_INLINE__\n"
2523 "__attribute__((__gnu_inline__))\n"
2524 "#endif\n"
2525 "__inline int";
2527 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2531 fix = {
2532 hackname = netbsd_c99_inline_2;
2533 mach = "*-*-netbsd*";
2534 files = signal.h;
2535 select = "#define _SIGINLINE extern __inline";
2537 c_fix = format;
2538 c_fix_arg = <<- _EOArg_
2539 #ifdef __GNUC_STDC_INLINE__
2540 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2541 #else
2543 #endif
2544 _EOArg_;
2546 test_text = "#define _SIGINLINE extern __inline";
2551 * NetBSD has a semicolon after the ending '}' for some extern "C".
2553 fix = {
2554 hackname = netbsd_extra_semicolon;
2555 mach = "*-*-netbsd*";
2556 files = sys/cdefs.h;
2557 select = "#define[ \t]*__END_DECLS[ \t]*};";
2559 c_fix = format;
2560 c_fix_arg = "#define __END_DECLS }";
2562 test_text = "#define __END_DECLS };";
2566 /* newlib's stdint.h has several failures to conform to C99. The fix
2567 for these removed a comment that can be matched to identify unfixed
2568 versions. */
2569 fix = {
2570 hackname = newlib_stdint_1;
2571 files = stdint-newlib.h, stdint.h;
2572 select = "@todo - Add support for wint_t types";
2573 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2574 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2575 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2576 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2577 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2578 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2579 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2580 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2581 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2582 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2583 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2584 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2585 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2586 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2587 test_text = "/* @todo - Add support for wint_t types. */\n"
2588 "#define INT32_MIN (-2147483647-1)\n"
2589 "#define INT32_MAX 2147483647\n"
2590 "#define UINT32_MAX 4294967295U\n"
2591 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2592 "#define INT_LEAST32_MAX 2147483647\n"
2593 "#define UINT_LEAST32_MAX 4294967295U\n"
2594 "#define INT_FAST8_MIN INT8_MIN\n"
2595 "#define INT_FAST8_MAX INT8_MAX\n"
2596 "#define UINT_FAST8_MAX UINT8_MAX\n"
2597 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2598 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2599 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2600 "#define UINT8_C(x) x##U\n"
2601 "#define UINT16_C(x) x##U";
2605 fix = {
2606 hackname = newlib_stdint_2;
2607 files = stdint-newlib.h, stdint.h;
2608 select = "@todo - Add support for wint_t types";
2609 c_fix = format;
2610 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2611 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2612 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2613 "#define WCHAR_MAX __WCHAR_MAX__\n"
2614 "#define WCHAR_MIN __WCHAR_MIN__\n"
2615 "#define WINT_MAX __WINT_MAX__\n"
2616 "#define WINT_MIN __WINT_MIN__\n\n"
2617 "%0";
2618 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2619 test_text = "/* @todo - Add support for wint_t types. */\n"
2620 "/** Macros for minimum-width integer constant expressions */";
2625 * NeXT 3.2 adds const prefix to some math functions.
2626 * These conflict with the built-in functions.
2628 fix = {
2629 hackname = next_math_prefix;
2630 files = ansi/math.h;
2631 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2633 c_fix = format;
2634 c_fix_arg = "extern double %1(";
2635 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2637 test_text = "extern\tdouble\t__const__\tmumble();";
2642 * NeXT 3.2 uses the word "template" as a parameter for some
2643 * functions. GCC reports an invalid use of a reserved key word
2644 * with the built-in functions.
2646 fix = {
2647 hackname = next_template;
2648 files = bsd/libc.h;
2649 select = "[ \t]template\\)";
2651 c_fix = format;
2652 c_fix_arg = "(%1)";
2653 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2654 test_text = "extern mumble( char * template); /* fix */";
2659 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2660 * function prototypes. That conflicts with the built-in functions.
2662 fix = {
2663 hackname = next_volitile;
2664 files = ansi/stdlib.h;
2665 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2667 c_fix = format;
2668 c_fix_arg = "extern void %1(";
2669 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2671 test_text = "extern\tvolatile\tvoid\tabort();";
2676 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2677 * Note that version 3 of the NeXT system has wait.h in a different directory,
2678 * so that this code won't do anything. But wait.h in version 3 has a
2679 * conditional, so it doesn't need this fix. So everything is okay.
2681 fix = {
2682 hackname = next_wait_union;
2683 files = sys/wait.h;
2685 select = 'wait\(union wait';
2686 c_fix = format;
2687 c_fix_arg = "wait(void";
2688 test_text = "extern pid_d wait(union wait*);";
2693 * a missing semi-colon at the end of the nodeent structure definition.
2695 fix = {
2696 hackname = nodeent_syntax;
2697 files = netdnet/dnetdb.h;
2698 select = "char[ \t]*\\*na_addr[ \t]*$";
2699 c_fix = format;
2700 c_fix_arg = "%0;";
2701 test_text = "char *na_addr\t";
2705 * Fix OpenBSD's NULL definition.
2707 fix = {
2708 hackname = openbsd_null_definition;
2709 mach = "*-*-openbsd*";
2710 files = locale.h, stddef.h, stdio.h, string.h,
2711 time.h, unistd.h, wchar.h, sys/param.h;
2712 select = "__GNUG__";
2713 c_fix = format;
2714 c_fix_arg = "#ifndef NULL\n"
2715 "#ifdef __cplusplus\n"
2716 "#ifdef __GNUG__\n"
2717 "#define NULL\t__null\n"
2718 "#else\t /* ! __GNUG__ */\n"
2719 "#define NULL\t0L\n"
2720 "#endif\t /* __GNUG__ */\n"
2721 "#else\t /* ! __cplusplus */\n"
2722 "#define NULL\t((void *)0)\n"
2723 "#endif\t /* __cplusplus */\n"
2724 "#endif\t /* !NULL */";
2726 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2727 "^#ifdef[ \t]*__GNUG__\n"
2728 "^#define[ \t]*NULL[ \t]*__null\n"
2729 "^#else\n"
2730 "^#define[ \t]*NULL[ \t]*0L\n"
2731 "^#endif\n"
2732 "^#endif";
2733 test_text =
2734 "#ifndef NULL\n"
2735 "#ifdef __GNUG__\n"
2736 "#define NULL __null\n"
2737 "#else\n"
2738 "#define NULL 0L\n"
2739 "#endif\n"
2740 "#endif\n";
2744 * obstack.h used casts as lvalues.
2746 * We need to change postincrements of casted pointers (which are
2747 * then dereferenced and assigned into) of the form
2749 * *((TYPE*)PTRVAR)++ = (VALUE)
2751 * into expressions like
2753 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2755 * which is correct for the cases used in obstack.h since PTRVAR is
2756 * of type char * and the value of the expression is not used.
2758 fix = {
2759 hackname = obstack_lvalue_cast;
2760 files = obstack.h;
2761 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2762 c_fix = format;
2763 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2764 test_text = "*((void **) (h)->next_free)++ = (aptr)";
2768 * Fix OpenBSD's va_start define.
2770 fix = {
2771 hackname = openbsd_va_start;
2772 mach = "*-*-openbsd*";
2773 files = stdarg.h;
2774 select = '__builtin_stdarg_start';
2775 c_fix = format;
2776 c_fix_arg = __builtin_va_start;
2778 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
2782 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2783 * defining regex.h related types. This causes libg++ build and usage
2784 * failures. Fixing this correctly requires checking and modifying 3 files.
2786 fix = {
2787 hackname = osf_namespace_a;
2788 files = reg_types.h;
2789 files = sys/lc_core.h;
2790 test = " -r reg_types.h";
2791 test = " -r sys/lc_core.h";
2792 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2793 test = " -z \"`grep __regex_t regex.h`\"";
2795 c_fix = format;
2796 c_fix_arg = "__%0";
2797 c_fix_arg = "reg(ex|off|match)_t";
2799 test_text = "`touch sys/lc_core.h`"
2800 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2801 "extern regex_t re;\n"
2802 "extern regoff_t ro;\n"
2803 "extern regmatch_t rm;\n";
2806 fix = {
2807 hackname = osf_namespace_c;
2808 files = regex.h;
2809 test = " -r reg_types.h";
2810 test = " -r sys/lc_core.h";
2811 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2812 test = " -z \"`grep __regex_t regex.h`\"";
2814 select = "#include <reg_types\.h>.*";
2815 c_fix = format;
2816 c_fix_arg = "%0\n"
2817 "typedef __regex_t\tregex_t;\n"
2818 "typedef __regoff_t\tregoff_t;\n"
2819 "typedef __regmatch_t\tregmatch_t;";
2821 test_text = "#include <reg_types.h>";
2826 * On broken glibc-2.3.3 systems an array of incomplete structures is
2827 * passed to __sigsetjmp. Fix that to take a pointer instead.
2829 fix = {
2830 hackname = pthread_incomplete_struct_argument;
2831 files = pthread.h;
2832 select = "struct __jmp_buf_tag";
2833 c_fix = format;
2834 c_fix_arg = "%1 *%2%3";
2835 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2836 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2840 * Fix return type of fread and fwrite on sysV68
2842 fix = {
2843 hackname = read_ret_type;
2844 files = stdio.h;
2845 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2846 c_fix = format;
2847 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2848 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2850 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2855 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2857 fix = {
2858 hackname = rpc_xdr_lvalue_cast_a;
2859 files = rpc/xdr.h;
2860 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2861 c_fix = format;
2862 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2863 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2864 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2868 fix = {
2869 hackname = rpc_xdr_lvalue_cast_b;
2870 files = rpc/xdr.h;
2871 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2872 c_fix = format;
2873 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2874 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2875 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2880 * function class(double x) conflicts with C++ keyword on rs/6000
2882 fix = {
2883 hackname = rs6000_double;
2884 files = math.h;
2885 select = '[^a-zA-Z_]class\(';
2887 c_fix = format;
2888 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2889 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2891 test_text = "extern int class();";
2896 * Wrong fchmod prototype on RS/6000.
2898 fix = {
2899 hackname = rs6000_fchmod;
2900 files = sys/stat.h;
2901 select = 'fchmod\(char \*';
2902 c_fix = format;
2903 c_fix_arg = "fchmod(int";
2904 test_text = "extern int fchmod(char *, mode_t);";
2909 * parameters conflict with C++ new on rs/6000
2911 fix = {
2912 hackname = rs6000_param;
2913 files = "stdio.h";
2914 files = "unistd.h";
2916 select = 'rename\(const char \*old, const char \*new\)';
2917 c_fix = format;
2918 c_fix_arg = 'rename(const char *_old, const char *_new)';
2920 test_text = 'extern int rename(const char *old, const char *new);';
2925 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
2926 * for C99. This is wrong for C++, which needs many C99 features, but
2927 * only supports __restrict.
2929 fix = {
2930 hackname = solaris___restrict;
2931 files = sys/feature_tests.h;
2932 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
2933 mach = "*-*-solaris2*";
2934 c_fix = format;
2935 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
2936 "#else\n%0\n#endif";
2937 test_text = "#define _RESTRICT_KYWD restrict";
2942 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
2943 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
2944 * and imaginary definitions which are not supported by GCC.
2946 fix = {
2947 hackname = solaris_complex;
2948 mach = "*-*-solaris2.*";
2949 files = complex.h;
2950 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
2951 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
2952 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
2953 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
2954 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
2955 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
2956 test_text = "#define _Complex_I _Complex_I\n"
2957 "#define complex _Complex\n"
2958 "#define _Imaginary_I _Imaginary_I\n"
2959 "#define imaginary _Imaginary\n"
2960 "#undef I\n"
2961 "#define I _Imaginary_I";
2966 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
2967 * extern "C" instead so libstdc++ can use it.
2969 fix = {
2970 hackname = solaris_complex_cxx;
2971 mach = "*-*-solaris2.*";
2972 files = complex.h;
2973 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
2974 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
2975 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
2976 "#ifdef\t__cplusplus\\\n}\\\n#endif";
2977 test_text = "#if !defined(__cplusplus)\n"
2978 "#endif /* !defined(__cplusplus) */";
2983 * g++ rejects functions declared with both C and C++ linkage.
2985 fix = {
2986 hackname = solaris_cxx_linkage;
2987 mach = '*-*-solaris2*';
2988 files = "iso/stdlib_iso.h";
2989 select = "(#if __cplusplus >= 199711L)\n"
2990 "(extern \"C\\+\\+\" \\{\n)"
2991 "(.*(bsearch|qsort).*)";
2992 c_fix = format;
2993 c_fix_arg = "%1 && !__GNUG__\n%2%3";
2995 test_text =
2996 "#if __cplusplus >= 199711L\n"
2997 "extern \"C++\" {\n"
2998 " void *bsearch(const void *, const void *, size_t, size_t,";
3003 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3004 * _STRICT_STDC, but uses it.
3006 fix = {
3007 hackname = solaris_getc_strict_stdc;
3008 mach = "*-*-solaris2*";
3009 files = "iso/stdio_iso.h";
3010 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3011 c_fix = format;
3012 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3014 test_text =
3015 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3020 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
3022 fix = {
3023 hackname = solaris_longjmp_noreturn;
3024 mach = "*-*-solaris2*";
3025 files = "iso/setjmp_iso.h";
3026 bypass = "__NORETURN";
3027 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
3028 c_fix = format;
3029 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
3031 test_text = "extern void longjmp(jmp_buf, int);";
3036 * Sun Solaris 10 defines several C99 math macros in terms of
3037 * builtins specific to the Studio compiler, in particular not
3038 * compatible with the GNU compiler.
3040 fix = {
3041 hackname = solaris_math_1;
3042 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3043 bypass = "__GNUC__";
3044 files = iso/math_c99.h;
3045 c_fix = format;
3046 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3047 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3048 test_text =
3049 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3050 "#undef HUGE_VAL\n"
3051 "#define HUGE_VAL __builtin_huge_val\n"
3052 "#undef HUGE_VALF\n"
3053 "#define HUGE_VALF __builtin_huge_valf\n"
3054 "#undef HUGE_VALL\n"
3055 "#define HUGE_VALL __builtin_huge_vall";
3058 fix = {
3059 hackname = solaris_math_2;
3060 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3061 bypass = "__GNUC__";
3062 files = iso/math_c99.h;
3063 c_fix = format;
3064 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3065 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3066 test_text =
3067 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3068 "#undef INFINITY\n"
3069 "#define INFINITY __builtin_infinity";
3072 fix = {
3073 hackname = solaris_math_3;
3074 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3075 bypass = "__GNUC__";
3076 files = iso/math_c99.h;
3077 c_fix = format;
3078 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3079 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3080 test_text =
3081 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3082 "#undef NAN\n"
3083 "#define NAN __builtin_nan";
3086 fix = {
3087 hackname = solaris_math_4;
3088 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3089 bypass = "__GNUC__";
3090 files = iso/math_c99.h;
3091 c_fix = format;
3092 c_fix_arg = "#define\tfpclassify(x) \\\n"
3093 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3094 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3095 test_text =
3096 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3097 "#undef fpclassify\n"
3098 "#define fpclassify(x) __builtin_fpclassify(x)";
3101 fix = {
3102 hackname = solaris_math_8;
3103 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3104 bypass = "__GNUC__";
3105 files = iso/math_c99.h;
3106 c_fix = format;
3107 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3108 "\t\t\t ? __builtin_signbitf(x) \\\n"
3109 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3110 "\t\t\t ? __builtin_signbitl(x) \\\n"
3111 "\t\t\t : __builtin_signbit(x))";
3112 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3113 test_text = <<- _EOText_
3114 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3115 #undef signbit
3116 #define signbit(x) __builtin_signbit(x)
3117 _EOText_;
3120 fix = {
3121 hackname = solaris_math_9;
3122 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3123 bypass = "__GNUC__";
3124 files = iso/math_c99.h;
3125 c_fix = format;
3126 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3127 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3128 test_text =
3129 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3130 "#undef isgreater\n"
3131 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3132 "#undef isgreaterequal\n"
3133 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3134 "#undef isless\n"
3135 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3136 "#undef islessequal\n"
3137 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3138 "#undef islessgreater\n"
3139 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3140 "#undef isunordered\n"
3141 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3145 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3146 * exception. Provide an alternative using GCC's builtin.
3149 fix = {
3150 hackname = solaris_math_10;
3151 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3152 files = iso/math_c99.h;
3153 c_fix = format;
3154 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3155 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3156 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3157 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3158 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3159 test_text =
3160 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3161 "#undef isinf\n"
3162 "#define isinf(x) __extension__( \\\\\n"
3163 " { __typeof(x) __x_i = (x); \\\\\n"
3164 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3165 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3169 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3170 * "0" for the last field of the pthread_mutex_t structure, which is
3171 * of type upad64_t, which itself is typedef'd to int64_t, but with
3172 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3173 * initializer to "{0}" instead
3175 fix = {
3176 hackname = solaris_mutex_init_2;
3177 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3178 files = pthread.h;
3180 * On Solaris 10, this fix is unnecessary because upad64_t is
3181 * always defined correctly regardless of the definition of the
3182 * __STDC__ macro. The first "mach" pattern matches up to
3183 * solaris9. The second "mach" pattern will not match any two (or
3184 * more) digit solaris version, but it will match e.g. 2.5.1.
3186 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3187 c_fix = format;
3188 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3189 "%0\n"
3190 "#else\n"
3191 "%1, {0}}%4\n"
3192 "#endif";
3193 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3194 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3195 ",[ \t]*0\\}" "(|[ \t].*)$";
3196 test_text =
3197 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3198 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3199 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3200 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3201 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3202 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3203 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3208 * The pow overloads with int were removed in C++ 2011.
3210 fix = {
3211 hackname = solaris_pow_int_overload;
3212 mach = '*-*-solaris2*';
3213 files = "iso/math_iso.h";
3214 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3215 " *\\{[^{}]*\n[^{}]*\\}";
3216 c_fix = format;
3217 c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif";
3219 test_text =
3220 " inline long double pow(long double __X, int __Y) { return\n"
3221 " __powl(__X, (long double) (__Y)); }";
3226 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3227 * fields of the pthread_rwlock_t structure, which are of type
3228 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3229 * defined (e.g. by -ansi) it is a union. So change the initializer
3230 * to "{0}" instead.
3232 fix = {
3233 hackname = solaris_rwlock_init_1;
3234 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3235 files = pthread.h;
3236 mach = '*-*-solaris*';
3237 c_fix = format;
3238 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3239 "%0\n"
3240 "#else\n"
3241 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3242 "#endif";
3243 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3244 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3246 test_text =
3247 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3248 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3253 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3254 * structure. As such, it need two levels of brackets, but only
3255 * contains one. Wrap the macro definition in an extra layer.
3257 fix = {
3258 hackname = solaris_once_init_1;
3259 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3260 files = pthread.h;
3261 mach = '*-*-solaris*';
3262 c_fix = format;
3263 c_fix_arg = "%1{%2}%3";
3264 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3265 test_text =
3266 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3267 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3272 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3273 * fields of the pthread_once_t structure, which are of type
3274 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3275 * defined (e.g. by -ansi) it is a union. So change the initializer
3276 * to "{0}" instead. This test relies on solaris_once_init_1.
3278 fix = {
3279 hackname = solaris_once_init_2;
3280 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3281 files = pthread.h;
3283 * On Solaris 10, this fix is unnecessary because upad64_t is
3284 * always defined correctly regardless of the definition of the
3285 * __STDC__ macro. The first "mach" pattern matches up to
3286 * solaris9. The second "mach" pattern will not match any two (or
3287 * more) digit solaris version, but it will match e.g. 2.5.1.
3289 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3290 c_fix = format;
3291 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3292 "%0\n"
3293 "#else\n"
3294 "%1{0}, {0}, {0}, {%3}%4\n"
3295 "#endif";
3296 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3297 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3298 test_text =
3299 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3300 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3305 * Sun Solaris 2 has a version of sys/int_const.h that defines
3306 * UINT8_C and UINT16_C to unsigned constants.
3308 fix = {
3309 hackname = solaris_int_const;
3310 files = sys/int_const.h;
3311 mach = '*-*-solaris2*';
3312 c_fix = format;
3313 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3314 "%1\n"
3315 "#define\tUINT16_C(c)\t(c)";
3316 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3317 "(/\*.*\*/)\n"
3318 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3319 test_text =
3320 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3321 "/* CSTYLED */\n"
3322 "#define UINT16_C(c) __CONCAT__(c,u)";
3327 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3328 * UINT8_MAX and UINT16_MAX to unsigned constants.
3330 fix = {
3331 hackname = solaris_int_limits_1;
3332 files = sys/int_limits.h;
3333 mach = '*-*-solaris2*';
3334 c_fix = format;
3335 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3336 "#define\tUINT16_MAX\t(65535)";
3337 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3338 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3339 test_text =
3340 "#define UINT8_MAX (255U)\n"
3341 "#define UINT16_MAX (65535U)";
3346 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3347 * INT_FAST16 limits to wrong values for sys/int_types.h.
3349 fix = {
3350 hackname = solaris_int_limits_2;
3351 files = sys/int_limits.h;
3352 mach = '*-*-solaris2*';
3353 c_fix = format;
3354 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3355 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3356 test_text =
3357 "#define INT_FAST16_MAX INT16_MAX\n"
3358 "#define UINT_FAST16_MAX UINT16_MAX\n"
3359 "#define INT_FAST16_MIN INT16_MIN";
3364 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3365 * SIZE_MAX as unsigned long.
3367 fix = {
3368 hackname = solaris_int_limits_3;
3369 files = sys/int_limits.h;
3370 mach = '*-*-solaris2*';
3371 c_fix = format;
3372 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3373 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3374 test_text =
3375 "#define SIZE_MAX 4294967295UL";
3380 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3381 * of Standard C99 64-bit types in 32-bit mode.
3383 fix = {
3384 hackname = solaris_int_types;
3385 select = "__STDC__ - 0 == 0";
3386 bypass = "_LONGLONG_TYPE";
3387 files = sys/int_types.h;
3388 c_fix = format;
3389 c_fix_arg =
3390 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3391 test_text =
3392 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3393 "typedef long long int64_t;\n"
3394 "#endif\n\n"
3395 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3396 "typedef int64_t intmax_t;\n"
3397 "#endif";
3402 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3403 * posix_spawn declarations, which doesn't work with C++.
3405 fix = {
3406 hackname = solaris_posix_spawn_restrict;
3407 files = spawn.h;
3408 mach = '*-*-solaris2*';
3409 c_fix = format;
3410 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3411 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3412 test_text =
3413 "char *const argv[_RESTRICT_KYWD],\n"
3414 "char *const envp[_RESTRICT_KYWD]);";
3419 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3420 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3422 fix = {
3423 hackname = solaris_std___filbuf;
3424 files = stdio.h;
3425 mach = '*-*-solaris2*';
3426 bypass = "using std::__filbuf";
3427 select = "(using std::perror;\n)(#endif)";
3428 c_fix = format;
3429 c_fix_arg = "%1#ifndef _LP64\n"
3430 "using std::__filbuf;\n"
3431 "using std::__flsbuf;\n"
3432 "#endif\n%2";
3434 test_text = "using std::perror;\n"
3435 "#endif";
3440 * Sun Solaris 8 has what appears to be some gross workaround for
3441 * some old version of their c++ compiler. G++ doesn't want it
3442 * either, but doesn't want to be tied to SunPRO version numbers.
3444 fix = {
3445 hackname = solaris_stdio_tag;
3446 files = stdio_tag.h;
3448 select = '__cplusplus < 54321L';
3449 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3450 "!defined(__GNUC__)" so we no longer need to fix it. */
3451 bypass = '__GNUC__';
3452 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3454 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3459 * On Solaris 9, __va_list needs to become a typedef for
3460 * __builtin_va_list to make -Wmissing-format-attribute work.
3462 fix = {
3463 hackname = solaris_sys_va_list;
3464 files = sys/va_list.h;
3465 mach = '*-*-solaris2.9';
3466 select = "#if.*__STDC__.*\n"
3467 "typedef void \\*__va_list;\n"
3468 "#else\n"
3469 "typedef char \\*__va_list;\n"
3470 "#endif";
3472 c_fix = format;
3473 c_fix_arg = "#ifdef __GNUC__\n"
3474 "typedef __builtin_va_list __va_list;\n"
3475 "#else\n"
3476 "%0\n"
3477 "#endif";
3478 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3479 "typedef void *__va_list;\n"
3480 "#else\n"
3481 "typedef char *__va_list;\n"
3482 "#endif";
3487 * a missing semi-colon at the end of the statsswtch structure definition.
3489 fix = {
3490 hackname = statsswtch;
3491 files = rpcsvc/rstat.h;
3492 select = "boottime$";
3493 c_fix = format;
3494 c_fix_arg = "boottime;";
3495 test_text = "struct statswtch {\n int boottime\n};";
3500 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3501 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3502 * OK too.
3504 fix = {
3505 hackname = stdio_stdarg_h;
3506 files = stdio.h;
3507 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3509 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3510 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3512 mach = '*-*-solaris2.1[0-9]*';
3513 not_machine = true;
3515 c_fix = wrap;
3517 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3519 test_text = "";
3524 * Don't use or define the name va_list in stdio.h. This is for
3525 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3526 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3527 * indicate that the header knows what it's doing -- under SUSv2,
3528 * stdio.h is required to define va_list, and we shouldn't break
3529 * that.
3531 fix = {
3532 hackname = stdio_va_list;
3533 files = stdio.h;
3534 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3536 * On Solaris 10, the definition in
3537 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3538 * there is therefore no need for this fix there.
3540 mach = '*-*-solaris2.1[0-9]*';
3541 not_machine = true;
3544 * Use __gnuc_va_list in arg types in place of va_list.
3545 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3546 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3547 * trailing parentheses and semicolon save all other systems from this.
3548 * Define __not_va_list__ (something harmless and unused)
3549 * instead of va_list.
3550 * Don't claim to have defined va_list.
3552 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3553 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3554 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3555 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3556 "s@ va_list@ __not_va_list__@\n"
3557 "s@\\*va_list@*__not_va_list__@\n"
3558 "s@ __va_list)@ __gnuc_va_list)@\n"
3559 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3560 "@typedef \\1 __not_va_list__;@\n"
3561 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3562 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3563 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3564 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3565 "s@VA_LIST@DUMMY_VA_LIST@\n"
3566 "s@_Va_LIST@_VA_LIST@";
3567 test_text = "extern void mumble( va_list);";
3572 * Fix headers that use va_list from stdio.h to use the updated
3573 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3574 * dealt with elsewhere. The presence of __gnuc_va_list,
3575 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3576 * knows what it's doing.
3578 fix = {
3579 hackname = stdio_va_list_clients;
3580 files = com_err.h;
3581 files = cps.h;
3582 files = curses.h;
3583 files = krb5.h;
3584 files = lc_core.h;
3585 files = pfmt.h;
3586 files = wchar.h;
3587 files = curses_colr/curses.h;
3588 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3589 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3590 otherwise protected. */
3591 bypass = 'include <stdarg\.h>|#ifdef va_start';
3594 * Use __gnuc_va_list in arg types in place of va_list.
3595 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3596 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3597 * trailing parentheses and semicolon save all other systems from this.
3598 * Define __not_va_list__ (something harmless and unused)
3599 * instead of va_list.
3600 * Don't claim to have defined va_list.
3602 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3603 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3604 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3605 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3606 "s@ va_list@ __not_va_list__@\n"
3607 "s@\\*va_list@*__not_va_list__@\n"
3608 "s@ __va_list)@ __gnuc_va_list)@\n"
3609 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3610 "@typedef \\1 __not_va_list__;@\n"
3611 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3612 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3613 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3614 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3615 "s@VA_LIST@DUMMY_VA_LIST@\n"
3616 "s@_Va_LIST@_VA_LIST@";
3617 test_text = "extern void mumble( va_list);";
3622 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3623 * is "!defined( __STRICT_ANSI__ )"
3625 fix = {
3626 hackname = strict_ansi_not;
3627 select = "^([ \t]*#[ \t]*if.*)"
3628 "(!__STDC__"
3629 "|__STDC__[ \t]*==[ \t]*0"
3630 "|__STDC__[ \t]*!=[ \t]*1"
3631 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3632 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3633 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3634 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3635 is not defined by GCC, so it is safe. */
3636 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3637 c_test = stdc_0_in_system_headers;
3639 c_fix = format;
3640 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3642 test_text = "#if !__STDC__ \n"
3643 "#if __STDC__ == 0\n"
3644 "#if __STDC__ != 1\n"
3645 "#if __STDC__ - 0 == 0"
3646 "/* not std C */\nint foo;\n"
3647 "\n#end-end-end-end-if :-)";
3651 * "__STDC__-0==0"
3652 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3654 fix = {
3655 hackname = strict_ansi_not_ctd;
3656 files = math.h, limits.h, stdio.h, signal.h,
3657 stdlib.h, sys/signal.h, time.h;
3659 * Starting at the beginning of a line, skip white space and
3660 * a leading "(" or "&&" or "||". One of those must be found.
3661 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3662 * expression. If these are nested, then they must accumulate
3663 * because we won't match any closing parentheses. Finally,
3664 * after skipping over all that, we must then match our suspect
3665 * phrase: "__STDC__-0==0" with or without white space.
3667 select = "^([ \t]*" '(\(|&&|\|\|)'
3668 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3669 "[ \t(]*)"
3670 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3671 c_test = stdc_0_in_system_headers;
3673 c_fix = format;
3674 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3676 test_text = "#if 1 && \\\\\n"
3677 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3678 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3679 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3680 "int foo;\n#endif";
3685 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3686 * is "defined( __STRICT_ANSI__ )"
3688 fix = {
3689 hackname = strict_ansi_only;
3690 select = "^([ \t]*#[ \t]*if.*)"
3691 "(__STDC__[ \t]*!=[ \t]*0"
3692 "|__STDC__[ \t]*==[ \t]*1"
3693 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3694 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3695 c_test = stdc_0_in_system_headers;
3697 c_fix = format;
3698 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3700 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3705 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3706 * in prototype without previous definition.
3708 fix = {
3709 hackname = struct_file;
3710 files = rpc/xdr.h;
3711 select = '^.*xdrstdio_create.*struct __file_s';
3712 c_fix = format;
3713 c_fix_arg = "struct __file_s;\n%0";
3714 test_text = "extern void xdrstdio_create( struct __file_s* );";
3719 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3720 * in prototype without previous definition.
3722 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3723 * function, and does define it.
3725 fix = {
3726 hackname = struct_sockaddr;
3727 files = rpc/auth.h;
3728 select = "^.*authdes_create.*struct sockaddr[^_]";
3729 bypass = "<sys/socket\.h>";
3730 bypass = "struct sockaddr;\n";
3731 c_fix = format;
3732 c_fix_arg = "struct sockaddr;\n%0";
3733 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3738 * Apply fix this to all OSs since this problem seems to effect
3739 * more than just SunOS.
3741 fix = {
3742 hackname = sun_auth_proto;
3743 files = rpc/auth.h;
3744 files = rpc/clnt.h;
3745 files = rpc/svc.h;
3746 files = rpc/xdr.h;
3747 bypass = "__cplusplus";
3749 * Select those files containing '(*name)()'.
3751 select = '\(\*[a-z][a-z_]*\)\(\)';
3753 c_fix = format;
3754 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3755 "#else\n%1();%2\n#endif";
3756 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3758 test_text =
3759 "struct auth_t {\n"
3760 " int (*name)(); /* C++ bad */\n"
3761 "};";
3766 * Fix bogus #ifdef on SunOS 4.1.
3768 fix = {
3769 hackname = sun_bogus_ifdef;
3770 files = "hsfs/hsfs_spec.h";
3771 files = "hsfs/iso_spec.h";
3772 select = '#ifdef(.*\|\|.*)';
3773 c_fix = format;
3774 c_fix_arg = "#if%1";
3776 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3781 * Fix the CAT macro in SunOS memvar.h.
3783 fix = {
3784 hackname = sun_catmacro;
3785 files = pixrect/memvar.h;
3786 select = "^#define[ \t]+CAT\\(a,b\\).*";
3787 c_fix = format;
3789 c_fix_arg =
3790 "#ifdef __STDC__\n"
3791 "# define CAT(a,b) a##b\n"
3792 "#else\n%0\n#endif";
3794 test_text =
3795 "#define CAT(a,b)\ta/**/b";
3800 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3801 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3803 fix = {
3804 hackname = sun_malloc;
3805 files = malloc.h;
3806 bypass = "_CLASSIC_ANSI_TYPES";
3808 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3809 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3810 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3811 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3812 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3814 test_text =
3815 "typedef char *\tmalloc_t;\n"
3816 "int \tfree();\n"
3817 "char*\tmalloc();\n"
3818 "char*\tcalloc();\n"
3819 "char*\trealloc();";
3824 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3826 fix = {
3827 hackname = sun_rusers_semi;
3828 files = rpcsvc/rusers.h;
3829 select = "_cnt$";
3830 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3831 test_text = "struct mumble\n int _cnt\n};";
3836 * signal.h on SunOS defines signal using (),
3837 * which causes trouble when compiling with g++ -pedantic.
3839 fix = {
3840 hackname = sun_signal;
3841 files = sys/signal.h;
3842 files = signal.h;
3843 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3845 c_fix = format;
3846 c_fix_arg =
3847 "#ifdef __cplusplus\n"
3848 "void\t(*signal(...))(...);\n"
3849 "#else\n%0\n#endif";
3851 test_text = "void\t(*signal())();";
3856 * Correct the return type for strlen in strings.h in SunOS 4.
3858 fix = {
3859 hackname = sunos_strlen;
3860 files = strings.h;
3861 select = "int[ \t]*strlen\\(\\);(.*)";
3862 c_fix = format;
3863 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3864 test_text = " int\tstrlen(); /* string length */";
3869 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3870 * that is visible to any ANSI compiler using this include. Simply
3871 * delete the lines that #define some string functions to internal forms.
3873 fix = {
3874 hackname = svr4_disable_opt;
3875 files = string.h;
3876 select = '#define.*__std_hdr_';
3877 sed = '/#define.*__std_hdr_/d';
3878 test_text = "#define strlen __std_hdr_strlen\n";
3883 * Fix broken decl of getcwd present on some svr4 systems.
3885 fix = {
3886 hackname = svr4_getcwd;
3887 files = stdlib.h;
3888 files = unistd.h;
3889 files = prototypes.h;
3890 select = 'getcwd\(char \*, int\)';
3892 c_fix = format;
3893 c_fix_arg = "getcwd(char *, size_t)";
3895 test_text = "extern char* getcwd(char *, int);";
3900 * Fix broken decl of profil present on some svr4 systems.
3902 fix = {
3903 hackname = svr4_profil;
3904 files = stdlib.h;
3905 files = unistd.h;
3907 select =
3908 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3909 c_fix = format;
3910 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3912 test_text =
3913 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3918 * Correct types for signal handler constants like SIG_DFL; they might be
3919 * void (*) (), and should be void (*) (int). C++ doesn't like the
3920 * old style.
3922 fix = {
3923 hackname = svr4_sighandler_type;
3924 files = sys/signal.h;
3925 select = 'void *\(\*\)\(\)';
3926 c_fix = format;
3927 c_fix_arg = "void (*)(int)";
3928 test_text = "#define SIG_DFL (void(*)())0\n"
3929 "#define SIG_IGN (void (*)())0\n";
3934 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
3935 * function 'getrnge' in <regexp.h> before they declare it. For these
3936 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
3937 * early on.
3939 * 'getrnge' traditionally manipulates a file-scope global called 'size',
3940 * so put the declaration right after the declaration of 'size'.
3942 * Don't do this if there is already a `static void getrnge' declaration
3943 * present, since this would cause a redeclaration error. Solaris 2.x has
3944 * such a declaration.
3946 fix = {
3947 hackname = svr4_undeclared_getrnge;
3948 files = regexp.h;
3949 select = "getrnge";
3950 bypass = "static void getrnge";
3951 c_fix = format;
3952 c_fix_arg = "%0\n"
3953 "static int getrnge ();";
3954 c_fix_arg = "^static int[ \t]+size;";
3955 test_text = "static int size;\n"
3956 "/* stuff which calls getrnge() */\n"
3957 "static getrnge()\n"
3958 "{}";
3963 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
3964 * in string.h on sysV68
3965 * Correct the return type for strlen in string.h on Lynx.
3966 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
3967 * Add missing const for strdup on OSF/1 V3.0.
3968 * On sysV88 layout is slightly different.
3970 fix = {
3971 hackname = sysv68_string;
3972 files = testing.h;
3973 files = string.h;
3974 bypass = "_CLASSIC_ANSI_TYPES";
3976 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
3977 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
3978 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
3980 sed = "/^extern char$/N";
3981 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3983 sed = "/^extern int$/N";
3984 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3986 sed = "/^\tstrncmp(),$/N";
3987 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
3988 '\1;' "\\\nextern unsigned int\\\n\\2/";
3990 test_text =
3991 "extern int strlen();\n"
3993 "extern int ffs(long);\n"
3995 "extern char\n"
3996 "\t*memccpy(),\n"
3997 "\tmemcpy();\n"
3999 "extern int\n"
4000 "\tstrcmp(),\n"
4001 "\tstrncmp(),\n"
4002 "\tstrlen(),\n"
4003 "\tstrspn();\n"
4005 "extern int\n"
4006 "\tstrlen(), strspn();";
4011 * Fix return type of calloc, malloc, realloc, bsearch and exit
4013 fix = {
4014 hackname = sysz_stdlib_for_sun;
4015 files = stdlib.h;
4016 bypass = "_CLASSIC_ANSI_TYPES";
4018 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4019 c_fix = format;
4020 c_fix_arg = "void *\t%1(";
4022 test_text =
4023 "extern char*\tcalloc(size_t);\n"
4024 "extern char*\tmalloc(size_t);\n"
4025 "extern char*\trealloc(void*,size_t);\n"
4026 "extern char*\tbsearch(void*,size_t,size_t);\n";
4031 * __thread is now a keyword.
4033 fix = {
4034 hackname = thread_keyword;
4035 files = "pthread.h";
4036 files = "bits/sigthread.h";
4037 select = "([* ])__thread([,)])";
4038 c_fix = format;
4039 c_fix_arg = "%1__thr%2";
4041 test_text =
4042 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4043 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4044 "extern int pthread_cancel (pthread_t __thread);";
4048 * if the #if says _cplusplus, not the double underscore __cplusplus
4049 * that it should be
4051 fix = {
4052 hackname = tinfo_cplusplus;
4053 files = tinfo.h;
4054 select = "[ \t]_cplusplus";
4056 c_fix = format;
4057 c_fix_arg = " __cplusplus";
4058 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4063 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4065 fix = {
4066 hackname = ultrix_const;
4067 files = stdio.h;
4068 select = 'perror\( char \*';
4070 c_fix = format;
4071 c_fix_arg = "%1 const %3 *__";
4072 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4073 "[ \t]+(char|void) \\*__";
4075 test_text =
4076 "extern void perror( char *__s );\n"
4077 "extern int fputs( char *__s, FILE *);\n"
4078 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4079 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4080 "extern int scanf( char *__format, ...);\n";
4085 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4087 fix = {
4088 hackname = ultrix_const2;
4089 files = stdio.h;
4091 select = '\*fopen\( char \*';
4092 c_fix = format;
4093 c_fix_arg = "%1( const char *%3, const char *";
4094 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4095 "[ \t]*char[ \t]*\\*([^,]*),"
4096 "[ \t]*char[ \t]*\\*[ \t]*";
4098 test_text =
4099 "extern FILE *fopen( char *__filename, char *__type );\n"
4100 "extern int sscanf( char *__s, char *__format, ...);\n"
4101 "extern FILE *popen(char *, char *);\n"
4102 "extern char *tempnam(char*,char*);\n";
4107 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4109 fix = {
4110 hackname = va_i960_macro;
4111 files = arch/i960/archI960.h;
4112 select = "__(vsiz|vali|vpad|alignof__)";
4114 c_fix = format;
4115 c_fix_arg = "__vx%1";
4117 test_text =
4118 "extern int __vsiz vsiz;\n"
4119 "extern int __vali vali;\n"
4120 "extern int __vpad vpad;\n"
4121 "#define __alignof__(x) ...";
4126 * Define __CAN_USE_EXTERN_PREFIX on vms.
4128 fix = {
4129 hackname = vms_define_can_use_extern_prefix;
4130 files = "rtldef/decc$types.h";
4131 select = "#[ \t]*else\n"
4132 "#[ \t]*if defined\\(__DECCXX\\)\n"
4133 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4134 mach = "*-*-*vms*";
4135 c_fix = format;
4137 c_fix_arg = "%0"
4138 "# elif defined (__GNUC__)\n"
4139 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4141 test_text = "# else\n"
4142 "# if defined(__DECCXX)\n"
4143 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4144 "# endif\n"
4145 "# endif\n";
4149 * On VMS, use pragma extern_model instead of VAX-C keywords.
4151 fix = {
4152 hackname = vms_use_pragma_extern_model;
4153 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4154 "# pragma extern_model __save\n";
4155 mach = "*-*-*vms*";
4156 c_fix = format;
4158 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4159 "# pragma extern_model __save\n";
4161 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4162 "# pragma extern_model __save\n"
4163 "# pragma extern_model strict_refdef\n"
4164 " extern struct x zz$yy;\n"
4165 "# pragma extern_model __restore\n"
4166 "#endif\n";
4170 * On VMS, disable the use of dec-c string builtins
4172 fix = {
4173 hackname = vms_disable_decc_string_builtins;
4174 select = "#if !defined\\(__VAX\\)\n";
4175 mach = "*-*-*vms*";
4176 files = "rtldef/string.h";
4177 c_fix = format;
4179 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4181 test_text = "#if !defined(__VAX)\n";
4185 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4186 * conflict while building gcc. Likewise for <builtins.h>
4188 fix = {
4189 hackname = vms_use_quoted_include;
4190 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4191 mach = "*-*-*vms*";
4192 files = rtldef/wait.h, starlet_c/pthread.h;
4193 c_fix = format;
4195 c_fix_arg = '%1<sys/%2.h>';
4197 test_text = "# include <resource.h>";
4201 * On VMS, add missing braces around sigset_t constants.
4203 fix = {
4204 hackname = vms_add_missing_braces;
4205 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4206 mach = "*-*-*vms*";
4207 files = "rtldef/signal.h";
4208 c_fix = format;
4210 c_fix_arg = '%1 {%2} ';
4212 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4213 "{0x00000000, 0x00000000},\n"
4214 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4218 * On VMS, fix incompatible redeclaration of hostalias.
4220 fix = {
4221 hackname = vms_do_not_redeclare_hostalias;
4222 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4223 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4224 mach = "*-*-*vms*";
4225 files = "rtldef/resolv.h";
4226 c_fix = format;
4228 c_fix_arg = "%1\n"
4229 "/* %2 */";
4231 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4232 "__char_ptr32 hostalias (const char *);\n";
4236 * On VMS, some DEC-C builtins are directly used.
4238 fix = {
4239 hackname = vms_decc_builtin;
4240 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4241 mach = "*-*-*vms*";
4242 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4243 rtldef/socket.h;
4244 sed = "s@__MEMSET@memset@";
4245 sed = "s@__MEMMOVE@memmove@";
4246 sed = "s@__MEMCPY@memcpy@";
4247 sed = "s@__STRLEN@strlen@";
4248 sed = "s@__STRCPY@strcpy@";
4250 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4254 * On VMS, do not declare getopt and al if pointers are 64 bit.
4256 fix = {
4257 hackname = vms_no_64bit_getopt;
4258 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4259 /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
4260 mach = "*-*-*vms*";
4261 files = rtldef/stdio.h, rtldef/unistd.h;
4262 c_fix = format;
4264 c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n"
4265 "%0"
4266 "#endif\n";
4268 test_text = "int getopt (int, char * const [], const char *);";
4272 * On VMS, forward declare structure before referencing them in prototypes.
4274 fix = {
4275 hackname = vms_forward_declare_struct;
4276 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4277 "#ifdef __cplusplus\n";
4278 mach = "*-*-*vms*";
4279 files = rtldef/if.h;
4280 c_fix = format;
4282 c_fix_arg = "%1"
4283 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4285 test_text = "/* forward decls for C++ */\n"
4286 "#ifdef __cplusplus\n"
4287 "struct foo;\n"
4288 "#endif\n";
4292 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4293 * which is not yet fully supported by gcc.
4295 fix = {
4296 hackname = vms_use_fast_setjmp;
4297 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4298 mach = "*-*-*vms*";
4299 files = rtldef/setjmp.h;
4300 c_fix = format;
4302 c_fix_arg = "%0 defined (__GNUC__) ||";
4304 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4308 * AIX and Interix headers define NULL to be cast to a void pointer,
4309 * which is illegal in ANSI C++.
4311 fix = {
4312 hackname = void_null;
4313 files = curses.h;
4314 files = dbm.h;
4315 files = locale.h;
4316 files = stdio.h;
4317 files = stdlib.h;
4318 files = string.h;
4319 files = time.h;
4320 files = unistd.h;
4321 files = sys/dir.h;
4322 files = sys/param.h;
4323 files = sys/types.h;
4324 /* avoid changing C++ friendly NULL */
4325 bypass = __cplusplus;
4326 bypass = __null;
4327 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4328 c_fix = format;
4329 c_fix_arg = "#define NULL 0";
4330 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4335 * Make VxWorks header which is almost gcc ready fully gcc ready.
4337 fix = {
4338 hackname = vxworks_gcc_problem;
4339 files = types/vxTypesBase.h;
4340 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4342 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4343 "#if 1/";
4345 sed = "/[ \t]size_t/i\\\n"
4346 "#ifndef _GCC_SIZE_T\\\n"
4347 "#define _GCC_SIZE_T\n";
4349 sed = "/[ \t]size_t/a\\\n"
4350 "#endif\n";
4352 sed = "/[ \t]ptrdiff_t/i\\\n"
4353 "#ifndef _GCC_PTRDIFF_T\\\n"
4354 "#define _GCC_PTRDIFF_T\n";
4356 sed = "/[ \t]ptrdiff_t/a\\\n"
4357 "#endif\n";
4359 sed = "/[ \t]wchar_t/i\\\n"
4360 "#ifndef _GCC_WCHAR_T\\\n"
4361 "#define _GCC_WCHAR_T\n";
4363 sed = "/[ \t]wchar_t/a\\\n"
4364 "#endif\n";
4366 test_text =
4367 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4368 "typedef unsigned int size_t;\n"
4369 "typedef long ptrdiff_t;\n"
4370 "typedef unsigned short wchar_t;\n"
4371 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4376 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4378 fix = {
4379 hackname = vxworks_needs_vxtypes;
4380 files = time.h;
4381 select = "uint_t([ \t]+_clocks_per_sec)";
4382 c_fix = format;
4383 c_fix_arg = "unsigned int%1";
4384 test_text = "uint_t\t_clocks_per_sec;";
4389 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4391 fix = {
4392 hackname = vxworks_needs_vxworks;
4393 files = sys/stat.h;
4394 test = " -r types/vxTypesOld.h";
4395 test = " -n \"`egrep '#include' $file`\"";
4396 test = " -n \"`egrep ULONG $file`\"";
4397 select = "#[ \t]define[ \t]+__INCstath";
4399 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4400 "#include <types/vxTypesOld.h>\n";
4402 test_text = "`touch types/vxTypesOld.h`"
4403 "#include </dev/null> /* ULONG */\n"
4404 "# define\t__INCstath <sys/stat.h>";
4409 * Another bad dependency in VxWorks 5.2 <time.h>.
4411 fix = {
4412 hackname = vxworks_time;
4413 files = time.h;
4414 test = " -r vxWorks.h";
4416 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4417 c_fix = format;
4419 c_fix_arg =
4420 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4421 "#ifdef __cplusplus\n"
4422 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4423 "#else\n"
4424 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4425 "#endif\n"
4426 "#define __gcc_VOIDFUNCPTR_defined\n"
4427 "#endif\n"
4428 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4430 test_text = "`touch vxWorks.h`"
4431 "#define VOIDFUNCPTR (void(*)())";
4436 * There are several name conflicts with C++ reserved words in X11 header
4437 * files. These are fixed in some versions, so don't do the fixes if
4438 * we find __cplusplus in the file. These were found on the RS/6000.
4440 fix = {
4441 hackname = x11_class;
4442 files = X11/ShellP.h;
4443 bypass = __cplusplus;
4444 select = "^([ \t]*char \\*)class;(.*)";
4445 c_fix = format;
4446 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4447 "#else\n%1class;%2\n#endif";
4448 test_text =
4449 "struct {\n"
4450 " char *class;\n"
4451 "} mumble;\n";
4456 * class in Xm/BaseClassI.h
4458 fix = {
4459 hackname = x11_class_usage;
4460 files = Xm/BaseClassI.h;
4461 bypass = "__cplusplus";
4463 select = " class\\)";
4464 c_fix = format;
4465 c_fix_arg = " c_class)";
4467 test_text = "extern mumble (int class);\n";
4472 * new in Xm/Traversal.h
4474 fix = {
4475 hackname = x11_new;
4476 files = Xm/Traversal.h;
4477 bypass = __cplusplus;
4479 sed = "/Widget\told, new;/i\\\n"
4480 "#ifdef __cplusplus\\\n"
4481 "\\\tWidget\told, c_new;\\\n"
4482 "#else\n";
4484 sed = "/Widget\told, new;/a\\\n"
4485 "#endif\n";
4487 sed = "s/Widget new,/Widget c_new,/g";
4488 test_text =
4489 "struct wedge {\n"
4490 " Widget\told, new;\n"
4491 "};\nextern Wedged( Widget new, Widget old );";
4496 * Incorrect sprintf declaration in X11/Xmu.h
4498 fix = {
4499 hackname = x11_sprintf;
4500 files = X11/Xmu.h;
4501 files = X11/Xmu/Xmu.h;
4502 select = "^extern char \\*\tsprintf\\(\\);$";
4504 c_fix = format;
4505 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4507 test_text = "extern char *\tsprintf();";
4510 /*EOF*/