2017-03-15 Yaakov Selkowitz <yselkowitz@redhat.com>
[official-gcc.git] / fixincludes / inclhack.def
blob8a5514ffcabf4f4b1dc01929a2002632a8f7e3f8
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[ \t]*=[ \t]*(.*);'
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_;
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
72 fix = {
73 hackname = AAB_aix_fcntl;
74 files = fcntl.h;
75 select = "define open[ \t]open64";
76 mach = "*-*-aix*";
77 test-text = ''; /* no way to test */
79 c_fix = wrap;
81 c_fix_arg = "";
83 c_fix_arg = <<- _EOArg_
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
88 #undef open
89 #undef creat
90 #undef openat
91 /* Alias the symbols using asm */
92 extern "C" {
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
97 #endif
99 #endif
100 #endif
102 _EOArg_;
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
109 fix = {
110 hackname = AAB_darwin7_9_long_double_funcs;
111 mach = "*-*-darwin7.9*";
112 files = architecture/ppc/math.h;
113 bypass = "powl";
114 replace = <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
116 10.3.9. */
117 #ifndef __MATH__
118 # undef __APPLE_CC__
119 # define __APPLE_CC__ 1345
120 # include_next <architecture/ppc/math.h>
121 # undef __APPLE_CC__
122 # define __APPLE_CC__ 1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
126 # else
127 # define __LIBMLDBL_COMPAT(sym)
128 # endif /* __LONG_DOUBLE_128__ */
129 # endif /* __LIBMLDBL_COMPAT */
130 # ifdef __cplusplus
131 extern "C" {
132 # endif
133 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
190 # ifdef __cplusplus
192 # endif
193 #endif /* __MATH__ */
194 _EndOfHeader_;
198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
200 fix = {
201 hackname = AAB_fd_zero_asm_posix_types_h;
202 files = asm/posix_types.h;
203 mach = 'i[34567]86-*-linux*';
204 bypass = '} while';
205 bypass = 'x86_64';
206 bypass = 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
210 * the start, so that if #include_next gets another instance of
211 * the wrapper, this will follow the #include_next chain until
212 * we arrive at the real <asm/posix_types.h>.
214 replace = <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel. */
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include <features.h>
219 #include_next <asm/posix_types.h>
221 #if defined(__FD_ZERO) && !defined(__GLIBC__)
222 #undef __FD_ZERO
223 #define __FD_ZERO(fdsetp) \
224 do { \
225 int __d0, __d1; \
226 __asm__ __volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0), "=&D" (__d1) \
228 : "a" (0), "0" (__FDSET_LONGS), \
229 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
230 } while (0)
231 #endif
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif /* _POSIX_TYPES_H_WRAPPER */
235 _EndOfHeader_;
239 * This fixes __FD_ZERO bug for glibc-1.x
241 fix = {
242 hackname = AAB_fd_zero_gnu_types_h;
243 files = gnu/types.h;
244 mach = 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
248 * the start, so that if #include_next gets another instance of
249 * the wrapper, this will follow the #include_next chain until
250 * we arrive at the real <gnu/types.h>.
252 replace = <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
254 #ifndef _TYPES_H_WRAPPER
255 #include <features.h>
256 #include_next <gnu/types.h>
258 #if defined(__FD_ZERO) && !defined(__GLIBC__)
259 #undef __FD_ZERO
260 # define __FD_ZERO(fdsetp) \
261 do { \
262 int __d0, __d1; \
263 __asm__ __volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0), "=&D" (__d1) \
265 : "a" (0), "0" (__FDSET_LONGS), \
266 "1" ((__fd_set *) (fdsetp)) :"memory"); \
267 } while (0)
268 #endif
270 #define _TYPES_H_WRAPPER
271 #endif /* _TYPES_H_WRAPPER */
272 _EndOfHeader_;
276 * This fixes __FD_ZERO bug for glibc-2.0.x
278 fix = {
279 hackname = AAB_fd_zero_selectbits_h;
280 files = selectbits.h;
281 mach = 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
285 * the start, so that if #include_next gets another instance of
286 * the wrapper, this will follow the #include_next chain until
287 * we arrive at the real <selectbits.h>.
289 replace = <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include <features.h>
293 #include_next <selectbits.h>
295 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
296 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
297 && __GLIBC_MINOR__ == 0
298 #undef __FD_ZERO
299 #define __FD_ZERO(fdsetp) \\
300 do { \\
301 int __d0, __d1; \\
302 __asm__ __volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0), "=&D" (__d1) \\
304 : "a" (0), "0" (sizeof (__fd_set) \\
305 / sizeof (__fd_mask)), \\
306 "1" ((__fd_mask *) (fdsetp)) \\
307 : "memory"); \\
308 } while (0)
309 #endif
311 #define _SELECTBITS_H_WRAPPER
312 #endif /* _SELECTBITS_H_WRAPPER */
313 _EndOfHeader_;
317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
318 * the same interface as <stdarg.h>. No idea why they couldn't have just
319 * used the standard header.
321 fix = {
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris*';
325 replace = <<- _EndOfHeader_
326 #ifdef __STDC__
327 #include <stdarg.h>
328 #else
329 #include <varargs.h>
330 #endif
331 _EndOfHeader_;
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
341 fix = {
342 hackname = AAB_sun_memcpy;
343 files = memory.h;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
350 #ifndef __memory_h__
351 #define __memory_h__
353 #ifdef __STDC__
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
358 #else
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
365 extern int memcmp();
367 #endif /* __memory_h__ */
368 _EndOfHeader_;
372 * Fix assert.h on VxWorks:
374 fix = {
375 hackname = AAB_vxworks_assert;
376 files = assert.h;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
380 #ifndef _ASSERT_H
381 #define _ASSERT_H
383 #ifdef assert
384 #undef assert
385 #endif
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
389 #else
390 extern void __assert ();
391 #endif
393 #ifdef NDEBUG
394 #define assert(ign) ((void)0)
395 #else
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
405 #endif
407 #endif
408 _EndOfHeader_;
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
415 fix = {
416 hackname = AAB_vxworks_regs_vxtypes;
417 files = regs.h;
418 mach = "*-*-vxworks*";
420 replace = <<- _EndOfHeader_
421 #ifndef _REGS_H
422 #define _REGS_H
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
425 #endif
426 _EndOfHeader_;
430 * Make VxWorks stdint.h a bit more compliant - add typedefs
432 fix = {
433 hackname = AAB_vxworks_stdint;
434 files = stdint.h;
435 mach = "*-*-vxworks*";
437 replace = <<- _EndOfHeader_
438 #ifndef _STDINT_H
439 #define _STDINT_H
440 /* get int*_t, uint*_t */
441 #include <types/vxTypes.h>
443 /* get legacy vxworks types for compatibility */
444 #include <types/vxTypesOld.h>
446 typedef long intptr_t;
447 typedef unsigned long uintptr_t;
449 typedef int64_t intmax_t;
450 typedef uint64_t uintmax_t;
452 typedef int8_t int_least8_t;
453 typedef int16_t int_least16_t;
454 typedef int32_t int_least32_t;
455 typedef int64_t int_least64_t;
457 typedef uint8_t uint_least8_t;
458 typedef uint16_t uint_least16_t;
459 typedef uint32_t uint_least32_t;
460 typedef uint64_t uint_least64_t;
462 typedef int8_t int_fast8_t;
463 typedef int int_fast16_t;
464 typedef int32_t int_fast32_t;
465 typedef int64_t int_fast64_t;
467 typedef uint8_t uint_fast8_t;
468 typedef unsigned int uint_fast16_t;
469 typedef uint32_t uint_fast32_t;
470 typedef uint64_t uint_fast64_t;
472 /* Ranges */
473 #define UINT8_MAX (~(uint8_t)0)
474 #define UINT8_MIN 0
475 #define UINT16_MAX (~(uint16_t)0)
476 #define UINT16_MIN 0
477 #define UINT32_MAX (~(uint32_t)0)
478 #define UINT32_MIN 0
479 #define UINT64_MAX (~(uint64_t)0)
480 #define UINT64_MIN 0
482 #define UINTPTR_MAX (~(uintptr_t)0)
483 #define UINTPTR_MIN 0
485 /* Need to do int_fast16_t as well, as type
486 size may be architecture dependent */
487 #define UINT_FAST16_MAX (~(uint_fast16_t)0)
488 #define UINT_FAST16_MAX 0
490 #define INT8_MAX (UINT8_MAX>>1)
491 #define INT8_MIN (INT8_MAX+1)
492 #define INT16_MAX (UINT16_MAX>>1)
493 #define INT16_MIN (INT16_MAX+1)
494 #define INT32_MAX (UINT32_MAX>>1)
495 #define INT32_MIN (INT32_MAX+1)
496 #define INT64_MAX (UINT64_MAX>>1)
497 #define INT64_MIN (INT64_MAX+1)
499 #define INTPTR_MAX (UINTPTR_MAX>>1)
500 #define INTPTR_MIN (INTPTR_MAX+1)
502 #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
503 #define INT_FAST16_MIN (INT_FAST16_MAX+1)
505 /* now define equiv. constants */
506 #define UINT_FAST8_MAX UINT8_MAX
507 #define UINT_FAST8_MIN UINT_FAST8_MIN
508 #define INT_FAST8_MAX INT8_MAX
509 #define INT_FAST8_MIN INT8_MIN
510 #define UINT_FAST32_MAX UINT32_MAX
511 #define UINT_FAST32_MIN UINT32_MIN
512 #define INT_FAST32_MAX INT32_MAX
513 #define INT_FAST32_MIN INT32_MIN
514 #define UINT_FAST64_MAX UINT64_MAX
515 #define UINT_FAST64_MIN UINT64_MIN
516 #define INT_FAST64_MAX INT64_MAX
517 #define INT_FAST64_MIN INT64_MIN
519 #define UINT_LEAST8_MAX UINT8_MAX
520 #define UINT_LEAST8_MIN UINT8_MIN
521 #define INT_LEAST8_MAX INT8_MAX
522 #define INT_LEAST8_MIN INT8_MIN
523 #define UINT_LEAST16_MAX UINT16_MAX
524 #define UINT_LEAST16_MIN UINT16_MIN
525 #define INT_LEAST16_MAX INT16_MAX
526 #define INT_LEAST16_MIN INT16_MIN
527 #define UINT_LEAST32_MAX UINT32_MAX
528 #define UINT_LEAST32_MIN UINT32_MIN
529 #define INT_LEAST32_MAX INT32_MAX
530 #define INT_LEAST32_MIN INT32_MIN
531 #define UINT_LEAST64_MAX UINT64_MAX
532 #define UINT_LEAST64_MIN UINT64_MIN
533 #define INT_LEAST64_MAX INT64_MAX
534 #define INT_LEAST64_MIN INT64_MIN
536 #define UINTMAX_MAX UINT64_MAX
537 #define UINTMAX_MIN UINT64_MIN
538 #define INTMAX_MAX INT64_MAX
539 #define INTMAX_MIN INT64_MIN
541 #endif
542 _EndOfHeader_;
546 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
548 fix = {
549 hackname = AAB_vxworks_unistd;
550 files = unistd.h;
551 mach = "*-*-vxworks*";
553 replace = <<- _EndOfHeader_
554 #ifndef _UNISTD_H
555 #define _UNISTD_H
556 #include_next <unistd.h>
557 #include <ioLib.h>
558 #ifndef STDIN_FILENO
559 #define STDIN_FILENO 0
560 #endif
561 #ifndef STDOUT_FILENO
562 #define STDOUT_FILENO 1
563 #endif
564 #ifndef STDERR_FILENO
565 #define STDERR_FILENO 2
566 #endif
567 #endif /* _UNISTD_H */
568 _EndOfHeader_;
572 * assert.h on AIX 7 redefines static_assert as _Static_assert without
573 * protecting C++.
575 fix = {
576 hackname = aix_assert;
577 mach = "*-*-aix*";
578 files = assert.h;
579 select = "#define[ \t]static_assert[ \t]_Static_assert";
580 c_fix = format;
581 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
582 test_text = "#define static_assert _Static_assert";
586 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
587 * which only is provided by AIX xlc C99.
589 fix = {
590 hackname = aix_complex;
591 mach = "*-*-aix*";
592 files = complex.h;
593 select = "#define[ \t]_Complex_I[ \t]__I";
594 c_fix = format;
595 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
596 test_text = "#define _Complex_I __I\n";
600 * On AIX some headers are not properly guarded by 'extern "C"'.
602 fix = {
603 hackname = aix_externc;
604 mach = "*-*-aix*";
605 files = ctype.h;
606 files = fcntl.h;
607 files = langinfo.h;
608 files = ldfcn.h;
609 files = sys/localedef.h;
610 files = sys/times.h;
611 bypass = "extern \"C\"";
612 c_fix = wrap;
613 c_fix_arg = "#ifdef __cplusplus\n"
614 "extern \"C\" {\n"
615 "#endif\n";
616 c_fix_arg = "#ifdef __cplusplus\n"
617 "}\n"
618 "#endif\n";
619 test_text = "extern int __n_pthreads;\n";
623 * On AIX sys/socket.h assumes C++.
625 fix = {
626 hackname = aix_externcpp1;
627 mach = "*-*-aix*";
628 files = "sys/socket.h";
629 select = "#ifdef __cplusplus";
630 c_fix = format;
631 c_fix_arg = "#ifdef __cplusplus\n"
632 "extern \"C++\" {";
633 test_text = "#ifdef __cplusplus";
637 fix = {
638 hackname = aix_externcpp2;
639 mach = "*-*-aix*";
640 files = "sys/socket.h";
641 select = "#else /\\* __cplusplus \\*/";
642 c_fix = format;
643 c_fix_arg = "} /* extern \"C++\" */\n"
644 "#else /* __cplusplus */";
645 test_text = "#else /* __cplusplus */";
650 * malloc.h on AIX6 uses XLC++ specific builtin syntax
652 fix = {
653 hackname = aix_malloc;
654 mach = "*-*-aix*";
655 files = "malloc.h";
656 select = "#ifdef __cplusplus";
657 c_fix = format;
658 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
659 test_text = "#ifdef __cplusplus";
663 * net/if_arp.h defines a variable fc_softc instead of adding a
664 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
666 fix = {
667 hackname = aix_net_if_arp;
668 mach = "*-*-aix*";
669 files = "net/if_arp.h";
670 select = "^struct fc_softc \\{";
671 c_fix = format;
672 c_fix_arg = "typedef struct _fc_softc {";
673 test_text = "struct fc_softc {\n int a;\n};";
677 * Fix AIX definition of NULL for G++.
679 fix = {
680 hackname = aix_null;
681 mach = "*-*-aix*";
682 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
683 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
684 bypass = __null;
685 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
686 c_fix = format;
687 c_fix_arg = <<- _EOFix_
688 #ifndef NULL
689 #ifdef __cplusplus
690 #ifdef __GNUG__
691 #define NULL __null
692 #else /* ! __GNUG__ */
693 #define NULL 0L
694 #endif /* __GNUG__ */
695 #else /* ! __cplusplus */
696 #define NULL ((void *)0)
697 #endif /* __cplusplus */
698 #endif /* !NULL */
699 _EOFix_;
700 test_text = "# define\tNULL \t(0L) /* typed NULL */";
704 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
705 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
706 * braces.
708 fix = {
709 hackname = aix_once_init_1;
710 mach = "*-*-aix*";
711 files = "pthread.h";
712 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
713 "\\{ \\\\\n";
714 c_fix = format;
715 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
716 "{{ \\\n";
717 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
718 "{ \\\\\n";
721 fix = {
722 hackname = aix_once_init_2;
723 mach = "*-*-aix*";
724 files = "pthread.h";
725 select = "[ \t]0 \\\\\n"
726 "\\}\n";
727 c_fix = format;
728 c_fix_arg = " 0 \\\n"
729 "}}\n";
730 test_text = " 0 \\\\\n"
731 "}\n";
734 fix = {
735 hackname = aix_mutex_initializer_1;
736 mach = "*-*-aix*";
737 files = "pthread.h";
738 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
739 "\\{ \\\\\n";
740 c_fix = format;
741 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
742 "{{ \\\n";
743 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
744 "{ \\\\\n";
747 fix = {
748 hackname = aix_cond_initializer_1;
749 mach = "*-*-aix*";
750 files = "pthread.h";
751 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
752 "\\{ \\\\\n";
753 c_fix = format;
754 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
755 "{{ \\\n";
756 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
757 "{ \\\\\n";
760 fix = {
761 hackname = aix_rwlock_initializer_1;
762 mach = "*-*-aix*";
763 files = "pthread.h";
764 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
765 "\\{ \\\\\n";
766 c_fix = format;
767 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
768 "{{ \\\n";
769 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
770 "{ \\\\\n";
774 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
775 * which violates a requirement of ISO C.
777 fix = {
778 hackname = aix_pthread;
779 files = "pthread.h";
780 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
781 c_fix = format;
782 c_fix_arg = "%1 %2";
783 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
784 "{...init stuff...}";
788 * AIX stdint.h fixes.
790 fix = {
791 hackname = aix_stdint_1;
792 mach = "*-*-aix*";
793 files = stdint-aix.h, stdint.h;
794 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
795 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
796 c_fix = format;
797 c_fix_arg = "#define UINT8_MAX (255)\n"
798 "#define UINT16_MAX (65535)";
799 test_text = "#define UINT8_MAX (255U)\n"
800 "#define UINT16_MAX (65535U)";
804 * aix_stdint_2
806 fix = {
807 hackname = aix_stdint_2;
808 mach = "*-*-aix*";
809 files = stdint-aix.h, stdint.h;
810 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
811 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
812 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
813 "#else\n"
814 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
815 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
816 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
817 c_fix = format;
818 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
819 "#define INTPTR_MAX 9223372036854775807L\n"
820 "#define UINTPTR_MAX 18446744073709551615UL\n"
821 "#else\n"
822 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
823 "#define INTPTR_MAX 2147483647L\n"
824 "#define UINTPTR_MAX 4294967295UL";
825 test_text = "#define INTPTR_MIN INT64_MIN\n"
826 "#define INTPTR_MAX INT64_MAX\n"
827 "#define UINTPTR_MAX UINT64_MAX\n"
828 "#else\n"
829 "#define INTPTR_MIN INT32_MIN\n"
830 "#define INTPTR_MAX INT32_MAX\n"
831 "#define UINTPTR_MAX UINT32_MAX";
835 * aix_stdint_3
837 fix = {
838 hackname = aix_stdint_3;
839 mach = "*-*-aix*";
840 files = stdint-aix.h, stdint.h;
841 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
842 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
843 "#else\n"
844 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
845 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
846 c_fix = format;
847 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
848 "#define PTRDIFF_MAX 9223372036854775807L\n"
849 "#else\n"
850 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
851 "#define PTRDIFF_MAX 2147483647L";
852 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
853 "#define PTRDIFF_MAX INT64_MAX\n"
854 "#else\n"
855 "#define PTRDIFF_MIN INT32_MIN\n"
856 "#define PTRDIFF_MAX INT32_MAX";
860 * aix_stdint_4
862 fix = {
863 hackname = aix_stdint_4;
864 mach = "*-*-aix*";
865 files = stdint-aix.h, stdint.h;
866 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
867 "#else\n"
868 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
869 c_fix = format;
870 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
871 "#else\n"
872 "#define SIZE_MAX 4294967295UL";
873 test_text = "#define SIZE_MAX UINT64_MAX\n"
874 "#else\n"
875 "#define SIZE_MAX UINT32_MAX";
879 * aix_stdint_5
881 fix = {
882 hackname = aix_stdint_5;
883 mach = "*-*-aix*";
884 files = stdint-aix.h, stdint.h;
885 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
886 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
887 c_fix = format;
888 c_fix_arg = "#define UINT8_C(c) c\n"
889 "#define UINT16_C(c) c";
890 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
891 "#define UINT16_C(c) __CONCAT__(c,U)";
895 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
896 produces wrong code with G++.
898 fix = {
899 hackname = aix_stdio_inline;
900 mach = "*-*-aix*";
901 files = stdio.h;
902 select = "#ifdef __cplusplus\\\n"
903 "}\\\n\\\n"
904 "#ifdef ferror\\\n";
905 c_fix = format;
906 c_fix_arg = "#ifdef __cplusplus\n"
907 "}\n"
908 "#endif\n\n"
909 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
910 "#ifdef ferror\n";
911 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
915 * stdlib.h on AIX uses #define on malloc and friends.
917 fix = {
918 hackname = aix_stdlib_malloc;
919 mach = "*-*-aix*";
920 files = stdlib.h;
921 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
922 c_fix = format;
923 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
924 test_text = "#define malloc __linux_malloc";
927 fix = {
928 hackname = aix_stdlib_realloc;
929 mach = "*-*-aix*";
930 files = stdlib.h;
931 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
932 c_fix = format;
933 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
934 test_text = "#define realloc __linux_realloc";
937 fix = {
938 hackname = aix_stdlib_calloc;
939 mach = "*-*-aix*";
940 files = stdlib.h;
941 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
942 c_fix = format;
943 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
944 test_text = "#define calloc __linux_calloc";
947 fix = {
948 hackname = aix_stdlib_valloc;
949 mach = "*-*-aix*";
950 files = stdlib.h;
951 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
952 c_fix = format;
953 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
954 test_text = "#define valloc __linux_valloc";
958 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
960 fix = {
961 hackname = aix_strtof_const;
962 mach = "*-*-aix*";
963 files = stdlib.h;
964 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
965 c_fix = format;
966 c_fix_arg = "%1(const char *, char **);";
967 test_text = "extern float strtof(char *, char **);";
971 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
972 * in an otherwise harmless (and #ifed out) macro definition
974 fix = {
975 hackname = aix_sysmachine;
976 mach = "*-*-aix*";
977 files = sys/machine.h;
978 select = "\\\\ +\n";
979 c_fix = format;
980 c_fix_arg = "\\\n";
981 test_text = "#define FOO \\\n"
982 " bar \\ \n baz \\ \n bat";
986 * sys/wait.h on AIX 5.2 defines macros that have both signed and
987 * unsigned types in conditional expressions.
989 fix = {
990 hackname = aix_syswait_2;
991 mach = "*-*-aix*";
992 files = sys/wait.h;
993 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
994 c_fix = format;
995 c_fix_arg = "? (int)%1";
996 test_text = "#define WSTOPSIG(__x) "
997 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
1001 * sys/signal.h on some versions of AIX uses volatile in the typedef of
1002 * sig_atomic_t, which causes gcc to generate a warning about duplicate
1003 * volatile when a sig_atomic_t variable is declared volatile, as
1004 * required by ANSI C.
1006 fix = {
1007 hackname = aix_volatile;
1008 mach = "*-*-aix*";
1009 files = sys/signal.h;
1010 select = "typedef volatile int sig_atomic_t";
1011 c_fix = format;
1012 c_fix_arg = "typedef int sig_atomic_t";
1013 test_text = "typedef volatile int sig_atomic_t;";
1017 * Fix __assert declaration in assert.h on Alpha OSF/1.
1019 fix = {
1020 hackname = alpha___assert;
1021 files = "assert.h";
1022 select = '__assert\(char \*, char \*, int\)';
1023 c_fix = format;
1024 c_fix_arg = "__assert(const char *, const char *, int)";
1025 test_text = 'extern void __assert(char *, char *, int);';
1029 * Fix assert macro in assert.h on Alpha OSF/1.
1030 * The superfluous int cast breaks C++.
1032 fix = {
1033 hackname = alpha_assert;
1034 files = "assert.h";
1035 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
1036 c_fix = format;
1037 c_fix_arg = "%1(EX)";
1038 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
1039 ': __assert(#EX, __FILE__, __LINE__))';
1043 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1045 fix = {
1046 hackname = alpha_getopt;
1047 files = "stdio.h";
1048 files = "stdlib.h";
1049 select = 'getopt\(int, char \*\[\], *char \*\)';
1050 c_fix = format;
1051 c_fix_arg = "getopt(int, char *const[], const char *)";
1052 test_text = 'extern int getopt(int, char *[], char *);';
1056 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
1058 fix = {
1059 hackname = alpha_if_semicolon;
1060 files = net/if.h;
1061 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
1062 c_fix = format;
1063 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
1064 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1068 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1070 fix = {
1071 hackname = alpha_parens;
1072 files = sym.h;
1073 select = '#ifndef\(__mips64\)';
1074 c_fix = format;
1075 c_fix_arg = "#ifndef __mips64";
1076 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1080 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1081 * And OpenBSD.
1083 fix = {
1084 hackname = alpha_sbrk;
1085 files = unistd.h;
1086 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1087 c_fix = format;
1088 c_fix_arg = "void *sbrk(";
1089 test_text = "extern char* sbrk(ptrdiff_t increment);";
1093 * For C++, avoid any typedef or macro definition of bool,
1094 * and use the built in type instead.
1095 * HP/UX 10.20 also has it in curses_colr/curses.h.
1097 fix = {
1098 hackname = avoid_bool_define;
1099 files = curses.h;
1100 files = curses_colr/curses.h;
1101 files = term.h;
1102 files = tinfo.h;
1104 select = "#[ \t]*define[ \t]+bool[ \t]";
1105 bypass = "__cplusplus";
1107 c_fix = format;
1108 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1109 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1111 test_text = "# define bool\t char \n";
1115 * avoid_bool_type
1117 fix = {
1118 hackname = avoid_bool_type;
1119 files = curses.h;
1120 files = curses_colr/curses.h;
1121 files = term.h;
1122 files = tinfo.h;
1124 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1125 bypass = "__cplusplus";
1127 c_fix = format;
1128 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1130 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1134 * For C++, avoid any typedef definition of wchar_t,
1135 * and use the built in type instead.
1136 * Don't do this for headers that are smart enough to do the right
1137 * thing (recent [n]curses.h and Xlib.h).
1138 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1139 * and will be broken by the edit.
1142 fix = {
1143 hackname = avoid_wchar_t_type;
1145 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1146 bypass = "__cplusplus";
1147 bypass = "_LINUX_NLS_H";
1148 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1150 c_fix = format;
1151 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1153 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1157 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1159 fix = {
1160 hackname = bad_struct_term;
1161 files = curses.h;
1162 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1163 c_fix = format;
1164 c_fix_arg = "struct term;";
1166 test_text = 'typedef struct term;';
1170 * Fix one other error in this file:
1171 * a mismatched quote not inside a C comment.
1173 fix = {
1174 hackname = badquote;
1175 files = sundev/vuid_event.h;
1176 select = "doesn't";
1177 c_fix = format;
1178 c_fix_arg = "does not";
1180 test_text = "/* doesn't have matched single quotes */";
1184 * check for broken assert.h that needs stdio.h
1186 fix = {
1187 hackname = broken_assert_stdio;
1188 files = assert.h;
1189 select = stderr;
1190 bypass = "include.*stdio\\.h";
1191 c_fix = wrap;
1192 c_fix_arg = "#include <stdio.h>\n";
1193 test_text = "extern FILE* stderr;";
1197 * check for broken assert.h that needs stdlib.h
1199 fix = {
1200 hackname = broken_assert_stdlib;
1201 files = assert.h;
1202 select = 'exit *\(|abort *\(';
1203 bypass = "include.*stdlib\\.h";
1204 c_fix = wrap;
1205 c_fix_arg = "#ifdef __cplusplus\n"
1206 "#include <stdlib.h>\n"
1207 "#endif\n";
1208 test_text = "extern void exit ( int );";
1212 * Remove `extern double cabs' declarations from math.h.
1213 * This conflicts with C99. Discovered on AIX.
1214 * Darwin hides its broken cabs in architecture-specific subdirs.
1216 fix = {
1217 hackname = broken_cabs;
1218 files = math.h, "architecture/*/math.h";
1219 select = "^extern[ \t]+double[ \t]+cabs";
1221 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1222 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1224 test_text = "#ifdef __STDC__\n"
1225 "extern double cabs(struct dbl_hypot);\n"
1226 "#else\n"
1227 "extern double cabs();\n"
1228 "#endif\n"
1229 "extern double cabs ( _Complex z );";
1233 * Fixup Darwin's broken check for __builtin_nanf.
1235 fix = {
1236 hackname = broken_nan;
1238 * It is tempting to omit the first "files" entry. Do not.
1239 * The testing machinery will take the first "files" entry as the name
1240 * of a test file to play with. It would be a nuisance to have a directory
1241 * with the name "*".
1243 files = "architecture/ppc/math.h";
1244 files = "architecture/*/math.h";
1245 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1246 bypass = "powl";
1247 c_fix = format;
1248 c_fix_arg = "#if 1";
1249 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1253 * Various systems derived from BSD4.4 contain a macro definition
1254 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1255 * Known to be fixed in FreeBSD 5 system headers.
1257 fix = {
1258 hackname = bsd_stdio_attrs_conflict;
1259 mach = "*-*-*bsd*";
1260 mach = "*-*-*darwin*";
1261 files = stdio.h;
1262 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1263 c_fix = format;
1264 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1265 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1266 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1267 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1268 test_text = '#define vfscanf __svfscanf';
1272 * Fix various macros used to define ioctl numbers.
1273 * The traditional syntax was:
1275 * #define _CTRL(n, x) (('n'<<8)+x)
1276 * #define TCTRLCFOO _CTRL(T, 1)
1278 * but this does not work with the C standard, which disallows macro
1279 * expansion inside strings. We have to rewrite it thus:
1281 * #define _CTRL(n, x) ((n<<8)+x)
1282 * #define TCTRLCFOO _CTRL('T', 1)
1284 * The select expressions match too much, but the c_fix code is cautious.
1286 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1288 fix = {
1289 hackname = ctrl_quotes_def;
1290 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1291 c_fix = char_macro_def;
1292 c_fix_arg = "CTRL";
1295 * This is two tests in order to ensure that the "CTRL(c)" can
1296 * be selected in isolation from the multi-arg format
1298 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1299 test_text = "#define _CTRL(c) ('c'&037)";
1303 * Fix various macros used to define ioctl numbers.
1305 fix = {
1306 hackname = ctrl_quotes_use;
1307 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1308 c_fix = char_macro_use;
1309 c_fix_arg = "CTRL";
1310 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1314 * sys/mman.h on HP/UX is not C++ ready,
1315 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1317 * rpc/types.h on OSF1/2.0 is not C++ ready,
1318 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1320 * The problem is the declaration of malloc.
1322 fix = {
1323 hackname = cxx_unready;
1324 files = sys/mman.h;
1325 files = rpc/types.h;
1326 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1327 not within a macro. */
1328 bypass = '"C"|__BEGIN_DECLS';
1330 c_fix = wrap;
1331 c_fix_arg = "#ifdef __cplusplus\n"
1332 "extern \"C\" {\n"
1333 "#endif\n";
1334 c_fix_arg = "#ifdef __cplusplus\n"
1335 "}\n"
1336 "#endif\n";
1337 test_text = "extern void* malloc( size_t );";
1341 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1342 * unconditionally.
1344 fix = {
1345 hackname = darwin_availabilityinternal;
1346 mach = "*-*-darwin*";
1347 files = AvailabilityInternal.h;
1348 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1349 c_fix = format;
1350 c_fix_arg = <<- _EOFix_
1351 #if defined(__has_attribute)
1352 #if __has_attribute(availability)
1354 #else
1355 #define %1
1356 #endif
1357 #else
1358 #define %1
1359 #endif
1360 _EOFix_;
1362 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1363 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1367 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1368 * you have to not use "" includes.
1370 fix = {
1371 hackname = darwin_9_long_double_funcs_2;
1372 mach = "*-*-darwin7.9*";
1373 files = math.h;
1374 select = '#include[ \t]+\"';
1375 c_fix = format;
1376 c_fix_arg = "%1<%2.h>";
1378 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1380 test_text = '#include "architecture/ppc/math.h"';
1384 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1385 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1387 fix = {
1388 hackname = darwin_externc;
1389 mach = "*-*-darwin*";
1390 files = mach-o/swap.h;
1391 files = mach/mach_time.h;
1392 files = mach/mach_traps.h;
1393 files = mach/message.h;
1394 files = mach/mig.h;
1395 files = mach/semaphore.h;
1396 bypass = "extern \"C\"";
1397 bypass = "__BEGIN_DECLS";
1398 c_fix = wrap;
1399 c_fix_arg = "#ifdef __cplusplus\n"
1400 "extern \"C\" {\n"
1401 "#endif\n";
1402 c_fix_arg = "#ifdef __cplusplus\n"
1403 "}\n"
1404 "#endif\n";
1405 test_text = "extern void swap_fat_header();\n";
1409 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1410 * bad __GNUC__ tests.
1412 fix = {
1413 hackname = darwin_gcc4_breakage;
1414 mach = "*-*-darwin*";
1415 files = AvailabilityMacros.h;
1416 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1417 c_fix = format;
1418 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1419 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1420 "(__GNUC_MINOR__ >= 1)\n";
1424 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1426 fix = {
1427 hackname = darwin_longjmp_noreturn;
1428 mach = "*-*-darwin*";
1429 files = "i386/setjmp.h";
1430 bypass = "__dead2";
1431 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1432 c_fix = format;
1433 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1435 test_text = "void siglongjmp(sigjmp_buf, int);";
1439 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1441 fix = {
1442 hackname = darwin_os_trace_1;
1443 mach = "*-*-darwin*";
1444 files = os/trace.h;
1445 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1446 c_fix = format;
1447 c_fix_arg = "%1";
1448 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1452 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1453 * extension without guard.
1455 fix = {
1456 hackname = darwin_os_trace_2;
1457 mach = "*-*-darwin*";
1458 files = os/trace.h;
1459 select = "typedef.*\\^os_trace_payload_t.*";
1460 c_fix = format;
1461 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1462 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1466 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1467 * os_trace_payload_t typedef, too.
1469 fix = {
1470 hackname = darwin_os_trace_3;
1471 mach = "*-*-darwin*";
1472 files = os/trace.h;
1473 select = <<- _EOSelect_
1474 __(API|OSX)_.*
1475 OS_EXPORT.*
1477 _os_trace.*os_trace_payload_t payload);
1478 _EOSelect_;
1479 c_fix = format;
1480 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1481 test_text = <<- _EOText_
1482 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1483 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1484 void
1485 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1487 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1488 OS_EXPORT OS_NOTHROW
1489 void
1490 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1491 _EOText_;
1495 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1496 * why would you ever put it in a system header file?
1498 fix = {
1499 hackname = darwin_private_extern;
1500 mach = "*-*-darwin*";
1501 files = mach-o/dyld.h;
1502 select = "__private_extern__ [a-z_]+ _dyld_";
1503 c_fix = format;
1504 c_fix_arg = "extern";
1505 c_fix_arg = "__private_extern__";
1506 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1507 "const char *dyld_func_name,\n"
1508 "unsigned long *address);\n";
1512 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1513 * unsigned constants.
1515 fix = {
1516 hackname = darwin_stdint_1;
1517 mach = "*-*-darwin*";
1518 files = stdint-darwin.h, stdint.h;
1519 c_fix = format;
1520 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1521 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1522 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1523 test_text = "#define UINT8_C(v) (v ## U)\n"
1524 "#define UINT16_C(v) (v ## U)";
1528 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1529 * with wrong types.
1531 fix = {
1532 hackname = darwin_stdint_2;
1533 mach = "*-*-darwin*";
1534 files = stdint-darwin.h, stdint.h;
1535 c_fix = format;
1536 c_fix_arg = "#if __WORDSIZE == 64\n"
1537 "#define INTPTR_MAX 9223372036854775807L\n"
1538 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1539 "#else\n"
1540 "#define INTPTR_MAX 2147483647L\n"
1541 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1542 "#endif";
1543 select = "#if __WORDSIZE == 64\n"
1544 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1545 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1546 "#else\n"
1547 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1548 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1549 "#endif";
1550 test_text = "#if __WORDSIZE == 64\n"
1551 "#define INTPTR_MIN INT64_MIN\n"
1552 "#define INTPTR_MAX INT64_MAX\n"
1553 "#else\n"
1554 "#define INTPTR_MIN INT32_MIN\n"
1555 "#define INTPTR_MAX INT32_MAX\n"
1556 "#endif";
1560 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1562 fix = {
1563 hackname = darwin_stdint_3;
1564 mach = "*-*-darwin*";
1565 files = stdint-darwin.h, stdint.h;
1566 c_fix = format;
1567 c_fix_arg = "#if __WORDSIZE == 64\n"
1568 "#define UINTPTR_MAX 18446744073709551615UL\n"
1569 "#else\n"
1570 "#define UINTPTR_MAX 4294967295UL\n"
1571 "#endif";
1572 select = "#if __WORDSIZE == 64\n"
1573 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1574 "#else\n"
1575 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1576 "#endif";
1577 test_text = "#if __WORDSIZE == 64\n"
1578 "#define UINTPTR_MAX UINT64_MAX\n"
1579 "#else\n"
1580 "#define UINTPTR_MAX UINT32_MAX\n"
1581 "#endif";
1585 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1587 fix = {
1588 hackname = darwin_stdint_4;
1589 mach = "*-*-darwin*";
1590 files = stdint-darwin.h, stdint.h;
1591 c_fix = format;
1592 c_fix_arg = "#if __WORDSIZE == 64\n"
1593 "#define SIZE_MAX 18446744073709551615UL\n"
1594 "#else\n"
1595 "#define SIZE_MAX 4294967295UL\n"
1596 "#endif";
1597 select = "#if __WORDSIZE == 64\n"
1598 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1599 "#else\n"
1600 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1601 "#endif";
1602 test_text = "#if __WORDSIZE == 64\n"
1603 "#define SIZE_MAX UINT64_MAX\n"
1604 "#else\n"
1605 "#define SIZE_MAX UINT32_MAX\n"
1606 "#endif";
1610 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1611 * with a wrong type.
1613 fix = {
1614 hackname = darwin_stdint_5;
1615 mach = "*-*-darwin*";
1616 files = stdint-darwin.h, stdint.h;
1617 c_fix = format;
1618 c_fix_arg = "#if __WORDSIZE == 64\n"
1619 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1620 "#define INTMAX_MAX 9223372036854775807L\n"
1621 "#define UINTMAX_MAX 18446744073709551615UL\n"
1622 "#else\n"
1623 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1624 "#define INTMAX_MAX 9223372036854775807LL\n"
1625 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1626 "#endif";
1627 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1628 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1629 "\n"
1630 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1631 test_text = "#define INTMAX_MIN INT64_MIN\n"
1632 "#define INTMAX_MAX INT64_MAX\n"
1633 "\n"
1634 "#define UINTMAX_MAX UINT64_MAX";
1638 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1639 * with a wrong type.
1641 fix = {
1642 hackname = darwin_stdint_6;
1643 mach = "*-*-darwin*";
1644 files = stdint-darwin.h, stdint.h;
1645 c_fix = format;
1646 c_fix_arg = "#if __WORDSIZE == 64\n"
1647 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1648 "#define PTRDIFF_MAX 9223372036854775807L\n"
1649 "#else\n"
1650 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1651 "#define PTRDIFF_MAX 2147483647\n"
1652 "#endif";
1653 select = "#if __WORDSIZE == 64\n"
1654 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1655 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1656 "#else\n"
1657 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1658 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1659 "#endif";
1660 test_text = "#if __WORDSIZE == 64\n"
1661 "#define PTRDIFF_MIN INT64_MIN\n"
1662 "#define PTRDIFF_MAX INT64_MAX\n"
1663 "#else\n"
1664 "#define PTRDIFF_MIN INT32_MIN\n"
1665 "#define PTRDIFF_MAX INT32_MAX\n"
1666 "#endif";
1670 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1671 * with a wrong type.
1673 fix = {
1674 hackname = darwin_stdint_7;
1675 mach = "*-*-darwin*";
1676 files = stdint-darwin.h, stdint.h;
1677 c_fix = format;
1678 c_fix_arg = "#if __WORDSIZE == 64\n"
1679 "#define INTMAX_C(v) (v ## L)\n"
1680 "#define UINTMAX_C(v) (v ## UL)\n"
1681 "#else\n"
1682 "#define INTMAX_C(v) (v ## LL)\n"
1683 "#define UINTMAX_C(v) (v ## ULL)\n"
1684 "#endif";
1685 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1686 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1687 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1688 "#define UINTMAX_C(v) (v ## ULL)";
1692 * Fix <c_asm.h> on Digital UNIX V4.0:
1693 * It contains a prototype for a DEC C internal asm() function,
1694 * clashing with gcc's asm keyword. So protect this with __DECC.
1696 fix = {
1697 hackname = dec_intern_asm;
1698 files = c_asm.h;
1699 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1700 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1701 "#endif\n";
1702 test_text =
1703 "float fasm {\n"
1704 " ... asm stuff ...\n"
1705 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1709 * Fix typo in <wchar.h> on DJGPP 2.03.
1711 fix = {
1712 hackname = djgpp_wchar_h;
1713 file = wchar.h;
1714 select = "__DJ_wint_t";
1715 bypass = "sys/djtypes.h";
1716 c_fix = format;
1717 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1718 c_fix_arg = "#include <stddef.h>";
1719 test_text = "#include <stddef.h>\n"
1720 "extern __DJ_wint_t x;\n";
1724 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1726 fix = {
1727 hackname = ecd_cursor;
1728 files = "sunwindow/win_lock.h";
1729 files = "sunwindow/win_cursor.h";
1730 select = 'ecd\.cursor';
1731 c_fix = format;
1732 c_fix_arg = 'ecd_cursor';
1734 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1738 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1739 * that fails when compiling for SSE-less 32-bit x86.
1741 fix = {
1742 hackname = feraiseexcept_nosse_divbyzero;
1743 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1744 files = bits/fenv.h, '*/bits/fenv.h';
1745 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1746 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1747 bypass = "\"fdivp .*; fwait\"";
1749 c_fix = format;
1750 c_fix_arg = <<- _EOText_
1751 # ifdef __SSE_MATH__
1753 # else
1754 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1755 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1756 # endif
1757 _EOText_;
1759 test_text = <<- _EOText_
1760 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1761 _EOText_;
1765 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1766 * that fails when compiling for SSE-less 32-bit x86.
1768 fix = {
1769 hackname = feraiseexcept_nosse_invalid;
1770 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1771 files = bits/fenv.h, '*/bits/fenv.h';
1772 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1773 ": \"x\" \\(__f\\)\\);$";
1774 bypass = "\"fdiv .*; fwait\"";
1776 c_fix = format;
1777 c_fix_arg = <<- _EOText_
1778 # ifdef __SSE_MATH__
1780 # else
1781 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1782 %1 : "=t" (__f) : "0" (__f));
1783 # endif
1784 _EOText_;
1786 test_text = <<- _EOText_
1787 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1788 _EOText_;
1792 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1793 * neither the existence of GCC 3 nor its exact feature set yet break
1794 * (by design?) when __GNUC__ is set beyond 2.
1796 fix = {
1797 hackname = freebsd_gcc3_breakage;
1798 mach = "*-*-freebsd*";
1799 files = sys/cdefs.h;
1800 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1801 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1802 c_fix = format;
1803 c_fix_arg = '%0 || __GNUC__ >= 3';
1804 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1808 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1809 * neither the existence of GCC 4 nor its exact feature set yet break
1810 * (by design?) when __GNUC__ is set beyond 3.
1812 fix = {
1813 hackname = freebsd_gcc4_breakage;
1814 mach = "*-*-freebsd*";
1815 files = sys/cdefs.h;
1816 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1817 c_fix = format;
1818 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1819 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1823 * Some versions of glibc don't expect the C99 inline semantics.
1825 fix = {
1826 hackname = glibc_c99_inline_1;
1827 files = features.h, '*/features.h';
1828 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1829 c_fix = format;
1830 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1831 test_text = <<-EOT
1832 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1833 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1834 # define __USE_EXTERN_INLINES 1
1835 #endif
1836 EOT;
1840 * Similar, but a version that didn't have __NO_INLINE__
1842 fix = {
1843 hackname = glibc_c99_inline_1a;
1844 files = features.h, '*/features.h';
1845 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1846 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1847 c_fix = format;
1848 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1849 test_text = <<-EOT
1850 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1851 # define __USE_EXTERN_INLINES 1
1852 #endif
1853 EOT;
1857 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1858 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1859 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1861 fix = {
1862 hackname = glibc_c99_inline_2;
1863 files = sys/stat.h, '*/sys/stat.h';
1864 select = "extern __inline__ int";
1865 sed = "s/extern int \\(stat\\)/"
1866 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1867 "__inline__ int \\1/";
1868 sed = "s/extern int \\([lf]stat\\)/"
1869 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1870 "__inline__ int \\1/";
1871 sed = "s/extern int \\(mknod\\)/"
1872 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1873 "__inline__ int \\1/";
1874 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1875 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1876 "__inline__ int __REDIRECT\\1 (\\2/";
1877 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1878 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1879 "__inline__ int __REDIRECT\\1 (\\2/";
1880 sed = "s/^extern __inline__ int/"
1881 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1882 "__inline__ int/";
1883 test_text = <<-EOT
1884 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1885 extern __inline__ int
1886 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1888 EOT;
1892 * glibc_c99_inline_3
1894 fix = {
1895 hackname = glibc_c99_inline_3;
1896 files = bits/string2.h, '*/bits/string2.h';
1897 select = "extern __inline";
1898 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1899 c_fix = format;
1900 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1901 c_fix_arg = "^# ifdef __cplusplus$";
1902 test_text = <<-EOT
1903 # ifdef __cplusplus
1904 # define __STRING_INLINE inline
1905 # else
1906 # define __STRING_INLINE extern __inline
1907 # endif
1908 EOT;
1912 * glibc_c99_inline_4
1914 fix = {
1915 hackname = glibc_c99_inline_4;
1916 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1917 pthread.h, '*/pthread.h';
1918 bypass = "__extern_inline|__gnu_inline__";
1919 select = "(^| )extern __inline";
1920 c_fix = format;
1921 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1922 test_text = <<-EOT
1923 __extension__ extern __inline unsigned int
1924 extern __inline unsigned int
1925 EOT;
1928 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1929 * so we replace them with versions that correspond to the
1930 * definition.
1932 fix = {
1933 hackname = glibc_mutex_init;
1934 files = pthread.h;
1935 select = '\{ *\{ *0, *\} *\}';
1936 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1937 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1938 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1939 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1940 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1941 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1942 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1943 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1944 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1945 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1946 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1947 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1948 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1949 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1950 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1951 "N;s/^[ \t]*#[ \t]*"
1952 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1953 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1954 "# \\1\\\n"
1955 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1956 "# else\\\n"
1957 "# \\1\\\n"
1958 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1959 "# endif/";
1960 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1961 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1962 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1963 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1965 test_text = <<- _EOText_
1966 #define PTHREAD_MUTEX_INITIALIZER \\
1967 { { 0, } }
1968 #ifdef __USE_GNU
1969 # if __WORDSIZE == 64
1970 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1971 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1972 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1973 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1974 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1975 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1976 # else
1977 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1978 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1979 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1980 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1981 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1982 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1983 # endif
1984 #endif
1985 # define PTHREAD_RWLOCK_INITIALIZER \\
1986 { { 0, } }
1987 # ifdef __USE_GNU
1988 # if __WORDSIZE == 64
1989 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1990 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1991 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1992 # else
1993 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1994 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1995 # endif
1996 # endif
1997 #define PTHREAD_COND_INITIALIZER { { 0, } }
1998 _EOText_;
2001 /* glibc versions before 2.5 have a version of stdint.h that defines
2002 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2003 versions with stdint.h based on those glibc versions. */
2004 fix = {
2005 hackname = glibc_stdint;
2006 files = stdint.h;
2007 select = "GNU C Library";
2008 c_fix = format;
2009 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2010 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2011 test_text = "/* This file is part of the GNU C Library. */\n"
2012 "# define UINT8_C(c)\tc ## U\n"
2013 "# define UINT16_C(c)\tc ## U";
2016 /* Some versions of glibc have a version of bits/string2.h that
2017 produces "value computed is not used" warnings from strncpy; fix
2018 this definition by using __builtin_strncpy instead as in newer
2019 versions. */
2020 fix = {
2021 hackname = glibc_strncpy;
2022 files = bits/string2.h, '*/bits/string2.h';
2023 bypass = "__builtin_strncpy";
2024 c_fix = format;
2025 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2026 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
2027 test_text = <<-EOT
2028 # define strncpy(dest, src, n) \
2029 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
2030 ? (strlen (src) + 1 >= ((size_t) (n)) \\
2031 ? (char *) memcpy (dest, src, n) \\
2032 : strncpy (dest, src, n)) \\
2033 : strncpy (dest, src, n)))
2034 EOT;
2038 /* glibc's tgmath.h relies on an expression that is not an integer
2039 constant expression being treated as it was by GCC 4.4 and
2040 earlier. */
2041 fix = {
2042 hackname = glibc_tgmath;
2043 files = tgmath.h;
2044 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2045 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2046 c_fix = format;
2047 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
2048 "(__builtin_classify_type ((type) 0) == 9 && "
2049 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2050 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2054 * Fix these files to use the types we think they should for
2055 * ptrdiff_t, size_t, and wchar_t.
2057 * This defines the types in terms of macros predefined by our 'cpp'.
2058 * This is supposedly necessary for glibc's handling of these types.
2059 * It's probably not necessary for anyone else, but it doesn't hurt.
2061 fix = {
2062 hackname = gnu_types;
2063 files = "sys/types.h";
2064 files = "stdlib.h";
2065 files = "sys/stdtypes.h";
2066 files = "stddef.h";
2067 files = "memory.h";
2068 files = "unistd.h";
2069 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2070 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2071 c_fix = gnu_type;
2072 /* The Solaris 10 headers already define these types correctly. */
2073 mach = '*-*-solaris2.1[0-9]*';
2074 not_machine = true;
2076 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2077 "typedef uint_t size_t; /* uint_t */\n"
2078 "typedef ushort_t wchar_t; /* ushort_t */";
2082 * Fix HP & Sony's use of "../machine/xxx.h"
2083 * to refer to: <machine/xxx.h>
2085 fix = {
2086 hackname = hp_inline;
2087 files = sys/spinlock.h;
2088 files = machine/machparam.h;
2089 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2091 c_fix = format;
2092 c_fix_arg = "%1<machine/%2.h>";
2094 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2095 '([a-z]+)\.h"';
2097 test_text = ' # include "../machine/mumble.h"';
2101 * Check for (...) in C++ code in HP/UX sys/file.h.
2103 fix = {
2104 hackname = hp_sysfile;
2105 files = sys/file.h;
2106 select = "HPUX_SOURCE";
2108 c_fix = format;
2109 c_fix_arg = "(struct file *, ...)";
2110 c_fix_arg = '\(\.\.\.\)';
2112 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2116 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2117 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2119 fix = {
2120 hackname = hppa_hpux_fp_macros;
2121 mach = "hppa*-hp-hpux11*";
2122 files = math.h;
2123 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2124 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2125 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2126 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2127 "#[ \t]*define[ \t]*FP_NAN.*\n";
2128 c_fix = format;
2129 c_fix_arg = <<- _EOFix_
2130 #endif /* _INCLUDE_HPUX_SOURCE */
2132 #if defined(_INCLUDE_HPUX_SOURCE) || \
2133 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2134 %0#endif
2136 #ifdef _INCLUDE_HPUX_SOURCE
2138 _EOFix_;
2140 test_text =
2141 "# define FP_NORMAL 0\n"
2142 "# define FP_ZERO 1\n"
2143 "# define FP_INFINITE 2\n"
2144 "# define FP_SUBNORMAL 3\n"
2145 "# define FP_NAN 4\n";
2149 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2150 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2152 fix = {
2153 hackname = hpux10_cpp_pow_inline;
2154 files = fixinc-test-limits.h, math.h;
2155 select = <<- END_POW_INLINE
2156 ^# +ifdef +__cplusplus
2158 +inline +double +pow\(double +__d,int +__expon\) +\{
2159 [ ]+return +pow\(__d,\(double\)__expon\);
2161 +extern +"C" +\{
2162 #else
2163 # +endif
2164 END_POW_INLINE;
2166 c_fix = format;
2167 c_fix_arg = "";
2169 test_text =
2170 "# ifdef __cplusplus\n"
2171 " }\n"
2172 " inline double pow(double __d,int __expon) {\n"
2173 "\t return pow(__d,(double)__expon);\n"
2174 " }\n"
2175 ' extern "C"' " {\n"
2176 "#else\n"
2177 "# endif";
2180 fix = {
2181 hackname = hpux11_cpp_pow_inline;
2182 files = math.h;
2183 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2184 " +return pow\\(d, \\(double\\)expon\\);\n"
2185 " +\\}\n";
2186 c_fix = format;
2187 c_fix_arg = "";
2189 test_text =
2190 " inline double pow(double d,int expon) {\n"
2191 " return pow(d, (double)expon);\n"
2192 " }\n";
2196 * Fix hpux 10.X missing ctype declarations 1
2198 fix = {
2199 hackname = hpux10_ctype_declarations1;
2200 files = ctype.h;
2201 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2202 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2203 c_fix = format;
2204 c_fix_arg = "#ifdef _PROTOTYPES\n"
2205 "extern int __tolower(int);\n"
2206 "extern int __toupper(int);\n"
2207 "#else /* NOT _PROTOTYPES */\n"
2208 "extern int __tolower();\n"
2209 "extern int __toupper();\n"
2210 "#endif /* _PROTOTYPES */\n\n"
2211 "%0\n";
2213 test_text = "# define _toupper(__c) __toupper(__c)\n";
2217 * Fix hpux 10.X missing ctype declarations 2
2219 fix = {
2220 hackname = hpux10_ctype_declarations2;
2221 files = ctype.h;
2222 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2223 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2224 c_fix = format;
2225 c_fix_arg = "%0\n\n"
2226 "#ifdef _PROTOTYPES\n"
2227 " extern int _isalnum(int);\n"
2228 " extern int _isalpha(int);\n"
2229 " extern int _iscntrl(int);\n"
2230 " extern int _isdigit(int);\n"
2231 " extern int _isgraph(int);\n"
2232 " extern int _islower(int);\n"
2233 " extern int _isprint(int);\n"
2234 " extern int _ispunct(int);\n"
2235 " extern int _isspace(int);\n"
2236 " extern int _isupper(int);\n"
2237 " extern int _isxdigit(int);\n"
2238 "# else /* not _PROTOTYPES */\n"
2239 " extern int _isalnum();\n"
2240 " extern int _isalpha();\n"
2241 " extern int _iscntrl();\n"
2242 " extern int _isdigit();\n"
2243 " extern int _isgraph();\n"
2244 " extern int _islower();\n"
2245 " extern int _isprint();\n"
2246 " extern int _ispunct();\n"
2247 " extern int _isspace();\n"
2248 " extern int _isupper();\n"
2249 " extern int _isxdigit();\n"
2250 "#endif /* _PROTOTYPES */\n";
2252 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2253 " extern unsigned int *__SB_masks;\n";
2257 * Fix hpux 10.X missing stdio declarations
2259 fix = {
2260 hackname = hpux10_stdio_declarations;
2261 files = stdio.h;
2262 select = "^#[ \t]*define _iob[ \t]*__iob";
2263 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2264 c_fix = format;
2265 c_fix_arg = "%0\n\n"
2266 "# if defined(__STDC__) || defined(__cplusplus)\n"
2267 " extern int snprintf(char *, size_t, const char *, ...);\n"
2268 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2269 "# else /* not __STDC__) || __cplusplus */\n"
2270 " extern int snprintf();\n"
2271 " extern int vsnprintf();\n"
2272 "# endif /* __STDC__) || __cplusplus */\n";
2274 test_text = "# define _iob __iob\n";
2278 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2279 * As a result, we need to include sys/stdsyms.h in alloca.h.
2281 fix = {
2282 hackname = hppa_hpux11_alloca;
2283 mach = "hppa*-*-hpux11*";
2284 files = alloca.h;
2285 select = "#ifndef _STDDEF_INCLUDED";
2286 c_fix = format;
2287 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2288 "# include <sys/stdsyms.h>\n"
2289 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2290 "%0";
2292 test_text = "#ifndef _STDDEF_INCLUDED";
2296 * Make sure hpux defines abs in header.
2298 fix = {
2299 hackname = hpux11_abs;
2300 mach = "*-hp-hpux11*";
2301 files = stdlib.h;
2302 select = "ifndef _MATH_INCLUDED";
2303 c_fix = format;
2304 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2305 test_text = "#ifndef _MATH_INCLUDED";
2309 * Fix hpux11 __LWP_RWLOCK_VALID define
2311 fix = {
2312 hackname = hpux11_lwp_rwlock_valid;
2313 mach = "*-hp-hpux11*";
2314 files = sys/pthread.h;
2315 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2316 c_fix = format;
2317 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2318 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2322 * hpux sendfile()
2324 fix = {
2325 hackname = hpux11_extern_sendfile;
2326 mach = "*-hp-hpux11.[12]*";
2327 files = sys/socket.h;
2328 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2329 c_fix = format;
2330 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2331 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2332 " const struct iovec *, int));\n";
2336 * hpux sendpath()
2338 fix = {
2339 hackname = hpux11_extern_sendpath;
2340 mach = "*-hp-hpux11.[12]*";
2341 files = sys/socket.h;
2342 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2343 c_fix = format;
2344 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2345 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2346 " const struct iovec *, int));\n";
2350 * Keep HP-UX 11 from stomping on C++ math namespace
2351 * with defines for fabsf.
2353 fix = {
2354 hackname = hpux11_fabsf;
2355 mach = "*-hp-hpux11*";
2356 files = math.h;
2357 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2359 c_fix = format;
2360 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2362 test_text =
2363 "#ifdef _PA_RISC\n"
2364 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2365 "#endif";
2369 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2370 * in pthread.h need to be constant expressions to be standard complient.
2371 * As a result, we need to remove the void * casts in the initializers
2372 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2373 * to use the long type.
2375 fix = {
2376 hackname = hpux11_pthread_pointer;
2377 mach = "*-hp-hpux11.[0-3]*";
2378 files = sys/pthread.h;
2379 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2381 c_fix = format;
2382 c_fix_arg = "long\t%2%3";
2383 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2387 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2389 fix = {
2390 hackname = hpux11_pthread_const;
2391 mach = "*-hp-hpux11.[0-3]*";
2392 files = sys/pthread.h;
2393 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2395 c_fix = format;
2396 c_fix_arg = "%11";
2397 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2401 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2402 * being defined by having it define _hpux_size_t instead.
2404 fix = {
2405 hackname = hpux11_size_t;
2406 mach = "*-hp-hpux11*";
2407 select = "__size_t";
2409 c_fix = format;
2410 c_fix_arg = "_hpux_size_t";
2412 test_text =
2413 "#define __size_t size_t\n"
2414 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2418 * Fix hpux 11.00 broken snprintf declaration
2419 * (third argument is char *, needs to be const char * to prevent
2420 * spurious warnings with -Wwrite-strings or in C++).
2422 fix = {
2423 hackname = hpux11_snprintf;
2424 files = stdio.h;
2425 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2426 ' *(char *\*, *\.\.\.\);)';
2427 c_fix = format;
2428 c_fix_arg = '%1 const %3';
2430 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2431 "extern int snprintf(char *, __size_t, char *, ...);\n"
2432 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2436 * Fix hpux 11.00 broken vsnprintf declaration
2438 fix = {
2439 hackname = hpux11_vsnprintf;
2440 files = stdio.h;
2441 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2442 'const char \*,) __va__list\);';
2443 c_fix = format;
2444 c_fix_arg = "%1 __va_list);";
2446 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2447 ' __va__list);';
2451 * Fix missing const in hpux vsscanf declaration
2453 fix = {
2454 hackname = hpux_vsscanf;
2455 mach = "*-*-hpux*";
2456 files = stdio.h;
2457 select = '(extern int vsscanf\()char';
2458 c_fix = format;
2459 c_fix_arg = "%1const char";
2461 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2465 * get rid of bogus inline definitions in HP-UX 8.0
2467 fix = {
2468 hackname = hpux8_bogus_inlines;
2469 files = math.h;
2470 select = inline;
2471 bypass = "__GNUG__";
2472 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2473 "@extern \"C\" int abs(int);@";
2474 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2475 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2476 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2477 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2478 "inline double sqr(double v) { return v**0.5; }";
2482 * hpux intptr
2484 fix = {
2485 hackname = hpux_c99_intptr;
2486 mach = "*-hp-hpux11.3*";
2487 files = stdint-hpux11.h, stdint.h;
2488 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2489 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2490 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2491 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2492 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2493 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2494 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2495 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2496 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2497 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2498 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2499 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2500 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2501 "#define PTRDIFF_MIN INT32_MIN\n"
2502 "#define INTPTR_MAX INT32_MAX\n"
2503 "#define INTPTR_MIN INT32_MIN\n"
2504 "#define UINTPTR_MAX UINT32_MAX\n"
2505 "#define SIZE_MAX UINT32_MAX\n";
2509 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2511 fix = {
2512 hackname = hpux_c99_inttypes;
2513 mach = "*-hp-hpux11.[23]*";
2514 files = inttypes.h;
2515 files = stdint-hpux11.h, stdint.h;
2516 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2517 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2518 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2519 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2520 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2521 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2522 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2523 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2524 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2525 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2526 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2527 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2531 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2533 fix = {
2534 hackname = hpux_c99_inttypes2;
2535 mach = "*-hp-hpux11.2*";
2536 files = stdint-hpux11.h, stdint.h;
2537 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2538 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2539 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2540 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2541 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2542 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2543 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2544 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2545 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2546 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2547 "# define INT16_C(__c) ((short)(__c))\n"
2548 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2552 * Fix hpux broken ctype macros
2554 fix = {
2555 hackname = hpux_ctype_macros;
2556 files = ctype.h;
2557 select = '((: |\()__SB_masks \? )'
2558 '(__SB_masks\[__(alnum|c)\] & _IS)';
2559 c_fix = format;
2560 c_fix_arg = "%1(int)%3";
2562 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2563 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2567 * hpux errno()
2569 fix = {
2570 hackname = hpux_extern_errno;
2571 mach = "*-hp-hpux10.*";
2572 mach = "*-hp-hpux11.[0-2]*";
2573 files = errno.h;
2574 select = "^[ \t]*extern int errno;$";
2575 c_fix = format;
2576 c_fix_arg = "#ifdef __cplusplus\n"
2577 "extern \"C\" {\n"
2578 "#endif\n"
2579 "%0\n"
2580 "#ifdef __cplusplus\n"
2581 "}\n"
2582 "#endif";
2583 test_text = " extern int errno;\n";
2587 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2589 fix = {
2590 hackname = hpux_htonl;
2591 files = netinet/in.h;
2592 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2593 "(/\\*\n"
2594 " \\* Macros for number representation conversion\\.\n"
2595 " \\*/\n"
2596 "#ifndef ntohl)";
2597 c_fix = format;
2598 c_fix_arg = "#if 1\n%1";
2600 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2601 "/*\n"
2602 " * Macros for number representation conversion.\n"
2603 " */\n"
2604 "#ifndef ntohl\n"
2605 "#define ntohl(x) (x)\n"
2606 "#define ntohs(x) (x)\n"
2607 "#define htonl(x) (x)\n"
2608 "#define htons(x) (x)\n"
2609 "#endif\n"
2610 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2614 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2616 fix = {
2617 hackname = hpux_imaginary_i;
2618 mach = "ia64-hp-hpux11.*";
2619 files = complex.h;
2620 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2621 c_fix = format;
2622 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2623 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2627 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2629 fix = {
2630 hackname = hpux_inttype_int8_t;
2631 mach = "*-hp-hpux1[01].*";
2632 files = sys/_inttypes.h;
2633 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2634 c_fix = format;
2635 c_fix_arg = "typedef signed char int%18_t;";
2636 test_text = "typedef char int_least8_t;\n"
2637 "typedef char int8_t;\n";
2641 * HP-UX long_double
2643 fix = {
2644 hackname = hpux_long_double;
2645 mach = "*-*-hpux10*";
2646 mach = "*-*-hpux11.[012]*";
2647 files = stdlib.h;
2648 select = "extern[ \t]long_double[ \t]strtold";
2649 bypass = "long_double_t";
2650 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2651 sed = "s/long_double/long double/g";
2653 test_text = "# ifndef _LONG_DOUBLE\n"
2654 "# define _LONG_DOUBLE\n"
2655 " typedef struct {\n"
2656 " unsigned int word1, word2, word3, word4;\n"
2657 " } long_double;\n"
2658 "# endif /* _LONG_DOUBLE */\n"
2659 "extern long_double strtold(const char *, char **);\n";
2663 * We cannot use the above rule on 11.31 because it removes the strtold
2664 * definition. ia64 is OK with no hack, PA needs some help.
2666 fix = {
2667 hackname = hpux_long_double_2;
2668 mach = "hppa*-*-hpux11.3*";
2669 files = stdlib.h;
2670 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2671 "defined\\(_PROTOTYPES\\) \\|\\| "
2672 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2673 c_fix = format;
2674 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2676 test_text = "# if !defined(__ia64) || "
2677 "!defined(_PROTOTYPES) || "
2678 "defined(_LONG_DOUBLE_STRUCT)\n";
2682 * Add missing braces to pthread initializer defines.
2684 fix = {
2685 hackname = hpux_pthread_initializers;
2686 mach = "*-hp-hpux11.[0-3]*";
2687 files = sys/pthread.h;
2688 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2689 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2690 sed = "s@^[ \t]*1,[ \t]*\\\\"
2691 "@\t{ 1, 0 }@";
2692 sed = "/^[ \t]*0$/d";
2693 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2694 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2695 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2696 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2697 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2698 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2699 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2700 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2701 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2702 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2703 sed = "s@__PTHREAD_COND_VALID, 0"
2704 "@{ __PTHREAD_COND_VALID, 0 }@";
2705 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2706 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2707 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2708 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2709 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2710 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2711 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2712 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2713 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2714 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2715 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2716 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2717 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2718 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2719 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2720 "}\n";
2724 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2725 * type and mpinfou is only defined when _KERNEL is set.
2727 fix = {
2728 hackname = hpux_spu_info;
2729 mach = "*-hp-hpux*";
2731 * It is tempting to omit the first "files" entry. Do not.
2732 * The testing machinery will take the first "files" entry as the name
2733 * of a test file to play with. It would be a nuisance to have a directory
2734 * with the name "*".
2736 files = "ia64/sys/getppdp.h";
2737 files = "*/sys/getppdp.h";
2738 select = "^.*extern.*spu_info.*";
2740 c_fix = format;
2741 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2743 test_text = "extern union mpinfou spu_info[];";
2747 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2749 fix = {
2750 hackname = hpux_stdint_least_fast;
2751 mach = "*-hp-hpux11.2*";
2752 files = stdint-hpux11.h, stdint.h;
2753 select =
2754 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2755 c_fix = format;
2756 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2757 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2758 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2762 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2764 fix = {
2765 hackname = hpux_longjmp;
2766 mach = "*-hp-hpux*";
2767 files = setjmp.h;
2768 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2770 c_fix = format;
2771 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2773 test_text = 'extern void longjmp __((jmp_buf, int));';
2777 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2779 fix = {
2780 hackname = hpux_systime;
2781 files = sys/time.h;
2782 select = "^extern struct sigevent;";
2784 c_fix = format;
2785 c_fix_arg = "struct sigevent;";
2787 test_text = 'extern struct sigevent;';
2791 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2793 fix = {
2794 hackname = huge_val_hex;
2795 files = bits/huge_val.h, '*/bits/huge_val.h';
2796 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2797 bypass = "__builtin_huge_val";
2799 c_fix = format;
2800 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2802 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2806 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2808 fix = {
2809 hackname = huge_valf_hex;
2810 files = bits/huge_val.h, '*/bits/huge_val.h';
2811 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2812 bypass = "__builtin_huge_valf";
2814 c_fix = format;
2815 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2817 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2821 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2823 fix = {
2824 hackname = huge_vall_hex;
2825 files = bits/huge_val.h, '*/bits/huge_val.h';
2826 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2827 bypass = "__builtin_huge_vall";
2829 c_fix = format;
2830 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2832 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2836 * Fix return type of abort and free
2838 fix = {
2839 hackname = int_abort_free_and_exit;
2840 files = stdlib.h;
2841 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2842 bypass = "_CLASSIC_ANSI_TYPES";
2844 c_fix = format;
2845 c_fix_arg = "void\t%1(";
2847 test_text = "extern int abort(int);\n"
2848 "extern int free(void*);\n"
2849 "extern int exit(void*);";
2853 * Fix various macros used to define ioctl numbers.
2854 * The traditional syntax was:
2856 * #define _IO(n, x) (('n'<<8)+x)
2857 * #define TIOCFOO _IO(T, 1)
2859 * but this does not work with the C standard, which disallows macro
2860 * expansion inside strings. We have to rewrite it thus:
2862 * #define _IO(n, x) ((n<<8)+x)
2863 * #define TIOCFOO _IO('T', 1)
2865 * The select expressions match too much, but the c_fix code is cautious.
2867 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2869 fix = {
2870 hackname = io_quotes_def;
2871 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2872 c_fix = char_macro_def;
2873 c_fix_arg = "IO";
2874 test_text =
2875 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2876 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2877 "#define _IO(x,y) ('x'<<8|y)";
2878 test_text =
2879 "#define XX_IO(x) ('x'<<8|256)";
2883 * Fix the usage of the ioctl macro numbers.
2885 fix = {
2886 hackname = io_quotes_use;
2887 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2888 "\\( *[^,']";
2889 c_fix = char_macro_use;
2890 c_fix_arg = "IO";
2891 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2892 "#define TIOCFOO \\\\\n"
2893 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2897 * Check for missing ';' in struct
2899 fix = {
2900 hackname = ip_missing_semi;
2901 files = netinet/ip.h;
2902 select = "}$";
2903 sed = "/^struct/,/^};/s/}$/};/";
2904 test_text=
2905 "struct mumble {\n"
2906 " union {\n"
2907 " int x;\n"
2908 " }\n"
2909 "}; /* mumbled struct */\n";
2913 * Non-traditional "const" declaration in Irix's limits.h.
2915 fix = {
2916 hackname = irix_limits_const;
2917 files = fixinc-test-limits.h, limits.h;
2918 select = "^extern const ";
2919 c_fix = format;
2920 c_fix_arg = "extern __const ";
2921 test_text = "extern const char limit; /* test limits */";
2925 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2926 * taking char *. However, GCC uses void * for va_list, so
2927 * calling vfprintf with a va_list fails in C++. */
2928 fix = {
2929 hackname = irix_stdio_va_list;
2930 files = stdio.h;
2932 select = '/\* va_list \*/ char \*';
2933 c_fix = format;
2934 c_fix_arg = "__gnuc_va_list";
2935 test_text =
2936 "extern int printf( const char *, /* va_list */ char * );";
2940 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2941 * use / * * / to concatenate tokens.
2943 fix = {
2944 hackname = kandr_concat;
2945 files = "sparc/asm_linkage.h";
2946 files = "sun*/asm_linkage.h";
2947 files = "arm/as_support.h";
2948 files = "arm/mc_type.h";
2949 files = "arm/xcb.h";
2950 files = "dev/chardefmac.h";
2951 files = "dev/ps_irq.h";
2952 files = "dev/screen.h";
2953 files = "dev/scsi.h";
2954 files = "sys/tty.h";
2955 files = "Xm.acorn/XmP.h";
2956 files = bsd43/bsd43_.h;
2957 select = '/\*\*/';
2958 c_fix = format;
2959 c_fix_arg = '##';
2960 test_text = "#define __CONCAT__(a,b) a/**/b";
2964 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2965 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2966 * constant on recent versions of g++.
2968 fix = {
2969 hackname = linux_ia64_ucontext;
2970 files = "sys/ucontext.h";
2971 mach = "ia64-*-linux*";
2972 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2973 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2974 c_fix = format;
2975 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2976 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2977 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2981 * Remove header file warning from sys/time.h. Autoconf's
2982 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2983 * which causes warning on LynxOS. Remove the warning.
2985 fix = {
2986 hackname = lynxos_no_warning_in_sys_time_h;
2987 files = sys/time.h;
2988 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2989 c_fix = format;
2990 c_fix_arg = "";
2991 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2995 * Add missing declaration for putenv.
2997 fix = {
2998 hackname = lynxos_missing_putenv;
2999 mach = '*-*-lynxos*';
3000 files = stdlib.h;
3001 bypass = 'putenv[ \t]*\\(';
3002 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3003 c_fix = format;
3004 c_fix_arg = "%0\n"
3005 "extern int putenv _AP((char *));";
3006 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3007 test_text = "extern char *getenv _AP((const char *));";
3011 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3013 * On NetBSD, machine is a symbolic link to an architecture specific
3014 * directory name, so we can't match a specific file name here.
3016 fix = {
3017 hackname = machine_ansi_h_va_list;
3018 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
3019 bypass = '__builtin_va_list';
3021 c_fix = format;
3022 c_fix_arg = "%1__builtin_va_list";
3023 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3025 test_text = " # define _BSD_VA_LIST_\tchar**";
3029 * Fix non-ansi machine name defines
3031 fix = {
3032 hackname = machine_name;
3033 c_test = machine_name;
3034 c_fix = machine_name;
3036 test_text = "/* MACH_DIFF: */\n"
3037 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
3038 "\n/* no uniform test, so be careful :-) */";
3042 * Some math.h files define struct exception (it's in the System V
3043 * Interface Definition), which conflicts with the class exception defined
3044 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
3045 * This is not a great fix, but I haven't been able to think of anything
3046 * better.
3048 fix = {
3049 hackname = math_exception;
3050 files = math.h;
3051 select = "struct exception";
3053 * This should be bypassed on __cplusplus, but some supposedly C++
3054 * aware headers, such as Solaris 8 and 9, don't wrap their struct
3055 * exception either. So currently we bypass only for glibc, based on a
3056 * comment in the fixed glibc header. Ick.
3058 bypass = 'We have a problem when using C\+\+|for C\+\+, '
3059 '_[a-z0-9A-Z_]+_exception; for C, exception';
3060 /* The Solaris 10 headers already get this right. */
3061 mach = '*-*-solaris2.1[0-9]*';
3062 not_machine = true;
3063 c_fix = wrap;
3065 c_fix_arg = "#ifdef __cplusplus\n"
3066 "#define exception __math_exception\n"
3067 "#endif\n";
3069 c_fix_arg = "#ifdef __cplusplus\n"
3070 "#undef exception\n"
3071 "#endif\n";
3073 test_text = "typedef struct exception t_math_exception;";
3077 * This looks pretty broken to me. ``dbl_max_def'' will contain
3078 * "define DBL_MAX " at the start, when what we really want is just
3079 * the value portion. Can't figure out how to write a test case
3080 * for this either :-(
3082 fix = {
3083 hackname = math_huge_val_from_dbl_max;
3084 files = math.h;
3087 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3088 * in math.h, this fix applies.
3090 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3091 bypass = "define[ \t]+DBL_MAX";
3093 shell =
3095 * See if we have a definition for DBL_MAX in float.h.
3096 * If we do, we will replace the one in math.h with that one.
3099 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3100 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3102 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3103 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3104 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3105 "\telse cat\n"
3106 "\tfi";
3108 test_text =
3109 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3110 "#define HUGE_VAL DBL_MAX";
3114 * nested comment
3116 fix = {
3117 hackname = nested_auth_des;
3118 files = rpc/rpc.h;
3119 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3120 c_fix = format;
3121 c_fix_arg = "%1*/ /*";
3122 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3126 * Some versions of NetBSD don't expect the C99 inline semantics.
3128 fix = {
3129 hackname = netbsd_c99_inline_1;
3130 mach = "*-*-netbsd*";
3131 files = signal.h;
3132 select = "extern __inline int";
3134 c_fix = format;
3135 c_fix_arg = "extern\n"
3136 "#ifdef __GNUC_STDC_INLINE__\n"
3137 "__attribute__((__gnu_inline__))\n"
3138 "#endif\n"
3139 "__inline int";
3141 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3145 * netbsd_c99_inline_2
3147 fix = {
3148 hackname = netbsd_c99_inline_2;
3149 mach = "*-*-netbsd*";
3150 files = signal.h;
3151 select = "#define _SIGINLINE extern __inline";
3153 c_fix = format;
3154 c_fix_arg = <<- _EOArg_
3155 #ifdef __GNUC_STDC_INLINE__
3156 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3157 #else
3159 #endif
3160 _EOArg_;
3162 test_text = "#define _SIGINLINE extern __inline";
3166 * NetBSD has a semicolon after the ending '}' for some extern "C".
3168 fix = {
3169 hackname = netbsd_extra_semicolon;
3170 mach = "*-*-netbsd*";
3171 files = sys/cdefs.h;
3172 select = "#define[ \t]*__END_DECLS[ \t]*};";
3174 c_fix = format;
3175 c_fix_arg = "#define __END_DECLS }";
3177 test_text = "#define __END_DECLS };";
3181 * newlib's stdint.h has several failures to conform to C99. The fix
3182 * for these removed a comment that can be matched to identify unfixed
3183 * versions.
3185 fix = {
3186 hackname = newlib_stdint_1;
3187 files = stdint-newlib.h, stdint.h;
3188 select = "@todo - Add support for wint_t types";
3189 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3190 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3191 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3192 sed = "s@#define INT_LEAST32_MIN.*@"
3193 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3194 sed = "s@#define INT_LEAST32_MAX.*@"
3195 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3196 sed = "s@#define UINT_LEAST32_MAX.*@"
3197 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3198 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3199 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3200 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3201 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3202 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3203 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3204 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3205 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3206 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3207 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3208 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3209 test_text = "/* @todo - Add support for wint_t types. */\n"
3210 "#define INT32_MIN (-2147483647-1)\n"
3211 "#define INT32_MAX 2147483647\n"
3212 "#define UINT32_MAX 4294967295U\n"
3213 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3214 "#define INT_LEAST32_MAX 2147483647\n"
3215 "#define UINT_LEAST32_MAX 4294967295U\n"
3216 "#define INT_FAST8_MIN INT8_MIN\n"
3217 "#define INT_FAST8_MAX INT8_MAX\n"
3218 "#define UINT_FAST8_MAX UINT8_MAX\n"
3219 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3220 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3221 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3222 "#define UINT8_C(x) x##U\n"
3223 "#define UINT16_C(x) x##U";
3227 * newlib_stdint_2
3229 fix = {
3230 hackname = newlib_stdint_2;
3231 files = stdint-newlib.h, stdint.h;
3232 select = "@todo - Add support for wint_t types";
3233 c_fix = format;
3234 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3235 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3236 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3237 "#define WCHAR_MAX __WCHAR_MAX__\n"
3238 "#define WCHAR_MIN __WCHAR_MIN__\n"
3239 "#define WINT_MAX __WINT_MAX__\n"
3240 "#define WINT_MIN __WINT_MIN__\n\n"
3241 "%0";
3242 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3243 test_text = "/* @todo - Add support for wint_t types. */\n"
3244 "/** Macros for minimum-width integer constant expressions */";
3248 * NeXT 3.2 adds const prefix to some math functions.
3249 * These conflict with the built-in functions.
3251 fix = {
3252 hackname = next_math_prefix;
3253 files = ansi/math.h;
3254 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3256 c_fix = format;
3257 c_fix_arg = "extern double %1(";
3258 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3260 test_text = "extern\tdouble\t__const__\tmumble();";
3264 * NeXT 3.2 uses the word "template" as a parameter for some
3265 * functions. GCC reports an invalid use of a reserved key word
3266 * with the built-in functions.
3268 fix = {
3269 hackname = next_template;
3270 files = bsd/libc.h;
3271 select = "[ \t]template\\)";
3273 c_fix = format;
3274 c_fix_arg = "(%1)";
3275 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3276 test_text = "extern mumble( char * template); /* fix */";
3280 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3281 * function prototypes. That conflicts with the built-in functions.
3283 fix = {
3284 hackname = next_volitile;
3285 files = ansi/stdlib.h;
3286 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3288 c_fix = format;
3289 c_fix_arg = "extern void %1(";
3290 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3292 test_text = "extern\tvolatile\tvoid\tabort();";
3296 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3297 * Note that version 3 of the NeXT system has wait.h in a different directory,
3298 * so that this code won't do anything. But wait.h in version 3 has a
3299 * conditional, so it doesn't need this fix. So everything is okay.
3301 fix = {
3302 hackname = next_wait_union;
3303 files = sys/wait.h;
3305 select = 'wait\(union wait';
3306 c_fix = format;
3307 c_fix_arg = "wait(void";
3308 test_text = "extern pid_d wait(union wait*);";
3312 * a missing semi-colon at the end of the nodeent structure definition.
3314 fix = {
3315 hackname = nodeent_syntax;
3316 files = netdnet/dnetdb.h;
3317 select = "char[ \t]*\\*na_addr[ \t]*$";
3318 c_fix = format;
3319 c_fix_arg = "%0;";
3320 test_text = "char *na_addr\t";
3324 * Fix OpenBSD's NULL definition.
3326 fix = {
3327 hackname = openbsd_null_definition;
3328 mach = "*-*-openbsd*";
3329 files = locale.h, stddef.h, stdio.h, string.h,
3330 time.h, unistd.h, wchar.h, sys/param.h;
3331 select = "__GNUG__";
3332 c_fix = format;
3333 c_fix_arg = "#ifndef NULL\n"
3334 "#ifdef __cplusplus\n"
3335 "#ifdef __GNUG__\n"
3336 "#define NULL\t__null\n"
3337 "#else\t /* ! __GNUG__ */\n"
3338 "#define NULL\t0L\n"
3339 "#endif\t /* __GNUG__ */\n"
3340 "#else\t /* ! __cplusplus */\n"
3341 "#define NULL\t((void *)0)\n"
3342 "#endif\t /* __cplusplus */\n"
3343 "#endif\t /* !NULL */";
3345 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3346 "^#ifdef[ \t]*__GNUG__\n"
3347 "^#define[ \t]*NULL[ \t]*__null\n"
3348 "^#else\n"
3349 "^#define[ \t]*NULL[ \t]*0L\n"
3350 "^#endif\n"
3351 "^#endif";
3352 test_text =
3353 "#ifndef NULL\n"
3354 "#ifdef __GNUG__\n"
3355 "#define NULL __null\n"
3356 "#else\n"
3357 "#define NULL 0L\n"
3358 "#endif\n"
3359 "#endif\n";
3363 * obstack.h used casts as lvalues.
3365 * We need to change postincrements of casted pointers (which are
3366 * then dereferenced and assigned into) of the form
3368 * *((TYPE*)PTRVAR)++ = (VALUE)
3370 * into expressions like
3372 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3374 * which is correct for the cases used in obstack.h since PTRVAR is
3375 * of type char * and the value of the expression is not used.
3377 fix = {
3378 hackname = obstack_lvalue_cast;
3379 files = obstack.h;
3380 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3381 c_fix = format;
3382 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3383 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3387 * Fix OpenBSD's va_start define.
3389 fix = {
3390 hackname = openbsd_va_start;
3391 mach = "*-*-openbsd*";
3392 files = stdarg.h;
3393 select = '__builtin_stdarg_start';
3394 c_fix = format;
3395 c_fix_arg = __builtin_va_start;
3397 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3401 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3402 * defining regex.h related types. This causes libg++ build and usage
3403 * failures. Fixing this correctly requires checking and modifying 3 files.
3405 fix = {
3406 hackname = osf_namespace_a;
3407 files = reg_types.h;
3408 files = sys/lc_core.h;
3409 test = " -r reg_types.h";
3410 test = " -r sys/lc_core.h";
3411 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3412 test = " -z \"`grep __regex_t regex.h`\"";
3414 c_fix = format;
3415 c_fix_arg = "__%0";
3416 c_fix_arg = "reg(ex|off|match)_t";
3418 test_text = "`touch sys/lc_core.h`"
3419 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3420 "extern regex_t re;\n"
3421 "extern regoff_t ro;\n"
3422 "extern regmatch_t rm;\n";
3425 fix = {
3426 hackname = osf_namespace_c;
3427 files = regex.h;
3428 test = " -r reg_types.h";
3429 test = " -r sys/lc_core.h";
3430 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3431 test = " -z \"`grep __regex_t regex.h`\"";
3433 select = "#include <reg_types\.h>.*";
3434 c_fix = format;
3435 c_fix_arg = "%0\n"
3436 "typedef __regex_t\tregex_t;\n"
3437 "typedef __regoff_t\tregoff_t;\n"
3438 "typedef __regmatch_t\tregmatch_t;";
3440 test_text = "#include <reg_types.h>";
3444 * On broken glibc-2.3.3 systems an array of incomplete structures is
3445 * passed to __sigsetjmp. Fix that to take a pointer instead.
3447 fix = {
3448 hackname = pthread_incomplete_struct_argument;
3449 files = pthread.h;
3450 select = "struct __jmp_buf_tag";
3451 c_fix = format;
3452 c_fix_arg = "%1 *%2%3";
3453 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3454 "(__env)\\[1\\](.*)$";
3455 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3456 "int __savemask);";
3460 * Fix return type of fread and fwrite on sysV68
3462 fix = {
3463 hackname = read_ret_type;
3464 files = stdio.h;
3465 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3466 c_fix = format;
3467 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3468 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3470 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3474 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3476 fix = {
3477 hackname = rpc_xdr_lvalue_cast_a;
3478 files = rpc/xdr.h;
3479 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3480 c_fix = format;
3481 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3482 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3483 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3487 * rpc_xdr_lvalue_cast_b
3489 fix = {
3490 hackname = rpc_xdr_lvalue_cast_b;
3491 files = rpc/xdr.h;
3492 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3493 c_fix = format;
3494 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3495 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3496 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3500 * function class(double x) conflicts with C++ keyword on rs/6000
3502 fix = {
3503 hackname = rs6000_double;
3504 files = math.h;
3505 select = '[^a-zA-Z_]class\(';
3507 c_fix = format;
3508 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3509 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3511 test_text = "extern int class();";
3515 * Wrong fchmod prototype on RS/6000.
3517 fix = {
3518 hackname = rs6000_fchmod;
3519 files = sys/stat.h;
3520 select = 'fchmod\(char \*';
3521 c_fix = format;
3522 c_fix_arg = "fchmod(int";
3523 test_text = "extern int fchmod(char *, mode_t);";
3527 * parameters conflict with C++ new on rs/6000
3529 fix = {
3530 hackname = rs6000_param;
3531 files = "stdio.h";
3532 files = "unistd.h";
3534 select = 'rename\(const char \*old, const char \*new\)';
3535 c_fix = format;
3536 c_fix_arg = 'rename(const char *_old, const char *_new)';
3538 test_text = 'extern int rename(const char *old, const char *new);';
3542 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3543 * for C99. This is wrong for C++, which needs many C99 features, but
3544 * only supports __restrict.
3546 fix = {
3547 hackname = solaris___restrict;
3548 files = sys/feature_tests.h;
3549 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3550 mach = "*-*-solaris2*";
3551 c_fix = format;
3552 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3553 "#else\n%0\n#endif";
3554 test_text = "#define _RESTRICT_KYWD restrict";
3558 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3559 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3560 * and imaginary definitions which are not supported by GCC.
3562 fix = {
3563 hackname = solaris_complex;
3564 mach = "*-*-solaris2.*";
3565 files = complex.h;
3566 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3567 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3568 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3569 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3570 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3571 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3572 test_text = "#define _Complex_I _Complex_I\n"
3573 "#define complex _Complex\n"
3574 "#define _Imaginary_I _Imaginary_I\n"
3575 "#define imaginary _Imaginary\n"
3576 "#undef I\n"
3577 "#define I _Imaginary_I";
3581 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3582 * extern "C" instead so libstdc++ can use it.
3584 fix = {
3585 hackname = solaris_complex_cxx;
3586 mach = "*-*-solaris2.*";
3587 files = complex.h;
3588 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3589 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3590 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3591 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3592 test_text = "#if !defined(__cplusplus)\n"
3593 "#endif /* !defined(__cplusplus) */";
3597 * g++ rejects functions declared with both C and C++ linkage.
3599 fix = {
3600 hackname = solaris_cxx_linkage;
3601 mach = '*-*-solaris2*';
3602 files = "iso/stdlib_iso.h";
3603 select = "(#if __cplusplus >= 199711L)\n"
3604 "(extern \"C\\+\\+\" \\{\n)"
3605 "(.*(bsearch|qsort).*)";
3606 c_fix = format;
3607 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3609 test_text =
3610 "#if __cplusplus >= 199711L\n"
3611 "extern \"C++\" {\n"
3612 " void *bsearch(const void *, const void *, size_t, size_t,";
3616 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3617 * _STRICT_STDC, but uses it.
3619 fix = {
3620 hackname = solaris_getc_strict_stdc;
3621 mach = "*-*-solaris2*";
3622 files = "iso/stdio_iso.h";
3623 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3624 c_fix = format;
3625 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3627 test_text =
3628 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3632 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3634 fix = {
3635 hackname = solaris_gets_c11;
3636 mach = "*-*-solaris2*";
3637 files = "iso/stdio_iso.h";
3638 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3640 c_fix = format;
3641 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3642 "%1 __attribute__((__deprecated__));\n"
3643 "#endif";
3645 test_text = "extern char *gets(char *);";
3649 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3651 fix = {
3652 hackname = solaris_gets_cxx14;
3653 mach = "*-*-solaris2*";
3654 files = "iso/stdio_iso.h";
3655 select = <<- _EOSelect_
3656 (#if __STDC_VERSION__ < 201112L)
3657 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3658 _EOSelect_;
3659 c_fix = format;
3660 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3662 test_text = <<- _EOText_
3663 #if __STDC_VERSION__ < 201112L
3664 extern char *gets(char *) __ATTR_DEPRECATED;
3665 _EOText_;
3669 * Sun Solaris 2 has a version of sys/int_const.h that defines
3670 * UINT8_C and UINT16_C to unsigned constants.
3672 fix = {
3673 hackname = solaris_int_const;
3674 files = sys/int_const.h;
3675 mach = '*-*-solaris2*';
3676 c_fix = format;
3677 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3678 "%1\n"
3679 "#define\tUINT16_C(c)\t(c)";
3680 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3681 "(/\*.*\*/)\n"
3682 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3683 test_text =
3684 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3685 "/* CSTYLED */\n"
3686 "#define UINT16_C(c) __CONCAT__(c,u)";
3690 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3691 * UINT8_MAX and UINT16_MAX to unsigned constants.
3693 fix = {
3694 hackname = solaris_int_limits_1;
3695 files = sys/int_limits.h;
3696 mach = '*-*-solaris2*';
3697 c_fix = format;
3698 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3699 "#define\tUINT16_MAX\t(65535)";
3700 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3701 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3702 test_text =
3703 "#define UINT8_MAX (255U)\n"
3704 "#define UINT16_MAX (65535U)";
3708 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3709 * INT_FAST16 limits to wrong values for sys/int_types.h.
3711 fix = {
3712 hackname = solaris_int_limits_2;
3713 files = sys/int_limits.h;
3714 mach = '*-*-solaris2*';
3715 c_fix = format;
3716 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3717 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3718 test_text =
3719 "#define INT_FAST16_MAX INT16_MAX\n"
3720 "#define UINT_FAST16_MAX UINT16_MAX\n"
3721 "#define INT_FAST16_MIN INT16_MIN";
3725 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3726 * SIZE_MAX as unsigned long.
3728 fix = {
3729 hackname = solaris_int_limits_3;
3730 files = sys/int_limits.h;
3731 mach = '*-*-solaris2*';
3732 c_fix = format;
3733 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3734 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3735 test_text =
3736 "#define SIZE_MAX 4294967295UL";
3740 * Sun Solaris 10 defines several C99 math macros in terms of
3741 * builtins specific to the Studio compiler, in particular not
3742 * compatible with the GNU compiler.
3744 fix = {
3745 hackname = solaris_math_1;
3746 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3747 bypass = "__GNUC__";
3748 files = iso/math_c99.h;
3749 c_fix = format;
3750 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3751 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3752 test_text =
3753 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3754 "#undef HUGE_VAL\n"
3755 "#define HUGE_VAL __builtin_huge_val\n"
3756 "#undef HUGE_VALF\n"
3757 "#define HUGE_VALF __builtin_huge_valf\n"
3758 "#undef HUGE_VALL\n"
3759 "#define HUGE_VALL __builtin_huge_vall";
3763 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3764 * exception. Provide an alternative using GCC's builtin.
3766 fix = {
3767 hackname = solaris_math_10;
3768 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3769 files = iso/math_c99.h;
3770 c_fix = format;
3771 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3772 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3773 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3774 "[ \t]*\\\\\n"
3775 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3776 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3777 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3778 "\\(-INFINITY\\);[ \t]*\\}\\)";
3779 test_text =
3780 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3781 "#undef isinf\n"
3782 "#define isinf(x) __extension__( \\\\\n"
3783 " { __typeof(x) __x_i = (x); \\\\\n"
3784 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3785 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3789 * Solaris math INFINITY
3791 fix = {
3792 hackname = solaris_math_2;
3793 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3794 bypass = "__GNUC__";
3795 files = iso/math_c99.h;
3796 c_fix = format;
3797 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3798 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3799 test_text =
3800 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3801 "#undef INFINITY\n"
3802 "#define INFINITY __builtin_infinity";
3806 * Solaris math NAN
3808 fix = {
3809 hackname = solaris_math_3;
3810 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3811 bypass = "__GNUC__";
3812 files = iso/math_c99.h;
3813 c_fix = format;
3814 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3815 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3816 test_text =
3817 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3818 "#undef NAN\n"
3819 "#define NAN __builtin_nan";
3823 * Solaris math fpclassify
3825 fix = {
3826 hackname = solaris_math_4;
3827 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3828 bypass = "__GNUC__";
3829 files = iso/math_c99.h;
3830 c_fix = format;
3831 c_fix_arg = "#define\tfpclassify(x) \\\n"
3832 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3833 "FP_SUBNORMAL, FP_ZERO, (x))";
3834 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3835 test_text =
3836 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3837 "#undef fpclassify\n"
3838 "#define fpclassify(x) __builtin_fpclassify(x)";
3842 * Solaris math signbit
3844 fix = {
3845 hackname = solaris_math_8;
3846 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3847 bypass = "__GNUC__";
3848 files = iso/math_c99.h;
3849 c_fix = format;
3850 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3851 "\t\t\t ? __builtin_signbitf(x) \\\n"
3852 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3853 "\t\t\t ? __builtin_signbitl(x) \\\n"
3854 "\t\t\t : __builtin_signbit(x))";
3855 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3856 test_text = <<- _EOText_
3857 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3858 #undef signbit
3859 #define signbit(x) __builtin_signbit(x)
3860 _EOText_;
3864 * Solaris math comparison macros
3866 fix = {
3867 hackname = solaris_math_9;
3868 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3869 bypass = "__GNUC__";
3870 files = iso/math_c99.h;
3871 c_fix = format;
3872 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3873 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3874 "__builtin_[a-z]+\\(y\\)\\)";
3875 test_text =
3876 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3877 "#undef isgreater\n"
3878 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3879 "#undef isgreaterequal\n"
3880 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3881 "#undef isless\n"
3882 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3883 "#undef islessequal\n"
3884 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3885 "#undef islessgreater\n"
3886 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3887 "#undef isunordered\n"
3888 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3892 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3893 * warnings.
3895 fix = {
3896 hackname = solaris_math_11;
3897 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3898 files = iso/math_c99.h;
3899 c_fix = format;
3900 c_fix_arg = << _EOArg_
3901 #undef signbit
3902 #define signbit(x) (sizeof(x) == sizeof(float) \
3903 ? __builtin_signbitf(x) \
3904 : sizeof(x) == sizeof(long double) \
3905 ? __builtin_signbitl(x) \
3906 : __builtin_signbit(x))
3907 _EOArg_;
3908 c_fix_arg = << _EOArg_
3909 ^#undef[ ]+signbit
3910 #if defined\(__sparc\)
3911 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3912 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3913 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3914 #elif defined\(__i386\) \|\| defined\(__amd64\)
3915 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3916 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3917 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3918 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3919 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3920 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3921 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3922 #endif
3923 _EOArg_;
3924 test_text = << _EOText_
3925 /* @(#)math_c99.h 1.14 13/03/27 */
3926 #undef signbit
3927 #if defined(__sparc)
3928 #define signbit(x) __extension__( \\
3929 { __typeof(x) __x_s = (x); \\
3930 (int) (*(unsigned *) &__x_s >> 31); })
3931 #elif defined(__i386) || defined(__amd64)
3932 #define signbit(x) __extension__( \\
3933 { __typeof(x) __x_s = (x); \\
3934 (sizeof (__x_s) == sizeof (float) ? \\
3935 (int) (*(unsigned *) &__x_s >> 31) : \\
3936 sizeof (__x_s) == sizeof (double) ? \\
3937 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3938 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3939 #endif
3940 _EOText_;
3944 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3946 fix = {
3947 hackname = solaris_math_12;
3948 files = math.h;
3949 mach = '*-*-solaris2*';
3950 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3951 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3952 test_text = << _EOText_
3953 #if __cplusplus >= 201103L
3954 #undef _GLIBCXX_USE_C99_MATH
3955 #undef _GLIBCXX_USE_C99_MATH_TR1
3956 #endif
3957 _EOText_;
3961 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3962 * structure. As such, it need two levels of brackets, but only
3963 * contains one. Wrap the macro definition in an extra layer.
3965 fix = {
3966 hackname = solaris_once_init_1;
3967 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3968 files = pthread.h;
3969 mach = '*-*-solaris*';
3970 c_fix = format;
3971 c_fix_arg = "%1{%2}%3";
3972 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3973 test_text =
3974 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3975 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3979 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3980 * posix_spawn declarations, which doesn't work with C++.
3982 fix = {
3983 hackname = solaris_posix_spawn_restrict;
3984 files = spawn.h;
3985 mach = '*-*-solaris2*';
3986 c_fix = format;
3987 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3988 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3989 test_text =
3990 "char *const argv[_RESTRICT_KYWD],\n"
3991 "char *const envp[_RESTRICT_KYWD]);";
3995 * The pow overloads with int were removed in C++ 2011 DR 550.
3997 fix = {
3998 hackname = solaris_pow_int_overload;
3999 mach = '*-*-solaris2*';
4000 files = "iso/math_iso.h";
4001 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4002 " *\\{[^{}]*\n[^{}]*\\}";
4003 c_fix = format;
4004 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4006 test_text =
4007 " inline long double pow(long double __X, int __Y) { return\n"
4008 " __powl(__X, (long double) (__Y)); }";
4012 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4013 * fields of the pthread_rwlock_t structure, which are of type
4014 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
4015 * defined (e.g. by -ansi) it is a union. So change the initializer
4016 * to "{0}" instead.
4018 fix = {
4019 hackname = solaris_rwlock_init_1;
4020 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4021 files = pthread.h;
4022 mach = '*-*-solaris*';
4023 c_fix = format;
4024 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4025 "%0\n"
4026 "#else\n"
4027 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4028 "#endif";
4029 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4030 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4032 test_text =
4033 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
4034 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4038 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
4039 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
4041 fix = {
4042 hackname = solaris_std___filbuf;
4043 files = stdio.h;
4044 mach = '*-*-solaris2*';
4045 bypass = "using std::__filbuf";
4046 select = "(using std::perror;\n)(#endif)";
4047 c_fix = format;
4048 c_fix_arg = "%1#ifndef _LP64\n"
4049 "using std::__filbuf;\n"
4050 "using std::__flsbuf;\n"
4051 "#endif\n%2";
4053 test_text = "using std::perror;\n"
4054 "#endif";
4058 * Solaris <stdio.h> shouldn't use std::gets for C++14.
4060 fix = {
4061 hackname = solaris_std_gets_cxx14;
4062 mach = "*-*-solaris2*";
4063 files = "stdio.h";
4064 select = "using std::gets;";
4066 c_fix = format;
4067 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4069 test_text = "using std::gets;";
4073 * Sun Solaris 8 has what appears to be some gross workaround for
4074 * some old version of their c++ compiler. G++ doesn't want it
4075 * either, but doesn't want to be tied to SunPRO version numbers.
4077 fix = {
4078 hackname = solaris_stdio_tag;
4079 files = stdio_tag.h;
4081 select = '__cplusplus < 54321L';
4082 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4083 "!defined(__GNUC__)" so we no longer need to fix it. */
4084 bypass = '__GNUC__';
4085 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4087 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4091 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4093 fix = {
4094 hackname = solaris_stdlib_noreturn;
4095 mach = "*-*-solaris2*";
4096 files = "iso/stdlib_c99.h";
4097 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4099 c_fix = format;
4100 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4102 test_text = "extern _Noreturn void quick_exit(int);";
4106 * a missing semi-colon at the end of the statsswtch structure definition.
4108 fix = {
4109 hackname = statsswtch;
4110 files = rpcsvc/rstat.h;
4111 select = "boottime$";
4112 c_fix = format;
4113 c_fix_arg = "boottime;";
4114 test_text = "struct statswtch {\n int boottime\n};";
4118 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4119 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4120 * OK too.
4122 fix = {
4123 hackname = stdio_stdarg_h;
4124 files = stdio.h;
4125 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4127 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4128 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4130 mach = '*-*-solaris2.1[0-9]*';
4131 not_machine = true;
4133 c_fix = wrap;
4135 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4137 test_text = "";
4141 * Don't use or define the name va_list in stdio.h. This is for
4142 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4143 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4144 * indicate that the header knows what it's doing -- under SUSv2,
4145 * stdio.h is required to define va_list, and we shouldn't break
4146 * that.
4148 fix = {
4149 hackname = stdio_va_list;
4150 files = stdio.h;
4151 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4153 * On Solaris 10, the definition in
4154 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4155 * there is therefore no need for this fix there.
4157 mach = '*-*-solaris2.1[0-9]*';
4158 not_machine = true;
4161 * Use __gnuc_va_list in arg types in place of va_list.
4162 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4163 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4164 * trailing parentheses and semicolon save all other systems from this.
4165 * Define __not_va_list__ (something harmless and unused)
4166 * instead of va_list.
4167 * Don't claim to have defined va_list.
4169 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4170 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4171 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4172 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4173 "s@ va_list@ __not_va_list__@\n"
4174 "s@\\*va_list@*__not_va_list__@\n"
4175 "s@ __va_list)@ __gnuc_va_list)@\n"
4176 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4177 "@typedef \\1 __not_va_list__;@\n"
4178 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4179 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4180 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4181 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4182 "s@VA_LIST@DUMMY_VA_LIST@\n"
4183 "s@_Va_LIST@_VA_LIST@";
4184 test_text = "extern void mumble( va_list);";
4188 * Fix headers that use va_list from stdio.h to use the updated
4189 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4190 * dealt with elsewhere. The presence of __gnuc_va_list,
4191 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4192 * knows what it's doing.
4194 fix = {
4195 hackname = stdio_va_list_clients;
4196 files = com_err.h;
4197 files = cps.h;
4198 files = curses.h;
4199 files = krb5.h;
4200 files = lc_core.h;
4201 files = pfmt.h;
4202 files = wchar.h;
4203 files = curses_colr/curses.h;
4204 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4205 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4206 otherwise protected. */
4207 bypass = 'include <stdarg\.h>|#ifdef va_start';
4210 * Use __gnuc_va_list in arg types in place of va_list.
4211 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4212 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4213 * trailing parentheses and semicolon save all other systems from this.
4214 * Define __not_va_list__ (something harmless and unused)
4215 * instead of va_list.
4216 * Don't claim to have defined va_list.
4218 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4219 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4220 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4221 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4222 "s@ va_list@ __not_va_list__@\n"
4223 "s@\\*va_list@*__not_va_list__@\n"
4224 "s@ __va_list)@ __gnuc_va_list)@\n"
4225 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4226 "@typedef \\1 __not_va_list__;@\n"
4227 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4228 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4229 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4230 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4231 "s@VA_LIST@DUMMY_VA_LIST@\n"
4232 "s@_Va_LIST@_VA_LIST@";
4233 test_text = "extern void mumble( va_list);";
4237 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4238 * is "!defined( __STRICT_ANSI__ )"
4240 fix = {
4241 hackname = strict_ansi_not;
4242 select = "^([ \t]*#[ \t]*if.*)"
4243 "(!__STDC__"
4244 "|__STDC__[ \t]*==[ \t]*0"
4245 "|__STDC__[ \t]*!=[ \t]*1"
4246 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4247 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4248 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4249 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4250 is not defined by GCC, so it is safe. */
4251 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4252 c_test = stdc_0_in_system_headers;
4254 c_fix = format;
4255 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4257 test_text = "#if !__STDC__ \n"
4258 "#if __STDC__ == 0\n"
4259 "#if __STDC__ != 1\n"
4260 "#if __STDC__ - 0 == 0"
4261 "/* not std C */\nint foo;\n"
4262 "\n#end-end-end-end-if :-)";
4266 * "__STDC__-0==0"
4267 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4269 fix = {
4270 hackname = strict_ansi_not_ctd;
4271 files = math.h, limits.h, stdio.h, signal.h,
4272 stdlib.h, sys/signal.h, time.h;
4274 * Starting at the beginning of a line, skip white space and
4275 * a leading "(" or "&&" or "||". One of those must be found.
4276 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4277 * expression. If these are nested, then they must accumulate
4278 * because we won't match any closing parentheses. Finally,
4279 * after skipping over all that, we must then match our suspect
4280 * phrase: "__STDC__-0==0" with or without white space.
4282 select = "^([ \t]*" '(\(|&&|\|\|)'
4283 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4284 "[ \t(]*)"
4285 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4286 c_test = stdc_0_in_system_headers;
4288 c_fix = format;
4289 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4291 test_text = "#if 1 && \\\\\n"
4292 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4293 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4294 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4295 "int foo;\n#endif";
4299 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4300 * is "defined( __STRICT_ANSI__ )"
4302 fix = {
4303 hackname = strict_ansi_only;
4304 select = "^([ \t]*#[ \t]*if.*)"
4305 "(__STDC__[ \t]*!=[ \t]*0"
4306 "|__STDC__[ \t]*==[ \t]*1"
4307 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4308 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4309 c_test = stdc_0_in_system_headers;
4311 c_fix = format;
4312 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4314 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4318 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4319 * in prototype without previous definition.
4321 fix = {
4322 hackname = struct_file;
4323 files = rpc/xdr.h;
4324 select = '^.*xdrstdio_create.*struct __file_s';
4325 c_fix = format;
4326 c_fix_arg = "struct __file_s;\n%0";
4327 test_text = "extern void xdrstdio_create( struct __file_s* );";
4331 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4332 * in prototype without previous definition.
4334 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4335 * function, and does define it.
4337 fix = {
4338 hackname = struct_sockaddr;
4339 files = rpc/auth.h;
4340 select = "^.*authdes_create.*struct sockaddr[^_]";
4341 bypass = "<sys/socket\.h>";
4342 bypass = "struct sockaddr;\n";
4343 c_fix = format;
4344 c_fix_arg = "struct sockaddr;\n%0";
4345 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4349 * Apply fix this to all OSs since this problem seems to effect
4350 * more than just SunOS.
4352 fix = {
4353 hackname = sun_auth_proto;
4354 files = rpc/auth.h;
4355 files = rpc/clnt.h;
4356 files = rpc/svc.h;
4357 files = rpc/xdr.h;
4358 bypass = "__cplusplus";
4360 * Select those files containing '(*name)()'.
4362 select = '\(\*[a-z][a-z_]*\)\(\)';
4364 c_fix = format;
4365 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4366 "#else\n%1();%2\n#endif";
4367 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4369 test_text =
4370 "struct auth_t {\n"
4371 " int (*name)(); /* C++ bad */\n"
4372 "};";
4376 * Fix bogus #ifdef on SunOS 4.1.
4378 fix = {
4379 hackname = sun_bogus_ifdef;
4380 files = "hsfs/hsfs_spec.h";
4381 files = "hsfs/iso_spec.h";
4382 select = '#ifdef(.*\|\|.*)';
4383 c_fix = format;
4384 c_fix_arg = "#if%1";
4386 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4390 * Fix the CAT macro in SunOS memvar.h.
4392 fix = {
4393 hackname = sun_catmacro;
4394 files = pixrect/memvar.h;
4395 select = "^#define[ \t]+CAT\\(a,b\\).*";
4396 c_fix = format;
4398 c_fix_arg =
4399 "#ifdef __STDC__\n"
4400 "# define CAT(a,b) a##b\n"
4401 "#else\n%0\n#endif";
4403 test_text =
4404 "#define CAT(a,b)\ta/**/b";
4408 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4409 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4411 fix = {
4412 hackname = sun_malloc;
4413 files = malloc.h;
4414 bypass = "_CLASSIC_ANSI_TYPES";
4416 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4417 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4418 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4419 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4420 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4422 test_text =
4423 "typedef char *\tmalloc_t;\n"
4424 "int \tfree();\n"
4425 "char*\tmalloc();\n"
4426 "char*\tcalloc();\n"
4427 "char*\trealloc();";
4431 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4433 fix = {
4434 hackname = sun_rusers_semi;
4435 files = rpcsvc/rusers.h;
4436 select = "_cnt$";
4437 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4438 test_text = "struct mumble\n int _cnt\n};";
4442 * signal.h on SunOS defines signal using (),
4443 * which causes trouble when compiling with g++ -pedantic.
4445 fix = {
4446 hackname = sun_signal;
4447 files = sys/signal.h;
4448 files = signal.h;
4449 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4451 c_fix = format;
4452 c_fix_arg =
4453 "#ifdef __cplusplus\n"
4454 "void\t(*signal(...))(...);\n"
4455 "#else\n%0\n#endif";
4457 test_text = "void\t(*signal())();";
4461 * Correct the return type for strlen in strings.h in SunOS 4.
4463 fix = {
4464 hackname = sunos_strlen;
4465 files = strings.h;
4466 select = "int[ \t]*strlen\\(\\);(.*)";
4467 c_fix = format;
4468 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4469 test_text = " int\tstrlen(); /* string length */";
4473 * Linux kernel's vt.h breaks C++
4475 fix = {
4476 hackname = suse_linux_vt_cxx;
4477 files = linux/vt.h;
4479 select = "^[ \t]*unsigned int new;";
4480 c_fix = format;
4481 c_fix_arg = "unsigned int newev;";
4483 test_text = " unsigned int new; /* New console (if changing) */";
4487 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4488 * that is visible to any ANSI compiler using this include. Simply
4489 * delete the lines that #define some string functions to internal forms.
4491 fix = {
4492 hackname = svr4_disable_opt;
4493 files = string.h;
4494 select = '#define.*__std_hdr_';
4495 sed = '/#define.*__std_hdr_/d';
4496 test_text = "#define strlen __std_hdr_strlen\n";
4500 * Fix broken decl of getcwd present on some svr4 systems.
4502 fix = {
4503 hackname = svr4_getcwd;
4504 files = stdlib.h;
4505 files = unistd.h;
4506 files = prototypes.h;
4507 select = 'getcwd\(char \*, int\)';
4509 c_fix = format;
4510 c_fix_arg = "getcwd(char *, size_t)";
4512 test_text = "extern char* getcwd(char *, int);";
4516 * Fix broken decl of profil present on some svr4 systems.
4518 fix = {
4519 hackname = svr4_profil;
4520 files = stdlib.h;
4521 files = unistd.h;
4523 select =
4524 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4525 c_fix = format;
4526 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4528 test_text =
4529 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4533 * Correct types for signal handler constants like SIG_DFL; they might be
4534 * void (*) (), and should be void (*) (int). C++ doesn't like the
4535 * old style.
4537 fix = {
4538 hackname = svr4_sighandler_type;
4539 files = sys/signal.h;
4540 select = 'void *\(\*\)\(\)';
4541 c_fix = format;
4542 c_fix_arg = "void (*)(int)";
4543 test_text = "#define SIG_DFL (void(*)())0\n"
4544 "#define SIG_IGN (void (*)())0\n";
4548 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4549 * function 'getrnge' in <regexp.h> before they declare it. For these
4550 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4551 * early on.
4553 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4554 * so put the declaration right after the declaration of 'size'.
4556 * Don't do this if there is already a `static void getrnge' declaration
4557 * present, since this would cause a redeclaration error. Solaris 2.x has
4558 * such a declaration.
4560 fix = {
4561 hackname = svr4_undeclared_getrnge;
4562 files = regexp.h;
4563 select = "getrnge";
4564 bypass = "static void getrnge";
4565 c_fix = format;
4566 c_fix_arg = "%0\n"
4567 "static int getrnge ();";
4568 c_fix_arg = "^static int[ \t]+size;";
4569 test_text = "static int size;\n"
4570 "/* stuff which calls getrnge() */\n"
4571 "static getrnge()\n"
4572 "{}";
4576 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4577 * in string.h on sysV68
4578 * Correct the return type for strlen in string.h on Lynx.
4579 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4580 * Add missing const for strdup on OSF/1 V3.0.
4581 * On sysV88 layout is slightly different.
4583 fix = {
4584 hackname = sysv68_string;
4585 files = testing.h;
4586 files = string.h;
4587 bypass = "_CLASSIC_ANSI_TYPES";
4589 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4590 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4591 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4593 sed = "/^extern char$/N";
4594 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4596 sed = "/^extern int$/N";
4597 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4599 sed = "/^\tstrncmp(),$/N";
4600 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4601 '\1;' "\\\nextern unsigned int\\\n\\2/";
4603 test_text =
4604 "extern int strlen();\n"
4606 "extern int ffs(long);\n"
4608 "extern char\n"
4609 "\t*memccpy(),\n"
4610 "\tmemcpy();\n"
4612 "extern int\n"
4613 "\tstrcmp(),\n"
4614 "\tstrncmp(),\n"
4615 "\tstrlen(),\n"
4616 "\tstrspn();\n"
4618 "extern int\n"
4619 "\tstrlen(), strspn();";
4623 * Fix return type of calloc, malloc, realloc, bsearch and exit
4625 fix = {
4626 hackname = sysz_stdlib_for_sun;
4627 files = stdlib.h;
4628 bypass = "_CLASSIC_ANSI_TYPES";
4630 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4631 c_fix = format;
4632 c_fix_arg = "void *\t%1(";
4634 test_text =
4635 "extern char*\tcalloc(size_t);\n"
4636 "extern char*\tmalloc(size_t);\n"
4637 "extern char*\trealloc(void*,size_t);\n"
4638 "extern char*\tbsearch(void*,size_t,size_t);\n";
4642 * __thread is now a keyword.
4644 fix = {
4645 hackname = thread_keyword;
4646 files = "pthread.h";
4647 files = bits/sigthread.h, '*/bits/sigthread.h';
4648 select = "([* ])__thread([,)])";
4649 c_fix = format;
4650 c_fix_arg = "%1__thr%2";
4652 test_text =
4653 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4654 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4655 "extern int pthread_cancel (pthread_t __thread);";
4659 * if the #if says _cplusplus, not the double underscore __cplusplus
4660 * that it should be
4662 fix = {
4663 hackname = tinfo_cplusplus;
4664 files = tinfo.h;
4665 select = "[ \t]_cplusplus";
4667 c_fix = format;
4668 c_fix_arg = " __cplusplus";
4669 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4673 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4675 fix = {
4676 hackname = ultrix_const;
4677 files = stdio.h;
4678 select = 'perror\( char \*';
4680 c_fix = format;
4681 c_fix_arg = "%1 const %3 *__";
4682 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4683 "[ \t]+(char|void) \\*__";
4685 test_text =
4686 "extern void perror( char *__s );\n"
4687 "extern int fputs( char *__s, FILE *);\n"
4688 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4689 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4690 "extern int scanf( char *__format, ...);\n";
4694 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4696 fix = {
4697 hackname = ultrix_const2;
4698 files = stdio.h;
4700 select = '\*fopen\( char \*';
4701 c_fix = format;
4702 c_fix_arg = "%1( const char *%3, const char *";
4703 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4704 "[ \t]*char[ \t]*\\*([^,]*),"
4705 "[ \t]*char[ \t]*\\*[ \t]*";
4707 test_text =
4708 "extern FILE *fopen( char *__filename, char *__type );\n"
4709 "extern int sscanf( char *__s, char *__format, ...);\n"
4710 "extern FILE *popen(char *, char *);\n"
4711 "extern char *tempnam(char*,char*);\n";
4715 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4717 fix = {
4718 hackname = va_i960_macro;
4719 files = arch/i960/archI960.h;
4720 select = "__(vsiz|vali|vpad|alignof__)";
4722 c_fix = format;
4723 c_fix_arg = "__vx%1";
4725 test_text =
4726 "extern int __vsiz vsiz;\n"
4727 "extern int __vali vali;\n"
4728 "extern int __vpad vpad;\n"
4729 "#define __alignof__(x) ...";
4733 * On VMS, add missing braces around sigset_t constants.
4735 fix = {
4736 hackname = vms_add_missing_braces;
4737 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4738 mach = "*-*-*vms*";
4739 files = "rtldef/signal.h";
4740 c_fix = format;
4742 c_fix_arg = '%1 {%2} ';
4744 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4745 "{0x00000000, 0x00000000},\n"
4746 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4750 * On VMS, some DEC-C builtins are directly used.
4752 fix = {
4753 hackname = vms_decc_builtin;
4754 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4755 mach = "*-*-*vms*";
4756 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4757 rtldef/socket.h;
4758 sed = "s@__MEMSET@memset@";
4759 sed = "s@__MEMMOVE@memmove@";
4760 sed = "s@__MEMCPY@memcpy@";
4761 sed = "s@__STRLEN@strlen@";
4762 sed = "s@__STRCPY@strcpy@";
4764 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4768 * Define __CAN_USE_EXTERN_PREFIX on vms.
4770 fix = {
4771 hackname = vms_define_can_use_extern_prefix;
4772 files = "rtldef/decc$types.h";
4773 select = "#[ \t]*else\n"
4774 "#[ \t]*if defined\\(__DECCXX\\)\n"
4775 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4776 mach = "*-*-*vms*";
4777 c_fix = format;
4779 c_fix_arg = "%0"
4780 "# elif defined (__GNUC__)\n"
4781 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4783 test_text = "# else\n"
4784 "# if defined(__DECCXX)\n"
4785 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4786 "# endif\n"
4787 "# endif\n";
4791 * On VMS, disable the use of dec-c string builtins
4793 fix = {
4794 hackname = vms_disable_decc_string_builtins;
4795 select = "#if !defined\\(__VAX\\)\n";
4796 mach = "*-*-*vms*";
4797 files = "rtldef/string.h";
4798 c_fix = format;
4800 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4802 test_text = "#if !defined(__VAX)\n";
4806 * On VMS, fix incompatible redeclaration of hostalias.
4808 fix = {
4809 hackname = vms_do_not_redeclare_hostalias;
4810 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4811 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4812 mach = "*-*-*vms*";
4813 files = "rtldef/resolv.h";
4814 c_fix = format;
4816 c_fix_arg = "%1\n"
4817 "/* %2 */";
4819 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4820 "__char_ptr32 hostalias (const char *);\n";
4824 * On VMS, forward declare structure before referencing them in prototypes.
4826 fix = {
4827 hackname = vms_forward_declare_struct;
4828 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4829 "#ifdef __cplusplus\n";
4830 mach = "*-*-*vms*";
4831 files = rtldef/if.h;
4832 c_fix = format;
4834 c_fix_arg = "%1"
4835 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4837 test_text = "/* forward decls for C++ */\n"
4838 "#ifdef __cplusplus\n"
4839 "struct foo;\n"
4840 "#endif\n";
4844 * On VMS, do not declare getopt and al if pointers are 64 bit.
4846 fix = {
4847 hackname = vms_no_64bit_getopt;
4848 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4849 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4850 mach = "*-*-*vms*";
4851 files = rtldef/stdio.h, rtldef/unistd.h;
4852 c_fix = format;
4854 c_fix_arg = <<- _EOArg_
4855 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4856 %0#endif
4858 _EOArg_;
4860 test_text = "int getopt (int, char * const [], const char *);";
4864 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4865 * which is not yet fully supported by gcc.
4867 fix = {
4868 hackname = vms_use_fast_setjmp;
4869 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4870 mach = "*-*-*vms*";
4871 files = rtldef/setjmp.h;
4872 c_fix = format;
4874 c_fix_arg = "%0 defined (__GNUC__) ||";
4876 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4880 * On VMS, use pragma extern_model instead of VAX-C keywords.
4882 fix = {
4883 hackname = vms_use_pragma_extern_model;
4884 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4885 "# pragma extern_model __save\n";
4886 mach = "*-*-*vms*";
4887 c_fix = format;
4889 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4890 "# pragma extern_model __save\n";
4892 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4893 "# pragma extern_model __save\n"
4894 "# pragma extern_model strict_refdef\n"
4895 " extern struct x zz$yy;\n"
4896 "# pragma extern_model __restore\n"
4897 "#endif\n";
4901 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4902 * conflict while building gcc. Likewise for <builtins.h>
4904 fix = {
4905 hackname = vms_use_quoted_include;
4906 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4907 mach = "*-*-*vms*";
4908 files = rtldef/wait.h, starlet_c/pthread.h;
4909 c_fix = format;
4911 c_fix_arg = '%1<sys/%2.h>';
4913 test_text = "# include <resource.h>";
4917 * AIX and Interix headers define NULL to be cast to a void pointer,
4918 * which is illegal in ANSI C++.
4920 fix = {
4921 hackname = void_null;
4922 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4923 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4924 /* avoid changing C++ friendly NULL */
4925 bypass = __cplusplus;
4926 bypass = __null;
4927 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4928 c_fix = format;
4929 c_fix_arg = <<- _EOFix_
4930 #ifndef NULL
4931 #ifdef __cplusplus
4932 #ifdef __GNUG__
4933 #define NULL __null
4934 #else /* ! __GNUG__ */
4935 #define NULL 0L
4936 #endif /* __GNUG__ */
4937 #else /* ! __cplusplus */
4938 #define NULL ((void *)0)
4939 #endif /* __cplusplus */
4940 #endif /* !NULL */
4941 _EOFix_;
4942 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4946 * Make VxWorks header which is almost gcc ready fully gcc ready.
4948 fix = {
4949 hackname = vxworks_gcc_problem;
4950 files = types/vxTypesBase.h;
4951 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4953 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4954 "#if 1/";
4956 sed = "/[ \t]size_t/i\\\n"
4957 "#ifndef _GCC_SIZE_T\\\n"
4958 "#define _GCC_SIZE_T\n";
4960 sed = "/[ \t]size_t/a\\\n"
4961 "#endif\n";
4963 sed = "/[ \t]ptrdiff_t/i\\\n"
4964 "#ifndef _GCC_PTRDIFF_T\\\n"
4965 "#define _GCC_PTRDIFF_T\n";
4967 sed = "/[ \t]ptrdiff_t/a\\\n"
4968 "#endif\n";
4970 sed = "/[ \t]wchar_t/i\\\n"
4971 "#ifndef _GCC_WCHAR_T\\\n"
4972 "#define _GCC_WCHAR_T\n";
4974 sed = "/[ \t]wchar_t/a\\\n"
4975 "#endif\n";
4977 test_text =
4978 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4979 "typedef unsigned int size_t;\n"
4980 "typedef long ptrdiff_t;\n"
4981 "typedef unsigned short wchar_t;\n"
4982 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4986 * Wrap VxWorks ioctl to keep everything pretty
4988 fix = {
4989 hackname = vxworks_ioctl_macro;
4990 files = ioLib.h;
4991 mach = "*-*-vxworks*";
4993 c_fix = format;
4994 c_fix_arg = "%0\n"
4995 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4996 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4998 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5002 * Wrap VxWorks mkdir to be posix compliant
5004 fix = {
5005 hackname = vxworks_mkdir_macro;
5006 files = sys/stat.h;
5007 mach = "*-*-vxworks*";
5009 c_fix = format;
5010 c_fix_arg = "%0\n"
5011 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5012 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5013 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5014 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5015 "\\)[\t ]*;";
5017 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
5021 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
5023 fix = {
5024 hackname = vxworks_needs_vxtypes;
5025 files = time.h;
5026 select = "uint_t([ \t]+_clocks_per_sec)";
5027 c_fix = format;
5028 c_fix_arg = "unsigned int%1";
5029 test_text = "uint_t\t_clocks_per_sec;";
5033 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5035 fix = {
5036 hackname = vxworks_needs_vxworks;
5037 files = sys/stat.h;
5038 test = " -r types/vxTypesOld.h";
5039 test = " -n \"`egrep '#include' $file`\"";
5040 test = " -n \"`egrep ULONG $file`\"";
5041 select = "#[ \t]define[ \t]+__INCstath";
5043 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5044 "#include <types/vxTypesOld.h>\n";
5046 test_text = "`touch types/vxTypesOld.h`"
5047 "#include </dev/null> /* ULONG */\n"
5048 "# define\t__INCstath <sys/stat.h>";
5052 * Make it so VxWorks does not include gcc/regs.h accidentally
5054 fix = {
5055 hackname = vxworks_regs;
5056 mach = "*-*-vxworks*";
5058 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5059 c_fix = format;
5060 c_fix_arg = "#include <arch/../regs.h>";
5062 test_text = "#include <regs.h>\n";
5066 * Another bad dependency in VxWorks 5.2 <time.h>.
5068 fix = {
5069 hackname = vxworks_time;
5070 files = time.h;
5071 test = " -r vxWorks.h";
5073 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5074 c_fix = format;
5076 c_fix_arg =
5077 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5078 "#ifdef __cplusplus\n"
5079 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5080 "#else\n"
5081 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5082 "#endif\n"
5083 "#define __gcc_VOIDFUNCPTR_defined\n"
5084 "#endif\n"
5085 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5087 test_text = "`touch vxWorks.h`"
5088 "#define VOIDFUNCPTR (void(*)())";
5092 * This hack makes write const-correct on VxWorks
5094 fix = {
5095 hackname = vxworks_write_const;
5096 files = ioLib.h;
5097 mach = "*-*-vxworks*";
5099 c_fix = format;
5100 c_fix_arg = "extern int write (int, const char*, size_t);";
5101 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5102 "[\t ]*int[\t ]*,"
5103 "[\t ]*char[\t ]*\\*[\t ]*,"
5104 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5106 test_text = "extern int write ( int , char * , size_t ) ;";
5110 * There are several name conflicts with C++ reserved words in X11 header
5111 * files. These are fixed in some versions, so don't do the fixes if
5112 * we find __cplusplus in the file. These were found on the RS/6000.
5114 fix = {
5115 hackname = x11_class;
5116 files = X11/ShellP.h;
5117 bypass = __cplusplus;
5118 select = "^([ \t]*char \\*)class;(.*)";
5119 c_fix = format;
5120 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5121 "#else\n%1class;%2\n#endif";
5122 test_text =
5123 "struct {\n"
5124 " char *class;\n"
5125 "} mumble;\n";
5129 * class in Xm/BaseClassI.h
5131 fix = {
5132 hackname = x11_class_usage;
5133 files = Xm/BaseClassI.h;
5134 bypass = "__cplusplus";
5136 select = " class\\)";
5137 c_fix = format;
5138 c_fix_arg = " c_class)";
5140 test_text = "extern mumble (int class);\n";
5144 * new in Xm/Traversal.h
5146 fix = {
5147 hackname = x11_new;
5148 files = Xm/Traversal.h;
5149 bypass = __cplusplus;
5151 sed = "/Widget\told, new;/i\\\n"
5152 "#ifdef __cplusplus\\\n"
5153 "\\\tWidget\told, c_new;\\\n"
5154 "#else\n";
5156 sed = "/Widget\told, new;/a\\\n"
5157 "#endif\n";
5159 sed = "s/Widget new,/Widget c_new,/g";
5160 test_text =
5161 "struct wedge {\n"
5162 " Widget\told, new;\n"
5163 "};\nextern Wedged( Widget new, Widget old );";
5167 * Incorrect sprintf declaration in X11/Xmu.h
5169 fix = {
5170 hackname = x11_sprintf;
5171 files = X11/Xmu.h;
5172 files = X11/Xmu/Xmu.h;
5173 select = "^extern char \\*\tsprintf\\(\\);$";
5175 c_fix = format;
5176 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5178 test_text = "extern char *\tsprintf();";
5180 /*EOF*/