/cp
[official-gcc.git] / fixincludes / inclhack.def
blob89c7aa8d93879ecaa92930587448df1423b34a02
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 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
897 fix = {
898 hackname = aix_strtof_const;
899 files = stdlib.h;
900 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
901 c_fix = format;
902 c_fix_arg = "%1(const char *, char **);";
903 test_text = "extern float strtof(char *, char **);";
907 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
908 * in an otherwise harmless (and #ifed out) macro definition
910 fix = {
911 hackname = aix_sysmachine;
912 files = sys/machine.h;
913 select = "\\\\ +\n";
914 c_fix = format;
915 c_fix_arg = "\\\n";
916 test_text = "#define FOO \\\n"
917 " bar \\ \n baz \\ \n bat";
921 * sys/wait.h on AIX 5.2 defines macros that have both signed and
922 * unsigned types in conditional expressions.
924 fix = {
925 hackname = aix_syswait_2;
926 files = sys/wait.h;
927 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
928 c_fix = format;
929 c_fix_arg = "? (int)%1";
930 test_text = "#define WSTOPSIG(__x) "
931 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
935 * sys/signal.h on some versions of AIX uses volatile in the typedef of
936 * sig_atomic_t, which causes gcc to generate a warning about duplicate
937 * volatile when a sig_atomic_t variable is declared volatile, as
938 * required by ANSI C.
940 fix = {
941 hackname = aix_volatile;
942 files = sys/signal.h;
943 select = "typedef volatile int sig_atomic_t";
944 c_fix = format;
945 c_fix_arg = "typedef int sig_atomic_t";
946 test_text = "typedef volatile int sig_atomic_t;";
950 * Fix __assert declaration in assert.h on Alpha OSF/1.
952 fix = {
953 hackname = alpha___assert;
954 files = "assert.h";
955 select = '__assert\(char \*, char \*, int\)';
956 c_fix = format;
957 c_fix_arg = "__assert(const char *, const char *, int)";
958 test_text = 'extern void __assert(char *, char *, int);';
962 * Fix assert macro in assert.h on Alpha OSF/1.
963 * The superfluous int cast breaks C++.
965 fix = {
966 hackname = alpha_assert;
967 files = "assert.h";
968 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
969 c_fix = format;
970 c_fix_arg = "%1(EX)";
971 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
972 ': __assert(#EX, __FILE__, __LINE__))';
976 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
978 fix = {
979 hackname = alpha_getopt;
980 files = "stdio.h";
981 files = "stdlib.h";
982 select = 'getopt\(int, char \*\[\], *char \*\)';
983 c_fix = format;
984 c_fix_arg = "getopt(int, char *const[], const char *)";
985 test_text = 'extern int getopt(int, char *[], char *);';
989 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
991 fix = {
992 hackname = alpha_if_semicolon;
993 files = net/if.h;
994 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
995 c_fix = format;
996 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
997 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1001 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1003 fix = {
1004 hackname = alpha_parens;
1005 files = sym.h;
1006 select = '#ifndef\(__mips64\)';
1007 c_fix = format;
1008 c_fix_arg = "#ifndef __mips64";
1009 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1013 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1014 * And OpenBSD.
1016 fix = {
1017 hackname = alpha_sbrk;
1018 files = unistd.h;
1019 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1020 c_fix = format;
1021 c_fix_arg = "void *sbrk(";
1022 test_text = "extern char* sbrk(ptrdiff_t increment);";
1026 * For C++, avoid any typedef or macro definition of bool,
1027 * and use the built in type instead.
1028 * HP/UX 10.20 also has it in curses_colr/curses.h.
1030 fix = {
1031 hackname = avoid_bool_define;
1032 files = curses.h;
1033 files = curses_colr/curses.h;
1034 files = term.h;
1035 files = tinfo.h;
1037 select = "#[ \t]*define[ \t]+bool[ \t]";
1038 bypass = "__cplusplus";
1040 c_fix = format;
1041 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1042 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1044 test_text = "# define bool\t char \n";
1048 * avoid_bool_type
1050 fix = {
1051 hackname = avoid_bool_type;
1052 files = curses.h;
1053 files = curses_colr/curses.h;
1054 files = term.h;
1055 files = tinfo.h;
1057 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1058 bypass = "__cplusplus";
1060 c_fix = format;
1061 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1063 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1067 * For C++, avoid any typedef definition of wchar_t,
1068 * and use the built in type instead.
1069 * Don't do this for headers that are smart enough to do the right
1070 * thing (recent [n]curses.h and Xlib.h).
1071 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1072 * and will be broken by the edit.
1075 fix = {
1076 hackname = avoid_wchar_t_type;
1078 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1079 bypass = "__cplusplus";
1080 bypass = "_LINUX_NLS_H";
1081 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1083 c_fix = format;
1084 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1086 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1090 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1092 fix = {
1093 hackname = bad_struct_term;
1094 files = curses.h;
1095 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1096 c_fix = format;
1097 c_fix_arg = "struct term;";
1099 test_text = 'typedef struct term;';
1103 * Fix one other error in this file:
1104 * a mismatched quote not inside a C comment.
1106 fix = {
1107 hackname = badquote;
1108 files = sundev/vuid_event.h;
1109 select = "doesn't";
1110 c_fix = format;
1111 c_fix_arg = "does not";
1113 test_text = "/* doesn't have matched single quotes */";
1117 * check for broken assert.h that needs stdio.h
1119 fix = {
1120 hackname = broken_assert_stdio;
1121 files = assert.h;
1122 select = stderr;
1123 bypass = "include.*stdio\\.h";
1124 c_fix = wrap;
1125 c_fix_arg = "#include <stdio.h>\n";
1126 test_text = "extern FILE* stderr;";
1130 * check for broken assert.h that needs stdlib.h
1132 fix = {
1133 hackname = broken_assert_stdlib;
1134 files = assert.h;
1135 select = 'exit *\(|abort *\(';
1136 bypass = "include.*stdlib\\.h";
1137 c_fix = wrap;
1138 c_fix_arg = "#ifdef __cplusplus\n"
1139 "#include <stdlib.h>\n"
1140 "#endif\n";
1141 test_text = "extern void exit ( int );";
1145 * Remove `extern double cabs' declarations from math.h.
1146 * This conflicts with C99. Discovered on AIX.
1147 * Darwin hides its broken cabs in architecture-specific subdirs.
1149 fix = {
1150 hackname = broken_cabs;
1151 files = math.h, "architecture/*/math.h";
1152 select = "^extern[ \t]+double[ \t]+cabs";
1154 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1155 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1157 test_text = "#ifdef __STDC__\n"
1158 "extern double cabs(struct dbl_hypot);\n"
1159 "#else\n"
1160 "extern double cabs();\n"
1161 "#endif\n"
1162 "extern double cabs ( _Complex z );";
1166 * Fixup Darwin's broken check for __builtin_nanf.
1168 fix = {
1169 hackname = broken_nan;
1171 * It is tempting to omit the first "files" entry. Do not.
1172 * The testing machinery will take the first "files" entry as the name
1173 * of a test file to play with. It would be a nuisance to have a directory
1174 * with the name "*".
1176 files = "architecture/ppc/math.h";
1177 files = "architecture/*/math.h";
1178 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1179 bypass = "powl";
1180 c_fix = format;
1181 c_fix_arg = "#if 1";
1182 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1186 * Various systems derived from BSD4.4 contain a macro definition
1187 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1188 * Known to be fixed in FreeBSD 5 system headers.
1190 fix = {
1191 hackname = bsd_stdio_attrs_conflict;
1192 mach = "*-*-*bsd*";
1193 mach = "*-*-*darwin*";
1194 files = stdio.h;
1195 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1196 c_fix = format;
1197 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1198 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1199 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1200 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1201 test_text = '#define vfscanf __svfscanf';
1205 * Fix various macros used to define ioctl numbers.
1206 * The traditional syntax was:
1208 * #define _CTRL(n, x) (('n'<<8)+x)
1209 * #define TCTRLCFOO _CTRL(T, 1)
1211 * but this does not work with the C standard, which disallows macro
1212 * expansion inside strings. We have to rewrite it thus:
1214 * #define _CTRL(n, x) ((n<<8)+x)
1215 * #define TCTRLCFOO _CTRL('T', 1)
1217 * The select expressions match too much, but the c_fix code is cautious.
1219 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1221 fix = {
1222 hackname = ctrl_quotes_def;
1223 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1224 c_fix = char_macro_def;
1225 c_fix_arg = "CTRL";
1228 * This is two tests in order to ensure that the "CTRL(c)" can
1229 * be selected in isolation from the multi-arg format
1231 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1232 test_text = "#define _CTRL(c) ('c'&037)";
1236 * Fix various macros used to define ioctl numbers.
1238 fix = {
1239 hackname = ctrl_quotes_use;
1240 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1241 c_fix = char_macro_use;
1242 c_fix_arg = "CTRL";
1243 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1247 * sys/mman.h on HP/UX is not C++ ready,
1248 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1250 * rpc/types.h on OSF1/2.0 is not C++ ready,
1251 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1253 * The problem is the declaration of malloc.
1255 fix = {
1256 hackname = cxx_unready;
1257 files = sys/mman.h;
1258 files = rpc/types.h;
1259 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1260 not within a macro. */
1261 bypass = '"C"|__BEGIN_DECLS';
1263 c_fix = wrap;
1264 c_fix_arg = "#ifdef __cplusplus\n"
1265 "extern \"C\" {\n"
1266 "#endif\n";
1267 c_fix_arg = "#ifdef __cplusplus\n"
1268 "}\n"
1269 "#endif\n";
1270 test_text = "extern void* malloc( size_t );";
1274 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1275 * you have to not use "" includes.
1277 fix = {
1278 hackname = darwin_9_long_double_funcs_2;
1279 mach = "*-*-darwin7.9*";
1280 files = math.h;
1281 select = '#include[ \t]+\"';
1282 c_fix = format;
1283 c_fix_arg = "%1<%2.h>";
1285 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1287 test_text = '#include "architecture/ppc/math.h"';
1291 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1292 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1294 fix = {
1295 hackname = darwin_externc;
1296 mach = "*-*-darwin*";
1297 files = mach-o/swap.h;
1298 files = mach/mach_time.h;
1299 files = mach/mach_traps.h;
1300 files = mach/message.h;
1301 files = mach/mig.h;
1302 files = mach/semaphore.h;
1303 bypass = "extern \"C\"";
1304 bypass = "__BEGIN_DECLS";
1305 c_fix = wrap;
1306 c_fix_arg = "#ifdef __cplusplus\n"
1307 "extern \"C\" {\n"
1308 "#endif\n";
1309 c_fix_arg = "#ifdef __cplusplus\n"
1310 "}\n"
1311 "#endif\n";
1312 test_text = "extern void swap_fat_header();\n";
1316 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1317 * bad __GNUC__ tests.
1319 fix = {
1320 hackname = darwin_gcc4_breakage;
1321 mach = "*-*-darwin*";
1322 files = AvailabilityMacros.h;
1323 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1324 c_fix = format;
1325 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1326 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1327 "(__GNUC_MINOR__ >= 1)\n";
1331 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1332 * why would you ever put it in a system header file?
1334 fix = {
1335 hackname = darwin_private_extern;
1336 mach = "*-*-darwin*";
1337 files = mach-o/dyld.h;
1338 select = "__private_extern__ [a-z_]+ _dyld_";
1339 c_fix = format;
1340 c_fix_arg = "extern";
1341 c_fix_arg = "__private_extern__";
1342 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1343 "const char *dyld_func_name,\n"
1344 "unsigned long *address);\n";
1348 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1349 * unsigned constants.
1351 fix = {
1352 hackname = darwin_stdint_1;
1353 mach = "*-*-darwin*";
1354 files = stdint-darwin.h, stdint.h;
1355 c_fix = format;
1356 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1357 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1358 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1359 test_text = "#define UINT8_C(v) (v ## U)\n"
1360 "#define UINT16_C(v) (v ## U)";
1364 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1365 * with wrong types.
1367 fix = {
1368 hackname = darwin_stdint_2;
1369 mach = "*-*-darwin*";
1370 files = stdint-darwin.h, stdint.h;
1371 c_fix = format;
1372 c_fix_arg = "#if __WORDSIZE == 64\n"
1373 "#define INTPTR_MAX 9223372036854775807L\n"
1374 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1375 "#else\n"
1376 "#define INTPTR_MAX 2147483647L\n"
1377 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1378 "#endif";
1379 select = "#if __WORDSIZE == 64\n"
1380 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1381 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1382 "#else\n"
1383 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1384 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1385 "#endif";
1386 test_text = "#if __WORDSIZE == 64\n"
1387 "#define INTPTR_MIN INT64_MIN\n"
1388 "#define INTPTR_MAX INT64_MAX\n"
1389 "#else\n"
1390 "#define INTPTR_MIN INT32_MIN\n"
1391 "#define INTPTR_MAX INT32_MAX\n"
1392 "#endif";
1396 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1398 fix = {
1399 hackname = darwin_stdint_3;
1400 mach = "*-*-darwin*";
1401 files = stdint-darwin.h, stdint.h;
1402 c_fix = format;
1403 c_fix_arg = "#if __WORDSIZE == 64\n"
1404 "#define UINTPTR_MAX 18446744073709551615UL\n"
1405 "#else\n"
1406 "#define UINTPTR_MAX 4294967295UL\n"
1407 "#endif";
1408 select = "#if __WORDSIZE == 64\n"
1409 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1410 "#else\n"
1411 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1412 "#endif";
1413 test_text = "#if __WORDSIZE == 64\n"
1414 "#define UINTPTR_MAX UINT64_MAX\n"
1415 "#else\n"
1416 "#define UINTPTR_MAX UINT32_MAX\n"
1417 "#endif";
1421 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1423 fix = {
1424 hackname = darwin_stdint_4;
1425 mach = "*-*-darwin*";
1426 files = stdint-darwin.h, stdint.h;
1427 c_fix = format;
1428 c_fix_arg = "#if __WORDSIZE == 64\n"
1429 "#define SIZE_MAX 18446744073709551615UL\n"
1430 "#else\n"
1431 "#define SIZE_MAX 4294967295UL\n"
1432 "#endif";
1433 select = "#if __WORDSIZE == 64\n"
1434 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1435 "#else\n"
1436 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1437 "#endif";
1438 test_text = "#if __WORDSIZE == 64\n"
1439 "#define SIZE_MAX UINT64_MAX\n"
1440 "#else\n"
1441 "#define SIZE_MAX UINT32_MAX\n"
1442 "#endif";
1446 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1447 * with a wrong type.
1449 fix = {
1450 hackname = darwin_stdint_5;
1451 mach = "*-*-darwin*";
1452 files = stdint-darwin.h, stdint.h;
1453 c_fix = format;
1454 c_fix_arg = "#if __WORDSIZE == 64\n"
1455 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1456 "#define INTMAX_MAX 9223372036854775807L\n"
1457 "#define UINTMAX_MAX 18446744073709551615UL\n"
1458 "#else\n"
1459 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1460 "#define INTMAX_MAX 9223372036854775807LL\n"
1461 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1462 "#endif";
1463 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1464 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1465 "\n"
1466 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1467 test_text = "#define INTMAX_MIN INT64_MIN\n"
1468 "#define INTMAX_MAX INT64_MAX\n"
1469 "\n"
1470 "#define UINTMAX_MAX UINT64_MAX";
1474 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1475 * with a wrong type.
1477 fix = {
1478 hackname = darwin_stdint_6;
1479 mach = "*-*-darwin*";
1480 files = stdint-darwin.h, stdint.h;
1481 c_fix = format;
1482 c_fix_arg = "#if __WORDSIZE == 64\n"
1483 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1484 "#define PTRDIFF_MAX 9223372036854775807L\n"
1485 "#else\n"
1486 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1487 "#define PTRDIFF_MAX 2147483647\n"
1488 "#endif";
1489 select = "#if __WORDSIZE == 64\n"
1490 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1491 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1492 "#else\n"
1493 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1494 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1495 "#endif";
1496 test_text = "#if __WORDSIZE == 64\n"
1497 "#define PTRDIFF_MIN INT64_MIN\n"
1498 "#define PTRDIFF_MAX INT64_MAX\n"
1499 "#else\n"
1500 "#define PTRDIFF_MIN INT32_MIN\n"
1501 "#define PTRDIFF_MAX INT32_MAX\n"
1502 "#endif";
1506 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1507 * with a wrong type.
1509 fix = {
1510 hackname = darwin_stdint_7;
1511 mach = "*-*-darwin*";
1512 files = stdint-darwin.h, stdint.h;
1513 c_fix = format;
1514 c_fix_arg = "#if __WORDSIZE == 64\n"
1515 "#define INTMAX_C(v) (v ## L)\n"
1516 "#define UINTMAX_C(v) (v ## UL)\n"
1517 "#else\n"
1518 "#define INTMAX_C(v) (v ## LL)\n"
1519 "#define UINTMAX_C(v) (v ## ULL)\n"
1520 "#endif";
1521 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1522 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1523 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1524 "#define UINTMAX_C(v) (v ## ULL)";
1528 * Fix <c_asm.h> on Digital UNIX V4.0:
1529 * It contains a prototype for a DEC C internal asm() function,
1530 * clashing with gcc's asm keyword. So protect this with __DECC.
1532 fix = {
1533 hackname = dec_intern_asm;
1534 files = c_asm.h;
1535 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1536 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1537 "#endif\n";
1538 test_text =
1539 "float fasm {\n"
1540 " ... asm stuff ...\n"
1541 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1545 * Fix typo in <wchar.h> on DJGPP 2.03.
1547 fix = {
1548 hackname = djgpp_wchar_h;
1549 file = wchar.h;
1550 select = "__DJ_wint_t";
1551 bypass = "sys/djtypes.h";
1552 c_fix = format;
1553 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1554 c_fix_arg = "#include <stddef.h>";
1555 test_text = "#include <stddef.h>\n"
1556 "extern __DJ_wint_t x;\n";
1560 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1562 fix = {
1563 hackname = ecd_cursor;
1564 files = "sunwindow/win_lock.h";
1565 files = "sunwindow/win_cursor.h";
1566 select = 'ecd\.cursor';
1567 c_fix = format;
1568 c_fix_arg = 'ecd_cursor';
1570 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1574 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1575 * that fails when compiling for SSE-less 32-bit x86.
1577 fix = {
1578 hackname = feraiseexcept_nosse_divbyzero;
1579 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1580 files = bits/fenv.h, '*/bits/fenv.h';
1581 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1582 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1583 bypass = "\"fdivp .*; fwait\"";
1585 c_fix = format;
1586 c_fix_arg = <<- _EOText_
1587 # ifdef __SSE_MATH__
1589 # else
1590 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1591 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1592 # endif
1593 _EOText_;
1595 test_text = <<- _EOText_
1596 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1597 _EOText_;
1601 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1602 * that fails when compiling for SSE-less 32-bit x86.
1604 fix = {
1605 hackname = feraiseexcept_nosse_invalid;
1606 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1607 files = bits/fenv.h, '*/bits/fenv.h';
1608 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1609 ": \"x\" \\(__f\\)\\);$";
1610 bypass = "\"fdiv .*; fwait\"";
1612 c_fix = format;
1613 c_fix_arg = <<- _EOText_
1614 # ifdef __SSE_MATH__
1616 # else
1617 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1618 %1 : "=t" (__f) : "0" (__f));
1619 # endif
1620 _EOText_;
1622 test_text = <<- _EOText_
1623 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1624 _EOText_;
1628 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1629 * neither the existence of GCC 3 nor its exact feature set yet break
1630 * (by design?) when __GNUC__ is set beyond 2.
1632 fix = {
1633 hackname = freebsd_gcc3_breakage;
1634 mach = "*-*-freebsd*";
1635 files = sys/cdefs.h;
1636 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1637 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1638 c_fix = format;
1639 c_fix_arg = '%0 || __GNUC__ >= 3';
1640 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1644 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1645 * neither the existence of GCC 4 nor its exact feature set yet break
1646 * (by design?) when __GNUC__ is set beyond 3.
1648 fix = {
1649 hackname = freebsd_gcc4_breakage;
1650 mach = "*-*-freebsd*";
1651 files = sys/cdefs.h;
1652 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1653 c_fix = format;
1654 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1655 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1659 * Some versions of glibc don't expect the C99 inline semantics.
1661 fix = {
1662 hackname = glibc_c99_inline_1;
1663 files = features.h, '*/features.h';
1664 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1665 c_fix = format;
1666 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1667 test_text = <<-EOT
1668 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1669 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1670 # define __USE_EXTERN_INLINES 1
1671 #endif
1672 EOT;
1676 * Similar, but a version that didn't have __NO_INLINE__
1678 fix = {
1679 hackname = glibc_c99_inline_1a;
1680 files = features.h, '*/features.h';
1681 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1682 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1683 c_fix = format;
1684 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1685 test_text = <<-EOT
1686 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1687 # define __USE_EXTERN_INLINES 1
1688 #endif
1689 EOT;
1693 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1694 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1695 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1697 fix = {
1698 hackname = glibc_c99_inline_2;
1699 files = sys/stat.h, '*/sys/stat.h';
1700 select = "extern __inline__ int";
1701 sed = "s/extern int \\(stat\\)/"
1702 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1703 "__inline__ int \\1/";
1704 sed = "s/extern int \\([lf]stat\\)/"
1705 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1706 "__inline__ int \\1/";
1707 sed = "s/extern int \\(mknod\\)/"
1708 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1709 "__inline__ int \\1/";
1710 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1711 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1712 "__inline__ int __REDIRECT\\1 (\\2/";
1713 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1714 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1715 "__inline__ int __REDIRECT\\1 (\\2/";
1716 sed = "s/^extern __inline__ int/"
1717 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1718 "__inline__ int/";
1719 test_text = <<-EOT
1720 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1721 extern __inline__ int
1722 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1724 EOT;
1728 * glibc_c99_inline_3
1730 fix = {
1731 hackname = glibc_c99_inline_3;
1732 files = bits/string2.h, '*/bits/string2.h';
1733 select = "extern __inline";
1734 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1735 c_fix = format;
1736 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1737 c_fix_arg = "^# ifdef __cplusplus$";
1738 test_text = <<-EOT
1739 # ifdef __cplusplus
1740 # define __STRING_INLINE inline
1741 # else
1742 # define __STRING_INLINE extern __inline
1743 # endif
1744 EOT;
1748 * glibc_c99_inline_4
1750 fix = {
1751 hackname = glibc_c99_inline_4;
1752 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1753 pthread.h, '*/pthread.h';
1754 bypass = "__extern_inline|__gnu_inline__";
1755 select = "(^| )extern __inline";
1756 c_fix = format;
1757 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1758 test_text = <<-EOT
1759 __extension__ extern __inline unsigned int
1760 extern __inline unsigned int
1761 EOT;
1764 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1765 * so we replace them with versions that correspond to the
1766 * definition.
1768 fix = {
1769 hackname = glibc_mutex_init;
1770 files = pthread.h;
1771 select = '\{ *\{ *0, *\} *\}';
1772 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1773 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1774 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1775 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1776 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1777 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1778 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1779 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1780 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1781 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1782 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1783 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1784 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1785 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1786 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1787 "N;s/^[ \t]*#[ \t]*"
1788 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1789 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1790 "# \\1\\\n"
1791 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1792 "# else\\\n"
1793 "# \\1\\\n"
1794 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1795 "# endif/";
1796 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1797 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1798 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1799 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1801 test_text = <<- _EOText_
1802 #define PTHREAD_MUTEX_INITIALIZER \\
1803 { { 0, } }
1804 #ifdef __USE_GNU
1805 # if __WORDSIZE == 64
1806 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1807 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1808 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1809 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1810 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1811 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1812 # else
1813 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1814 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1815 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1816 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1817 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1818 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1819 # endif
1820 #endif
1821 # define PTHREAD_RWLOCK_INITIALIZER \\
1822 { { 0, } }
1823 # ifdef __USE_GNU
1824 # if __WORDSIZE == 64
1825 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1826 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1827 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1828 # else
1829 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1830 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1831 # endif
1832 # endif
1833 #define PTHREAD_COND_INITIALIZER { { 0, } }
1834 _EOText_;
1837 /* glibc versions before 2.5 have a version of stdint.h that defines
1838 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1839 versions with stdint.h based on those glibc versions. */
1840 fix = {
1841 hackname = glibc_stdint;
1842 files = stdint.h;
1843 select = "GNU C Library";
1844 c_fix = format;
1845 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1846 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1847 test_text = "/* This file is part of the GNU C Library. */\n"
1848 "# define UINT8_C(c)\tc ## U\n"
1849 "# define UINT16_C(c)\tc ## U";
1852 /* Some versions of glibc have a version of bits/string2.h that
1853 produces "value computed is not used" warnings from strncpy; fix
1854 this definition by using __builtin_strncpy instead as in newer
1855 versions. */
1856 fix = {
1857 hackname = glibc_strncpy;
1858 files = bits/string2.h, '*/bits/string2.h';
1859 bypass = "__builtin_strncpy";
1860 c_fix = format;
1861 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1862 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1863 test_text = <<-EOT
1864 # define strncpy(dest, src, n) \
1865 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1866 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1867 ? (char *) memcpy (dest, src, n) \\
1868 : strncpy (dest, src, n)) \\
1869 : strncpy (dest, src, n)))
1870 EOT;
1874 /* glibc's tgmath.h relies on an expression that is not an integer
1875 constant expression being treated as it was by GCC 4.4 and
1876 earlier. */
1877 fix = {
1878 hackname = glibc_tgmath;
1879 files = tgmath.h;
1880 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1881 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1882 c_fix = format;
1883 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1884 "(__builtin_classify_type ((type) 0) == 9 && "
1885 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1886 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1890 * Fix these files to use the types we think they should for
1891 * ptrdiff_t, size_t, and wchar_t.
1893 * This defines the types in terms of macros predefined by our 'cpp'.
1894 * This is supposedly necessary for glibc's handling of these types.
1895 * It's probably not necessary for anyone else, but it doesn't hurt.
1897 fix = {
1898 hackname = gnu_types;
1899 files = "sys/types.h";
1900 files = "stdlib.h";
1901 files = "sys/stdtypes.h";
1902 files = "stddef.h";
1903 files = "memory.h";
1904 files = "unistd.h";
1905 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1906 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1907 c_fix = gnu_type;
1908 /* The Solaris 10 headers already define these types correctly. */
1909 mach = '*-*-solaris2.1[0-9]*';
1910 not_machine = true;
1912 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1913 "typedef uint_t size_t; /* uint_t */\n"
1914 "typedef ushort_t wchar_t; /* ushort_t */";
1918 * Fix HP & Sony's use of "../machine/xxx.h"
1919 * to refer to: <machine/xxx.h>
1921 fix = {
1922 hackname = hp_inline;
1923 files = sys/spinlock.h;
1924 files = machine/machparam.h;
1925 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1927 c_fix = format;
1928 c_fix_arg = "%1<machine/%2.h>";
1930 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1931 '([a-z]+)\.h"';
1933 test_text = ' # include "../machine/mumble.h"';
1937 * Check for (...) in C++ code in HP/UX sys/file.h.
1939 fix = {
1940 hackname = hp_sysfile;
1941 files = sys/file.h;
1942 select = "HPUX_SOURCE";
1944 c_fix = format;
1945 c_fix_arg = "(struct file *, ...)";
1946 c_fix_arg = '\(\.\.\.\)';
1948 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1952 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1953 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1955 fix = {
1956 hackname = hppa_hpux_fp_macros;
1957 mach = "hppa*-hp-hpux11*";
1958 files = math.h;
1959 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1960 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1961 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1962 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1963 "#[ \t]*define[ \t]*FP_NAN.*\n";
1964 c_fix = format;
1965 c_fix_arg = <<- _EOFix_
1966 #endif /* _INCLUDE_HPUX_SOURCE */
1968 #if defined(_INCLUDE_HPUX_SOURCE) || \
1969 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1970 %0#endif
1972 #ifdef _INCLUDE_HPUX_SOURCE
1974 _EOFix_;
1976 test_text =
1977 "# define FP_NORMAL 0\n"
1978 "# define FP_ZERO 1\n"
1979 "# define FP_INFINITE 2\n"
1980 "# define FP_SUBNORMAL 3\n"
1981 "# define FP_NAN 4\n";
1985 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1986 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1988 fix = {
1989 hackname = hpux10_cpp_pow_inline;
1990 files = fixinc-test-limits.h, math.h;
1991 select = <<- END_POW_INLINE
1992 ^# +ifdef +__cplusplus
1994 +inline +double +pow\(double +__d,int +__expon\) +\{
1995 [ ]+return +pow\(__d,\(double\)__expon\);
1997 +extern +"C" +\{
1998 #else
1999 # +endif
2000 END_POW_INLINE;
2002 c_fix = format;
2003 c_fix_arg = "";
2005 test_text =
2006 "# ifdef __cplusplus\n"
2007 " }\n"
2008 " inline double pow(double __d,int __expon) {\n"
2009 "\t return pow(__d,(double)__expon);\n"
2010 " }\n"
2011 ' extern "C"' " {\n"
2012 "#else\n"
2013 "# endif";
2016 fix = {
2017 hackname = hpux11_cpp_pow_inline;
2018 files = math.h;
2019 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2020 " +return pow\\(d, \\(double\\)expon\\);\n"
2021 " +\\}\n";
2022 c_fix = format;
2023 c_fix_arg = "";
2025 test_text =
2026 " inline double pow(double d,int expon) {\n"
2027 " return pow(d, (double)expon);\n"
2028 " }\n";
2032 * Fix hpux 10.X missing ctype declarations 1
2034 fix = {
2035 hackname = hpux10_ctype_declarations1;
2036 files = ctype.h;
2037 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2038 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2039 c_fix = format;
2040 c_fix_arg = "#ifdef _PROTOTYPES\n"
2041 "extern int __tolower(int);\n"
2042 "extern int __toupper(int);\n"
2043 "#else /* NOT _PROTOTYPES */\n"
2044 "extern int __tolower();\n"
2045 "extern int __toupper();\n"
2046 "#endif /* _PROTOTYPES */\n\n"
2047 "%0\n";
2049 test_text = "# define _toupper(__c) __toupper(__c)\n";
2053 * Fix hpux 10.X missing ctype declarations 2
2055 fix = {
2056 hackname = hpux10_ctype_declarations2;
2057 files = ctype.h;
2058 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2059 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2060 c_fix = format;
2061 c_fix_arg = "%0\n\n"
2062 "#ifdef _PROTOTYPES\n"
2063 " extern int _isalnum(int);\n"
2064 " extern int _isalpha(int);\n"
2065 " extern int _iscntrl(int);\n"
2066 " extern int _isdigit(int);\n"
2067 " extern int _isgraph(int);\n"
2068 " extern int _islower(int);\n"
2069 " extern int _isprint(int);\n"
2070 " extern int _ispunct(int);\n"
2071 " extern int _isspace(int);\n"
2072 " extern int _isupper(int);\n"
2073 " extern int _isxdigit(int);\n"
2074 "# else /* not _PROTOTYPES */\n"
2075 " extern int _isalnum();\n"
2076 " extern int _isalpha();\n"
2077 " extern int _iscntrl();\n"
2078 " extern int _isdigit();\n"
2079 " extern int _isgraph();\n"
2080 " extern int _islower();\n"
2081 " extern int _isprint();\n"
2082 " extern int _ispunct();\n"
2083 " extern int _isspace();\n"
2084 " extern int _isupper();\n"
2085 " extern int _isxdigit();\n"
2086 "#endif /* _PROTOTYPES */\n";
2088 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2089 " extern unsigned int *__SB_masks;\n";
2093 * Fix hpux 10.X missing stdio declarations
2095 fix = {
2096 hackname = hpux10_stdio_declarations;
2097 files = stdio.h;
2098 select = "^#[ \t]*define _iob[ \t]*__iob";
2099 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2100 c_fix = format;
2101 c_fix_arg = "%0\n\n"
2102 "# if defined(__STDC__) || defined(__cplusplus)\n"
2103 " extern int snprintf(char *, size_t, const char *, ...);\n"
2104 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2105 "# else /* not __STDC__) || __cplusplus */\n"
2106 " extern int snprintf();\n"
2107 " extern int vsnprintf();\n"
2108 "# endif /* __STDC__) || __cplusplus */\n";
2110 test_text = "# define _iob __iob\n";
2114 * Make sure hpux defines abs in header.
2116 fix = {
2117 hackname = hpux11_abs;
2118 mach = "*-hp-hpux11*";
2119 files = stdlib.h;
2120 select = "ifndef _MATH_INCLUDED";
2121 c_fix = format;
2122 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2123 test_text = "#ifndef _MATH_INCLUDED";
2127 * Fix hpux11 __LWP_RWLOCK_VALID define
2129 fix = {
2130 hackname = hpux11_lwp_rwlock_valid;
2131 mach = "*-hp-hpux11*";
2132 files = sys/pthread.h;
2133 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2134 c_fix = format;
2135 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2136 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2140 * hpux sendfile()
2142 fix = {
2143 hackname = hpux11_extern_sendfile;
2144 mach = "*-hp-hpux11.[12]*";
2145 files = sys/socket.h;
2146 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2147 c_fix = format;
2148 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2149 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2150 " const struct iovec *, int));\n";
2154 * hpux sendpath()
2156 fix = {
2157 hackname = hpux11_extern_sendpath;
2158 mach = "*-hp-hpux11.[12]*";
2159 files = sys/socket.h;
2160 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2161 c_fix = format;
2162 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2163 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2164 " const struct iovec *, int));\n";
2168 * Keep HP-UX 11 from stomping on C++ math namespace
2169 * with defines for fabsf.
2171 fix = {
2172 hackname = hpux11_fabsf;
2173 files = math.h;
2174 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2175 bypass = "__cplusplus";
2177 c_fix = format;
2178 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2180 test_text =
2181 "#ifdef _PA_RISC\n"
2182 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2183 "#endif";
2187 * Fix C99 constant in __POINTER_SET define.
2189 fix = {
2190 hackname = hpux11_pthread_const;
2191 mach = "*-hp-hpux11.[0-3]*";
2192 files = sys/pthread.h;
2193 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2195 c_fix = format;
2196 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2197 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2201 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2202 * being defined by having it define _hpux_size_t instead.
2204 fix = {
2205 hackname = hpux11_size_t;
2206 mach = "*-hp-hpux11*";
2207 select = "__size_t";
2209 c_fix = format;
2210 c_fix_arg = "_hpux_size_t";
2212 test_text =
2213 "#define __size_t size_t\n"
2214 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2218 * Fix hpux 11.00 broken snprintf declaration
2219 * (third argument is char *, needs to be const char * to prevent
2220 * spurious warnings with -Wwrite-strings or in C++).
2222 fix = {
2223 hackname = hpux11_snprintf;
2224 files = stdio.h;
2225 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2226 ' *(char *\*, *\.\.\.\);)';
2227 c_fix = format;
2228 c_fix_arg = '%1 const %3';
2230 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2231 "extern int snprintf(char *, __size_t, char *, ...);\n"
2232 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2236 * Fix hpux 11.00 broken vsnprintf declaration
2238 fix = {
2239 hackname = hpux11_vsnprintf;
2240 files = stdio.h;
2241 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2242 'const char \*,) __va__list\);';
2243 c_fix = format;
2244 c_fix_arg = "%1 __va_list);";
2246 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2247 ' __va__list);';
2251 * get rid of bogus inline definitions in HP-UX 8.0
2253 fix = {
2254 hackname = hpux8_bogus_inlines;
2255 files = math.h;
2256 select = inline;
2257 bypass = "__GNUG__";
2258 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2259 "@extern \"C\" int abs(int);@";
2260 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2261 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2262 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2263 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2264 "inline double sqr(double v) { return v**0.5; }";
2268 * hpux intptr
2270 fix = {
2271 hackname = hpux_c99_intptr;
2272 mach = "*-hp-hpux11.3*";
2273 files = stdint-hpux11.h, stdint.h;
2274 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2275 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2276 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2277 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2278 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2279 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2280 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2281 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2282 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2283 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2284 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2285 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2286 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2287 "#define PTRDIFF_MIN INT32_MIN\n"
2288 "#define INTPTR_MAX INT32_MAX\n"
2289 "#define INTPTR_MIN INT32_MIN\n"
2290 "#define UINTPTR_MAX UINT32_MAX\n"
2291 "#define SIZE_MAX UINT32_MAX\n";
2295 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2297 fix = {
2298 hackname = hpux_c99_inttypes;
2299 mach = "*-hp-hpux11.[23]*";
2300 files = inttypes.h;
2301 files = stdint-hpux11.h, stdint.h;
2302 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2303 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2304 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2305 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2306 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2307 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2308 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2309 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2310 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2311 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2312 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2313 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2317 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2319 fix = {
2320 hackname = hpux_c99_inttypes2;
2321 mach = "*-hp-hpux11.2*";
2322 files = stdint-hpux11.h, stdint.h;
2323 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2324 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2325 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2326 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2327 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2328 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2329 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2330 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2331 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2332 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2333 "# define INT16_C(__c) ((short)(__c))\n"
2334 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2338 * Fix hpux broken ctype macros
2340 fix = {
2341 hackname = hpux_ctype_macros;
2342 files = ctype.h;
2343 select = '((: |\()__SB_masks \? )'
2344 '(__SB_masks\[__(alnum|c)\] & _IS)';
2345 c_fix = format;
2346 c_fix_arg = "%1(int)%3";
2348 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2349 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2353 * hpux errno()
2355 fix = {
2356 hackname = hpux_extern_errno;
2357 mach = "*-hp-hpux10.*";
2358 mach = "*-hp-hpux11.[0-2]*";
2359 files = errno.h;
2360 select = "^[ \t]*extern int errno;$";
2361 c_fix = format;
2362 c_fix_arg = "#ifdef __cplusplus\n"
2363 "extern \"C\" {\n"
2364 "#endif\n"
2365 "%0\n"
2366 "#ifdef __cplusplus\n"
2367 "}\n"
2368 "#endif";
2369 test_text = " extern int errno;\n";
2373 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2375 fix = {
2376 hackname = hpux_htonl;
2377 files = netinet/in.h;
2378 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2379 "(/\\*\n"
2380 " \\* Macros for number representation conversion\\.\n"
2381 " \\*/\n"
2382 "#ifndef ntohl)";
2383 c_fix = format;
2384 c_fix_arg = "#if 1\n%1";
2386 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2387 "/*\n"
2388 " * Macros for number representation conversion.\n"
2389 " */\n"
2390 "#ifndef ntohl\n"
2391 "#define ntohl(x) (x)\n"
2392 "#define ntohs(x) (x)\n"
2393 "#define htonl(x) (x)\n"
2394 "#define htons(x) (x)\n"
2395 "#endif\n"
2396 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2400 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2402 fix = {
2403 hackname = hpux_imaginary_i;
2404 mach = "ia64-hp-hpux11.*";
2405 files = complex.h;
2406 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2407 c_fix = format;
2408 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2409 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2413 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2415 fix = {
2416 hackname = hpux_inttype_int8_t;
2417 mach = "*-hp-hpux1[01].*";
2418 files = sys/_inttypes.h;
2419 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2420 c_fix = format;
2421 c_fix_arg = "typedef signed char int%18_t;";
2422 test_text = "typedef char int_least8_t;\n"
2423 "typedef char int8_t;\n";
2427 * HP-UX long_double
2429 fix = {
2430 hackname = hpux_long_double;
2431 mach = "*-*-hpux10*";
2432 mach = "*-*-hpux11.[012]*";
2433 files = stdlib.h;
2434 select = "extern[ \t]long_double[ \t]strtold";
2435 bypass = "long_double_t";
2436 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2437 sed = "s/long_double/long double/g";
2439 test_text = "# ifndef _LONG_DOUBLE\n"
2440 "# define _LONG_DOUBLE\n"
2441 " typedef struct {\n"
2442 " unsigned int word1, word2, word3, word4;\n"
2443 " } long_double;\n"
2444 "# endif /* _LONG_DOUBLE */\n"
2445 "extern long_double strtold(const char *, char **);\n";
2449 * We cannot use the above rule on 11.31 because it removes the strtold
2450 * definition. ia64 is OK with no hack, PA needs some help.
2452 fix = {
2453 hackname = hpux_long_double_2;
2454 mach = "hppa*-*-hpux11.3*";
2455 files = stdlib.h;
2456 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2457 "defined\\(_PROTOTYPES\\) \\|\\| "
2458 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2459 c_fix = format;
2460 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2462 test_text = "# if !defined(__ia64) || "
2463 "!defined(_PROTOTYPES) || "
2464 "defined(_LONG_DOUBLE_STRUCT)\n";
2468 * Add missing braces to pthread initializer defines.
2470 fix = {
2471 hackname = hpux_pthread_initializers;
2472 mach = "*-hp-hpux11.[0-3]*";
2473 files = sys/pthread.h;
2474 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2475 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2476 sed = "s@^[ \t]*1,[ \t]*\\\\"
2477 "@\t{ 1, 0 }@";
2478 sed = "/^[ \t]*0$/d";
2479 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2480 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2481 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2482 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2483 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2484 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2485 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2486 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2487 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2488 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2489 sed = "s@__PTHREAD_COND_VALID, 0"
2490 "@{ __PTHREAD_COND_VALID, 0 }@";
2491 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2492 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2493 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2494 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2495 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2496 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2497 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2498 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2499 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2500 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2501 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2502 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2503 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2504 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2505 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2506 "}\n";
2510 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2511 * type and mpinfou is only defined when _KERNEL is set.
2513 fix = {
2514 hackname = hpux_spu_info;
2515 mach = "*-hp-hpux*";
2517 * It is tempting to omit the first "files" entry. Do not.
2518 * The testing machinery will take the first "files" entry as the name
2519 * of a test file to play with. It would be a nuisance to have a directory
2520 * with the name "*".
2522 files = "ia64/sys/getppdp.h";
2523 files = "*/sys/getppdp.h";
2524 select = "^.*extern.*spu_info.*";
2526 c_fix = format;
2527 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2529 test_text = "extern union mpinfou spu_info[];";
2533 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2535 fix = {
2536 hackname = hpux_stdint_least_fast;
2537 mach = "*-hp-hpux11.2*";
2538 files = stdint-hpux11.h, stdint.h;
2539 select =
2540 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2541 c_fix = format;
2542 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2543 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2544 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2545 _EOFix_;
2549 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2551 fix = {
2552 hackname = hpux_systime;
2553 files = sys/time.h;
2554 select = "^extern struct sigevent;";
2556 c_fix = format;
2557 c_fix_arg = "struct sigevent;";
2559 test_text = 'extern struct sigevent;';
2563 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2565 fix = {
2566 hackname = huge_val_hex;
2567 files = bits/huge_val.h, '*/bits/huge_val.h';
2568 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2569 bypass = "__builtin_huge_val";
2571 c_fix = format;
2572 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2574 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2578 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2580 fix = {
2581 hackname = huge_valf_hex;
2582 files = bits/huge_val.h, '*/bits/huge_val.h';
2583 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2584 bypass = "__builtin_huge_valf";
2586 c_fix = format;
2587 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2589 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2593 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2595 fix = {
2596 hackname = huge_vall_hex;
2597 files = bits/huge_val.h, '*/bits/huge_val.h';
2598 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2599 bypass = "__builtin_huge_vall";
2601 c_fix = format;
2602 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2604 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2608 * Fix return type of abort and free
2610 fix = {
2611 hackname = int_abort_free_and_exit;
2612 files = stdlib.h;
2613 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2614 bypass = "_CLASSIC_ANSI_TYPES";
2616 c_fix = format;
2617 c_fix_arg = "void\t%1(";
2619 test_text = "extern int abort(int);\n"
2620 "extern int free(void*);\n"
2621 "extern int exit(void*);";
2625 * Fix various macros used to define ioctl numbers.
2626 * The traditional syntax was:
2628 * #define _IO(n, x) (('n'<<8)+x)
2629 * #define TIOCFOO _IO(T, 1)
2631 * but this does not work with the C standard, which disallows macro
2632 * expansion inside strings. We have to rewrite it thus:
2634 * #define _IO(n, x) ((n<<8)+x)
2635 * #define TIOCFOO _IO('T', 1)
2637 * The select expressions match too much, but the c_fix code is cautious.
2639 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2641 fix = {
2642 hackname = io_quotes_def;
2643 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2644 c_fix = char_macro_def;
2645 c_fix_arg = "IO";
2646 test_text =
2647 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2648 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2649 "#define _IO(x,y) ('x'<<8|y)";
2650 test_text =
2651 "#define XX_IO(x) ('x'<<8|256)";
2655 * Fix the usage of the ioctl macro numbers.
2657 fix = {
2658 hackname = io_quotes_use;
2659 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2660 "\\( *[^,']";
2661 c_fix = char_macro_use;
2662 c_fix_arg = "IO";
2663 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2664 "#define TIOCFOO \\\\\n"
2665 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2669 * Check for missing ';' in struct
2671 fix = {
2672 hackname = ip_missing_semi;
2673 files = netinet/ip.h;
2674 select = "}$";
2675 sed = "/^struct/,/^};/s/}$/};/";
2676 test_text=
2677 "struct mumble {\n"
2678 " union {\n"
2679 " int x;\n"
2680 " }\n"
2681 "}; /* mumbled struct */\n";
2685 * Non-traditional "const" declaration in Irix's limits.h.
2687 fix = {
2688 hackname = irix_limits_const;
2689 files = fixinc-test-limits.h, limits.h;
2690 select = "^extern const ";
2691 c_fix = format;
2692 c_fix_arg = "extern __const ";
2693 test_text = "extern const char limit; /* test limits */";
2697 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2698 * taking char *. However, GCC uses void * for va_list, so
2699 * calling vfprintf with a va_list fails in C++. */
2700 fix = {
2701 hackname = irix_stdio_va_list;
2702 files = stdio.h;
2704 select = '/\* va_list \*/ char \*';
2705 c_fix = format;
2706 c_fix_arg = "__gnuc_va_list";
2707 test_text =
2708 "extern int printf( const char *, /* va_list */ char * );";
2712 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2713 * use / * * / to concatenate tokens.
2715 fix = {
2716 hackname = kandr_concat;
2717 files = "sparc/asm_linkage.h";
2718 files = "sun*/asm_linkage.h";
2719 files = "arm/as_support.h";
2720 files = "arm/mc_type.h";
2721 files = "arm/xcb.h";
2722 files = "dev/chardefmac.h";
2723 files = "dev/ps_irq.h";
2724 files = "dev/screen.h";
2725 files = "dev/scsi.h";
2726 files = "sys/tty.h";
2727 files = "Xm.acorn/XmP.h";
2728 files = bsd43/bsd43_.h;
2729 select = '/\*\*/';
2730 c_fix = format;
2731 c_fix_arg = '##';
2732 test_text = "#define __CONCAT__(a,b) a/**/b";
2736 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2737 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2738 * constant on recent versions of g++.
2740 fix = {
2741 hackname = linux_ia64_ucontext;
2742 files = "sys/ucontext.h";
2743 mach = "ia64-*-linux*";
2744 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2745 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2746 c_fix = format;
2747 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2748 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2749 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2753 * Remove header file warning from sys/time.h. Autoconf's
2754 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2755 * which causes warning on LynxOS. Remove the warning.
2757 fix = {
2758 hackname = lynxos_no_warning_in_sys_time_h;
2759 files = sys/time.h;
2760 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2761 c_fix = format;
2762 c_fix_arg = "";
2763 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2767 * Add missing declaration for putenv.
2769 fix = {
2770 hackname = lynxos_missing_putenv;
2771 mach = '*-*-lynxos*';
2772 files = stdlib.h;
2773 bypass = 'putenv[ \t]*\\(';
2774 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2775 c_fix = format;
2776 c_fix_arg = "%0\n"
2777 "extern int putenv _AP((char *));";
2778 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2779 test_text = "extern char *getenv _AP((const char *));";
2783 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2785 * On NetBSD, machine is a symbolic link to an architecture specific
2786 * directory name, so we can't match a specific file name here.
2788 fix = {
2789 hackname = machine_ansi_h_va_list;
2790 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2791 bypass = '__builtin_va_list';
2793 c_fix = format;
2794 c_fix_arg = "%1__builtin_va_list";
2795 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2797 test_text = " # define _BSD_VA_LIST_\tchar**";
2801 * Fix non-ansi machine name defines
2803 fix = {
2804 hackname = machine_name;
2805 c_test = machine_name;
2806 c_fix = machine_name;
2808 test_text = "/* MACH_DIFF: */\n"
2809 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2810 "\n/* no uniform test, so be careful :-) */";
2814 * Some math.h files define struct exception (it's in the System V
2815 * Interface Definition), which conflicts with the class exception defined
2816 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2817 * This is not a great fix, but I haven't been able to think of anything
2818 * better.
2820 fix = {
2821 hackname = math_exception;
2822 files = math.h;
2823 select = "struct exception";
2825 * This should be bypassed on __cplusplus, but some supposedly C++
2826 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2827 * exception either. So currently we bypass only for glibc, based on a
2828 * comment in the fixed glibc header. Ick.
2830 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2831 '_[a-z0-9A-Z_]+_exception; for C, exception';
2832 /* The Solaris 10 headers already get this right. */
2833 mach = '*-*-solaris2.1[0-9]*';
2834 not_machine = true;
2835 c_fix = wrap;
2837 c_fix_arg = "#ifdef __cplusplus\n"
2838 "#define exception __math_exception\n"
2839 "#endif\n";
2841 c_fix_arg = "#ifdef __cplusplus\n"
2842 "#undef exception\n"
2843 "#endif\n";
2845 test_text = "typedef struct exception t_math_exception;";
2849 * This looks pretty broken to me. ``dbl_max_def'' will contain
2850 * "define DBL_MAX " at the start, when what we really want is just
2851 * the value portion. Can't figure out how to write a test case
2852 * for this either :-(
2854 fix = {
2855 hackname = math_huge_val_from_dbl_max;
2856 files = math.h;
2859 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2860 * in math.h, this fix applies.
2862 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2863 bypass = "define[ \t]+DBL_MAX";
2865 shell =
2867 * See if we have a definition for DBL_MAX in float.h.
2868 * If we do, we will replace the one in math.h with that one.
2871 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2872 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2874 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2875 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2876 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2877 "\telse cat\n"
2878 "\tfi";
2880 test_text =
2881 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2882 "#define HUGE_VAL DBL_MAX";
2886 * nested comment
2888 fix = {
2889 hackname = nested_auth_des;
2890 files = rpc/rpc.h;
2891 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2892 c_fix = format;
2893 c_fix_arg = "%1*/ /*";
2894 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2898 * Some versions of NetBSD don't expect the C99 inline semantics.
2900 fix = {
2901 hackname = netbsd_c99_inline_1;
2902 mach = "*-*-netbsd*";
2903 files = signal.h;
2904 select = "extern __inline int";
2906 c_fix = format;
2907 c_fix_arg = "extern\n"
2908 "#ifdef __GNUC_STDC_INLINE__\n"
2909 "__attribute__((__gnu_inline__))\n"
2910 "#endif\n"
2911 "__inline int";
2913 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2917 * netbsd_c99_inline_2
2919 fix = {
2920 hackname = netbsd_c99_inline_2;
2921 mach = "*-*-netbsd*";
2922 files = signal.h;
2923 select = "#define _SIGINLINE extern __inline";
2925 c_fix = format;
2926 c_fix_arg = <<- _EOArg_
2927 #ifdef __GNUC_STDC_INLINE__
2928 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2929 #else
2931 #endif
2932 _EOArg_;
2934 test_text = "#define _SIGINLINE extern __inline";
2938 * NetBSD has a semicolon after the ending '}' for some extern "C".
2940 fix = {
2941 hackname = netbsd_extra_semicolon;
2942 mach = "*-*-netbsd*";
2943 files = sys/cdefs.h;
2944 select = "#define[ \t]*__END_DECLS[ \t]*};";
2946 c_fix = format;
2947 c_fix_arg = "#define __END_DECLS }";
2949 test_text = "#define __END_DECLS };";
2953 * newlib's stdint.h has several failures to conform to C99. The fix
2954 * for these removed a comment that can be matched to identify unfixed
2955 * versions.
2957 fix = {
2958 hackname = newlib_stdint_1;
2959 files = stdint-newlib.h, stdint.h;
2960 select = "@todo - Add support for wint_t types";
2961 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2962 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2963 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2964 sed = "s@#define INT_LEAST32_MIN.*@"
2965 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2966 sed = "s@#define INT_LEAST32_MAX.*@"
2967 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2968 sed = "s@#define UINT_LEAST32_MAX.*@"
2969 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2970 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
2971 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2972 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
2973 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2974 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
2975 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2976 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2977 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2978 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2979 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2980 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2981 test_text = "/* @todo - Add support for wint_t types. */\n"
2982 "#define INT32_MIN (-2147483647-1)\n"
2983 "#define INT32_MAX 2147483647\n"
2984 "#define UINT32_MAX 4294967295U\n"
2985 "#define INT_LEAST32_MIN (-2147483647-1)\n"
2986 "#define INT_LEAST32_MAX 2147483647\n"
2987 "#define UINT_LEAST32_MAX 4294967295U\n"
2988 "#define INT_FAST8_MIN INT8_MIN\n"
2989 "#define INT_FAST8_MAX INT8_MAX\n"
2990 "#define UINT_FAST8_MAX UINT8_MAX\n"
2991 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2992 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2993 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2994 "#define UINT8_C(x) x##U\n"
2995 "#define UINT16_C(x) x##U";
2999 * newlib_stdint_2
3001 fix = {
3002 hackname = newlib_stdint_2;
3003 files = stdint-newlib.h, stdint.h;
3004 select = "@todo - Add support for wint_t types";
3005 c_fix = format;
3006 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3007 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3008 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3009 "#define WCHAR_MAX __WCHAR_MAX__\n"
3010 "#define WCHAR_MIN __WCHAR_MIN__\n"
3011 "#define WINT_MAX __WINT_MAX__\n"
3012 "#define WINT_MIN __WINT_MIN__\n\n"
3013 "%0";
3014 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3015 test_text = "/* @todo - Add support for wint_t types. */\n"
3016 "/** Macros for minimum-width integer constant expressions */";
3020 * NeXT 3.2 adds const prefix to some math functions.
3021 * These conflict with the built-in functions.
3023 fix = {
3024 hackname = next_math_prefix;
3025 files = ansi/math.h;
3026 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3028 c_fix = format;
3029 c_fix_arg = "extern double %1(";
3030 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3032 test_text = "extern\tdouble\t__const__\tmumble();";
3036 * NeXT 3.2 uses the word "template" as a parameter for some
3037 * functions. GCC reports an invalid use of a reserved key word
3038 * with the built-in functions.
3040 fix = {
3041 hackname = next_template;
3042 files = bsd/libc.h;
3043 select = "[ \t]template\\)";
3045 c_fix = format;
3046 c_fix_arg = "(%1)";
3047 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3048 test_text = "extern mumble( char * template); /* fix */";
3052 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3053 * function prototypes. That conflicts with the built-in functions.
3055 fix = {
3056 hackname = next_volitile;
3057 files = ansi/stdlib.h;
3058 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3060 c_fix = format;
3061 c_fix_arg = "extern void %1(";
3062 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3064 test_text = "extern\tvolatile\tvoid\tabort();";
3068 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3069 * Note that version 3 of the NeXT system has wait.h in a different directory,
3070 * so that this code won't do anything. But wait.h in version 3 has a
3071 * conditional, so it doesn't need this fix. So everything is okay.
3073 fix = {
3074 hackname = next_wait_union;
3075 files = sys/wait.h;
3077 select = 'wait\(union wait';
3078 c_fix = format;
3079 c_fix_arg = "wait(void";
3080 test_text = "extern pid_d wait(union wait*);";
3084 * a missing semi-colon at the end of the nodeent structure definition.
3086 fix = {
3087 hackname = nodeent_syntax;
3088 files = netdnet/dnetdb.h;
3089 select = "char[ \t]*\\*na_addr[ \t]*$";
3090 c_fix = format;
3091 c_fix_arg = "%0;";
3092 test_text = "char *na_addr\t";
3096 * Fix OpenBSD's NULL definition.
3098 fix = {
3099 hackname = openbsd_null_definition;
3100 mach = "*-*-openbsd*";
3101 files = locale.h, stddef.h, stdio.h, string.h,
3102 time.h, unistd.h, wchar.h, sys/param.h;
3103 select = "__GNUG__";
3104 c_fix = format;
3105 c_fix_arg = "#ifndef NULL\n"
3106 "#ifdef __cplusplus\n"
3107 "#ifdef __GNUG__\n"
3108 "#define NULL\t__null\n"
3109 "#else\t /* ! __GNUG__ */\n"
3110 "#define NULL\t0L\n"
3111 "#endif\t /* __GNUG__ */\n"
3112 "#else\t /* ! __cplusplus */\n"
3113 "#define NULL\t((void *)0)\n"
3114 "#endif\t /* __cplusplus */\n"
3115 "#endif\t /* !NULL */";
3117 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3118 "^#ifdef[ \t]*__GNUG__\n"
3119 "^#define[ \t]*NULL[ \t]*__null\n"
3120 "^#else\n"
3121 "^#define[ \t]*NULL[ \t]*0L\n"
3122 "^#endif\n"
3123 "^#endif";
3124 test_text =
3125 "#ifndef NULL\n"
3126 "#ifdef __GNUG__\n"
3127 "#define NULL __null\n"
3128 "#else\n"
3129 "#define NULL 0L\n"
3130 "#endif\n"
3131 "#endif\n";
3135 * obstack.h used casts as lvalues.
3137 * We need to change postincrements of casted pointers (which are
3138 * then dereferenced and assigned into) of the form
3140 * *((TYPE*)PTRVAR)++ = (VALUE)
3142 * into expressions like
3144 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3146 * which is correct for the cases used in obstack.h since PTRVAR is
3147 * of type char * and the value of the expression is not used.
3149 fix = {
3150 hackname = obstack_lvalue_cast;
3151 files = obstack.h;
3152 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3153 c_fix = format;
3154 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3155 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3159 * Fix OpenBSD's va_start define.
3161 fix = {
3162 hackname = openbsd_va_start;
3163 mach = "*-*-openbsd*";
3164 files = stdarg.h;
3165 select = '__builtin_stdarg_start';
3166 c_fix = format;
3167 c_fix_arg = __builtin_va_start;
3169 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3173 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3174 * defining regex.h related types. This causes libg++ build and usage
3175 * failures. Fixing this correctly requires checking and modifying 3 files.
3177 fix = {
3178 hackname = osf_namespace_a;
3179 files = reg_types.h;
3180 files = sys/lc_core.h;
3181 test = " -r reg_types.h";
3182 test = " -r sys/lc_core.h";
3183 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3184 test = " -z \"`grep __regex_t regex.h`\"";
3186 c_fix = format;
3187 c_fix_arg = "__%0";
3188 c_fix_arg = "reg(ex|off|match)_t";
3190 test_text = "`touch sys/lc_core.h`"
3191 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3192 "extern regex_t re;\n"
3193 "extern regoff_t ro;\n"
3194 "extern regmatch_t rm;\n";
3197 fix = {
3198 hackname = osf_namespace_c;
3199 files = regex.h;
3200 test = " -r reg_types.h";
3201 test = " -r sys/lc_core.h";
3202 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3203 test = " -z \"`grep __regex_t regex.h`\"";
3205 select = "#include <reg_types\.h>.*";
3206 c_fix = format;
3207 c_fix_arg = "%0\n"
3208 "typedef __regex_t\tregex_t;\n"
3209 "typedef __regoff_t\tregoff_t;\n"
3210 "typedef __regmatch_t\tregmatch_t;";
3212 test_text = "#include <reg_types.h>";
3216 * On broken glibc-2.3.3 systems an array of incomplete structures is
3217 * passed to __sigsetjmp. Fix that to take a pointer instead.
3219 fix = {
3220 hackname = pthread_incomplete_struct_argument;
3221 files = pthread.h;
3222 select = "struct __jmp_buf_tag";
3223 c_fix = format;
3224 c_fix_arg = "%1 *%2%3";
3225 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3226 "(__env)\\[1\\](.*)$";
3227 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3228 "int __savemask);";
3232 * Fix return type of fread and fwrite on sysV68
3234 fix = {
3235 hackname = read_ret_type;
3236 files = stdio.h;
3237 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3238 c_fix = format;
3239 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3240 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3242 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3246 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3248 fix = {
3249 hackname = rpc_xdr_lvalue_cast_a;
3250 files = rpc/xdr.h;
3251 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3252 c_fix = format;
3253 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3254 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3255 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3259 * rpc_xdr_lvalue_cast_b
3261 fix = {
3262 hackname = rpc_xdr_lvalue_cast_b;
3263 files = rpc/xdr.h;
3264 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3265 c_fix = format;
3266 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3267 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3268 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3272 * function class(double x) conflicts with C++ keyword on rs/6000
3274 fix = {
3275 hackname = rs6000_double;
3276 files = math.h;
3277 select = '[^a-zA-Z_]class\(';
3279 c_fix = format;
3280 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3281 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3283 test_text = "extern int class();";
3287 * Wrong fchmod prototype on RS/6000.
3289 fix = {
3290 hackname = rs6000_fchmod;
3291 files = sys/stat.h;
3292 select = 'fchmod\(char \*';
3293 c_fix = format;
3294 c_fix_arg = "fchmod(int";
3295 test_text = "extern int fchmod(char *, mode_t);";
3299 * parameters conflict with C++ new on rs/6000
3301 fix = {
3302 hackname = rs6000_param;
3303 files = "stdio.h";
3304 files = "unistd.h";
3306 select = 'rename\(const char \*old, const char \*new\)';
3307 c_fix = format;
3308 c_fix_arg = 'rename(const char *_old, const char *_new)';
3310 test_text = 'extern int rename(const char *old, const char *new);';
3314 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3315 * for C99. This is wrong for C++, which needs many C99 features, but
3316 * only supports __restrict.
3318 fix = {
3319 hackname = solaris___restrict;
3320 files = sys/feature_tests.h;
3321 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3322 mach = "*-*-solaris2*";
3323 c_fix = format;
3324 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3325 "#else\n%0\n#endif";
3326 test_text = "#define _RESTRICT_KYWD restrict";
3330 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3331 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3332 * and imaginary definitions which are not supported by GCC.
3334 fix = {
3335 hackname = solaris_complex;
3336 mach = "*-*-solaris2.*";
3337 files = complex.h;
3338 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3339 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3340 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3341 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3342 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3343 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3344 test_text = "#define _Complex_I _Complex_I\n"
3345 "#define complex _Complex\n"
3346 "#define _Imaginary_I _Imaginary_I\n"
3347 "#define imaginary _Imaginary\n"
3348 "#undef I\n"
3349 "#define I _Imaginary_I";
3353 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3354 * extern "C" instead so libstdc++ can use it.
3356 fix = {
3357 hackname = solaris_complex_cxx;
3358 mach = "*-*-solaris2.*";
3359 files = complex.h;
3360 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3361 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3362 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3363 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3364 test_text = "#if !defined(__cplusplus)\n"
3365 "#endif /* !defined(__cplusplus) */";
3369 * g++ rejects functions declared with both C and C++ linkage.
3371 fix = {
3372 hackname = solaris_cxx_linkage;
3373 mach = '*-*-solaris2*';
3374 files = "iso/stdlib_iso.h";
3375 select = "(#if __cplusplus >= 199711L)\n"
3376 "(extern \"C\\+\\+\" \\{\n)"
3377 "(.*(bsearch|qsort).*)";
3378 c_fix = format;
3379 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3381 test_text =
3382 "#if __cplusplus >= 199711L\n"
3383 "extern \"C++\" {\n"
3384 " void *bsearch(const void *, const void *, size_t, size_t,";
3388 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3389 * _STRICT_STDC, but uses it.
3391 fix = {
3392 hackname = solaris_getc_strict_stdc;
3393 mach = "*-*-solaris2*";
3394 files = "iso/stdio_iso.h";
3395 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3396 c_fix = format;
3397 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3399 test_text =
3400 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3404 * Sun Solaris 2 has a version of sys/int_const.h that defines
3405 * UINT8_C and UINT16_C to unsigned constants.
3407 fix = {
3408 hackname = solaris_int_const;
3409 files = sys/int_const.h;
3410 mach = '*-*-solaris2*';
3411 c_fix = format;
3412 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3413 "%1\n"
3414 "#define\tUINT16_C(c)\t(c)";
3415 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3416 "(/\*.*\*/)\n"
3417 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3418 test_text =
3419 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3420 "/* CSTYLED */\n"
3421 "#define UINT16_C(c) __CONCAT__(c,u)";
3425 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3426 * UINT8_MAX and UINT16_MAX to unsigned constants.
3428 fix = {
3429 hackname = solaris_int_limits_1;
3430 files = sys/int_limits.h;
3431 mach = '*-*-solaris2*';
3432 c_fix = format;
3433 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3434 "#define\tUINT16_MAX\t(65535)";
3435 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3436 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3437 test_text =
3438 "#define UINT8_MAX (255U)\n"
3439 "#define UINT16_MAX (65535U)";
3443 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3444 * INT_FAST16 limits to wrong values for sys/int_types.h.
3446 fix = {
3447 hackname = solaris_int_limits_2;
3448 files = sys/int_limits.h;
3449 mach = '*-*-solaris2*';
3450 c_fix = format;
3451 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3452 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3453 test_text =
3454 "#define INT_FAST16_MAX INT16_MAX\n"
3455 "#define UINT_FAST16_MAX UINT16_MAX\n"
3456 "#define INT_FAST16_MIN INT16_MIN";
3460 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3461 * SIZE_MAX as unsigned long.
3463 fix = {
3464 hackname = solaris_int_limits_3;
3465 files = sys/int_limits.h;
3466 mach = '*-*-solaris2*';
3467 c_fix = format;
3468 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3469 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3470 test_text =
3471 "#define SIZE_MAX 4294967295UL";
3475 * Sun Solaris 10 defines several C99 math macros in terms of
3476 * builtins specific to the Studio compiler, in particular not
3477 * compatible with the GNU compiler.
3479 fix = {
3480 hackname = solaris_math_1;
3481 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3482 bypass = "__GNUC__";
3483 files = iso/math_c99.h;
3484 c_fix = format;
3485 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3486 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3487 test_text =
3488 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3489 "#undef HUGE_VAL\n"
3490 "#define HUGE_VAL __builtin_huge_val\n"
3491 "#undef HUGE_VALF\n"
3492 "#define HUGE_VALF __builtin_huge_valf\n"
3493 "#undef HUGE_VALL\n"
3494 "#define HUGE_VALL __builtin_huge_vall";
3498 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3499 * exception. Provide an alternative using GCC's builtin.
3501 fix = {
3502 hackname = solaris_math_10;
3503 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3504 files = iso/math_c99.h;
3505 c_fix = format;
3506 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3507 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3508 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3509 "[ \t]*\\\\\n"
3510 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3511 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3512 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3513 "\\(-INFINITY\\);[ \t]*\\}\\)";
3514 test_text =
3515 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3516 "#undef isinf\n"
3517 "#define isinf(x) __extension__( \\\\\n"
3518 " { __typeof(x) __x_i = (x); \\\\\n"
3519 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3520 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3524 * Solaris math INFINITY
3526 fix = {
3527 hackname = solaris_math_2;
3528 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3529 bypass = "__GNUC__";
3530 files = iso/math_c99.h;
3531 c_fix = format;
3532 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3533 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3534 test_text =
3535 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3536 "#undef INFINITY\n"
3537 "#define INFINITY __builtin_infinity";
3541 * Solaris math NAN
3543 fix = {
3544 hackname = solaris_math_3;
3545 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3546 bypass = "__GNUC__";
3547 files = iso/math_c99.h;
3548 c_fix = format;
3549 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3550 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3551 test_text =
3552 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3553 "#undef NAN\n"
3554 "#define NAN __builtin_nan";
3558 * Solaris math fpclassify
3560 fix = {
3561 hackname = solaris_math_4;
3562 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3563 bypass = "__GNUC__";
3564 files = iso/math_c99.h;
3565 c_fix = format;
3566 c_fix_arg = "#define\tfpclassify(x) \\\n"
3567 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3568 "FP_SUBNORMAL, FP_ZERO, (x))";
3569 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3570 test_text =
3571 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3572 "#undef fpclassify\n"
3573 "#define fpclassify(x) __builtin_fpclassify(x)";
3577 * Solaris math signbit
3579 fix = {
3580 hackname = solaris_math_8;
3581 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3582 bypass = "__GNUC__";
3583 files = iso/math_c99.h;
3584 c_fix = format;
3585 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3586 "\t\t\t ? __builtin_signbitf(x) \\\n"
3587 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3588 "\t\t\t ? __builtin_signbitl(x) \\\n"
3589 "\t\t\t : __builtin_signbit(x))";
3590 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3591 test_text = <<- _EOText_
3592 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3593 #undef signbit
3594 #define signbit(x) __builtin_signbit(x)
3595 _EOText_;
3599 * Solaris math comparison macros
3601 fix = {
3602 hackname = solaris_math_9;
3603 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3604 bypass = "__GNUC__";
3605 files = iso/math_c99.h;
3606 c_fix = format;
3607 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3608 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3609 "__builtin_[a-z]+\\(y\\)\\)";
3610 test_text =
3611 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3612 "#undef isgreater\n"
3613 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3614 "#undef isgreaterequal\n"
3615 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3616 "#undef isless\n"
3617 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3618 "#undef islessequal\n"
3619 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3620 "#undef islessgreater\n"
3621 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3622 "#undef isunordered\n"
3623 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3627 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3628 * warnings.
3630 fix = {
3631 hackname = solaris_math_11;
3632 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3633 files = iso/math_c99.h;
3634 c_fix = format;
3635 c_fix_arg = << _EOArg_
3636 #undef signbit
3637 #define signbit(x) (sizeof(x) == sizeof(float) \
3638 ? __builtin_signbitf(x) \
3639 : sizeof(x) == sizeof(long double) \
3640 ? __builtin_signbitl(x) \
3641 : __builtin_signbit(x))
3642 _EOArg_;
3643 c_fix_arg = << _EOArg_
3644 ^#undef[ ]+signbit
3645 #if defined\(__sparc\)
3646 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3647 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3648 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3649 #elif defined\(__i386\) \|\| defined\(__amd64\)
3650 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3651 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3652 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3653 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3654 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3655 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3656 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3657 #endif
3658 _EOArg_;
3659 test_text = << _EOText_
3660 /* @(#)math_c99.h 1.14 13/03/27 */
3661 #undef signbit
3662 #if defined(__sparc)
3663 #define signbit(x) __extension__( \\
3664 { __typeof(x) __x_s = (x); \\
3665 (int) (*(unsigned *) &__x_s >> 31); })
3666 #elif defined(__i386) || defined(__amd64)
3667 #define signbit(x) __extension__( \\
3668 { __typeof(x) __x_s = (x); \\
3669 (sizeof (__x_s) == sizeof (float) ? \\
3670 (int) (*(unsigned *) &__x_s >> 31) : \\
3671 sizeof (__x_s) == sizeof (double) ? \\
3672 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3673 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3674 #endif
3675 _EOText_;
3679 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3680 * structure. As such, it need two levels of brackets, but only
3681 * contains one. Wrap the macro definition in an extra layer.
3683 fix = {
3684 hackname = solaris_once_init_1;
3685 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3686 files = pthread.h;
3687 mach = '*-*-solaris*';
3688 c_fix = format;
3689 c_fix_arg = "%1{%2}%3";
3690 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3691 test_text =
3692 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3693 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3697 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3698 * posix_spawn declarations, which doesn't work with C++.
3700 fix = {
3701 hackname = solaris_posix_spawn_restrict;
3702 files = spawn.h;
3703 mach = '*-*-solaris2*';
3704 c_fix = format;
3705 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3706 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3707 test_text =
3708 "char *const argv[_RESTRICT_KYWD],\n"
3709 "char *const envp[_RESTRICT_KYWD]);";
3713 * The pow overloads with int were removed in C++ 2011 DR 550.
3715 fix = {
3716 hackname = solaris_pow_int_overload;
3717 mach = '*-*-solaris2*';
3718 files = "iso/math_iso.h";
3719 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3720 " *\\{[^{}]*\n[^{}]*\\}";
3721 c_fix = format;
3722 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3724 test_text =
3725 " inline long double pow(long double __X, int __Y) { return\n"
3726 " __powl(__X, (long double) (__Y)); }";
3730 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3731 * fields of the pthread_rwlock_t structure, which are of type
3732 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3733 * defined (e.g. by -ansi) it is a union. So change the initializer
3734 * to "{0}" instead.
3736 fix = {
3737 hackname = solaris_rwlock_init_1;
3738 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3739 files = pthread.h;
3740 mach = '*-*-solaris*';
3741 c_fix = format;
3742 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3743 "%0\n"
3744 "#else\n"
3745 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3746 "#endif";
3747 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3748 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3750 test_text =
3751 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3752 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3756 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3757 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3759 fix = {
3760 hackname = solaris_std___filbuf;
3761 files = stdio.h;
3762 mach = '*-*-solaris2*';
3763 bypass = "using std::__filbuf";
3764 select = "(using std::perror;\n)(#endif)";
3765 c_fix = format;
3766 c_fix_arg = "%1#ifndef _LP64\n"
3767 "using std::__filbuf;\n"
3768 "using std::__flsbuf;\n"
3769 "#endif\n%2";
3771 test_text = "using std::perror;\n"
3772 "#endif";
3776 * Sun Solaris 8 has what appears to be some gross workaround for
3777 * some old version of their c++ compiler. G++ doesn't want it
3778 * either, but doesn't want to be tied to SunPRO version numbers.
3780 fix = {
3781 hackname = solaris_stdio_tag;
3782 files = stdio_tag.h;
3784 select = '__cplusplus < 54321L';
3785 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3786 "!defined(__GNUC__)" so we no longer need to fix it. */
3787 bypass = '__GNUC__';
3788 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3790 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3794 * a missing semi-colon at the end of the statsswtch structure definition.
3796 fix = {
3797 hackname = statsswtch;
3798 files = rpcsvc/rstat.h;
3799 select = "boottime$";
3800 c_fix = format;
3801 c_fix_arg = "boottime;";
3802 test_text = "struct statswtch {\n int boottime\n};";
3806 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3807 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3808 * OK too.
3810 fix = {
3811 hackname = stdio_stdarg_h;
3812 files = stdio.h;
3813 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3815 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3816 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3818 mach = '*-*-solaris2.1[0-9]*';
3819 not_machine = true;
3821 c_fix = wrap;
3823 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3825 test_text = "";
3829 * Don't use or define the name va_list in stdio.h. This is for
3830 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3831 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3832 * indicate that the header knows what it's doing -- under SUSv2,
3833 * stdio.h is required to define va_list, and we shouldn't break
3834 * that.
3836 fix = {
3837 hackname = stdio_va_list;
3838 files = stdio.h;
3839 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3841 * On Solaris 10, the definition in
3842 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3843 * there is therefore no need for this fix there.
3845 mach = '*-*-solaris2.1[0-9]*';
3846 not_machine = true;
3849 * Use __gnuc_va_list in arg types in place of va_list.
3850 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3851 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3852 * trailing parentheses and semicolon save all other systems from this.
3853 * Define __not_va_list__ (something harmless and unused)
3854 * instead of va_list.
3855 * Don't claim to have defined va_list.
3857 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3858 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3859 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3860 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3861 "s@ va_list@ __not_va_list__@\n"
3862 "s@\\*va_list@*__not_va_list__@\n"
3863 "s@ __va_list)@ __gnuc_va_list)@\n"
3864 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3865 "@typedef \\1 __not_va_list__;@\n"
3866 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3867 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3868 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3869 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3870 "s@VA_LIST@DUMMY_VA_LIST@\n"
3871 "s@_Va_LIST@_VA_LIST@";
3872 test_text = "extern void mumble( va_list);";
3876 * Fix headers that use va_list from stdio.h to use the updated
3877 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3878 * dealt with elsewhere. The presence of __gnuc_va_list,
3879 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3880 * knows what it's doing.
3882 fix = {
3883 hackname = stdio_va_list_clients;
3884 files = com_err.h;
3885 files = cps.h;
3886 files = curses.h;
3887 files = krb5.h;
3888 files = lc_core.h;
3889 files = pfmt.h;
3890 files = wchar.h;
3891 files = curses_colr/curses.h;
3892 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3893 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3894 otherwise protected. */
3895 bypass = 'include <stdarg\.h>|#ifdef va_start';
3898 * Use __gnuc_va_list in arg types in place of va_list.
3899 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3900 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3901 * trailing parentheses and semicolon save all other systems from this.
3902 * Define __not_va_list__ (something harmless and unused)
3903 * instead of va_list.
3904 * Don't claim to have defined va_list.
3906 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3907 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3908 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3909 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3910 "s@ va_list@ __not_va_list__@\n"
3911 "s@\\*va_list@*__not_va_list__@\n"
3912 "s@ __va_list)@ __gnuc_va_list)@\n"
3913 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3914 "@typedef \\1 __not_va_list__;@\n"
3915 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3916 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3917 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3918 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3919 "s@VA_LIST@DUMMY_VA_LIST@\n"
3920 "s@_Va_LIST@_VA_LIST@";
3921 test_text = "extern void mumble( va_list);";
3925 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3926 * is "!defined( __STRICT_ANSI__ )"
3928 fix = {
3929 hackname = strict_ansi_not;
3930 select = "^([ \t]*#[ \t]*if.*)"
3931 "(!__STDC__"
3932 "|__STDC__[ \t]*==[ \t]*0"
3933 "|__STDC__[ \t]*!=[ \t]*1"
3934 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3935 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3936 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3937 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3938 is not defined by GCC, so it is safe. */
3939 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3940 c_test = stdc_0_in_system_headers;
3942 c_fix = format;
3943 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3945 test_text = "#if !__STDC__ \n"
3946 "#if __STDC__ == 0\n"
3947 "#if __STDC__ != 1\n"
3948 "#if __STDC__ - 0 == 0"
3949 "/* not std C */\nint foo;\n"
3950 "\n#end-end-end-end-if :-)";
3954 * "__STDC__-0==0"
3955 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3957 fix = {
3958 hackname = strict_ansi_not_ctd;
3959 files = math.h, limits.h, stdio.h, signal.h,
3960 stdlib.h, sys/signal.h, time.h;
3962 * Starting at the beginning of a line, skip white space and
3963 * a leading "(" or "&&" or "||". One of those must be found.
3964 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3965 * expression. If these are nested, then they must accumulate
3966 * because we won't match any closing parentheses. Finally,
3967 * after skipping over all that, we must then match our suspect
3968 * phrase: "__STDC__-0==0" with or without white space.
3970 select = "^([ \t]*" '(\(|&&|\|\|)'
3971 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3972 "[ \t(]*)"
3973 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3974 c_test = stdc_0_in_system_headers;
3976 c_fix = format;
3977 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3979 test_text = "#if 1 && \\\\\n"
3980 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3981 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3982 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3983 "int foo;\n#endif";
3987 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3988 * is "defined( __STRICT_ANSI__ )"
3990 fix = {
3991 hackname = strict_ansi_only;
3992 select = "^([ \t]*#[ \t]*if.*)"
3993 "(__STDC__[ \t]*!=[ \t]*0"
3994 "|__STDC__[ \t]*==[ \t]*1"
3995 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3996 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3997 c_test = stdc_0_in_system_headers;
3999 c_fix = format;
4000 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4002 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4006 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4007 * in prototype without previous definition.
4009 fix = {
4010 hackname = struct_file;
4011 files = rpc/xdr.h;
4012 select = '^.*xdrstdio_create.*struct __file_s';
4013 c_fix = format;
4014 c_fix_arg = "struct __file_s;\n%0";
4015 test_text = "extern void xdrstdio_create( struct __file_s* );";
4019 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4020 * in prototype without previous definition.
4022 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4023 * function, and does define it.
4025 fix = {
4026 hackname = struct_sockaddr;
4027 files = rpc/auth.h;
4028 select = "^.*authdes_create.*struct sockaddr[^_]";
4029 bypass = "<sys/socket\.h>";
4030 bypass = "struct sockaddr;\n";
4031 c_fix = format;
4032 c_fix_arg = "struct sockaddr;\n%0";
4033 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4037 * Apply fix this to all OSs since this problem seems to effect
4038 * more than just SunOS.
4040 fix = {
4041 hackname = sun_auth_proto;
4042 files = rpc/auth.h;
4043 files = rpc/clnt.h;
4044 files = rpc/svc.h;
4045 files = rpc/xdr.h;
4046 bypass = "__cplusplus";
4048 * Select those files containing '(*name)()'.
4050 select = '\(\*[a-z][a-z_]*\)\(\)';
4052 c_fix = format;
4053 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4054 "#else\n%1();%2\n#endif";
4055 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4057 test_text =
4058 "struct auth_t {\n"
4059 " int (*name)(); /* C++ bad */\n"
4060 "};";
4064 * Fix bogus #ifdef on SunOS 4.1.
4066 fix = {
4067 hackname = sun_bogus_ifdef;
4068 files = "hsfs/hsfs_spec.h";
4069 files = "hsfs/iso_spec.h";
4070 select = '#ifdef(.*\|\|.*)';
4071 c_fix = format;
4072 c_fix_arg = "#if%1";
4074 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4078 * Fix the CAT macro in SunOS memvar.h.
4080 fix = {
4081 hackname = sun_catmacro;
4082 files = pixrect/memvar.h;
4083 select = "^#define[ \t]+CAT\\(a,b\\).*";
4084 c_fix = format;
4086 c_fix_arg =
4087 "#ifdef __STDC__\n"
4088 "# define CAT(a,b) a##b\n"
4089 "#else\n%0\n#endif";
4091 test_text =
4092 "#define CAT(a,b)\ta/**/b";
4096 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4097 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4099 fix = {
4100 hackname = sun_malloc;
4101 files = malloc.h;
4102 bypass = "_CLASSIC_ANSI_TYPES";
4104 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4105 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4106 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4107 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4108 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4110 test_text =
4111 "typedef char *\tmalloc_t;\n"
4112 "int \tfree();\n"
4113 "char*\tmalloc();\n"
4114 "char*\tcalloc();\n"
4115 "char*\trealloc();";
4119 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4121 fix = {
4122 hackname = sun_rusers_semi;
4123 files = rpcsvc/rusers.h;
4124 select = "_cnt$";
4125 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4126 test_text = "struct mumble\n int _cnt\n};";
4130 * signal.h on SunOS defines signal using (),
4131 * which causes trouble when compiling with g++ -pedantic.
4133 fix = {
4134 hackname = sun_signal;
4135 files = sys/signal.h;
4136 files = signal.h;
4137 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4139 c_fix = format;
4140 c_fix_arg =
4141 "#ifdef __cplusplus\n"
4142 "void\t(*signal(...))(...);\n"
4143 "#else\n%0\n#endif";
4145 test_text = "void\t(*signal())();";
4149 * Correct the return type for strlen in strings.h in SunOS 4.
4151 fix = {
4152 hackname = sunos_strlen;
4153 files = strings.h;
4154 select = "int[ \t]*strlen\\(\\);(.*)";
4155 c_fix = format;
4156 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4157 test_text = " int\tstrlen(); /* string length */";
4161 * Linux kernel's vt.h breaks C++
4163 fix = {
4164 hackname = suse_linux_vt_cxx;
4165 files = linux/vt.h;
4167 select = "^[ \t]*unsigned int new;";
4168 c_fix = format;
4169 c_fix_arg = "unsigned int newev;";
4171 test_text = " unsigned int new; /* New console (if changing) */";
4175 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4176 * that is visible to any ANSI compiler using this include. Simply
4177 * delete the lines that #define some string functions to internal forms.
4179 fix = {
4180 hackname = svr4_disable_opt;
4181 files = string.h;
4182 select = '#define.*__std_hdr_';
4183 sed = '/#define.*__std_hdr_/d';
4184 test_text = "#define strlen __std_hdr_strlen\n";
4188 * Fix broken decl of getcwd present on some svr4 systems.
4190 fix = {
4191 hackname = svr4_getcwd;
4192 files = stdlib.h;
4193 files = unistd.h;
4194 files = prototypes.h;
4195 select = 'getcwd\(char \*, int\)';
4197 c_fix = format;
4198 c_fix_arg = "getcwd(char *, size_t)";
4200 test_text = "extern char* getcwd(char *, int);";
4204 * Fix broken decl of profil present on some svr4 systems.
4206 fix = {
4207 hackname = svr4_profil;
4208 files = stdlib.h;
4209 files = unistd.h;
4211 select =
4212 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4213 c_fix = format;
4214 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4216 test_text =
4217 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4221 * Correct types for signal handler constants like SIG_DFL; they might be
4222 * void (*) (), and should be void (*) (int). C++ doesn't like the
4223 * old style.
4225 fix = {
4226 hackname = svr4_sighandler_type;
4227 files = sys/signal.h;
4228 select = 'void *\(\*\)\(\)';
4229 c_fix = format;
4230 c_fix_arg = "void (*)(int)";
4231 test_text = "#define SIG_DFL (void(*)())0\n"
4232 "#define SIG_IGN (void (*)())0\n";
4236 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4237 * function 'getrnge' in <regexp.h> before they declare it. For these
4238 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4239 * early on.
4241 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4242 * so put the declaration right after the declaration of 'size'.
4244 * Don't do this if there is already a `static void getrnge' declaration
4245 * present, since this would cause a redeclaration error. Solaris 2.x has
4246 * such a declaration.
4248 fix = {
4249 hackname = svr4_undeclared_getrnge;
4250 files = regexp.h;
4251 select = "getrnge";
4252 bypass = "static void getrnge";
4253 c_fix = format;
4254 c_fix_arg = "%0\n"
4255 "static int getrnge ();";
4256 c_fix_arg = "^static int[ \t]+size;";
4257 test_text = "static int size;\n"
4258 "/* stuff which calls getrnge() */\n"
4259 "static getrnge()\n"
4260 "{}";
4264 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4265 * in string.h on sysV68
4266 * Correct the return type for strlen in string.h on Lynx.
4267 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4268 * Add missing const for strdup on OSF/1 V3.0.
4269 * On sysV88 layout is slightly different.
4271 fix = {
4272 hackname = sysv68_string;
4273 files = testing.h;
4274 files = string.h;
4275 bypass = "_CLASSIC_ANSI_TYPES";
4277 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4278 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4279 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4281 sed = "/^extern char$/N";
4282 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4284 sed = "/^extern int$/N";
4285 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4287 sed = "/^\tstrncmp(),$/N";
4288 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4289 '\1;' "\\\nextern unsigned int\\\n\\2/";
4291 test_text =
4292 "extern int strlen();\n"
4294 "extern int ffs(long);\n"
4296 "extern char\n"
4297 "\t*memccpy(),\n"
4298 "\tmemcpy();\n"
4300 "extern int\n"
4301 "\tstrcmp(),\n"
4302 "\tstrncmp(),\n"
4303 "\tstrlen(),\n"
4304 "\tstrspn();\n"
4306 "extern int\n"
4307 "\tstrlen(), strspn();";
4311 * Fix return type of calloc, malloc, realloc, bsearch and exit
4313 fix = {
4314 hackname = sysz_stdlib_for_sun;
4315 files = stdlib.h;
4316 bypass = "_CLASSIC_ANSI_TYPES";
4318 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4319 c_fix = format;
4320 c_fix_arg = "void *\t%1(";
4322 test_text =
4323 "extern char*\tcalloc(size_t);\n"
4324 "extern char*\tmalloc(size_t);\n"
4325 "extern char*\trealloc(void*,size_t);\n"
4326 "extern char*\tbsearch(void*,size_t,size_t);\n";
4330 * __thread is now a keyword.
4332 fix = {
4333 hackname = thread_keyword;
4334 files = "pthread.h";
4335 files = bits/sigthread.h, '*/bits/sigthread.h';
4336 select = "([* ])__thread([,)])";
4337 c_fix = format;
4338 c_fix_arg = "%1__thr%2";
4340 test_text =
4341 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4342 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4343 "extern int pthread_cancel (pthread_t __thread);";
4347 * if the #if says _cplusplus, not the double underscore __cplusplus
4348 * that it should be
4350 fix = {
4351 hackname = tinfo_cplusplus;
4352 files = tinfo.h;
4353 select = "[ \t]_cplusplus";
4355 c_fix = format;
4356 c_fix_arg = " __cplusplus";
4357 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4361 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4363 fix = {
4364 hackname = ultrix_const;
4365 files = stdio.h;
4366 select = 'perror\( char \*';
4368 c_fix = format;
4369 c_fix_arg = "%1 const %3 *__";
4370 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4371 "[ \t]+(char|void) \\*__";
4373 test_text =
4374 "extern void perror( char *__s );\n"
4375 "extern int fputs( char *__s, FILE *);\n"
4376 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4377 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4378 "extern int scanf( char *__format, ...);\n";
4382 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4384 fix = {
4385 hackname = ultrix_const2;
4386 files = stdio.h;
4388 select = '\*fopen\( char \*';
4389 c_fix = format;
4390 c_fix_arg = "%1( const char *%3, const char *";
4391 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4392 "[ \t]*char[ \t]*\\*([^,]*),"
4393 "[ \t]*char[ \t]*\\*[ \t]*";
4395 test_text =
4396 "extern FILE *fopen( char *__filename, char *__type );\n"
4397 "extern int sscanf( char *__s, char *__format, ...);\n"
4398 "extern FILE *popen(char *, char *);\n"
4399 "extern char *tempnam(char*,char*);\n";
4403 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4405 fix = {
4406 hackname = va_i960_macro;
4407 files = arch/i960/archI960.h;
4408 select = "__(vsiz|vali|vpad|alignof__)";
4410 c_fix = format;
4411 c_fix_arg = "__vx%1";
4413 test_text =
4414 "extern int __vsiz vsiz;\n"
4415 "extern int __vali vali;\n"
4416 "extern int __vpad vpad;\n"
4417 "#define __alignof__(x) ...";
4421 * On VMS, add missing braces around sigset_t constants.
4423 fix = {
4424 hackname = vms_add_missing_braces;
4425 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4426 mach = "*-*-*vms*";
4427 files = "rtldef/signal.h";
4428 c_fix = format;
4430 c_fix_arg = '%1 {%2} ';
4432 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4433 "{0x00000000, 0x00000000},\n"
4434 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4438 * On VMS, some DEC-C builtins are directly used.
4440 fix = {
4441 hackname = vms_decc_builtin;
4442 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4443 mach = "*-*-*vms*";
4444 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4445 rtldef/socket.h;
4446 sed = "s@__MEMSET@memset@";
4447 sed = "s@__MEMMOVE@memmove@";
4448 sed = "s@__MEMCPY@memcpy@";
4449 sed = "s@__STRLEN@strlen@";
4450 sed = "s@__STRCPY@strcpy@";
4452 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4456 * Define __CAN_USE_EXTERN_PREFIX on vms.
4458 fix = {
4459 hackname = vms_define_can_use_extern_prefix;
4460 files = "rtldef/decc$types.h";
4461 select = "#[ \t]*else\n"
4462 "#[ \t]*if defined\\(__DECCXX\\)\n"
4463 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4464 mach = "*-*-*vms*";
4465 c_fix = format;
4467 c_fix_arg = "%0"
4468 "# elif defined (__GNUC__)\n"
4469 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4471 test_text = "# else\n"
4472 "# if defined(__DECCXX)\n"
4473 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4474 "# endif\n"
4475 "# endif\n";
4479 * On VMS, disable the use of dec-c string builtins
4481 fix = {
4482 hackname = vms_disable_decc_string_builtins;
4483 select = "#if !defined\\(__VAX\\)\n";
4484 mach = "*-*-*vms*";
4485 files = "rtldef/string.h";
4486 c_fix = format;
4488 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4490 test_text = "#if !defined(__VAX)\n";
4494 * On VMS, fix incompatible redeclaration of hostalias.
4496 fix = {
4497 hackname = vms_do_not_redeclare_hostalias;
4498 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4499 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4500 mach = "*-*-*vms*";
4501 files = "rtldef/resolv.h";
4502 c_fix = format;
4504 c_fix_arg = "%1\n"
4505 "/* %2 */";
4507 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4508 "__char_ptr32 hostalias (const char *);\n";
4512 * On VMS, forward declare structure before referencing them in prototypes.
4514 fix = {
4515 hackname = vms_forward_declare_struct;
4516 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4517 "#ifdef __cplusplus\n";
4518 mach = "*-*-*vms*";
4519 files = rtldef/if.h;
4520 c_fix = format;
4522 c_fix_arg = "%1"
4523 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4525 test_text = "/* forward decls for C++ */\n"
4526 "#ifdef __cplusplus\n"
4527 "struct foo;\n"
4528 "#endif\n";
4532 * On VMS, do not declare getopt and al if pointers are 64 bit.
4534 fix = {
4535 hackname = vms_no_64bit_getopt;
4536 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4537 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4538 mach = "*-*-*vms*";
4539 files = rtldef/stdio.h, rtldef/unistd.h;
4540 c_fix = format;
4542 c_fix_arg = <<- _EOArg_
4543 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4544 %0#endif
4546 _EOArg_;
4548 test_text = "int getopt (int, char * const [], const char *);";
4552 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4553 * which is not yet fully supported by gcc.
4555 fix = {
4556 hackname = vms_use_fast_setjmp;
4557 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4558 mach = "*-*-*vms*";
4559 files = rtldef/setjmp.h;
4560 c_fix = format;
4562 c_fix_arg = "%0 defined (__GNUC__) ||";
4564 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4568 * On VMS, use pragma extern_model instead of VAX-C keywords.
4570 fix = {
4571 hackname = vms_use_pragma_extern_model;
4572 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4573 "# pragma extern_model __save\n";
4574 mach = "*-*-*vms*";
4575 c_fix = format;
4577 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4578 "# pragma extern_model __save\n";
4580 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4581 "# pragma extern_model __save\n"
4582 "# pragma extern_model strict_refdef\n"
4583 " extern struct x zz$yy;\n"
4584 "# pragma extern_model __restore\n"
4585 "#endif\n";
4589 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4590 * conflict while building gcc. Likewise for <builtins.h>
4592 fix = {
4593 hackname = vms_use_quoted_include;
4594 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4595 mach = "*-*-*vms*";
4596 files = rtldef/wait.h, starlet_c/pthread.h;
4597 c_fix = format;
4599 c_fix_arg = '%1<sys/%2.h>';
4601 test_text = "# include <resource.h>";
4605 * AIX and Interix headers define NULL to be cast to a void pointer,
4606 * which is illegal in ANSI C++.
4608 fix = {
4609 hackname = void_null;
4610 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4611 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4612 /* avoid changing C++ friendly NULL */
4613 bypass = __cplusplus;
4614 bypass = __null;
4615 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4616 c_fix = format;
4617 c_fix_arg = <<- _EOFix_
4618 #ifndef NULL
4619 #ifdef __cplusplus
4620 #ifdef __GNUG__
4621 #define NULL __null
4622 #else /* ! __GNUG__ */
4623 #define NULL 0L
4624 #endif /* __GNUG__ */
4625 #else /* ! __cplusplus */
4626 #define NULL ((void *)0)
4627 #endif /* __cplusplus */
4628 #endif /* !NULL */
4629 _EOFix_;
4630 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4634 * Make VxWorks header which is almost gcc ready fully gcc ready.
4636 fix = {
4637 hackname = vxworks_gcc_problem;
4638 files = types/vxTypesBase.h;
4639 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4641 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4642 "#if 1/";
4644 sed = "/[ \t]size_t/i\\\n"
4645 "#ifndef _GCC_SIZE_T\\\n"
4646 "#define _GCC_SIZE_T\n";
4648 sed = "/[ \t]size_t/a\\\n"
4649 "#endif\n";
4651 sed = "/[ \t]ptrdiff_t/i\\\n"
4652 "#ifndef _GCC_PTRDIFF_T\\\n"
4653 "#define _GCC_PTRDIFF_T\n";
4655 sed = "/[ \t]ptrdiff_t/a\\\n"
4656 "#endif\n";
4658 sed = "/[ \t]wchar_t/i\\\n"
4659 "#ifndef _GCC_WCHAR_T\\\n"
4660 "#define _GCC_WCHAR_T\n";
4662 sed = "/[ \t]wchar_t/a\\\n"
4663 "#endif\n";
4665 test_text =
4666 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4667 "typedef unsigned int size_t;\n"
4668 "typedef long ptrdiff_t;\n"
4669 "typedef unsigned short wchar_t;\n"
4670 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4674 * Wrap VxWorks ioctl to keep everything pretty
4676 fix = {
4677 hackname = vxworks_ioctl_macro;
4678 files = ioLib.h;
4679 mach = "*-*-vxworks*";
4681 c_fix = format;
4682 c_fix_arg = "%0\n"
4683 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4684 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4686 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4690 * Wrap VxWorks mkdir to be posix compliant
4692 fix = {
4693 hackname = vxworks_mkdir_macro;
4694 files = sys/stat.h;
4695 mach = "*-*-vxworks*";
4697 c_fix = format;
4698 c_fix_arg = "%0\n"
4699 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4700 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4701 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4702 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4703 "\\)[\t ]*;";
4705 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4709 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4711 fix = {
4712 hackname = vxworks_needs_vxtypes;
4713 files = time.h;
4714 select = "uint_t([ \t]+_clocks_per_sec)";
4715 c_fix = format;
4716 c_fix_arg = "unsigned int%1";
4717 test_text = "uint_t\t_clocks_per_sec;";
4721 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4723 fix = {
4724 hackname = vxworks_needs_vxworks;
4725 files = sys/stat.h;
4726 test = " -r types/vxTypesOld.h";
4727 test = " -n \"`egrep '#include' $file`\"";
4728 test = " -n \"`egrep ULONG $file`\"";
4729 select = "#[ \t]define[ \t]+__INCstath";
4731 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4732 "#include <types/vxTypesOld.h>\n";
4734 test_text = "`touch types/vxTypesOld.h`"
4735 "#include </dev/null> /* ULONG */\n"
4736 "# define\t__INCstath <sys/stat.h>";
4740 * Make it so VxWorks does not include gcc/regs.h accidentally
4742 fix = {
4743 hackname = vxworks_regs;
4744 mach = "*-*-vxworks*";
4746 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4747 c_fix = format;
4748 c_fix_arg = "#include <arch/../regs.h>";
4750 test_text = "#include <regs.h>\n";
4754 * Another bad dependency in VxWorks 5.2 <time.h>.
4756 fix = {
4757 hackname = vxworks_time;
4758 files = time.h;
4759 test = " -r vxWorks.h";
4761 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4762 c_fix = format;
4764 c_fix_arg =
4765 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4766 "#ifdef __cplusplus\n"
4767 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4768 "#else\n"
4769 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4770 "#endif\n"
4771 "#define __gcc_VOIDFUNCPTR_defined\n"
4772 "#endif\n"
4773 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4775 test_text = "`touch vxWorks.h`"
4776 "#define VOIDFUNCPTR (void(*)())";
4780 * This hack makes write const-correct on VxWorks
4782 fix = {
4783 hackname = vxworks_write_const;
4784 files = ioLib.h;
4785 mach = "*-*-vxworks*";
4787 c_fix = format;
4788 c_fix_arg = "extern int write (int, const char*, size_t);";
4789 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4790 "[\t ]*int[\t ]*,"
4791 "[\t ]*char[\t ]*\\*[\t ]*,"
4792 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4794 test_text = "extern int write ( int , char * , size_t ) ;";
4798 * There are several name conflicts with C++ reserved words in X11 header
4799 * files. These are fixed in some versions, so don't do the fixes if
4800 * we find __cplusplus in the file. These were found on the RS/6000.
4802 fix = {
4803 hackname = x11_class;
4804 files = X11/ShellP.h;
4805 bypass = __cplusplus;
4806 select = "^([ \t]*char \\*)class;(.*)";
4807 c_fix = format;
4808 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4809 "#else\n%1class;%2\n#endif";
4810 test_text =
4811 "struct {\n"
4812 " char *class;\n"
4813 "} mumble;\n";
4817 * class in Xm/BaseClassI.h
4819 fix = {
4820 hackname = x11_class_usage;
4821 files = Xm/BaseClassI.h;
4822 bypass = "__cplusplus";
4824 select = " class\\)";
4825 c_fix = format;
4826 c_fix_arg = " c_class)";
4828 test_text = "extern mumble (int class);\n";
4832 * new in Xm/Traversal.h
4834 fix = {
4835 hackname = x11_new;
4836 files = Xm/Traversal.h;
4837 bypass = __cplusplus;
4839 sed = "/Widget\told, new;/i\\\n"
4840 "#ifdef __cplusplus\\\n"
4841 "\\\tWidget\told, c_new;\\\n"
4842 "#else\n";
4844 sed = "/Widget\told, new;/a\\\n"
4845 "#endif\n";
4847 sed = "s/Widget new,/Widget c_new,/g";
4848 test_text =
4849 "struct wedge {\n"
4850 " Widget\told, new;\n"
4851 "};\nextern Wedged( Widget new, Widget old );";
4855 * Incorrect sprintf declaration in X11/Xmu.h
4857 fix = {
4858 hackname = x11_sprintf;
4859 files = X11/Xmu.h;
4860 files = X11/Xmu/Xmu.h;
4861 select = "^extern char \\*\tsprintf\\(\\);$";
4863 c_fix = format;
4864 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4866 test_text = "extern char *\tsprintf();";
4868 /*EOF*/