Remove extra blank line.
[official-gcc.git] / fixincludes / inclhack.def
bloba615194c743f685abb95e586f00b792fd8d71a02
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_;
68 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
69 * open64 and creat to creat64. This fixes fcntl.h to
70 * undef those defines and use __asm__ to alias the symbols if
71 * building with g++ and -D_LARGE_FILES
73 fix = {
74 hackname = AAB_aix_fcntl;
75 files = fcntl.h;
76 select = "define open[ \t]open64";
77 mach = "*-*-aix*";
78 test-text = ''; /* no way to test */
80 c_fix = wrap;
82 c_fix_arg = "";
84 c_fix_arg = <<- _EOArg_
86 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
87 #define __need__aix_fcntl_h_fix
88 #ifdef __need__aix_fcntl_h_fix
89 #undef open
90 #undef creat
91 #undef openat
92 /* Alias the symbols using asm */
93 extern "C" {
94 extern int open(const char *, int, ...) __asm__("open64");
95 extern int creat(const char *, mode_t) __asm__("creat64");
96 #if (_XOPEN_SOURCE >= 700)
97 extern int openat(int, const char *, int, ...) __asm__("open64at");
98 #endif
100 #endif
101 #endif
103 _EOArg_;
108 * On Mac OS 10.3.9, the 'long double' functions are available in
109 * libSystem, but are not prototyped in math.h.
111 fix = {
112 hackname = AAB_darwin7_9_long_double_funcs;
113 mach = "*-*-darwin7.9*";
114 files = architecture/ppc/math.h;
115 bypass = "powl";
116 replace = <<- _EndOfHeader_
117 /* This file prototypes the long double functions available on Mac OS
118 10.3.9. */
119 #ifndef __MATH__
120 # undef __APPLE_CC__
121 # define __APPLE_CC__ 1345
122 # include_next <architecture/ppc/math.h>
123 # undef __APPLE_CC__
124 # define __APPLE_CC__ 1
125 # ifndef __LIBMLDBL_COMPAT
126 # ifdef __LONG_DOUBLE_128__
127 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
128 # else
129 # define __LIBMLDBL_COMPAT(sym)
130 # endif /* __LONG_DOUBLE_128__ */
131 # endif /* __LIBMLDBL_COMPAT */
132 # ifdef __cplusplus
133 extern "C" {
134 # endif
135 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
136 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
137 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
138 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
139 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
140 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
141 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
142 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
143 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
144 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
145 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
146 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
147 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
148 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
149 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
150 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
151 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
152 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
153 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
154 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
155 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
156 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
157 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
158 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
159 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
160 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
161 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
162 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
163 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
164 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
165 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
166 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
167 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
168 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
169 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
170 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
171 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
172 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
173 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
174 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
175 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
176 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
177 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
178 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
179 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
180 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
181 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
182 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
183 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
184 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
185 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
186 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
187 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
188 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
189 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
190 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
191 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
192 # ifdef __cplusplus
194 # endif
195 #endif /* __MATH__ */
196 _EndOfHeader_;
201 * ... and for the previous fix to be useful, you have to not use ""
202 * includes.
204 fix = {
205 hackname = AAB_darwin7_9_long_double_funcs_2;
206 mach = "*-*-darwin7.9*";
207 files = math.h;
208 select = '#include[ \t]+\"';
209 c_fix = format;
210 c_fix_arg = "%1<%2.h>";
212 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
214 test_text = '#include "architecture/ppc/math.h"';
219 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
221 fix = {
222 hackname = AAB_fd_zero_asm_posix_types_h;
223 files = asm/posix_types.h;
224 mach = 'i[34567]86-*-linux*';
225 bypass = '} while';
226 bypass = 'x86_64';
227 bypass = 'posix_types_64';
230 * Define _POSIX_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 <asm/posix_types.h>.
235 replace = <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro
237 for older versions of the Linux kernel. */
238 #ifndef _POSIX_TYPES_H_WRAPPER
239 #include <features.h>
240 #include_next <asm/posix_types.h>
242 #if defined(__FD_ZERO) && !defined(__GLIBC__)
243 #undef __FD_ZERO
244 #define __FD_ZERO(fdsetp) \
245 do { \
246 int __d0, __d1; \
247 __asm__ __volatile__("cld ; rep ; stosl" \
248 : "=&c" (__d0), "=&D" (__d1) \
249 : "a" (0), "0" (__FDSET_LONGS), \
250 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
251 } while (0)
252 #endif
254 #define _POSIX_TYPES_H_WRAPPER
255 #endif /* _POSIX_TYPES_H_WRAPPER */
256 _EndOfHeader_;
261 * This fixes __FD_ZERO bug for glibc-1.x
263 fix = {
264 hackname = AAB_fd_zero_gnu_types_h;
265 files = gnu/types.h;
266 mach = 'i[34567]86-*-linux*';
269 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
270 * the start, so that if #include_next gets another instance of
271 * the wrapper, this will follow the #include_next chain until
272 * we arrive at the real <gnu/types.h>.
274 replace = <<- _EndOfHeader_
275 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
276 #ifndef _TYPES_H_WRAPPER
277 #include <features.h>
278 #include_next <gnu/types.h>
280 #if defined(__FD_ZERO) && !defined(__GLIBC__)
281 #undef __FD_ZERO
282 # define __FD_ZERO(fdsetp) \
283 do { \
284 int __d0, __d1; \
285 __asm__ __volatile__("cld ; rep ; stosl" \
286 : "=&c" (__d0), "=&D" (__d1) \
287 : "a" (0), "0" (__FDSET_LONGS), \
288 "1" ((__fd_set *) (fdsetp)) :"memory"); \
289 } while (0)
290 #endif
292 #define _TYPES_H_WRAPPER
293 #endif /* _TYPES_H_WRAPPER */
294 _EndOfHeader_;
299 * This fixes __FD_ZERO bug for glibc-2.0.x
301 fix = {
302 hackname = AAB_fd_zero_selectbits_h;
303 files = selectbits.h;
304 mach = 'i[34567]86-*-linux*';
307 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
308 * the start, so that if #include_next gets another instance of
309 * the wrapper, this will follow the #include_next chain until
310 * we arrive at the real <selectbits.h>.
312 replace = <<- _EndOfHeader_
313 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
314 #ifndef _SELECTBITS_H_WRAPPER
315 #include <features.h>
316 #include_next <selectbits.h>
318 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
319 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
320 && __GLIBC_MINOR__ == 0
321 #undef __FD_ZERO
322 #define __FD_ZERO(fdsetp) \\
323 do { \\
324 int __d0, __d1; \\
325 __asm__ __volatile__ ("cld; rep; stosl" \\
326 : "=&c" (__d0), "=&D" (__d1) \\
327 : "a" (0), "0" (sizeof (__fd_set) \\
328 / sizeof (__fd_mask)), \\
329 "1" ((__fd_mask *) (fdsetp)) \\
330 : "memory"); \\
331 } while (0)
332 #endif
334 #define _SELECTBITS_H_WRAPPER
335 #endif /* _SELECTBITS_H_WRAPPER */
336 _EndOfHeader_;
341 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
342 * the same interface as <stdarg.h>. No idea why they couldn't have just
343 * used the standard header.
345 fix = {
346 hackname = AAB_solaris_sys_varargs_h;
347 files = "sys/varargs.h";
348 mach = '*-*-solaris*';
349 replace = <<- _EndOfHeader_
350 #ifdef __STDC__
351 #include <stdarg.h>
352 #else
353 #include <varargs.h>
354 #endif
355 _EndOfHeader_;
360 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
361 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
362 * many other systems have similar text but correct versions of the file.
363 * To ensure only Sun's is fixed, we grep for a likely unique string.
364 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
366 fix = {
367 hackname = AAB_sun_memcpy;
368 files = memory.h;
369 select = "/\\*\t@\\(#\\)"
370 "(head/memory.h\t50.1\t "
371 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
373 replace = <<- _EndOfHeader_
374 /* This file was generated by fixincludes */
375 #ifndef __memory_h__
376 #define __memory_h__
378 #ifdef __STDC__
379 extern void *memccpy();
380 extern void *memchr();
381 extern void *memcpy();
382 extern void *memset();
383 #else
384 extern char *memccpy();
385 extern char *memchr();
386 extern char *memcpy();
387 extern char *memset();
388 #endif /* __STDC__ */
390 extern int memcmp();
392 #endif /* __memory_h__ */
393 _EndOfHeader_;
398 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
399 * which only is provided by AIX xlc C99.
401 fix = {
402 hackname = aix_complex;
403 mach = "*-*-aix*";
404 files = complex.h;
405 select = "#define[ \t]_Complex_I[ \t]__I";
406 c_fix = format;
407 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
408 test_text = "#define _Complex_I __I\n";
412 * malloc.h on AIX6 uses XLC++ specific builtin syntax
414 fix = {
415 hackname = aix_malloc;
416 mach = "*-*-aix*";
417 files = "malloc.h";
418 select = "#ifdef __cplusplus";
419 c_fix = format;
420 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
421 test_text = "#ifdef __cplusplus";
425 * net/if_arp.h defines a variable fc_softc instead of adding a
426 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
428 fix = {
429 hackname = aix_net_if_arp;
430 mach = "*-*-aix*";
431 files = "net/if_arp.h";
432 select = "^struct fc_softc \\{";
433 c_fix = format;
434 c_fix_arg = "typedef struct _fc_softc {";
435 test_text = "struct fc_softc {\n int a;\n};";
439 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
440 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
441 * braces.
443 fix = {
444 hackname = aix_once_init_1;
445 mach = "*-*-aix*";
446 files = "pthread.h";
447 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
448 "\\{ \\\\\n";
449 c_fix = format;
450 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
451 "{{ \\\n";
452 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
453 "{ \\\\\n";
456 fix = {
457 hackname = aix_once_init_2;
458 mach = "*-*-aix*";
459 files = "pthread.h";
460 select = "[ \t]0 \\\\\n"
461 "\\}\n";
462 c_fix = format;
463 c_fix_arg = " 0 \\\n"
464 "}}\n";
465 test_text = " 0 \\\\\n"
466 "}\n";
469 fix = {
470 hackname = aix_mutex_initializer_1;
471 mach = "*-*-aix*";
472 files = "pthread.h";
473 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
474 "\\{ \\\\\n";
475 c_fix = format;
476 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
477 "{{ \\\n";
478 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
479 "{ \\\\\n";
482 fix = {
483 hackname = aix_cond_initializer_1;
484 mach = "*-*-aix*";
485 files = "pthread.h";
486 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
487 "\\{ \\\\\n";
488 c_fix = format;
489 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
490 "{{ \\\n";
491 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
492 "{ \\\\\n";
495 fix = {
496 hackname = aix_rwlock_initializer_1;
497 mach = "*-*-aix*";
498 files = "pthread.h";
499 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
500 "\\{ \\\\\n";
501 c_fix = format;
502 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
503 "{{ \\\n";
504 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
505 "{ \\\\\n";
509 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
510 * which violates a requirement of ISO C.
512 fix = {
513 hackname = aix_pthread;
514 files = "pthread.h";
515 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
516 c_fix = format;
517 c_fix_arg = "%1 %2";
518 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
519 "{...init stuff...}";
524 * AIX stdint.h fixes.
526 fix = {
527 hackname = aix_stdint_1;
528 mach = "*-*-aix*";
529 files = stdint-aix.h, stdint.h;
530 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
531 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
532 c_fix = format;
533 c_fix_arg = "#define UINT8_MAX (255)\n"
534 "#define UINT16_MAX (65535)";
535 test_text = "#define UINT8_MAX (255U)\n"
536 "#define UINT16_MAX (65535U)";
540 fix = {
541 hackname = aix_stdint_2;
542 mach = "*-*-aix*";
543 files = stdint-aix.h, stdint.h;
544 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
545 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
546 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
547 "#else\n"
548 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
549 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
550 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
551 c_fix = format;
552 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
553 "#define INTPTR_MAX 9223372036854775807L\n"
554 "#define UINTPTR_MAX 18446744073709551615UL\n"
555 "#else\n"
556 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
557 "#define INTPTR_MAX 2147483647L\n"
558 "#define UINTPTR_MAX 4294967295UL";
559 test_text = "#define INTPTR_MIN INT64_MIN\n"
560 "#define INTPTR_MAX INT64_MAX\n"
561 "#define UINTPTR_MAX UINT64_MAX\n"
562 "#else\n"
563 "#define INTPTR_MIN INT32_MIN\n"
564 "#define INTPTR_MAX INT32_MAX\n"
565 "#define UINTPTR_MAX UINT32_MAX";
569 fix = {
570 hackname = aix_stdint_3;
571 mach = "*-*-aix*";
572 files = stdint-aix.h, stdint.h;
573 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
574 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
575 "#else\n"
576 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
577 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
578 c_fix = format;
579 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
580 "#define PTRDIFF_MAX 9223372036854775807L\n"
581 "#else\n"
582 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
583 "#define PTRDIFF_MAX 2147483647L";
584 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
585 "#define PTRDIFF_MAX INT64_MAX\n"
586 "#else\n"
587 "#define PTRDIFF_MIN INT32_MIN\n"
588 "#define PTRDIFF_MAX INT32_MAX";
592 fix = {
593 hackname = aix_stdint_4;
594 mach = "*-*-aix*";
595 files = stdint-aix.h, stdint.h;
596 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
597 "#else\n"
598 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
599 c_fix = format;
600 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
601 "#else\n"
602 "#define SIZE_MAX 4294967295UL";
603 test_text = "#define SIZE_MAX UINT64_MAX\n"
604 "#else\n"
605 "#define SIZE_MAX UINT32_MAX";
609 fix = {
610 hackname = aix_stdint_5;
611 mach = "*-*-aix*";
612 files = stdint-aix.h, stdint.h;
613 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
614 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
615 c_fix = format;
616 c_fix_arg = "#define UINT8_C(c) c\n"
617 "#define UINT16_C(c) c";
618 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
619 "#define UINT16_C(c) __CONCAT__(c,U)";
624 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
625 * in an otherwise harmless (and #ifed out) macro definition
627 fix = {
628 hackname = aix_sysmachine;
629 files = sys/machine.h;
630 select = "\\\\ +\n";
631 c_fix = format;
632 c_fix_arg = "\\\n";
633 test_text = "#define FOO \\\n"
634 " bar \\ \n baz \\ \n bat";
639 * sys/wait.h on AIX 5.2 defines macros that have both signed and
640 * unsigned types in conditional expressions.
642 fix = {
643 hackname = aix_syswait_2;
644 files = sys/wait.h;
645 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
646 c_fix = format;
647 c_fix_arg = "? (int)%1";
648 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
653 * sys/signal.h on some versions of AIX uses volatile in the typedef of
654 * sig_atomic_t, which causes gcc to generate a warning about duplicate
655 * volatile when a sig_atomic_t variable is declared volatile, as
656 * required by ANSI C.
658 fix = {
659 hackname = aix_volatile;
660 files = sys/signal.h;
661 select = "typedef volatile int sig_atomic_t";
662 c_fix = format;
663 c_fix_arg = "typedef int sig_atomic_t";
664 test_text = "typedef volatile int sig_atomic_t;";
669 * Fix __assert declaration in assert.h on Alpha OSF/1.
671 fix = {
672 hackname = alpha___assert;
673 files = "assert.h";
674 select = '__assert\(char \*, char \*, int\)';
675 c_fix = format;
676 c_fix_arg = "__assert(const char *, const char *, int)";
677 test_text = 'extern void __assert(char *, char *, int);';
682 * Fix assert macro in assert.h on Alpha OSF/1.
683 * The superfluous int cast breaks C++.
685 fix = {
686 hackname = alpha_assert;
687 files = "assert.h";
688 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
689 c_fix = format;
690 c_fix_arg = "%1(EX)";
691 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
692 ': __assert(#EX, __FILE__, __LINE__))';
697 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
699 fix = {
700 hackname = alpha_getopt;
701 files = "stdio.h";
702 files = "stdlib.h";
703 select = 'getopt\(int, char \*\[\], *char \*\)';
704 c_fix = format;
705 c_fix_arg = "getopt(int, char *const[], const char *)";
706 test_text = 'extern int getopt(int, char *[], char *);';
711 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
713 fix = {
714 hackname = alpha_if_semicolon;
715 files = net/if.h;
716 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
717 c_fix = format;
718 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
719 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
724 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
726 fix = {
727 hackname = alpha_parens;
728 files = sym.h;
729 select = '#ifndef\(__mips64\)';
730 c_fix = format;
731 c_fix_arg = "#ifndef __mips64";
732 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
737 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
738 * And OpenBSD.
740 fix = {
741 hackname = alpha_sbrk;
742 files = unistd.h;
743 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
744 c_fix = format;
745 c_fix_arg = "void *sbrk(";
746 test_text = "extern char* sbrk(ptrdiff_t increment);";
751 * For C++, avoid any typedef or macro definition of bool,
752 * and use the built in type instead.
753 * HP/UX 10.20 also has it in curses_colr/curses.h.
755 fix = {
756 hackname = avoid_bool_define;
757 files = curses.h;
758 files = curses_colr/curses.h;
759 files = term.h;
760 files = tinfo.h;
762 select = "#[ \t]*define[ \t]+bool[ \t]";
763 bypass = "__cplusplus";
765 c_fix = format;
766 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
767 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
769 test_text = "# define bool\t char \n";
773 fix = {
774 hackname = avoid_bool_type;
775 files = curses.h;
776 files = curses_colr/curses.h;
777 files = term.h;
778 files = tinfo.h;
780 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
781 bypass = "__cplusplus";
783 c_fix = format;
784 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
786 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
791 * For C++, avoid any typedef definition of wchar_t,
792 * and use the built in type instead.
793 * Don't do this for headers that are smart enough to do the right
794 * thing (recent [n]curses.h and Xlib.h).
795 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
796 * and will be broken by the edit.
799 fix = {
800 hackname = avoid_wchar_t_type;
802 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
803 bypass = "__cplusplus";
804 bypass = "_LINUX_NLS_H";
805 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
807 c_fix = format;
808 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
810 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
815 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
817 fix = {
818 hackname = bad_struct_term;
819 files = curses.h;
820 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
821 c_fix = format;
822 c_fix_arg = "struct term;";
824 test_text = 'typedef struct term;';
829 * Fix one other error in this file:
830 * a mismatched quote not inside a C comment.
832 fix = {
833 hackname = badquote;
834 files = sundev/vuid_event.h;
835 select = "doesn't";
836 c_fix = format;
837 c_fix_arg = "does not";
839 test_text = "/* doesn't have matched single quotes */";
844 * check for broken assert.h that needs stdio.h
846 fix = {
847 hackname = broken_assert_stdio;
848 files = assert.h;
849 select = stderr;
850 bypass = "include.*stdio\\.h";
851 c_fix = wrap;
852 c_fix_arg = "#include <stdio.h>\n";
853 test_text = "extern FILE* stderr;";
858 * check for broken assert.h that needs stdlib.h
860 fix = {
861 hackname = broken_assert_stdlib;
862 files = assert.h;
863 select = 'exit *\(|abort *\(';
864 bypass = "include.*stdlib\\.h";
865 c_fix = wrap;
866 c_fix_arg = "#ifdef __cplusplus\n"
867 "#include <stdlib.h>\n"
868 "#endif\n";
869 test_text = "extern void exit ( int );";
874 * Remove `extern double cabs' declarations from math.h.
875 * This conflicts with C99. Discovered on AIX.
876 * Darwin hides its broken cabs in architecture-specific subdirs.
878 fix = {
879 hackname = broken_cabs;
880 files = math.h, "architecture/*/math.h";
881 select = "^extern[ \t]+double[ \t]+cabs";
883 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
884 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
886 test_text = "#ifdef __STDC__\n"
887 "extern double cabs(struct dbl_hypot);\n"
888 "#else\n"
889 "extern double cabs();\n"
890 "#endif\n"
891 "extern double cabs ( _Complex z );";
896 * Fixup Darwin's broken check for __builtin_nanf.
898 fix = {
899 hackname = broken_nan;
901 * It is tempting to omit the first "files" entry. Do not.
902 * The testing machinery will take the first "files" entry as the name
903 * of a test file to play with. It would be a nuisance to have a directory
904 * with the name "*".
906 files = "architecture/ppc/math.h";
907 files = "architecture/*/math.h";
908 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
909 bypass = "powl";
910 c_fix = format;
911 c_fix_arg = "#if 1";
912 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
917 * Various systems derived from BSD4.4 contain a macro definition
918 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
919 * Known to be fixed in FreeBSD 5 system headers.
921 fix = {
922 hackname = bsd_stdio_attrs_conflict;
923 mach = "*-*-*bsd*";
924 mach = "*-*-*darwin*";
925 files = stdio.h;
926 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
927 c_fix = format;
928 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
929 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
930 'int vfscanf(FILE *, const char *, __builtin_va_list) '
931 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
932 test_text = '#define vfscanf __svfscanf';
936 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
937 * that it conforms to ISO/IEC 14882:2011. It currently does
938 * not support the [[noreturn]] procedure attribute.
939 * When it does, this hack should be removed.
940 * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
942 fix = {
943 hackname = cdef_cplusplus;
944 files = sys/cdefs.h;
945 select = '\[\[noreturn\]\]';
946 c_fix = format;
947 c_fix_arg = '__attribute__((__noreturn__))';
948 test_text = "#define _Noreturn [[noreturn]]";
952 * Fix various macros used to define ioctl numbers.
953 * The traditional syntax was:
955 * #define _CTRL(n, x) (('n'<<8)+x)
956 * #define TCTRLCFOO _CTRL(T, 1)
958 * but this does not work with the C standard, which disallows macro
959 * expansion inside strings. We have to rewrite it thus:
961 * #define _CTRL(n, x) ((n<<8)+x)
962 * #define TCTRLCFOO _CTRL('T', 1)
964 * The select expressions match too much, but the c_fix code is cautious.
966 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
968 fix = {
969 hackname = ctrl_quotes_def;
970 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
971 c_fix = char_macro_def;
972 c_fix_arg = "CTRL";
975 * This is two tests in order to ensure that the "CTRL(c)" can
976 * be selected in isolation from the multi-arg format
978 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
979 test_text = "#define _CTRL(c) ('c'&037)";
982 fix = {
983 hackname = ctrl_quotes_use;
984 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
985 c_fix = char_macro_use;
986 c_fix_arg = "CTRL";
987 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
992 * sys/mman.h on HP/UX is not C++ ready,
993 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
995 * rpc/types.h on OSF1/2.0 is not C++ ready,
996 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
998 * The problem is the declaration of malloc.
1000 fix = {
1001 hackname = cxx_unready;
1002 files = sys/mman.h;
1003 files = rpc/types.h;
1004 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1005 not within a macro. */
1006 bypass = '"C"|__BEGIN_DECLS';
1008 c_fix = wrap;
1009 c_fix_arg = "#ifdef __cplusplus\n"
1010 "extern \"C\" {\n"
1011 "#endif\n";
1012 c_fix_arg = "#ifdef __cplusplus\n"
1013 "}\n"
1014 "#endif\n";
1015 test_text = "extern void* malloc( size_t );";
1020 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1021 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1023 fix = {
1024 hackname = darwin_externc;
1025 mach = "*-*-darwin*";
1026 files = mach-o/swap.h;
1027 files = mach/mach_time.h;
1028 files = mach/mach_traps.h;
1029 files = mach/message.h;
1030 files = mach/mig.h;
1031 files = mach/semaphore.h;
1032 bypass = "extern \"C\"";
1033 bypass = "__BEGIN_DECLS";
1034 c_fix = wrap;
1035 c_fix_arg = "#ifdef __cplusplus\n"
1036 "extern \"C\" {\n"
1037 "#endif\n";
1038 c_fix_arg = "#ifdef __cplusplus\n"
1039 "}\n"
1040 "#endif\n";
1041 test_text = "extern void swap_fat_header();\n";
1046 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1047 * bad __GNUC__ tests.
1050 fix = {
1051 hackname = darwin_gcc4_breakage;
1052 mach = "*-*-darwin*";
1053 files = AvailabilityMacros.h;
1054 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1055 c_fix = format;
1056 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1057 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1058 "(__GNUC_MINOR__ >= 1)\n";
1063 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1064 * why would you ever put it in a system header file?
1066 fix = {
1067 hackname = darwin_private_extern;
1068 mach = "*-*-darwin*";
1069 files = mach-o/dyld.h;
1070 select = "__private_extern__ [a-z_]+ _dyld_";
1071 c_fix = format;
1072 c_fix_arg = "extern";
1073 c_fix_arg = "__private_extern__";
1074 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1075 "const char *dyld_func_name,\n"
1076 "unsigned long *address);\n";
1081 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1082 * unsigned constants.
1084 fix = {
1085 hackname = darwin_stdint_1;
1086 mach = "*-*-darwin*";
1087 files = stdint-darwin.h, stdint.h;
1088 c_fix = format;
1089 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1090 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1091 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1092 test_text = "#define UINT8_C(v) (v ## U)\n"
1093 "#define UINT16_C(v) (v ## U)";
1098 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1099 * with wrong types.
1101 fix = {
1102 hackname = darwin_stdint_2;
1103 mach = "*-*-darwin*";
1104 files = stdint-darwin.h, stdint.h;
1105 c_fix = format;
1106 c_fix_arg = "#if __WORDSIZE == 64\n"
1107 "#define INTPTR_MAX 9223372036854775807L\n"
1108 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1109 "#else\n"
1110 "#define INTPTR_MAX 2147483647L\n"
1111 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1112 "#endif";
1113 select = "#if __WORDSIZE == 64\n"
1114 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1115 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1116 "#else\n"
1117 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1118 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1119 "#endif";
1120 test_text = "#if __WORDSIZE == 64\n"
1121 "#define INTPTR_MIN INT64_MIN\n"
1122 "#define INTPTR_MAX INT64_MAX\n"
1123 "#else\n"
1124 "#define INTPTR_MIN INT32_MIN\n"
1125 "#define INTPTR_MAX INT32_MAX\n"
1126 "#endif";
1131 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1133 fix = {
1134 hackname = darwin_stdint_3;
1135 mach = "*-*-darwin*";
1136 files = stdint-darwin.h, stdint.h;
1137 c_fix = format;
1138 c_fix_arg = "#if __WORDSIZE == 64\n"
1139 "#define UINTPTR_MAX 18446744073709551615UL\n"
1140 "#else\n"
1141 "#define UINTPTR_MAX 4294967295UL\n"
1142 "#endif";
1143 select = "#if __WORDSIZE == 64\n"
1144 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1145 "#else\n"
1146 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1147 "#endif";
1148 test_text = "#if __WORDSIZE == 64\n"
1149 "#define UINTPTR_MAX UINT64_MAX\n"
1150 "#else\n"
1151 "#define UINTPTR_MAX UINT32_MAX\n"
1152 "#endif";
1157 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1159 fix = {
1160 hackname = darwin_stdint_4;
1161 mach = "*-*-darwin*";
1162 files = stdint-darwin.h, stdint.h;
1163 c_fix = format;
1164 c_fix_arg = "#if __WORDSIZE == 64\n"
1165 "#define SIZE_MAX 18446744073709551615UL\n"
1166 "#else\n"
1167 "#define SIZE_MAX 4294967295UL\n"
1168 "#endif";
1169 select = "#if __WORDSIZE == 64\n"
1170 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1171 "#else\n"
1172 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1173 "#endif";
1174 test_text = "#if __WORDSIZE == 64\n"
1175 "#define SIZE_MAX UINT64_MAX\n"
1176 "#else\n"
1177 "#define SIZE_MAX UINT32_MAX\n"
1178 "#endif";
1183 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1184 * with a wrong type.
1186 fix = {
1187 hackname = darwin_stdint_5;
1188 mach = "*-*-darwin*";
1189 files = stdint-darwin.h, stdint.h;
1190 c_fix = format;
1191 c_fix_arg = "#if __WORDSIZE == 64\n"
1192 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1193 "#define INTMAX_MAX 9223372036854775807L\n"
1194 "#define UINTMAX_MAX 18446744073709551615UL\n"
1195 "#else\n"
1196 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1197 "#define INTMAX_MAX 9223372036854775807LL\n"
1198 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1199 "#endif";
1200 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1201 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1202 "\n"
1203 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1204 test_text = "#define INTMAX_MIN INT64_MIN\n"
1205 "#define INTMAX_MAX INT64_MAX\n"
1206 "\n"
1207 "#define UINTMAX_MAX UINT64_MAX";
1212 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1213 * with a wrong type.
1215 fix = {
1216 hackname = darwin_stdint_6;
1217 mach = "*-*-darwin*";
1218 files = stdint-darwin.h, stdint.h;
1219 c_fix = format;
1220 c_fix_arg = "#if __WORDSIZE == 64\n"
1221 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1222 "#define PTRDIFF_MAX 9223372036854775807L\n"
1223 "#else\n"
1224 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1225 "#define PTRDIFF_MAX 2147483647\n"
1226 "#endif";
1227 select = "#if __WORDSIZE == 64\n"
1228 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1229 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1230 "#else\n"
1231 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1232 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1233 "#endif";
1234 test_text = "#if __WORDSIZE == 64\n"
1235 "#define PTRDIFF_MIN INT64_MIN\n"
1236 "#define PTRDIFF_MAX INT64_MAX\n"
1237 "#else\n"
1238 "#define PTRDIFF_MIN INT32_MIN\n"
1239 "#define PTRDIFF_MAX INT32_MAX\n"
1240 "#endif";
1245 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1246 * with a wrong type.
1248 fix = {
1249 hackname = darwin_stdint_7;
1250 mach = "*-*-darwin*";
1251 files = stdint-darwin.h, stdint.h;
1252 c_fix = format;
1253 c_fix_arg = "#if __WORDSIZE == 64\n"
1254 "#define INTMAX_C(v) (v ## L)\n"
1255 "#define UINTMAX_C(v) (v ## UL)\n"
1256 "#else\n"
1257 "#define INTMAX_C(v) (v ## LL)\n"
1258 "#define UINTMAX_C(v) (v ## ULL)\n"
1259 "#endif";
1260 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1261 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1262 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1263 "#define UINTMAX_C(v) (v ## ULL)";
1268 * Fix <c_asm.h> on Digital UNIX V4.0:
1269 * It contains a prototype for a DEC C internal asm() function,
1270 * clashing with gcc's asm keyword. So protect this with __DECC.
1272 fix = {
1273 hackname = dec_intern_asm;
1274 files = c_asm.h;
1275 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1276 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1277 "#endif\n";
1278 test_text =
1279 "float fasm {\n"
1280 " ... asm stuff ...\n"
1281 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1286 * Fix typo in <wchar.h> on DJGPP 2.03.
1288 fix = {
1289 hackname = djgpp_wchar_h;
1290 file = wchar.h;
1291 select = "__DJ_wint_t";
1292 bypass = "sys/djtypes.h";
1293 c_fix = format;
1294 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1295 c_fix_arg = "#include <stddef.h>";
1296 test_text = "#include <stddef.h>\n"
1297 "extern __DJ_wint_t x;\n";
1302 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1304 fix = {
1305 hackname = ecd_cursor;
1306 files = "sunwindow/win_lock.h";
1307 files = "sunwindow/win_cursor.h";
1308 select = 'ecd\.cursor';
1309 c_fix = format;
1310 c_fix_arg = 'ecd_cursor';
1312 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1317 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1318 * neither the existence of GCC 3 nor its exact feature set yet break
1319 * (by design?) when __GNUC__ is set beyond 2.
1321 fix = {
1322 hackname = freebsd_gcc3_breakage;
1323 mach = "*-*-freebsd*";
1324 files = sys/cdefs.h;
1325 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1326 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1327 c_fix = format;
1328 c_fix_arg = '%0 || __GNUC__ >= 3';
1329 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1334 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1335 * neither the existence of GCC 4 nor its exact feature set yet break
1336 * (by design?) when __GNUC__ is set beyond 3.
1338 fix = {
1339 hackname = freebsd_gcc4_breakage;
1340 mach = "*-*-freebsd*";
1341 files = sys/cdefs.h;
1342 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1343 c_fix = format;
1344 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1345 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1350 * Some versions of glibc don't expect the C99 inline semantics.
1352 fix = {
1353 hackname = glibc_c99_inline_1;
1354 files = features.h, '*/features.h';
1355 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1356 c_fix = format;
1357 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1358 test_text = <<-EOT
1359 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1360 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1361 # define __USE_EXTERN_INLINES 1
1362 #endif
1363 EOT;
1368 * Similar, but a version that didn't have __NO_INLINE__
1370 fix = {
1371 hackname = glibc_c99_inline_1a;
1372 files = features.h, '*/features.h';
1373 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1374 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1375 c_fix = format;
1376 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1377 test_text = <<-EOT
1378 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1379 # define __USE_EXTERN_INLINES 1
1380 #endif
1381 EOT;
1386 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1387 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1388 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1390 fix = {
1391 hackname = glibc_c99_inline_2;
1392 files = sys/stat.h, '*/sys/stat.h';
1393 select = "extern __inline__ int";
1394 sed = "s/extern int \\(stat\\)/"
1395 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1396 "__inline__ int \\1/";
1397 sed = "s/extern int \\([lf]stat\\)/"
1398 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1399 "__inline__ int \\1/";
1400 sed = "s/extern int \\(mknod\\)/"
1401 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1402 "__inline__ int \\1/";
1403 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1404 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1405 "__inline__ int __REDIRECT\\1 (\\2/";
1406 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1407 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1408 "__inline__ int __REDIRECT\\1 (\\2/";
1409 sed = "s/^extern __inline__ int/"
1410 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1411 "__inline__ int/";
1412 test_text = <<-EOT
1413 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1414 extern __inline__ int
1415 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1417 EOT;
1421 fix = {
1422 hackname = glibc_c99_inline_3;
1423 files = bits/string2.h, '*/bits/string2.h';
1424 select = "extern __inline";
1425 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1426 c_fix = format;
1427 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1428 c_fix_arg = "^# ifdef __cplusplus$";
1429 test_text = <<-EOT
1430 # ifdef __cplusplus
1431 # define __STRING_INLINE inline
1432 # else
1433 # define __STRING_INLINE extern __inline
1434 # endif
1435 EOT;
1439 fix = {
1440 hackname = glibc_c99_inline_4;
1441 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1442 bypass = "__extern_inline|__gnu_inline__";
1443 select = "(^| )extern __inline";
1444 c_fix = format;
1445 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1446 test_text = <<-EOT
1447 __extension__ extern __inline unsigned int
1448 extern __inline unsigned int
1449 EOT;
1453 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1454 * so we replace them with versions that correspond to the
1455 * definition.
1457 fix = {
1458 hackname = glibc_mutex_init;
1459 files = pthread.h;
1460 select = '\{ *\{ *0, *\} *\}';
1461 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1462 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1463 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1464 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1465 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1466 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1467 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1468 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1469 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1470 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1471 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1472 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1473 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1474 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1475 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1476 "N;s/^[ \t]*#[ \t]*"
1477 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1478 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1479 "# \\1\\\n"
1480 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1481 "# else\\\n"
1482 "# \\1\\\n"
1483 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1484 "# endif/";
1485 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1486 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1487 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1488 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1490 test_text = <<- _EOText_
1491 #define PTHREAD_MUTEX_INITIALIZER \\
1492 { { 0, } }
1493 #ifdef __USE_GNU
1494 # if __WORDSIZE == 64
1495 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1496 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1497 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1498 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1499 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1500 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1501 # else
1502 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1503 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1504 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1505 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1506 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1507 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1508 # endif
1509 #endif
1510 # define PTHREAD_RWLOCK_INITIALIZER \\
1511 { { 0, } }
1512 # ifdef __USE_GNU
1513 # if __WORDSIZE == 64
1514 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1515 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1516 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1517 # else
1518 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1519 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1520 # endif
1521 # endif
1522 #define PTHREAD_COND_INITIALIZER { { 0, } }
1523 _EOText_;
1527 /* glibc versions before 2.5 have a version of stdint.h that defines
1528 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1529 versions with stdint.h based on those glibc versions. */
1530 fix = {
1531 hackname = glibc_stdint;
1532 files = stdint.h;
1533 select = "GNU C Library";
1534 c_fix = format;
1535 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1536 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1537 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";
1541 /* Some versions of glibc have a version of bits/string2.h that
1542 produces "value computed is not used" warnings from strncpy; fix
1543 this definition by using __builtin_strncpy instead as in newer
1544 versions. */
1545 fix = {
1546 hackname = glibc_strncpy;
1547 files = bits/string2.h;
1548 bypass = "__builtin_strncpy";
1549 c_fix = format;
1550 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1551 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1552 test_text = <<-EOT
1553 # define strncpy(dest, src, n) \
1554 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1555 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1556 ? (char *) memcpy (dest, src, n) \\
1557 : strncpy (dest, src, n)) \\
1558 : strncpy (dest, src, n)))
1559 EOT;
1563 /* glibc's tgmath.h relies on an expression that is not an integer
1564 constant expression being treated as it was by GCC 4.4 and
1565 earlier. */
1566 fix = {
1567 hackname = glibc_tgmath;
1568 files = tgmath.h;
1569 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1570 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1571 c_fix = format;
1572 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1573 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1577 * Fix these files to use the types we think they should for
1578 * ptrdiff_t, size_t, and wchar_t.
1580 * This defines the types in terms of macros predefined by our 'cpp'.
1581 * This is supposedly necessary for glibc's handling of these types.
1582 * It's probably not necessary for anyone else, but it doesn't hurt.
1584 fix = {
1585 hackname = gnu_types;
1586 files = "sys/types.h";
1587 files = "stdlib.h";
1588 files = "sys/stdtypes.h";
1589 files = "stddef.h";
1590 files = "memory.h";
1591 files = "unistd.h";
1592 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1593 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1594 c_fix = gnu_type;
1595 /* The Solaris 10 headers already define these types correctly. */
1596 mach = '*-*-solaris2.1[0-9]*';
1597 not_machine = true;
1599 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1600 "typedef uint_t size_t; /* uint_t */\n"
1601 "typedef ushort_t wchar_t; /* ushort_t */";
1606 * Fix HP & Sony's use of "../machine/xxx.h"
1607 * to refer to: <machine/xxx.h>
1609 fix = {
1610 hackname = hp_inline;
1611 files = sys/spinlock.h;
1612 files = machine/machparam.h;
1613 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1615 c_fix = format;
1616 c_fix_arg = "%1<machine/%2.h>";
1618 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1619 '([a-z]+)\.h"';
1621 test_text = ' # include "../machine/mumble.h"';
1626 * Check for (...) in C++ code in HP/UX sys/file.h.
1628 fix = {
1629 hackname = hp_sysfile;
1630 files = sys/file.h;
1631 select = "HPUX_SOURCE";
1633 c_fix = format;
1634 c_fix_arg = "(struct file *, ...)";
1635 c_fix_arg = '\(\.\.\.\)';
1637 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1642 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1643 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1645 fix = {
1646 hackname = hppa_hpux_fp_macros;
1647 mach = "hppa*-hp-hpux11*";
1648 files = math.h;
1649 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1650 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1651 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1652 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1653 "#[ \t]*define[ \t]*FP_NAN.*\n";
1654 c_fix = format;
1655 c_fix_arg = <<- _EOFix_
1656 #endif /* _INCLUDE_HPUX_SOURCE */
1658 #if defined(_INCLUDE_HPUX_SOURCE) || \
1659 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1660 %0#endif
1662 #ifdef _INCLUDE_HPUX_SOURCE
1664 _EOFix_;
1666 test_text =
1667 "# define FP_NORMAL 0\n"
1668 "# define FP_ZERO 1\n"
1669 "# define FP_INFINITE 2\n"
1670 "# define FP_SUBNORMAL 3\n"
1671 "# define FP_NAN 4\n";
1676 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1677 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1679 fix = {
1680 hackname = hpux10_cpp_pow_inline;
1681 files = fixinc-test-limits.h, math.h;
1682 select = <<- END_POW_INLINE
1683 ^# +ifdef +__cplusplus
1685 +inline +double +pow\(double +__d,int +__expon\) +\{
1686 [ ]+return +pow\(__d,\(double\)__expon\);
1688 +extern +"C" +\{
1689 #else
1690 # +endif
1691 END_POW_INLINE;
1693 c_fix = format;
1694 c_fix_arg = "";
1696 test_text =
1697 "# ifdef __cplusplus\n"
1698 " }\n"
1699 " inline double pow(double __d,int __expon) {\n"
1700 "\t return pow(__d,(double)__expon);\n"
1701 " }\n"
1702 ' extern "C"' " {\n"
1703 "#else\n"
1704 "# endif";
1707 fix = {
1708 hackname = hpux11_cpp_pow_inline;
1709 files = math.h;
1710 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1711 " +return pow\\(d, \\(double\\)expon\\);\n"
1712 " +\\}\n";
1713 c_fix = format;
1714 c_fix_arg = "";
1716 test_text =
1717 " inline double pow(double d,int expon) {\n"
1718 " return pow(d, (double)expon);\n"
1719 " }\n";
1724 * Fix hpux 10.X missing ctype declarations 1
1726 fix = {
1727 hackname = hpux10_ctype_declarations1;
1728 files = ctype.h;
1729 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1730 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1731 c_fix = format;
1732 c_fix_arg = "#ifdef _PROTOTYPES\n"
1733 "extern int __tolower(int);\n"
1734 "extern int __toupper(int);\n"
1735 "#else /* NOT _PROTOTYPES */\n"
1736 "extern int __tolower();\n"
1737 "extern int __toupper();\n"
1738 "#endif /* _PROTOTYPES */\n\n"
1739 "%0\n";
1741 test_text = "# define _toupper(__c) __toupper(__c)\n";
1746 * Fix hpux 10.X missing ctype declarations 2
1748 fix = {
1749 hackname = hpux10_ctype_declarations2;
1750 files = ctype.h;
1751 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1752 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1753 c_fix = format;
1754 c_fix_arg = "%0\n\n"
1755 "#ifdef _PROTOTYPES\n"
1756 " extern int _isalnum(int);\n"
1757 " extern int _isalpha(int);\n"
1758 " extern int _iscntrl(int);\n"
1759 " extern int _isdigit(int);\n"
1760 " extern int _isgraph(int);\n"
1761 " extern int _islower(int);\n"
1762 " extern int _isprint(int);\n"
1763 " extern int _ispunct(int);\n"
1764 " extern int _isspace(int);\n"
1765 " extern int _isupper(int);\n"
1766 " extern int _isxdigit(int);\n"
1767 "# else /* not _PROTOTYPES */\n"
1768 " extern int _isalnum();\n"
1769 " extern int _isalpha();\n"
1770 " extern int _iscntrl();\n"
1771 " extern int _isdigit();\n"
1772 " extern int _isgraph();\n"
1773 " extern int _islower();\n"
1774 " extern int _isprint();\n"
1775 " extern int _ispunct();\n"
1776 " extern int _isspace();\n"
1777 " extern int _isupper();\n"
1778 " extern int _isxdigit();\n"
1779 "#endif /* _PROTOTYPES */\n";
1781 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1782 " extern unsigned int *__SB_masks;\n";
1787 * Fix hpux 10.X missing stdio declarations
1789 fix = {
1790 hackname = hpux10_stdio_declarations;
1791 files = stdio.h;
1792 select = "^#[ \t]*define _iob[ \t]*__iob";
1793 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1794 c_fix = format;
1795 c_fix_arg = "%0\n\n"
1796 "# if defined(__STDC__) || defined(__cplusplus)\n"
1797 " extern int snprintf(char *, size_t, const char *, ...);\n"
1798 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1799 "# else /* not __STDC__) || __cplusplus */\n"
1800 " extern int snprintf();\n"
1801 " extern int vsnprintf();\n"
1802 "# endif /* __STDC__) || __cplusplus */\n";
1804 test_text = "# define _iob __iob\n";
1809 * Make sure hpux defines abs in header.
1811 fix = {
1812 hackname = hpux11_abs;
1813 mach = "*-hp-hpux11*";
1814 files = stdlib.h;
1815 select = "ifndef _MATH_INCLUDED";
1816 c_fix = format;
1817 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1818 test_text = "#ifndef _MATH_INCLUDED";
1823 * Keep HP-UX 11 from stomping on C++ math namespace
1824 * with defines for fabsf.
1826 fix = {
1827 hackname = hpux11_fabsf;
1828 files = math.h;
1829 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1830 bypass = "__cplusplus";
1832 c_fix = format;
1833 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1835 test_text =
1836 "#ifdef _PA_RISC\n"
1837 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1838 "#endif";
1843 * Fix C99 constant in __POINTER_SET define.
1845 fix = {
1846 hackname = hpux11_pthread_const;
1847 mach = "*-hp-hpux11.[0-3]*";
1848 files = sys/pthread.h;
1849 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
1851 c_fix = format;
1852 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
1853 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1858 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1859 * being defined by having it define _hpux_size_t instead.
1861 fix = {
1862 hackname = hpux11_size_t;
1863 mach = "*-hp-hpux11*";
1864 select = "__size_t";
1866 c_fix = format;
1867 c_fix_arg = "_hpux_size_t";
1869 test_text =
1870 "#define __size_t size_t\n"
1871 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1876 * Fix hpux 11.00 broken snprintf declaration
1877 * (third argument is char *, needs to be const char * to prevent
1878 * spurious warnings with -Wwrite-strings or in C++).
1880 fix = {
1881 hackname = hpux11_snprintf;
1882 files = stdio.h;
1883 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1884 ' *(char *\*, *\.\.\.\);)';
1885 c_fix = format;
1886 c_fix_arg = '%1 const %3';
1888 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1889 "extern int snprintf(char *, __size_t, char *, ...);\n"
1890 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1894 * Fix hpux 11.00 broken vsnprintf declaration
1896 fix = {
1897 hackname = hpux11_vsnprintf;
1898 files = stdio.h;
1899 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1900 'const char \*,) __va__list\);';
1901 c_fix = format;
1902 c_fix_arg = "%1 __va_list);";
1904 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1905 ' __va__list);';
1910 * get rid of bogus inline definitions in HP-UX 8.0
1912 fix = {
1913 hackname = hpux8_bogus_inlines;
1914 files = math.h;
1915 select = inline;
1916 bypass = "__GNUG__";
1917 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1918 "@extern \"C\" int abs(int);@";
1919 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1920 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1921 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1922 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1923 "inline double sqr(double v) { return v**0.5; }";
1928 * Fix hpux broken ctype macros
1930 fix = {
1931 hackname = hpux_ctype_macros;
1932 files = ctype.h;
1933 select = '((: |\()__SB_masks \? )'
1934 '(__SB_masks\[__(alnum|c)\] & _IS)';
1935 c_fix = format;
1936 c_fix_arg = "%1(int)%3";
1938 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1939 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1944 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1946 fix = {
1947 hackname = hpux_htonl;
1948 files = netinet/in.h;
1949 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
1950 "(/\\*\n"
1951 " \\* Macros for number representation conversion\\.\n"
1952 " \\*/\n"
1953 "#ifndef ntohl)";
1954 c_fix = format;
1955 c_fix_arg = "#if 1\n%1";
1957 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1958 "/*\n"
1959 " * Macros for number representation conversion.\n"
1960 " */\n"
1961 "#ifndef ntohl\n"
1962 "#define ntohl(x) (x)\n"
1963 "#define ntohs(x) (x)\n"
1964 "#define htonl(x) (x)\n"
1965 "#define htons(x) (x)\n"
1966 "#endif\n"
1967 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1972 * HP-UX long_double
1974 fix = {
1975 hackname = hpux_long_double;
1976 mach = "*-*-hpux10*";
1977 mach = "*-*-hpux11.[012]*";
1978 files = stdlib.h;
1979 select = "extern[ \t]long_double[ \t]strtold";
1980 bypass = "long_double_t";
1981 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1982 sed = "s/long_double/long double/g";
1984 test_text = "# ifndef _LONG_DOUBLE\n"
1985 "# define _LONG_DOUBLE\n"
1986 " typedef struct {\n"
1987 " unsigned int word1, word2, word3, word4;\n"
1988 " } long_double;\n"
1989 "# endif /* _LONG_DOUBLE */\n"
1990 "extern long_double strtold(const char *, char **);\n";
1994 * We cannot use the above rule on 11.31 because it removes the strtold
1995 * definition. ia64 is OK with no hack, PA needs some help.
1997 fix = {
1998 hackname = hpux_long_double_2;
1999 mach = "hppa*-*-hpux11.3*";
2000 files = stdlib.h;
2001 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
2002 c_fix = format;
2003 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2005 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
2009 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2011 fix = {
2012 hackname = hpux_systime;
2013 files = sys/time.h;
2014 select = "^extern struct sigevent;";
2016 c_fix = format;
2017 c_fix_arg = "struct sigevent;";
2019 test_text = 'extern struct sigevent;';
2024 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2025 * type and mpinfou is only defined when _KERNEL is set.
2027 fix = {
2028 hackname = hpux_spu_info;
2029 mach = "*-hp-hpux*";
2031 * It is tempting to omit the first "files" entry. Do not.
2032 * The testing machinery will take the first "files" entry as the name
2033 * of a test file to play with. It would be a nuisance to have a directory
2034 * with the name "*".
2036 files = "ia64/sys/getppdp.h";
2037 files = "*/sys/getppdp.h";
2038 select = "^.*extern.*spu_info.*";
2040 c_fix = format;
2041 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2043 test_text = "extern union mpinfou spu_info[];";
2046 fix = {
2047 hackname = hpux11_extern_sendfile;
2048 mach = "*-hp-hpux11.[12]*";
2049 files = sys/socket.h;
2050 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2051 c_fix = format;
2052 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2053 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2056 fix = {
2057 hackname = hpux11_extern_sendpath;
2058 mach = "*-hp-hpux11.[12]*";
2059 files = sys/socket.h;
2060 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2061 c_fix = format;
2062 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2063 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2066 fix = {
2067 hackname = hpux_extern_errno;
2068 mach = "*-hp-hpux10.*";
2069 mach = "*-hp-hpux11.[0-2]*";
2070 files = errno.h;
2071 select = "^[ \t]*extern int errno;$";
2072 c_fix = format;
2073 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2074 test_text = " extern int errno;\n";
2079 * Add missing braces to pthread initializer defines.
2081 fix = {
2082 hackname = hpux_pthread_initializers;
2083 mach = "*-hp-hpux11.[0-3]*";
2084 files = sys/pthread.h;
2085 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2086 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2087 sed = "s@^[ \t]*1,[ \t]*\\\\"
2088 "@\t{ 1, 0 }@";
2089 sed = "/^[ \t]*0$/d";
2090 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2091 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2092 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2093 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2094 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2095 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2096 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2097 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2098 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2099 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2100 sed = "s@__PTHREAD_COND_VALID, 0"
2101 "@{ __PTHREAD_COND_VALID, 0 }@";
2102 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2103 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2104 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2105 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2106 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2107 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2108 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2109 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2110 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2111 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2112 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2113 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2114 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2115 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2116 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2117 "}\n";
2120 fix = {
2121 hackname = hpux_c99_intptr;
2122 mach = "*-hp-hpux11.3*";
2123 files = stdint-hpux11.h, stdint.h;
2124 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2125 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2126 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2127 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2128 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2129 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2130 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2131 "#define PTRDIFF_MIN INT32_MIN\n"
2132 "#define INTPTR_MAX INT32_MAX\n"
2133 "#define INTPTR_MIN INT32_MIN\n"
2134 "#define UINTPTR_MAX UINT32_MAX\n"
2135 "#define SIZE_MAX UINT32_MAX\n";
2139 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2142 fix = {
2143 hackname = hpux_c99_inttypes;
2144 mach = "*-hp-hpux11.[23]*";
2145 files = inttypes.h;
2146 files = stdint-hpux11.h, stdint.h;
2147 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2148 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2149 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2150 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2151 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2152 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2153 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2154 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2157 fix = {
2158 hackname = hpux_c99_inttypes2;
2159 mach = "*-hp-hpux11.2*";
2160 files = stdint-hpux11.h, stdint.h;
2161 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2162 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2163 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2164 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2165 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2166 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2167 "# define INT16_C(__c) ((short)(__c))\n"
2168 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2171 fix = {
2172 hackname = hpux_stdint_least_fast;
2173 mach = "*-hp-hpux11.2*";
2174 files = stdint-hpux11.h, stdint.h;
2175 select =
2176 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2177 c_fix = format;
2178 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2179 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2180 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2181 _EOFix_;
2184 fix = {
2185 hackname = hpux_inttype_int8_t;
2186 mach = "*-hp-hpux1[01].*";
2187 files = sys/_inttypes.h;
2188 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2189 c_fix = format;
2190 c_fix_arg = "typedef signed char int%18_t;";
2191 test_text = "typedef char int_least8_t;\n"
2192 "typedef char int8_t;\n";
2195 fix = {
2196 hackname = hpux_imaginary_i;
2197 mach = "ia64-hp-hpux11.*";
2198 files = complex.h;
2199 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2200 c_fix = format;
2201 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2202 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2206 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2208 fix = {
2209 hackname = huge_val_hex;
2210 files = bits/huge_val.h;
2211 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2212 bypass = "__builtin_huge_val";
2214 c_fix = format;
2215 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2217 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2222 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2224 fix = {
2225 hackname = huge_valf_hex;
2226 files = bits/huge_val.h;
2227 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2228 bypass = "__builtin_huge_valf";
2230 c_fix = format;
2231 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2233 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2238 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2240 fix = {
2241 hackname = huge_vall_hex;
2242 files = bits/huge_val.h;
2243 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2244 bypass = "__builtin_huge_vall";
2246 c_fix = format;
2247 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2249 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2254 * Fix return type of abort and free
2256 fix = {
2257 hackname = int_abort_free_and_exit;
2258 files = stdlib.h;
2259 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2260 bypass = "_CLASSIC_ANSI_TYPES";
2262 c_fix = format;
2263 c_fix_arg = "void\t%1(";
2265 test_text = "extern int abort(int);\n"
2266 "extern int free(void*);\n"
2267 "extern int exit(void*);";
2272 * Fix various macros used to define ioctl numbers.
2273 * The traditional syntax was:
2275 * #define _IO(n, x) (('n'<<8)+x)
2276 * #define TIOCFOO _IO(T, 1)
2278 * but this does not work with the C standard, which disallows macro
2279 * expansion inside strings. We have to rewrite it thus:
2281 * #define _IO(n, x) ((n<<8)+x)
2282 * #define TIOCFOO _IO('T', 1)
2284 * The select expressions match too much, but the c_fix code is cautious.
2286 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2288 fix = {
2289 hackname = io_quotes_def;
2290 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2291 c_fix = char_macro_def;
2292 c_fix_arg = "IO";
2293 test_text =
2294 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2295 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2296 "#define _IO(x,y) ('x'<<8|y)";
2297 test_text =
2298 "#define XX_IO(x) ('x'<<8|256)";
2301 fix = {
2302 hackname = io_quotes_use;
2303 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2304 "\\( *[^,']";
2305 c_fix = char_macro_use;
2306 c_fix_arg = "IO";
2307 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2308 "#define TIOCFOO \\\\\n"
2309 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2314 * Check for missing ';' in struct
2316 fix = {
2317 hackname = ip_missing_semi;
2318 files = netinet/ip.h;
2319 select = "}$";
2320 sed = "/^struct/,/^};/s/}$/};/";
2321 test_text=
2322 "struct mumble {\n"
2323 " union {\n"
2324 " int x;\n"
2325 " }\n"
2326 "}; /* mumbled struct */\n";
2331 * Non-traditional "const" declaration in Irix's limits.h.
2333 fix = {
2334 hackname = irix_limits_const;
2335 files = fixinc-test-limits.h, limits.h;
2336 select = "^extern const ";
2337 c_fix = format;
2338 c_fix_arg = "extern __const ";
2339 test_text = "extern const char limit; /* test limits */";
2344 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2345 * taking char *. However, GCC uses void * for va_list, so
2346 * calling vfprintf with a va_list fails in C++. */
2347 fix = {
2348 hackname = irix_stdio_va_list;
2349 files = stdio.h;
2351 select = '/\* va_list \*/ char \*';
2352 c_fix = format;
2353 c_fix_arg = "__gnuc_va_list";
2354 test_text =
2355 "extern int printf( const char *, /* va_list */ char * );";
2360 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2361 * use / * * / to concatenate tokens.
2363 fix = {
2364 hackname = kandr_concat;
2365 files = "sparc/asm_linkage.h";
2366 files = "sun*/asm_linkage.h";
2367 files = "arm/as_support.h";
2368 files = "arm/mc_type.h";
2369 files = "arm/xcb.h";
2370 files = "dev/chardefmac.h";
2371 files = "dev/ps_irq.h";
2372 files = "dev/screen.h";
2373 files = "dev/scsi.h";
2374 files = "sys/tty.h";
2375 files = "Xm.acorn/XmP.h";
2376 files = bsd43/bsd43_.h;
2377 select = '/\*\*/';
2378 c_fix = format;
2379 c_fix_arg = '##';
2380 test_text = "#define __CONCAT__(a,b) a/**/b";
2384 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2385 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2386 * constant on recent versions of g++.
2388 fix = {
2389 hackname = linux_ia64_ucontext;
2390 files = "sys/ucontext.h";
2391 mach = "ia64-*-linux*";
2392 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2393 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2394 c_fix = format;
2395 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2396 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2397 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2402 * Remove header file warning from sys/time.h. Autoconf's
2403 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2404 * which causes warning on LynxOS. Remove the warning.
2406 fix = {
2407 hackname = lynxos_no_warning_in_sys_time_h;
2408 files = sys/time.h;
2409 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2410 c_fix = format;
2411 c_fix_arg = "";
2412 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2417 * Add missing declaration for putenv.
2419 fix = {
2420 hackname = lynxos_missing_putenv;
2421 mach = '*-*-lynxos*';
2422 files = stdlib.h;
2423 bypass = 'putenv[ \t]*\\(';
2424 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2425 c_fix = format;
2426 c_fix_arg = "%0\n"
2427 "extern int putenv _AP((char *));";
2428 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2429 test_text = "extern char *getenv _AP((const char *));";
2434 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2436 * On NetBSD, machine is a symbolic link to an architecture specific
2437 * directory name, so we can't match a specific file name here.
2439 fix = {
2440 hackname = machine_ansi_h_va_list;
2441 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2442 bypass = '__builtin_va_list';
2444 c_fix = format;
2445 c_fix_arg = "%1__builtin_va_list";
2446 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2448 test_text = " # define _BSD_VA_LIST_\tchar**";
2453 * Fix non-ansi machine name defines
2455 fix = {
2456 hackname = machine_name;
2457 c_test = machine_name;
2458 c_fix = machine_name;
2460 test_text = "/* MACH_DIFF: */\n"
2461 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2462 "\n/* no uniform test, so be careful :-) */";
2467 * Some math.h files define struct exception (it's in the System V
2468 * Interface Definition), which conflicts with the class exception defined
2469 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2470 * This is not a great fix, but I haven't been able to think of anything
2471 * better.
2473 fix = {
2474 hackname = math_exception;
2475 files = math.h;
2476 select = "struct exception";
2478 * This should be bypassed on __cplusplus, but some supposedly C++
2479 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2480 * exception either. So currently we bypass only for glibc, based on a
2481 * comment in the fixed glibc header. Ick.
2483 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2484 '_[a-z0-9A-Z_]+_exception; for C, exception';
2485 c_fix = wrap;
2487 c_fix_arg = "#ifdef __cplusplus\n"
2488 "#define exception __math_exception\n"
2489 "#endif\n";
2491 c_fix_arg = "#ifdef __cplusplus\n"
2492 "#undef exception\n"
2493 "#endif\n";
2495 test_text = "typedef struct exception t_math_exception;";
2500 * This looks pretty broken to me. ``dbl_max_def'' will contain
2501 * "define DBL_MAX " at the start, when what we really want is just
2502 * the value portion. Can't figure out how to write a test case
2503 * for this either :-(
2505 fix = {
2506 hackname = math_huge_val_from_dbl_max;
2507 files = math.h;
2510 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2511 * in math.h, this fix applies.
2513 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2514 bypass = "define[ \t]+DBL_MAX";
2516 shell =
2518 * See if we have a definition for DBL_MAX in float.h.
2519 * If we do, we will replace the one in math.h with that one.
2522 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2523 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2525 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2526 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2527 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2528 "\telse cat\n"
2529 "\tfi";
2531 test_text =
2532 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2533 "#define HUGE_VAL DBL_MAX";
2538 * nested comment
2540 fix = {
2541 hackname = nested_auth_des;
2542 files = rpc/rpc.h;
2543 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2544 c_fix = format;
2545 c_fix_arg = "%1*/ /*";
2546 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2551 * Some versions of NetBSD don't expect the C99 inline semantics.
2553 fix = {
2554 hackname = netbsd_c99_inline_1;
2555 mach = "*-*-netbsd*";
2556 files = signal.h;
2557 select = "extern __inline int";
2559 c_fix = format;
2560 c_fix_arg = "extern\n"
2561 "#ifdef __GNUC_STDC_INLINE__\n"
2562 "__attribute__((__gnu_inline__))\n"
2563 "#endif\n"
2564 "__inline int";
2566 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2570 fix = {
2571 hackname = netbsd_c99_inline_2;
2572 mach = "*-*-netbsd*";
2573 files = signal.h;
2574 select = "#define _SIGINLINE extern __inline";
2576 c_fix = format;
2577 c_fix_arg = <<- _EOArg_
2578 #ifdef __GNUC_STDC_INLINE__
2579 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2580 #else
2582 #endif
2583 _EOArg_;
2585 test_text = "#define _SIGINLINE extern __inline";
2590 * NetBSD has a semicolon after the ending '}' for some extern "C".
2592 fix = {
2593 hackname = netbsd_extra_semicolon;
2594 mach = "*-*-netbsd*";
2595 files = sys/cdefs.h;
2596 select = "#define[ \t]*__END_DECLS[ \t]*};";
2598 c_fix = format;
2599 c_fix_arg = "#define __END_DECLS }";
2601 test_text = "#define __END_DECLS };";
2605 /* newlib's stdint.h has several failures to conform to C99. The fix
2606 for these removed a comment that can be matched to identify unfixed
2607 versions. */
2608 fix = {
2609 hackname = newlib_stdint_1;
2610 files = stdint-newlib.h, stdint.h;
2611 select = "@todo - Add support for wint_t types";
2612 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2613 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2614 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2615 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2616 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2617 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2618 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2619 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2620 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2621 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2622 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2623 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2624 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2625 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2626 test_text = "/* @todo - Add support for wint_t types. */\n"
2627 "#define INT32_MIN (-2147483647-1)\n"
2628 "#define INT32_MAX 2147483647\n"
2629 "#define UINT32_MAX 4294967295U\n"
2630 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2631 "#define INT_LEAST32_MAX 2147483647\n"
2632 "#define UINT_LEAST32_MAX 4294967295U\n"
2633 "#define INT_FAST8_MIN INT8_MIN\n"
2634 "#define INT_FAST8_MAX INT8_MAX\n"
2635 "#define UINT_FAST8_MAX UINT8_MAX\n"
2636 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2637 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2638 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2639 "#define UINT8_C(x) x##U\n"
2640 "#define UINT16_C(x) x##U";
2644 fix = {
2645 hackname = newlib_stdint_2;
2646 files = stdint-newlib.h, stdint.h;
2647 select = "@todo - Add support for wint_t types";
2648 c_fix = format;
2649 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2650 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2651 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2652 "#define WCHAR_MAX __WCHAR_MAX__\n"
2653 "#define WCHAR_MIN __WCHAR_MIN__\n"
2654 "#define WINT_MAX __WINT_MAX__\n"
2655 "#define WINT_MIN __WINT_MIN__\n\n"
2656 "%0";
2657 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2658 test_text = "/* @todo - Add support for wint_t types. */\n"
2659 "/** Macros for minimum-width integer constant expressions */";
2664 * NeXT 3.2 adds const prefix to some math functions.
2665 * These conflict with the built-in functions.
2667 fix = {
2668 hackname = next_math_prefix;
2669 files = ansi/math.h;
2670 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2672 c_fix = format;
2673 c_fix_arg = "extern double %1(";
2674 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2676 test_text = "extern\tdouble\t__const__\tmumble();";
2681 * NeXT 3.2 uses the word "template" as a parameter for some
2682 * functions. GCC reports an invalid use of a reserved key word
2683 * with the built-in functions.
2685 fix = {
2686 hackname = next_template;
2687 files = bsd/libc.h;
2688 select = "[ \t]template\\)";
2690 c_fix = format;
2691 c_fix_arg = "(%1)";
2692 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2693 test_text = "extern mumble( char * template); /* fix */";
2698 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2699 * function prototypes. That conflicts with the built-in functions.
2701 fix = {
2702 hackname = next_volitile;
2703 files = ansi/stdlib.h;
2704 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2706 c_fix = format;
2707 c_fix_arg = "extern void %1(";
2708 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2710 test_text = "extern\tvolatile\tvoid\tabort();";
2715 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2716 * Note that version 3 of the NeXT system has wait.h in a different directory,
2717 * so that this code won't do anything. But wait.h in version 3 has a
2718 * conditional, so it doesn't need this fix. So everything is okay.
2720 fix = {
2721 hackname = next_wait_union;
2722 files = sys/wait.h;
2724 select = 'wait\(union wait';
2725 c_fix = format;
2726 c_fix_arg = "wait(void";
2727 test_text = "extern pid_d wait(union wait*);";
2732 * a missing semi-colon at the end of the nodeent structure definition.
2734 fix = {
2735 hackname = nodeent_syntax;
2736 files = netdnet/dnetdb.h;
2737 select = "char[ \t]*\\*na_addr[ \t]*$";
2738 c_fix = format;
2739 c_fix_arg = "%0;";
2740 test_text = "char *na_addr\t";
2744 * Fix OpenBSD's NULL definition.
2746 fix = {
2747 hackname = openbsd_null_definition;
2748 mach = "*-*-openbsd*";
2749 files = locale.h, stddef.h, stdio.h, string.h,
2750 time.h, unistd.h, wchar.h, sys/param.h;
2751 select = "__GNUG__";
2752 c_fix = format;
2753 c_fix_arg = "#ifndef NULL\n"
2754 "#ifdef __cplusplus\n"
2755 "#ifdef __GNUG__\n"
2756 "#define NULL\t__null\n"
2757 "#else\t /* ! __GNUG__ */\n"
2758 "#define NULL\t0L\n"
2759 "#endif\t /* __GNUG__ */\n"
2760 "#else\t /* ! __cplusplus */\n"
2761 "#define NULL\t((void *)0)\n"
2762 "#endif\t /* __cplusplus */\n"
2763 "#endif\t /* !NULL */";
2765 c_fix_arg = "^#ifndef[ \t]*NULL\n"
2766 "^#ifdef[ \t]*__GNUG__\n"
2767 "^#define[ \t]*NULL[ \t]*__null\n"
2768 "^#else\n"
2769 "^#define[ \t]*NULL[ \t]*0L\n"
2770 "^#endif\n"
2771 "^#endif";
2772 test_text =
2773 "#ifndef NULL\n"
2774 "#ifdef __GNUG__\n"
2775 "#define NULL __null\n"
2776 "#else\n"
2777 "#define NULL 0L\n"
2778 "#endif\n"
2779 "#endif\n";
2783 * obstack.h used casts as lvalues.
2785 * We need to change postincrements of casted pointers (which are
2786 * then dereferenced and assigned into) of the form
2788 * *((TYPE*)PTRVAR)++ = (VALUE)
2790 * into expressions like
2792 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2794 * which is correct for the cases used in obstack.h since PTRVAR is
2795 * of type char * and the value of the expression is not used.
2797 fix = {
2798 hackname = obstack_lvalue_cast;
2799 files = obstack.h;
2800 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2801 c_fix = format;
2802 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2803 test_text = "*((void **) (h)->next_free)++ = (aptr)";
2807 * Fix OpenBSD's va_start define.
2809 fix = {
2810 hackname = openbsd_va_start;
2811 mach = "*-*-openbsd*";
2812 files = stdarg.h;
2813 select = '__builtin_stdarg_start';
2814 c_fix = format;
2815 c_fix_arg = __builtin_va_start;
2817 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
2821 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2822 * defining regex.h related types. This causes libg++ build and usage
2823 * failures. Fixing this correctly requires checking and modifying 3 files.
2825 fix = {
2826 hackname = osf_namespace_a;
2827 files = reg_types.h;
2828 files = sys/lc_core.h;
2829 test = " -r reg_types.h";
2830 test = " -r sys/lc_core.h";
2831 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2832 test = " -z \"`grep __regex_t regex.h`\"";
2834 c_fix = format;
2835 c_fix_arg = "__%0";
2836 c_fix_arg = "reg(ex|off|match)_t";
2838 test_text = "`touch sys/lc_core.h`"
2839 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2840 "extern regex_t re;\n"
2841 "extern regoff_t ro;\n"
2842 "extern regmatch_t rm;\n";
2845 fix = {
2846 hackname = osf_namespace_c;
2847 files = regex.h;
2848 test = " -r reg_types.h";
2849 test = " -r sys/lc_core.h";
2850 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2851 test = " -z \"`grep __regex_t regex.h`\"";
2853 select = "#include <reg_types\.h>.*";
2854 c_fix = format;
2855 c_fix_arg = "%0\n"
2856 "typedef __regex_t\tregex_t;\n"
2857 "typedef __regoff_t\tregoff_t;\n"
2858 "typedef __regmatch_t\tregmatch_t;";
2860 test_text = "#include <reg_types.h>";
2865 * On broken glibc-2.3.3 systems an array of incomplete structures is
2866 * passed to __sigsetjmp. Fix that to take a pointer instead.
2868 fix = {
2869 hackname = pthread_incomplete_struct_argument;
2870 files = pthread.h;
2871 select = "struct __jmp_buf_tag";
2872 c_fix = format;
2873 c_fix_arg = "%1 *%2%3";
2874 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2875 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2879 * Fix return type of fread and fwrite on sysV68
2881 fix = {
2882 hackname = read_ret_type;
2883 files = stdio.h;
2884 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2885 c_fix = format;
2886 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2887 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2889 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2894 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2896 fix = {
2897 hackname = rpc_xdr_lvalue_cast_a;
2898 files = rpc/xdr.h;
2899 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2900 c_fix = format;
2901 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2902 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2903 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2907 fix = {
2908 hackname = rpc_xdr_lvalue_cast_b;
2909 files = rpc/xdr.h;
2910 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2911 c_fix = format;
2912 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2913 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2914 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2919 * function class(double x) conflicts with C++ keyword on rs/6000
2921 fix = {
2922 hackname = rs6000_double;
2923 files = math.h;
2924 select = '[^a-zA-Z_]class\(';
2926 c_fix = format;
2927 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2928 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2930 test_text = "extern int class();";
2935 * Wrong fchmod prototype on RS/6000.
2937 fix = {
2938 hackname = rs6000_fchmod;
2939 files = sys/stat.h;
2940 select = 'fchmod\(char \*';
2941 c_fix = format;
2942 c_fix_arg = "fchmod(int";
2943 test_text = "extern int fchmod(char *, mode_t);";
2948 * parameters conflict with C++ new on rs/6000
2950 fix = {
2951 hackname = rs6000_param;
2952 files = "stdio.h";
2953 files = "unistd.h";
2955 select = 'rename\(const char \*old, const char \*new\)';
2956 c_fix = format;
2957 c_fix_arg = 'rename(const char *_old, const char *_new)';
2959 test_text = 'extern int rename(const char *old, const char *new);';
2964 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
2965 * for C99. This is wrong for C++, which needs many C99 features, but
2966 * only supports __restrict.
2968 fix = {
2969 hackname = solaris___restrict;
2970 files = sys/feature_tests.h;
2971 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
2972 mach = "*-*-solaris2*";
2973 c_fix = format;
2974 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
2975 "#else\n%0\n#endif";
2976 test_text = "#define _RESTRICT_KYWD restrict";
2981 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
2982 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
2983 * and imaginary definitions which are not supported by GCC.
2985 fix = {
2986 hackname = solaris_complex;
2987 mach = "*-*-solaris2.*";
2988 files = complex.h;
2989 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
2990 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
2991 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
2992 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
2993 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
2994 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
2995 test_text = "#define _Complex_I _Complex_I\n"
2996 "#define complex _Complex\n"
2997 "#define _Imaginary_I _Imaginary_I\n"
2998 "#define imaginary _Imaginary\n"
2999 "#undef I\n"
3000 "#define I _Imaginary_I";
3005 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3006 * extern "C" instead so libstdc++ can use it.
3008 fix = {
3009 hackname = solaris_complex_cxx;
3010 mach = "*-*-solaris2.*";
3011 files = complex.h;
3012 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3013 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3014 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3015 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3016 test_text = "#if !defined(__cplusplus)\n"
3017 "#endif /* !defined(__cplusplus) */";
3022 * g++ rejects functions declared with both C and C++ linkage.
3024 fix = {
3025 hackname = solaris_cxx_linkage;
3026 mach = '*-*-solaris2*';
3027 files = "iso/stdlib_iso.h";
3028 select = "(#if __cplusplus >= 199711L)\n"
3029 "(extern \"C\\+\\+\" \\{\n)"
3030 "(.*(bsearch|qsort).*)";
3031 c_fix = format;
3032 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3034 test_text =
3035 "#if __cplusplus >= 199711L\n"
3036 "extern \"C++\" {\n"
3037 " void *bsearch(const void *, const void *, size_t, size_t,";
3042 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3043 * _STRICT_STDC, but uses it.
3045 fix = {
3046 hackname = solaris_getc_strict_stdc;
3047 mach = "*-*-solaris2*";
3048 files = "iso/stdio_iso.h";
3049 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3050 c_fix = format;
3051 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3053 test_text =
3054 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3059 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
3061 fix = {
3062 hackname = solaris_longjmp_noreturn;
3063 mach = "*-*-solaris2*";
3064 files = "iso/setjmp_iso.h";
3065 bypass = "__NORETURN";
3066 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
3067 c_fix = format;
3068 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
3070 test_text = "extern void longjmp(jmp_buf, int);";
3075 * Sun Solaris 10 defines several C99 math macros in terms of
3076 * builtins specific to the Studio compiler, in particular not
3077 * compatible with the GNU compiler.
3079 fix = {
3080 hackname = solaris_math_1;
3081 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3082 bypass = "__GNUC__";
3083 files = iso/math_c99.h;
3084 c_fix = format;
3085 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3086 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3087 test_text =
3088 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3089 "#undef HUGE_VAL\n"
3090 "#define HUGE_VAL __builtin_huge_val\n"
3091 "#undef HUGE_VALF\n"
3092 "#define HUGE_VALF __builtin_huge_valf\n"
3093 "#undef HUGE_VALL\n"
3094 "#define HUGE_VALL __builtin_huge_vall";
3097 fix = {
3098 hackname = solaris_math_2;
3099 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3100 bypass = "__GNUC__";
3101 files = iso/math_c99.h;
3102 c_fix = format;
3103 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3104 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3105 test_text =
3106 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3107 "#undef INFINITY\n"
3108 "#define INFINITY __builtin_infinity";
3111 fix = {
3112 hackname = solaris_math_3;
3113 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3114 bypass = "__GNUC__";
3115 files = iso/math_c99.h;
3116 c_fix = format;
3117 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3118 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3119 test_text =
3120 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3121 "#undef NAN\n"
3122 "#define NAN __builtin_nan";
3125 fix = {
3126 hackname = solaris_math_4;
3127 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3128 bypass = "__GNUC__";
3129 files = iso/math_c99.h;
3130 c_fix = format;
3131 c_fix_arg = "#define\tfpclassify(x) \\\n"
3132 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3133 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3134 test_text =
3135 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3136 "#undef fpclassify\n"
3137 "#define fpclassify(x) __builtin_fpclassify(x)";
3140 fix = {
3141 hackname = solaris_math_8;
3142 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3143 bypass = "__GNUC__";
3144 files = iso/math_c99.h;
3145 c_fix = format;
3146 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3147 "\t\t\t ? __builtin_signbitf(x) \\\n"
3148 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3149 "\t\t\t ? __builtin_signbitl(x) \\\n"
3150 "\t\t\t : __builtin_signbit(x))";
3151 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3152 test_text = <<- _EOText_
3153 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3154 #undef signbit
3155 #define signbit(x) __builtin_signbit(x)
3156 _EOText_;
3159 fix = {
3160 hackname = solaris_math_9;
3161 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3162 bypass = "__GNUC__";
3163 files = iso/math_c99.h;
3164 c_fix = format;
3165 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3166 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3167 test_text =
3168 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3169 "#undef isgreater\n"
3170 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3171 "#undef isgreaterequal\n"
3172 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3173 "#undef isless\n"
3174 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3175 "#undef islessequal\n"
3176 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3177 "#undef islessgreater\n"
3178 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3179 "#undef isunordered\n"
3180 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3184 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3185 * exception. Provide an alternative using GCC's builtin.
3188 fix = {
3189 hackname = solaris_math_10;
3190 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3191 files = iso/math_c99.h;
3192 c_fix = format;
3193 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3194 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3195 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3196 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3197 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3198 test_text =
3199 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3200 "#undef isinf\n"
3201 "#define isinf(x) __extension__( \\\\\n"
3202 " { __typeof(x) __x_i = (x); \\\\\n"
3203 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3204 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3208 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3209 * "0" for the last field of the pthread_mutex_t structure, which is
3210 * of type upad64_t, which itself is typedef'd to int64_t, but with
3211 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3212 * initializer to "{0}" instead
3214 fix = {
3215 hackname = solaris_mutex_init_2;
3216 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3217 files = pthread.h;
3219 * On Solaris 10, this fix is unnecessary because upad64_t is
3220 * always defined correctly regardless of the definition of the
3221 * __STDC__ macro. The first "mach" pattern matches up to
3222 * solaris9. The second "mach" pattern will not match any two (or
3223 * more) digit solaris version, but it will match e.g. 2.5.1.
3225 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3226 c_fix = format;
3227 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3228 "%0\n"
3229 "#else\n"
3230 "%1, {0}}%4\n"
3231 "#endif";
3232 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3233 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3234 ",[ \t]*0\\}" "(|[ \t].*)$";
3235 test_text =
3236 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3237 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3238 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3239 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3240 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3241 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3242 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3247 * The pow overloads with int were removed in C++ 2011.
3249 fix = {
3250 hackname = solaris_pow_int_overload;
3251 mach = '*-*-solaris2*';
3252 files = "iso/math_iso.h";
3253 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3254 " *\\{[^{}]*\n[^{}]*\\}";
3255 c_fix = format;
3256 c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif";
3258 test_text =
3259 " inline long double pow(long double __X, int __Y) { return\n"
3260 " __powl(__X, (long double) (__Y)); }";
3265 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3266 * fields of the pthread_rwlock_t structure, which are of type
3267 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3268 * defined (e.g. by -ansi) it is a union. So change the initializer
3269 * to "{0}" instead.
3271 fix = {
3272 hackname = solaris_rwlock_init_1;
3273 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3274 files = pthread.h;
3275 mach = '*-*-solaris*';
3276 c_fix = format;
3277 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3278 "%0\n"
3279 "#else\n"
3280 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3281 "#endif";
3282 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3283 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3285 test_text =
3286 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3287 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3292 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3293 * structure. As such, it need two levels of brackets, but only
3294 * contains one. Wrap the macro definition in an extra layer.
3296 fix = {
3297 hackname = solaris_once_init_1;
3298 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3299 files = pthread.h;
3300 mach = '*-*-solaris*';
3301 c_fix = format;
3302 c_fix_arg = "%1{%2}%3";
3303 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3304 test_text =
3305 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3306 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3311 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3312 * fields of the pthread_once_t structure, which are of type
3313 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3314 * defined (e.g. by -ansi) it is a union. So change the initializer
3315 * to "{0}" instead. This test relies on solaris_once_init_1.
3317 fix = {
3318 hackname = solaris_once_init_2;
3319 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3320 files = pthread.h;
3322 * On Solaris 10, this fix is unnecessary because upad64_t is
3323 * always defined correctly regardless of the definition of the
3324 * __STDC__ macro. The first "mach" pattern matches up to
3325 * solaris9. The second "mach" pattern will not match any two (or
3326 * more) digit solaris version, but it will match e.g. 2.5.1.
3328 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3329 c_fix = format;
3330 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3331 "%0\n"
3332 "#else\n"
3333 "%1{0}, {0}, {0}, {%3}%4\n"
3334 "#endif";
3335 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3336 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3337 test_text =
3338 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3339 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3344 * Sun Solaris 2 has a version of sys/int_const.h that defines
3345 * UINT8_C and UINT16_C to unsigned constants.
3347 fix = {
3348 hackname = solaris_int_const;
3349 files = sys/int_const.h;
3350 mach = '*-*-solaris2*';
3351 c_fix = format;
3352 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3353 "%1\n"
3354 "#define\tUINT16_C(c)\t(c)";
3355 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3356 "(/\*.*\*/)\n"
3357 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3358 test_text =
3359 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3360 "/* CSTYLED */\n"
3361 "#define UINT16_C(c) __CONCAT__(c,u)";
3366 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3367 * UINT8_MAX and UINT16_MAX to unsigned constants.
3369 fix = {
3370 hackname = solaris_int_limits_1;
3371 files = sys/int_limits.h;
3372 mach = '*-*-solaris2*';
3373 c_fix = format;
3374 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3375 "#define\tUINT16_MAX\t(65535)";
3376 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3377 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3378 test_text =
3379 "#define UINT8_MAX (255U)\n"
3380 "#define UINT16_MAX (65535U)";
3385 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3386 * INT_FAST16 limits to wrong values for sys/int_types.h.
3388 fix = {
3389 hackname = solaris_int_limits_2;
3390 files = sys/int_limits.h;
3391 mach = '*-*-solaris2*';
3392 c_fix = format;
3393 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3394 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3395 test_text =
3396 "#define INT_FAST16_MAX INT16_MAX\n"
3397 "#define UINT_FAST16_MAX UINT16_MAX\n"
3398 "#define INT_FAST16_MIN INT16_MIN";
3403 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3404 * SIZE_MAX as unsigned long.
3406 fix = {
3407 hackname = solaris_int_limits_3;
3408 files = sys/int_limits.h;
3409 mach = '*-*-solaris2*';
3410 c_fix = format;
3411 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3412 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3413 test_text =
3414 "#define SIZE_MAX 4294967295UL";
3419 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3420 * of Standard C99 64-bit types in 32-bit mode.
3422 fix = {
3423 hackname = solaris_int_types;
3424 select = "__STDC__ - 0 == 0";
3425 bypass = "_LONGLONG_TYPE";
3426 files = sys/int_types.h;
3427 c_fix = format;
3428 c_fix_arg =
3429 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3430 test_text =
3431 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3432 "typedef long long int64_t;\n"
3433 "#endif\n\n"
3434 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3435 "typedef int64_t intmax_t;\n"
3436 "#endif";
3441 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3442 * posix_spawn declarations, which doesn't work with C++.
3444 fix = {
3445 hackname = solaris_posix_spawn_restrict;
3446 files = spawn.h;
3447 mach = '*-*-solaris2*';
3448 c_fix = format;
3449 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3450 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3451 test_text =
3452 "char *const argv[_RESTRICT_KYWD],\n"
3453 "char *const envp[_RESTRICT_KYWD]);";
3458 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3459 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3461 fix = {
3462 hackname = solaris_std___filbuf;
3463 files = stdio.h;
3464 mach = '*-*-solaris2*';
3465 bypass = "using std::__filbuf";
3466 select = "(using std::perror;\n)(#endif)";
3467 c_fix = format;
3468 c_fix_arg = "%1#ifndef _LP64\n"
3469 "using std::__filbuf;\n"
3470 "using std::__flsbuf;\n"
3471 "#endif\n%2";
3473 test_text = "using std::perror;\n"
3474 "#endif";
3479 * Sun Solaris 8 has what appears to be some gross workaround for
3480 * some old version of their c++ compiler. G++ doesn't want it
3481 * either, but doesn't want to be tied to SunPRO version numbers.
3483 fix = {
3484 hackname = solaris_stdio_tag;
3485 files = stdio_tag.h;
3487 select = '__cplusplus < 54321L';
3488 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3489 "!defined(__GNUC__)" so we no longer need to fix it. */
3490 bypass = '__GNUC__';
3491 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3493 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3498 * On Solaris 9, __va_list needs to become a typedef for
3499 * __builtin_va_list to make -Wmissing-format-attribute work.
3501 fix = {
3502 hackname = solaris_sys_va_list;
3503 files = sys/va_list.h;
3504 mach = '*-*-solaris2.9';
3505 select = "#if.*__STDC__.*\n"
3506 "typedef void \\*__va_list;\n"
3507 "#else\n"
3508 "typedef char \\*__va_list;\n"
3509 "#endif";
3511 c_fix = format;
3512 c_fix_arg = "#ifdef __GNUC__\n"
3513 "typedef __builtin_va_list __va_list;\n"
3514 "#else\n"
3515 "%0\n"
3516 "#endif";
3517 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3518 "typedef void *__va_list;\n"
3519 "#else\n"
3520 "typedef char *__va_list;\n"
3521 "#endif";
3526 * a missing semi-colon at the end of the statsswtch structure definition.
3528 fix = {
3529 hackname = statsswtch;
3530 files = rpcsvc/rstat.h;
3531 select = "boottime$";
3532 c_fix = format;
3533 c_fix_arg = "boottime;";
3534 test_text = "struct statswtch {\n int boottime\n};";
3539 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3540 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3541 * OK too.
3543 fix = {
3544 hackname = stdio_stdarg_h;
3545 files = stdio.h;
3546 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3548 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3549 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3551 mach = '*-*-solaris2.1[0-9]*';
3552 not_machine = true;
3554 c_fix = wrap;
3556 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3558 test_text = "";
3563 * Don't use or define the name va_list in stdio.h. This is for
3564 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3565 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3566 * indicate that the header knows what it's doing -- under SUSv2,
3567 * stdio.h is required to define va_list, and we shouldn't break
3568 * that.
3570 fix = {
3571 hackname = stdio_va_list;
3572 files = stdio.h;
3573 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3575 * On Solaris 10, the definition in
3576 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3577 * there is therefore no need for this fix there.
3579 mach = '*-*-solaris2.1[0-9]*';
3580 not_machine = true;
3583 * Use __gnuc_va_list in arg types in place of va_list.
3584 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3585 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3586 * trailing parentheses and semicolon save all other systems from this.
3587 * Define __not_va_list__ (something harmless and unused)
3588 * instead of va_list.
3589 * Don't claim to have defined va_list.
3591 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3592 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3593 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3594 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3595 "s@ va_list@ __not_va_list__@\n"
3596 "s@\\*va_list@*__not_va_list__@\n"
3597 "s@ __va_list)@ __gnuc_va_list)@\n"
3598 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3599 "@typedef \\1 __not_va_list__;@\n"
3600 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3601 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3602 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3603 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3604 "s@VA_LIST@DUMMY_VA_LIST@\n"
3605 "s@_Va_LIST@_VA_LIST@";
3606 test_text = "extern void mumble( va_list);";
3611 * Fix headers that use va_list from stdio.h to use the updated
3612 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3613 * dealt with elsewhere. The presence of __gnuc_va_list,
3614 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3615 * knows what it's doing.
3617 fix = {
3618 hackname = stdio_va_list_clients;
3619 files = com_err.h;
3620 files = cps.h;
3621 files = curses.h;
3622 files = krb5.h;
3623 files = lc_core.h;
3624 files = pfmt.h;
3625 files = wchar.h;
3626 files = curses_colr/curses.h;
3627 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3628 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3629 otherwise protected. */
3630 bypass = 'include <stdarg\.h>|#ifdef va_start';
3633 * Use __gnuc_va_list in arg types in place of va_list.
3634 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3635 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3636 * trailing parentheses and semicolon save all other systems from this.
3637 * Define __not_va_list__ (something harmless and unused)
3638 * instead of va_list.
3639 * Don't claim to have defined va_list.
3641 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3642 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3643 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3644 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3645 "s@ va_list@ __not_va_list__@\n"
3646 "s@\\*va_list@*__not_va_list__@\n"
3647 "s@ __va_list)@ __gnuc_va_list)@\n"
3648 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3649 "@typedef \\1 __not_va_list__;@\n"
3650 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3651 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3652 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3653 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3654 "s@VA_LIST@DUMMY_VA_LIST@\n"
3655 "s@_Va_LIST@_VA_LIST@";
3656 test_text = "extern void mumble( va_list);";
3661 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3662 * is "!defined( __STRICT_ANSI__ )"
3664 fix = {
3665 hackname = strict_ansi_not;
3666 select = "^([ \t]*#[ \t]*if.*)"
3667 "(!__STDC__"
3668 "|__STDC__[ \t]*==[ \t]*0"
3669 "|__STDC__[ \t]*!=[ \t]*1"
3670 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3671 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3672 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3673 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3674 is not defined by GCC, so it is safe. */
3675 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3676 c_test = stdc_0_in_system_headers;
3678 c_fix = format;
3679 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3681 test_text = "#if !__STDC__ \n"
3682 "#if __STDC__ == 0\n"
3683 "#if __STDC__ != 1\n"
3684 "#if __STDC__ - 0 == 0"
3685 "/* not std C */\nint foo;\n"
3686 "\n#end-end-end-end-if :-)";
3690 * "__STDC__-0==0"
3691 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3693 fix = {
3694 hackname = strict_ansi_not_ctd;
3695 files = math.h, limits.h, stdio.h, signal.h,
3696 stdlib.h, sys/signal.h, time.h;
3698 * Starting at the beginning of a line, skip white space and
3699 * a leading "(" or "&&" or "||". One of those must be found.
3700 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3701 * expression. If these are nested, then they must accumulate
3702 * because we won't match any closing parentheses. Finally,
3703 * after skipping over all that, we must then match our suspect
3704 * phrase: "__STDC__-0==0" with or without white space.
3706 select = "^([ \t]*" '(\(|&&|\|\|)'
3707 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3708 "[ \t(]*)"
3709 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3710 c_test = stdc_0_in_system_headers;
3712 c_fix = format;
3713 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3715 test_text = "#if 1 && \\\\\n"
3716 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3717 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3718 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3719 "int foo;\n#endif";
3724 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3725 * is "defined( __STRICT_ANSI__ )"
3727 fix = {
3728 hackname = strict_ansi_only;
3729 select = "^([ \t]*#[ \t]*if.*)"
3730 "(__STDC__[ \t]*!=[ \t]*0"
3731 "|__STDC__[ \t]*==[ \t]*1"
3732 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3733 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3734 c_test = stdc_0_in_system_headers;
3736 c_fix = format;
3737 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3739 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3744 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3745 * in prototype without previous definition.
3747 fix = {
3748 hackname = struct_file;
3749 files = rpc/xdr.h;
3750 select = '^.*xdrstdio_create.*struct __file_s';
3751 c_fix = format;
3752 c_fix_arg = "struct __file_s;\n%0";
3753 test_text = "extern void xdrstdio_create( struct __file_s* );";
3758 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3759 * in prototype without previous definition.
3761 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3762 * function, and does define it.
3764 fix = {
3765 hackname = struct_sockaddr;
3766 files = rpc/auth.h;
3767 select = "^.*authdes_create.*struct sockaddr[^_]";
3768 bypass = "<sys/socket\.h>";
3769 bypass = "struct sockaddr;\n";
3770 c_fix = format;
3771 c_fix_arg = "struct sockaddr;\n%0";
3772 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3777 * Apply fix this to all OSs since this problem seems to effect
3778 * more than just SunOS.
3780 fix = {
3781 hackname = sun_auth_proto;
3782 files = rpc/auth.h;
3783 files = rpc/clnt.h;
3784 files = rpc/svc.h;
3785 files = rpc/xdr.h;
3786 bypass = "__cplusplus";
3788 * Select those files containing '(*name)()'.
3790 select = '\(\*[a-z][a-z_]*\)\(\)';
3792 c_fix = format;
3793 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3794 "#else\n%1();%2\n#endif";
3795 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3797 test_text =
3798 "struct auth_t {\n"
3799 " int (*name)(); /* C++ bad */\n"
3800 "};";
3805 * Fix bogus #ifdef on SunOS 4.1.
3807 fix = {
3808 hackname = sun_bogus_ifdef;
3809 files = "hsfs/hsfs_spec.h";
3810 files = "hsfs/iso_spec.h";
3811 select = '#ifdef(.*\|\|.*)';
3812 c_fix = format;
3813 c_fix_arg = "#if%1";
3815 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3820 * Fix the CAT macro in SunOS memvar.h.
3822 fix = {
3823 hackname = sun_catmacro;
3824 files = pixrect/memvar.h;
3825 select = "^#define[ \t]+CAT\\(a,b\\).*";
3826 c_fix = format;
3828 c_fix_arg =
3829 "#ifdef __STDC__\n"
3830 "# define CAT(a,b) a##b\n"
3831 "#else\n%0\n#endif";
3833 test_text =
3834 "#define CAT(a,b)\ta/**/b";
3839 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3840 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3842 fix = {
3843 hackname = sun_malloc;
3844 files = malloc.h;
3845 bypass = "_CLASSIC_ANSI_TYPES";
3847 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3848 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3849 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3850 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3851 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3853 test_text =
3854 "typedef char *\tmalloc_t;\n"
3855 "int \tfree();\n"
3856 "char*\tmalloc();\n"
3857 "char*\tcalloc();\n"
3858 "char*\trealloc();";
3863 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3865 fix = {
3866 hackname = sun_rusers_semi;
3867 files = rpcsvc/rusers.h;
3868 select = "_cnt$";
3869 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3870 test_text = "struct mumble\n int _cnt\n};";
3875 * signal.h on SunOS defines signal using (),
3876 * which causes trouble when compiling with g++ -pedantic.
3878 fix = {
3879 hackname = sun_signal;
3880 files = sys/signal.h;
3881 files = signal.h;
3882 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3884 c_fix = format;
3885 c_fix_arg =
3886 "#ifdef __cplusplus\n"
3887 "void\t(*signal(...))(...);\n"
3888 "#else\n%0\n#endif";
3890 test_text = "void\t(*signal())();";
3895 * Correct the return type for strlen in strings.h in SunOS 4.
3897 fix = {
3898 hackname = sunos_strlen;
3899 files = strings.h;
3900 select = "int[ \t]*strlen\\(\\);(.*)";
3901 c_fix = format;
3902 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3903 test_text = " int\tstrlen(); /* string length */";
3908 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3909 * that is visible to any ANSI compiler using this include. Simply
3910 * delete the lines that #define some string functions to internal forms.
3912 fix = {
3913 hackname = svr4_disable_opt;
3914 files = string.h;
3915 select = '#define.*__std_hdr_';
3916 sed = '/#define.*__std_hdr_/d';
3917 test_text = "#define strlen __std_hdr_strlen\n";
3922 * Fix broken decl of getcwd present on some svr4 systems.
3924 fix = {
3925 hackname = svr4_getcwd;
3926 files = stdlib.h;
3927 files = unistd.h;
3928 files = prototypes.h;
3929 select = 'getcwd\(char \*, int\)';
3931 c_fix = format;
3932 c_fix_arg = "getcwd(char *, size_t)";
3934 test_text = "extern char* getcwd(char *, int);";
3939 * Fix broken decl of profil present on some svr4 systems.
3941 fix = {
3942 hackname = svr4_profil;
3943 files = stdlib.h;
3944 files = unistd.h;
3946 select =
3947 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3948 c_fix = format;
3949 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3951 test_text =
3952 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3957 * Correct types for signal handler constants like SIG_DFL; they might be
3958 * void (*) (), and should be void (*) (int). C++ doesn't like the
3959 * old style.
3961 fix = {
3962 hackname = svr4_sighandler_type;
3963 files = sys/signal.h;
3964 select = 'void *\(\*\)\(\)';
3965 c_fix = format;
3966 c_fix_arg = "void (*)(int)";
3967 test_text = "#define SIG_DFL (void(*)())0\n"
3968 "#define SIG_IGN (void (*)())0\n";
3973 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
3974 * function 'getrnge' in <regexp.h> before they declare it. For these
3975 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
3976 * early on.
3978 * 'getrnge' traditionally manipulates a file-scope global called 'size',
3979 * so put the declaration right after the declaration of 'size'.
3981 * Don't do this if there is already a `static void getrnge' declaration
3982 * present, since this would cause a redeclaration error. Solaris 2.x has
3983 * such a declaration.
3985 fix = {
3986 hackname = svr4_undeclared_getrnge;
3987 files = regexp.h;
3988 select = "getrnge";
3989 bypass = "static void getrnge";
3990 c_fix = format;
3991 c_fix_arg = "%0\n"
3992 "static int getrnge ();";
3993 c_fix_arg = "^static int[ \t]+size;";
3994 test_text = "static int size;\n"
3995 "/* stuff which calls getrnge() */\n"
3996 "static getrnge()\n"
3997 "{}";
4002 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4003 * in string.h on sysV68
4004 * Correct the return type for strlen in string.h on Lynx.
4005 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4006 * Add missing const for strdup on OSF/1 V3.0.
4007 * On sysV88 layout is slightly different.
4009 fix = {
4010 hackname = sysv68_string;
4011 files = testing.h;
4012 files = string.h;
4013 bypass = "_CLASSIC_ANSI_TYPES";
4015 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4016 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4017 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4019 sed = "/^extern char$/N";
4020 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4022 sed = "/^extern int$/N";
4023 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4025 sed = "/^\tstrncmp(),$/N";
4026 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4027 '\1;' "\\\nextern unsigned int\\\n\\2/";
4029 test_text =
4030 "extern int strlen();\n"
4032 "extern int ffs(long);\n"
4034 "extern char\n"
4035 "\t*memccpy(),\n"
4036 "\tmemcpy();\n"
4038 "extern int\n"
4039 "\tstrcmp(),\n"
4040 "\tstrncmp(),\n"
4041 "\tstrlen(),\n"
4042 "\tstrspn();\n"
4044 "extern int\n"
4045 "\tstrlen(), strspn();";
4050 * Fix return type of calloc, malloc, realloc, bsearch and exit
4052 fix = {
4053 hackname = sysz_stdlib_for_sun;
4054 files = stdlib.h;
4055 bypass = "_CLASSIC_ANSI_TYPES";
4057 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4058 c_fix = format;
4059 c_fix_arg = "void *\t%1(";
4061 test_text =
4062 "extern char*\tcalloc(size_t);\n"
4063 "extern char*\tmalloc(size_t);\n"
4064 "extern char*\trealloc(void*,size_t);\n"
4065 "extern char*\tbsearch(void*,size_t,size_t);\n";
4070 * __thread is now a keyword.
4072 fix = {
4073 hackname = thread_keyword;
4074 files = "pthread.h";
4075 files = "bits/sigthread.h";
4076 select = "([* ])__thread([,)])";
4077 c_fix = format;
4078 c_fix_arg = "%1__thr%2";
4080 test_text =
4081 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4082 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4083 "extern int pthread_cancel (pthread_t __thread);";
4087 * if the #if says _cplusplus, not the double underscore __cplusplus
4088 * that it should be
4090 fix = {
4091 hackname = tinfo_cplusplus;
4092 files = tinfo.h;
4093 select = "[ \t]_cplusplus";
4095 c_fix = format;
4096 c_fix_arg = " __cplusplus";
4097 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4102 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4104 fix = {
4105 hackname = ultrix_const;
4106 files = stdio.h;
4107 select = 'perror\( char \*';
4109 c_fix = format;
4110 c_fix_arg = "%1 const %3 *__";
4111 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4112 "[ \t]+(char|void) \\*__";
4114 test_text =
4115 "extern void perror( char *__s );\n"
4116 "extern int fputs( char *__s, FILE *);\n"
4117 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4118 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4119 "extern int scanf( char *__format, ...);\n";
4124 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4126 fix = {
4127 hackname = ultrix_const2;
4128 files = stdio.h;
4130 select = '\*fopen\( char \*';
4131 c_fix = format;
4132 c_fix_arg = "%1( const char *%3, const char *";
4133 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4134 "[ \t]*char[ \t]*\\*([^,]*),"
4135 "[ \t]*char[ \t]*\\*[ \t]*";
4137 test_text =
4138 "extern FILE *fopen( char *__filename, char *__type );\n"
4139 "extern int sscanf( char *__s, char *__format, ...);\n"
4140 "extern FILE *popen(char *, char *);\n"
4141 "extern char *tempnam(char*,char*);\n";
4146 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4148 fix = {
4149 hackname = va_i960_macro;
4150 files = arch/i960/archI960.h;
4151 select = "__(vsiz|vali|vpad|alignof__)";
4153 c_fix = format;
4154 c_fix_arg = "__vx%1";
4156 test_text =
4157 "extern int __vsiz vsiz;\n"
4158 "extern int __vali vali;\n"
4159 "extern int __vpad vpad;\n"
4160 "#define __alignof__(x) ...";
4165 * Define __CAN_USE_EXTERN_PREFIX on vms.
4167 fix = {
4168 hackname = vms_define_can_use_extern_prefix;
4169 files = "rtldef/decc$types.h";
4170 select = "#[ \t]*else\n"
4171 "#[ \t]*if defined\\(__DECCXX\\)\n"
4172 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4173 mach = "*-*-*vms*";
4174 c_fix = format;
4176 c_fix_arg = "%0"
4177 "# elif defined (__GNUC__)\n"
4178 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4180 test_text = "# else\n"
4181 "# if defined(__DECCXX)\n"
4182 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4183 "# endif\n"
4184 "# endif\n";
4188 * On VMS, use pragma extern_model instead of VAX-C keywords.
4190 fix = {
4191 hackname = vms_use_pragma_extern_model;
4192 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4193 "# pragma extern_model __save\n";
4194 mach = "*-*-*vms*";
4195 c_fix = format;
4197 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4198 "# pragma extern_model __save\n";
4200 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4201 "# pragma extern_model __save\n"
4202 "# pragma extern_model strict_refdef\n"
4203 " extern struct x zz$yy;\n"
4204 "# pragma extern_model __restore\n"
4205 "#endif\n";
4209 * On VMS, disable the use of dec-c string builtins
4211 fix = {
4212 hackname = vms_disable_decc_string_builtins;
4213 select = "#if !defined\\(__VAX\\)\n";
4214 mach = "*-*-*vms*";
4215 files = "rtldef/string.h";
4216 c_fix = format;
4218 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4220 test_text = "#if !defined(__VAX)\n";
4224 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4225 * conflict while building gcc. Likewise for <builtins.h>
4227 fix = {
4228 hackname = vms_use_quoted_include;
4229 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4230 mach = "*-*-*vms*";
4231 files = rtldef/wait.h, starlet_c/pthread.h;
4232 c_fix = format;
4234 c_fix_arg = '%1<sys/%2.h>';
4236 test_text = "# include <resource.h>";
4240 * On VMS, add missing braces around sigset_t constants.
4242 fix = {
4243 hackname = vms_add_missing_braces;
4244 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4245 mach = "*-*-*vms*";
4246 files = "rtldef/signal.h";
4247 c_fix = format;
4249 c_fix_arg = '%1 {%2} ';
4251 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4252 "{0x00000000, 0x00000000},\n"
4253 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4257 * On VMS, fix incompatible redeclaration of hostalias.
4259 fix = {
4260 hackname = vms_do_not_redeclare_hostalias;
4261 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4262 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4263 mach = "*-*-*vms*";
4264 files = "rtldef/resolv.h";
4265 c_fix = format;
4267 c_fix_arg = "%1\n"
4268 "/* %2 */";
4270 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4271 "__char_ptr32 hostalias (const char *);\n";
4275 * On VMS, some DEC-C builtins are directly used.
4277 fix = {
4278 hackname = vms_decc_builtin;
4279 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4280 mach = "*-*-*vms*";
4281 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4282 rtldef/socket.h;
4283 sed = "s@__MEMSET@memset@";
4284 sed = "s@__MEMMOVE@memmove@";
4285 sed = "s@__MEMCPY@memcpy@";
4286 sed = "s@__STRLEN@strlen@";
4287 sed = "s@__STRCPY@strcpy@";
4289 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4293 * On VMS, do not declare getopt and al if pointers are 64 bit.
4295 fix = {
4296 hackname = vms_no_64bit_getopt;
4297 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4298 /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
4299 mach = "*-*-*vms*";
4300 files = rtldef/stdio.h, rtldef/unistd.h;
4301 c_fix = format;
4303 c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n"
4304 "%0"
4305 "#endif\n";
4307 test_text = "int getopt (int, char * const [], const char *);";
4311 * On VMS, forward declare structure before referencing them in prototypes.
4313 fix = {
4314 hackname = vms_forward_declare_struct;
4315 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4316 "#ifdef __cplusplus\n";
4317 mach = "*-*-*vms*";
4318 files = rtldef/if.h;
4319 c_fix = format;
4321 c_fix_arg = "%1"
4322 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4324 test_text = "/* forward decls for C++ */\n"
4325 "#ifdef __cplusplus\n"
4326 "struct foo;\n"
4327 "#endif\n";
4331 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4332 * which is not yet fully supported by gcc.
4334 fix = {
4335 hackname = vms_use_fast_setjmp;
4336 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4337 mach = "*-*-*vms*";
4338 files = rtldef/setjmp.h;
4339 c_fix = format;
4341 c_fix_arg = "%0 defined (__GNUC__) ||";
4343 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4347 * AIX and Interix headers define NULL to be cast to a void pointer,
4348 * which is illegal in ANSI C++.
4350 fix = {
4351 hackname = void_null;
4352 files = curses.h;
4353 files = dbm.h;
4354 files = locale.h;
4355 files = stdio.h;
4356 files = stdlib.h;
4357 files = string.h;
4358 files = time.h;
4359 files = unistd.h;
4360 files = sys/dir.h;
4361 files = sys/param.h;
4362 files = sys/types.h;
4363 /* avoid changing C++ friendly NULL */
4364 bypass = __cplusplus;
4365 bypass = __null;
4366 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4367 c_fix = format;
4368 c_fix_arg = "#define NULL 0";
4369 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4374 * Make VxWorks header which is almost gcc ready fully gcc ready.
4376 fix = {
4377 hackname = vxworks_gcc_problem;
4378 files = types/vxTypesBase.h;
4379 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4381 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4382 "#if 1/";
4384 sed = "/[ \t]size_t/i\\\n"
4385 "#ifndef _GCC_SIZE_T\\\n"
4386 "#define _GCC_SIZE_T\n";
4388 sed = "/[ \t]size_t/a\\\n"
4389 "#endif\n";
4391 sed = "/[ \t]ptrdiff_t/i\\\n"
4392 "#ifndef _GCC_PTRDIFF_T\\\n"
4393 "#define _GCC_PTRDIFF_T\n";
4395 sed = "/[ \t]ptrdiff_t/a\\\n"
4396 "#endif\n";
4398 sed = "/[ \t]wchar_t/i\\\n"
4399 "#ifndef _GCC_WCHAR_T\\\n"
4400 "#define _GCC_WCHAR_T\n";
4402 sed = "/[ \t]wchar_t/a\\\n"
4403 "#endif\n";
4405 test_text =
4406 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4407 "typedef unsigned int size_t;\n"
4408 "typedef long ptrdiff_t;\n"
4409 "typedef unsigned short wchar_t;\n"
4410 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4415 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4417 fix = {
4418 hackname = vxworks_needs_vxtypes;
4419 files = time.h;
4420 select = "uint_t([ \t]+_clocks_per_sec)";
4421 c_fix = format;
4422 c_fix_arg = "unsigned int%1";
4423 test_text = "uint_t\t_clocks_per_sec;";
4428 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4430 fix = {
4431 hackname = vxworks_needs_vxworks;
4432 files = sys/stat.h;
4433 test = " -r types/vxTypesOld.h";
4434 test = " -n \"`egrep '#include' $file`\"";
4435 test = " -n \"`egrep ULONG $file`\"";
4436 select = "#[ \t]define[ \t]+__INCstath";
4438 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4439 "#include <types/vxTypesOld.h>\n";
4441 test_text = "`touch types/vxTypesOld.h`"
4442 "#include </dev/null> /* ULONG */\n"
4443 "# define\t__INCstath <sys/stat.h>";
4448 * Another bad dependency in VxWorks 5.2 <time.h>.
4450 fix = {
4451 hackname = vxworks_time;
4452 files = time.h;
4453 test = " -r vxWorks.h";
4455 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4456 c_fix = format;
4458 c_fix_arg =
4459 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4460 "#ifdef __cplusplus\n"
4461 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4462 "#else\n"
4463 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4464 "#endif\n"
4465 "#define __gcc_VOIDFUNCPTR_defined\n"
4466 "#endif\n"
4467 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4469 test_text = "`touch vxWorks.h`"
4470 "#define VOIDFUNCPTR (void(*)())";
4475 * There are several name conflicts with C++ reserved words in X11 header
4476 * files. These are fixed in some versions, so don't do the fixes if
4477 * we find __cplusplus in the file. These were found on the RS/6000.
4479 fix = {
4480 hackname = x11_class;
4481 files = X11/ShellP.h;
4482 bypass = __cplusplus;
4483 select = "^([ \t]*char \\*)class;(.*)";
4484 c_fix = format;
4485 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4486 "#else\n%1class;%2\n#endif";
4487 test_text =
4488 "struct {\n"
4489 " char *class;\n"
4490 "} mumble;\n";
4495 * class in Xm/BaseClassI.h
4497 fix = {
4498 hackname = x11_class_usage;
4499 files = Xm/BaseClassI.h;
4500 bypass = "__cplusplus";
4502 select = " class\\)";
4503 c_fix = format;
4504 c_fix_arg = " c_class)";
4506 test_text = "extern mumble (int class);\n";
4511 * new in Xm/Traversal.h
4513 fix = {
4514 hackname = x11_new;
4515 files = Xm/Traversal.h;
4516 bypass = __cplusplus;
4518 sed = "/Widget\told, new;/i\\\n"
4519 "#ifdef __cplusplus\\\n"
4520 "\\\tWidget\told, c_new;\\\n"
4521 "#else\n";
4523 sed = "/Widget\told, new;/a\\\n"
4524 "#endif\n";
4526 sed = "s/Widget new,/Widget c_new,/g";
4527 test_text =
4528 "struct wedge {\n"
4529 " Widget\told, new;\n"
4530 "};\nextern Wedged( Widget new, Widget old );";
4535 * Incorrect sprintf declaration in X11/Xmu.h
4537 fix = {
4538 hackname = x11_sprintf;
4539 files = X11/Xmu.h;
4540 files = X11/Xmu/Xmu.h;
4541 select = "^extern char \\*\tsprintf\\(\\);$";
4543 c_fix = format;
4544 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4546 test_text = "extern char *\tsprintf();";
4549 /*EOF*/