gcc:
[official-gcc.git] / fixincludes / inclhack.def
blob4ce8b16e0a63c623e88732168678d649ae26080a
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 #ifdef _ASSERT_H
381 #undef _ASSERT_H
382 #undef assert
383 #endif
385 #define _ASSERT_H
387 #ifdef __cplusplus
388 extern "C" {
389 #endif
391 #if defined(__STDC__) || defined(__cplusplus)
392 extern void __assert (const char*);
393 #else
394 extern void __assert ();
395 #endif
397 #ifdef NDEBUG
398 #define assert(ign) ((void)0)
399 #else
401 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
402 #define ASSERT_STRINGIFY_HELPER(str) #str
404 #define assert(test) ((void) \
405 ((test) ? ((void)0) : \
406 __assert("Assertion failed: " #test ", file " \
407 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
409 #endif
411 #ifdef __cplusplus
413 #endif
414 _EndOfHeader_;
418 * Add needed include to regs.h (NOT the gcc header) on VxWorks
421 fix = {
422 hackname = AAB_vxworks_regs_vxtypes;
423 files = regs.h;
424 mach = "*-*-vxworks*";
426 replace = <<- _EndOfHeader_
427 #ifndef _REGS_H
428 #define _REGS_H
429 #include <types/vxTypesOld.h>
430 #include_next <arch/../regs.h>
431 #endif
432 _EndOfHeader_;
436 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
438 fix = {
439 hackname = AAB_vxworks_unistd;
440 files = unistd.h;
441 mach = "*-*-vxworks*";
443 replace = <<- _EndOfHeader_
444 #ifndef _UNISTD_H
445 #define _UNISTD_H
446 #include_next <unistd.h>
447 #include <ioLib.h>
448 #ifndef STDIN_FILENO
449 #define STDIN_FILENO 0
450 #endif
451 #ifndef STDOUT_FILENO
452 #define STDOUT_FILENO 1
453 #endif
454 #ifndef STDERR_FILENO
455 #define STDERR_FILENO 2
456 #endif
457 #endif /* _UNISTD_H */
458 _EndOfHeader_;
462 * assert.h on AIX 7 redefines static_assert as _Static_assert without
463 * protecting C++.
465 fix = {
466 hackname = aix_assert;
467 mach = "*-*-aix*";
468 files = assert.h;
469 select = "#define[ \t]static_assert[ \t]_Static_assert";
470 c_fix = format;
471 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
472 test_text = "#define static_assert _Static_assert";
476 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
477 * which only is provided by AIX xlc C99.
479 fix = {
480 hackname = aix_complex;
481 mach = "*-*-aix*";
482 files = complex.h;
483 select = "#define[ \t]_Complex_I[ \t]__I";
484 c_fix = format;
485 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
486 test_text = "#define _Complex_I __I\n";
490 * On AIX some headers are not properly guarded by 'extern "C"'.
492 fix = {
493 hackname = aix_externc;
494 mach = "*-*-aix*";
495 files = ctype.h;
496 files = fcntl.h;
497 files = langinfo.h;
498 files = ldfcn.h;
499 files = sys/localedef.h;
500 files = sys/times.h;
501 bypass = "extern \"C\"";
502 c_fix = wrap;
503 c_fix_arg = "#ifdef __cplusplus\n"
504 "extern \"C\" {\n"
505 "#endif\n";
506 c_fix_arg = "#ifdef __cplusplus\n"
507 "}\n"
508 "#endif\n";
509 test_text = "extern int __n_pthreads;\n";
513 * On AIX sys/socket.h assumes C++.
515 fix = {
516 hackname = aix_externcpp1;
517 mach = "*-*-aix*";
518 files = "sys/socket.h";
519 select = "#ifdef __cplusplus";
520 c_fix = format;
521 c_fix_arg = "#ifdef __cplusplus\n"
522 "extern \"C++\" {";
523 test_text = "#ifdef __cplusplus";
527 fix = {
528 hackname = aix_externcpp2;
529 mach = "*-*-aix*";
530 files = "sys/socket.h";
531 select = "#else /\\* __cplusplus \\*/";
532 c_fix = format;
533 c_fix_arg = "} /* extern \"C++\" */\n"
534 "#else /* __cplusplus */";
535 test_text = "#else /* __cplusplus */";
540 * malloc.h on AIX6 uses XLC++ specific builtin syntax
542 fix = {
543 hackname = aix_malloc;
544 mach = "*-*-aix*";
545 files = "malloc.h";
546 select = "#ifdef __cplusplus";
547 c_fix = format;
548 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
549 test_text = "#ifdef __cplusplus";
553 * net/if_arp.h defines a variable fc_softc instead of adding a
554 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
556 fix = {
557 hackname = aix_net_if_arp;
558 mach = "*-*-aix*";
559 files = "net/if_arp.h";
560 select = "^struct fc_softc \\{";
561 c_fix = format;
562 c_fix_arg = "typedef struct _fc_softc {";
563 test_text = "struct fc_softc {\n int a;\n};";
567 * Fix AIX definition of NULL for G++.
569 fix = {
570 hackname = aix_null;
571 mach = "*-*-aix*";
572 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
573 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
574 bypass = __null;
575 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
576 c_fix = format;
577 c_fix_arg = <<- _EOFix_
578 #ifndef NULL
579 #ifdef __cplusplus
580 #ifdef __GNUG__
581 #define NULL __null
582 #else /* ! __GNUG__ */
583 #define NULL 0L
584 #endif /* __GNUG__ */
585 #else /* ! __cplusplus */
586 #define NULL ((void *)0)
587 #endif /* __cplusplus */
588 #endif /* !NULL */
589 _EOFix_;
590 test_text = "# define\tNULL \t(0L) /* typed NULL */";
594 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
595 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
596 * braces.
598 fix = {
599 hackname = aix_once_init_1;
600 mach = "*-*-aix*";
601 files = "pthread.h";
602 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
603 "\\{ \\\\\n";
604 c_fix = format;
605 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
606 "{{ \\\n";
607 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
608 "{ \\\\\n";
611 fix = {
612 hackname = aix_once_init_2;
613 mach = "*-*-aix*";
614 files = "pthread.h";
615 select = "[ \t]0 \\\\\n"
616 "\\}\n";
617 c_fix = format;
618 c_fix_arg = " 0 \\\n"
619 "}}\n";
620 test_text = " 0 \\\\\n"
621 "}\n";
624 fix = {
625 hackname = aix_mutex_initializer_1;
626 mach = "*-*-aix*";
627 files = "pthread.h";
628 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
629 "\\{ \\\\\n";
630 c_fix = format;
631 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
632 "{{ \\\n";
633 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
634 "{ \\\\\n";
637 fix = {
638 hackname = aix_cond_initializer_1;
639 mach = "*-*-aix*";
640 files = "pthread.h";
641 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
642 "\\{ \\\\\n";
643 c_fix = format;
644 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
645 "{{ \\\n";
646 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
647 "{ \\\\\n";
650 fix = {
651 hackname = aix_rwlock_initializer_1;
652 mach = "*-*-aix*";
653 files = "pthread.h";
654 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
655 "\\{ \\\\\n";
656 c_fix = format;
657 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
658 "{{ \\\n";
659 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
660 "{ \\\\\n";
664 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
665 * which violates a requirement of ISO C.
667 fix = {
668 hackname = aix_pthread;
669 files = "pthread.h";
670 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
671 c_fix = format;
672 c_fix_arg = "%1 %2";
673 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
674 "{...init stuff...}";
678 * AIX stdint.h fixes.
680 fix = {
681 hackname = aix_stdint_1;
682 mach = "*-*-aix*";
683 files = stdint-aix.h, stdint.h;
684 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
685 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
686 c_fix = format;
687 c_fix_arg = "#define UINT8_MAX (255)\n"
688 "#define UINT16_MAX (65535)";
689 test_text = "#define UINT8_MAX (255U)\n"
690 "#define UINT16_MAX (65535U)";
694 * aix_stdint_2
696 fix = {
697 hackname = aix_stdint_2;
698 mach = "*-*-aix*";
699 files = stdint-aix.h, stdint.h;
700 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
701 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
702 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
703 "#else\n"
704 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
705 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
706 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
707 c_fix = format;
708 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
709 "#define INTPTR_MAX 9223372036854775807L\n"
710 "#define UINTPTR_MAX 18446744073709551615UL\n"
711 "#else\n"
712 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
713 "#define INTPTR_MAX 2147483647L\n"
714 "#define UINTPTR_MAX 4294967295UL";
715 test_text = "#define INTPTR_MIN INT64_MIN\n"
716 "#define INTPTR_MAX INT64_MAX\n"
717 "#define UINTPTR_MAX UINT64_MAX\n"
718 "#else\n"
719 "#define INTPTR_MIN INT32_MIN\n"
720 "#define INTPTR_MAX INT32_MAX\n"
721 "#define UINTPTR_MAX UINT32_MAX";
725 * aix_stdint_3
727 fix = {
728 hackname = aix_stdint_3;
729 mach = "*-*-aix*";
730 files = stdint-aix.h, stdint.h;
731 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
732 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
733 "#else\n"
734 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
735 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
736 c_fix = format;
737 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
738 "#define PTRDIFF_MAX 9223372036854775807L\n"
739 "#else\n"
740 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
741 "#define PTRDIFF_MAX 2147483647L";
742 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
743 "#define PTRDIFF_MAX INT64_MAX\n"
744 "#else\n"
745 "#define PTRDIFF_MIN INT32_MIN\n"
746 "#define PTRDIFF_MAX INT32_MAX";
750 * aix_stdint_4
752 fix = {
753 hackname = aix_stdint_4;
754 mach = "*-*-aix*";
755 files = stdint-aix.h, stdint.h;
756 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
757 "#else\n"
758 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
759 c_fix = format;
760 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
761 "#else\n"
762 "#define SIZE_MAX 4294967295UL";
763 test_text = "#define SIZE_MAX UINT64_MAX\n"
764 "#else\n"
765 "#define SIZE_MAX UINT32_MAX";
769 * aix_stdint_5
771 fix = {
772 hackname = aix_stdint_5;
773 mach = "*-*-aix*";
774 files = stdint-aix.h, stdint.h;
775 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
776 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
777 c_fix = format;
778 c_fix_arg = "#define UINT8_C(c) c\n"
779 "#define UINT16_C(c) c";
780 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
781 "#define UINT16_C(c) __CONCAT__(c,U)";
785 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
786 produces wrong code with G++.
788 fix = {
789 hackname = aix_stdio_inline;
790 mach = "*-*-aix*";
791 files = stdio.h;
792 select = "#ifdef __cplusplus\\\n"
793 "}\\\n\\\n"
794 "#ifdef ferror\\\n";
795 c_fix = format;
796 c_fix_arg = "#ifdef __cplusplus\n"
797 "}\n"
798 "#endif\n\n"
799 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
800 "#ifdef ferror\n";
801 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
805 * stdlib.h on AIX uses #define on malloc and friends.
807 fix = {
808 hackname = aix_stdlib_malloc;
809 mach = "*-*-aix*";
810 files = stdlib.h;
811 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
812 c_fix = format;
813 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
814 test_text = "#define malloc __linux_malloc";
817 fix = {
818 hackname = aix_stdlib_realloc;
819 mach = "*-*-aix*";
820 files = stdlib.h;
821 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
822 c_fix = format;
823 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
824 test_text = "#define realloc __linux_realloc";
827 fix = {
828 hackname = aix_stdlib_calloc;
829 mach = "*-*-aix*";
830 files = stdlib.h;
831 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
832 c_fix = format;
833 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
834 test_text = "#define calloc __linux_calloc";
837 fix = {
838 hackname = aix_stdlib_valloc;
839 mach = "*-*-aix*";
840 files = stdlib.h;
841 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
842 c_fix = format;
843 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
844 test_text = "#define valloc __linux_valloc";
847 fix = {
848 hackname = aix_stdlib_vec_malloc;
849 mach = "*-*-aix*";
850 files = stdlib.h;
851 select = "#define[ \t]+malloc[ \t]+vec_malloc";
852 c_fix = format;
853 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
854 test_text = "#define malloc vec_malloc";
857 fix = {
858 hackname = aix_stdlib_vec_calloc;
859 mach = "*-*-aix*";
860 files = stdlib.h;
861 select = "#define[ \t]+calloc[ \t]+vec_calloc";
862 c_fix = format;
863 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
864 test_text = "#define calloc vec_calloc";
868 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
870 fix = {
871 hackname = aix_strtof_const;
872 mach = "*-*-aix*";
873 files = stdlib.h;
874 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
875 c_fix = format;
876 c_fix_arg = "%1(const char *, char **);";
877 test_text = "extern float strtof(char *, char **);";
881 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
882 * in an otherwise harmless (and #ifed out) macro definition
884 fix = {
885 hackname = aix_sysmachine;
886 mach = "*-*-aix*";
887 files = sys/machine.h;
888 select = "\\\\ +\n";
889 c_fix = format;
890 c_fix_arg = "\\\n";
891 test_text = "#define FOO \\\n"
892 " bar \\ \n baz \\ \n bat";
896 * sys/wait.h on AIX 5.2 defines macros that have both signed and
897 * unsigned types in conditional expressions.
899 fix = {
900 hackname = aix_syswait_2;
901 mach = "*-*-aix*";
902 files = sys/wait.h;
903 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
904 c_fix = format;
905 c_fix_arg = "? (int)%1";
906 test_text = "#define WSTOPSIG(__x) "
907 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
911 * sys/signal.h on some versions of AIX uses volatile in the typedef of
912 * sig_atomic_t, which causes gcc to generate a warning about duplicate
913 * volatile when a sig_atomic_t variable is declared volatile, as
914 * required by ANSI C.
916 fix = {
917 hackname = aix_volatile;
918 mach = "*-*-aix*";
919 files = sys/signal.h;
920 select = "typedef volatile int sig_atomic_t";
921 c_fix = format;
922 c_fix_arg = "typedef int sig_atomic_t";
923 test_text = "typedef volatile int sig_atomic_t;";
927 * AIX unistd.h defines a static function with an empty parameter list.
929 fix = {
930 hackname = aix_unistd;
931 mach = "*-*-aix*";
932 files = unistd.h;
934 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
935 c_fix = format;
936 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
937 test_text = " static int getdtablesize()";
941 * Fix __assert declaration in assert.h on Alpha OSF/1.
943 fix = {
944 hackname = alpha___assert;
945 files = "assert.h";
946 select = '__assert\(char \*, char \*, int\)';
947 c_fix = format;
948 c_fix_arg = "__assert(const char *, const char *, int)";
949 test_text = 'extern void __assert(char *, char *, int);';
953 * Fix assert macro in assert.h on Alpha OSF/1.
954 * The superfluous int cast breaks C++.
956 fix = {
957 hackname = alpha_assert;
958 files = "assert.h";
959 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
960 c_fix = format;
961 c_fix_arg = "%1(EX)";
962 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
963 ': __assert(#EX, __FILE__, __LINE__))';
967 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
969 fix = {
970 hackname = alpha_getopt;
971 files = "stdio.h";
972 files = "stdlib.h";
973 select = 'getopt\(int, char \*\[\], *char \*\)';
974 c_fix = format;
975 c_fix_arg = "getopt(int, char *const[], const char *)";
976 test_text = 'extern int getopt(int, char *[], char *);';
980 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
982 fix = {
983 hackname = alpha_if_semicolon;
984 files = net/if.h;
985 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
986 c_fix = format;
987 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
988 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
992 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
994 fix = {
995 hackname = alpha_parens;
996 files = sym.h;
997 select = '#ifndef\(__mips64\)';
998 c_fix = format;
999 c_fix_arg = "#ifndef __mips64";
1000 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1004 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1005 * And OpenBSD.
1007 fix = {
1008 hackname = alpha_sbrk;
1009 files = unistd.h;
1010 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1011 c_fix = format;
1012 c_fix_arg = "void *sbrk(";
1013 test_text = "extern char* sbrk(ptrdiff_t increment);";
1017 * For C++, avoid any typedef or macro definition of bool,
1018 * and use the built in type instead.
1019 * HP/UX 10.20 also has it in curses_colr/curses.h.
1021 fix = {
1022 hackname = avoid_bool_define;
1023 files = curses.h;
1024 files = curses_colr/curses.h;
1025 files = term.h;
1026 files = tinfo.h;
1028 select = "#[ \t]*define[ \t]+bool[ \t]";
1029 bypass = "__cplusplus";
1031 c_fix = format;
1032 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1033 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1035 test_text = "# define bool\t char \n";
1039 * avoid_bool_type
1041 fix = {
1042 hackname = avoid_bool_type;
1043 files = curses.h;
1044 files = curses_colr/curses.h;
1045 files = term.h;
1046 files = tinfo.h;
1048 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1049 bypass = "__cplusplus";
1051 c_fix = format;
1052 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1054 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1058 * For C++, avoid any typedef definition of wchar_t,
1059 * and use the built in type instead.
1060 * Don't do this for headers that are smart enough to do the right
1061 * thing (recent [n]curses.h and Xlib.h).
1062 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1063 * and will be broken by the edit.
1066 fix = {
1067 hackname = avoid_wchar_t_type;
1069 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1070 bypass = "__cplusplus";
1071 bypass = "_LINUX_NLS_H";
1072 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1074 c_fix = format;
1075 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1077 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1081 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1083 fix = {
1084 hackname = bad_struct_term;
1085 files = curses.h;
1086 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1087 c_fix = format;
1088 c_fix_arg = "struct term;";
1090 test_text = 'typedef struct term;';
1094 * Fix one other error in this file:
1095 * a mismatched quote not inside a C comment.
1097 fix = {
1098 hackname = badquote;
1099 files = sundev/vuid_event.h;
1100 select = "doesn't";
1101 c_fix = format;
1102 c_fix_arg = "does not";
1104 test_text = "/* doesn't have matched single quotes */";
1108 * check for broken assert.h that needs stdio.h
1110 fix = {
1111 hackname = broken_assert_stdio;
1112 files = assert.h;
1113 select = stderr;
1114 bypass = "include.*stdio\\.h";
1115 c_fix = wrap;
1116 c_fix_arg = "#include <stdio.h>\n";
1117 test_text = "extern FILE* stderr;";
1121 * check for broken assert.h that needs stdlib.h
1123 fix = {
1124 hackname = broken_assert_stdlib;
1125 files = assert.h;
1126 select = 'exit *\(|abort *\(';
1127 bypass = "include.*stdlib\\.h";
1128 c_fix = wrap;
1129 c_fix_arg = "#ifdef __cplusplus\n"
1130 "#include <stdlib.h>\n"
1131 "#endif\n";
1132 test_text = "extern void exit ( int );";
1136 * Remove `extern double cabs' declarations from math.h.
1137 * This conflicts with C99. Discovered on AIX.
1138 * Darwin hides its broken cabs in architecture-specific subdirs.
1140 fix = {
1141 hackname = broken_cabs;
1142 files = math.h, "architecture/*/math.h";
1143 select = "^extern[ \t]+double[ \t]+cabs";
1145 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1146 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1148 test_text = "#ifdef __STDC__\n"
1149 "extern double cabs(struct dbl_hypot);\n"
1150 "#else\n"
1151 "extern double cabs();\n"
1152 "#endif\n"
1153 "extern double cabs ( _Complex z );";
1157 * Fixup Darwin's broken check for __builtin_nanf.
1159 fix = {
1160 hackname = broken_nan;
1162 * It is tempting to omit the first "files" entry. Do not.
1163 * The testing machinery will take the first "files" entry as the name
1164 * of a test file to play with. It would be a nuisance to have a directory
1165 * with the name "*".
1167 files = "architecture/ppc/math.h";
1168 files = "architecture/*/math.h";
1169 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1170 bypass = "powl";
1171 c_fix = format;
1172 c_fix_arg = "#if 1";
1173 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1177 * Various systems derived from BSD4.4 contain a macro definition
1178 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1179 * Known to be fixed in FreeBSD 5 system headers.
1181 fix = {
1182 hackname = bsd_stdio_attrs_conflict;
1183 mach = "*-*-*bsd*";
1184 mach = "*-*-*darwin*";
1185 files = stdio.h;
1186 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1187 c_fix = format;
1188 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1189 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1190 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1191 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1192 test_text = '#define vfscanf __svfscanf';
1196 * Fix various macros used to define ioctl numbers.
1197 * The traditional syntax was:
1199 * #define _CTRL(n, x) (('n'<<8)+x)
1200 * #define TCTRLCFOO _CTRL(T, 1)
1202 * but this does not work with the C standard, which disallows macro
1203 * expansion inside strings. We have to rewrite it thus:
1205 * #define _CTRL(n, x) ((n<<8)+x)
1206 * #define TCTRLCFOO _CTRL('T', 1)
1208 * The select expressions match too much, but the c_fix code is cautious.
1210 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1212 fix = {
1213 hackname = ctrl_quotes_def;
1214 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1215 c_fix = char_macro_def;
1216 c_fix_arg = "CTRL";
1219 * This is two tests in order to ensure that the "CTRL(c)" can
1220 * be selected in isolation from the multi-arg format
1222 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1223 test_text = "#define _CTRL(c) ('c'&037)";
1227 * Fix various macros used to define ioctl numbers.
1229 fix = {
1230 hackname = ctrl_quotes_use;
1231 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1232 c_fix = char_macro_use;
1233 c_fix_arg = "CTRL";
1234 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1238 * sys/mman.h on HP/UX is not C++ ready,
1239 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1241 * rpc/types.h on OSF1/2.0 is not C++ ready,
1242 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1244 * The problem is the declaration of malloc.
1246 fix = {
1247 hackname = cxx_unready;
1248 files = sys/mman.h;
1249 files = rpc/types.h;
1250 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1251 not within a macro. */
1252 bypass = '"C"|__BEGIN_DECLS';
1254 c_fix = wrap;
1255 c_fix_arg = "#ifdef __cplusplus\n"
1256 "extern \"C\" {\n"
1257 "#endif\n";
1258 c_fix_arg = "#ifdef __cplusplus\n"
1259 "}\n"
1260 "#endif\n";
1261 test_text = "extern void* malloc( size_t );";
1265 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1266 * unconditionally.
1268 fix = {
1269 hackname = darwin_availabilityinternal;
1270 mach = "*-*-darwin*";
1271 files = AvailabilityInternal.h;
1272 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1273 c_fix = format;
1274 c_fix_arg = <<- _EOFix_
1275 #if defined(__has_attribute)
1276 #if __has_attribute(availability)
1278 #else
1279 #define %1
1280 #endif
1281 #else
1282 #define %1
1283 #endif
1284 _EOFix_;
1286 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1287 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1291 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1292 * you have to not use "" includes.
1294 fix = {
1295 hackname = darwin_9_long_double_funcs_2;
1296 mach = "*-*-darwin7.9*";
1297 files = math.h;
1298 select = '#include[ \t]+\"';
1299 c_fix = format;
1300 c_fix_arg = "%1<%2.h>";
1302 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1304 test_text = '#include "architecture/ppc/math.h"';
1308 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1309 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1311 fix = {
1312 hackname = darwin_externc;
1313 mach = "*-*-darwin*";
1314 files = mach-o/swap.h;
1315 files = mach/mach_time.h;
1316 files = mach/mach_traps.h;
1317 files = mach/message.h;
1318 files = mach/mig.h;
1319 files = mach/semaphore.h;
1320 bypass = "extern \"C\"";
1321 bypass = "__BEGIN_DECLS";
1322 c_fix = wrap;
1323 c_fix_arg = "#ifdef __cplusplus\n"
1324 "extern \"C\" {\n"
1325 "#endif\n";
1326 c_fix_arg = "#ifdef __cplusplus\n"
1327 "}\n"
1328 "#endif\n";
1329 test_text = "extern void swap_fat_header();\n";
1333 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1334 * bad __GNUC__ tests.
1336 fix = {
1337 hackname = darwin_gcc4_breakage;
1338 mach = "*-*-darwin*";
1339 files = AvailabilityMacros.h;
1340 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1341 c_fix = format;
1342 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1343 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1344 "(__GNUC_MINOR__ >= 1)\n";
1348 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1350 fix = {
1351 hackname = darwin_longjmp_noreturn;
1352 mach = "*-*-darwin*";
1353 files = "i386/setjmp.h";
1354 bypass = "__dead2";
1355 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1356 c_fix = format;
1357 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1359 test_text = "void siglongjmp(sigjmp_buf, int);";
1363 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1365 fix = {
1366 hackname = darwin_os_trace_1;
1367 mach = "*-*-darwin*";
1368 files = os/trace.h;
1369 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1370 c_fix = format;
1371 c_fix_arg = "%1";
1372 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1376 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1377 * extension without guard.
1379 fix = {
1380 hackname = darwin_os_trace_2;
1381 mach = "*-*-darwin*";
1382 files = os/trace.h;
1383 select = "typedef.*\\^os_trace_payload_t.*";
1384 c_fix = format;
1385 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1386 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1390 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1391 * os_trace_payload_t typedef, too.
1393 fix = {
1394 hackname = darwin_os_trace_3;
1395 mach = "*-*-darwin*";
1396 files = os/trace.h;
1397 select = <<- _EOSelect_
1398 __(API|OSX)_.*
1399 OS_EXPORT.*
1401 _os_trace.*os_trace_payload_t payload);
1402 _EOSelect_;
1403 c_fix = format;
1404 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1405 test_text = <<- _EOText_
1406 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1407 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1408 void
1409 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1411 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1412 OS_EXPORT OS_NOTHROW
1413 void
1414 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1415 _EOText_;
1419 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1420 * why would you ever put it in a system header file?
1422 fix = {
1423 hackname = darwin_private_extern;
1424 mach = "*-*-darwin*";
1425 files = mach-o/dyld.h;
1426 select = "__private_extern__ [a-z_]+ _dyld_";
1427 c_fix = format;
1428 c_fix_arg = "extern";
1429 c_fix_arg = "__private_extern__";
1430 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1431 "const char *dyld_func_name,\n"
1432 "unsigned long *address);\n";
1436 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1437 * unsigned constants.
1439 fix = {
1440 hackname = darwin_stdint_1;
1441 mach = "*-*-darwin*";
1442 files = stdint-darwin.h, stdint.h;
1443 c_fix = format;
1444 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1445 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1446 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1447 test_text = "#define UINT8_C(v) (v ## U)\n"
1448 "#define UINT16_C(v) (v ## U)";
1452 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1453 * with wrong types.
1455 fix = {
1456 hackname = darwin_stdint_2;
1457 mach = "*-*-darwin*";
1458 files = stdint-darwin.h, stdint.h;
1459 c_fix = format;
1460 c_fix_arg = "#if __WORDSIZE == 64\n"
1461 "#define INTPTR_MAX 9223372036854775807L\n"
1462 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1463 "#else\n"
1464 "#define INTPTR_MAX 2147483647L\n"
1465 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1466 "#endif";
1467 select = "#if __WORDSIZE == 64\n"
1468 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1469 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1470 "#else\n"
1471 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1472 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1473 "#endif";
1474 test_text = "#if __WORDSIZE == 64\n"
1475 "#define INTPTR_MIN INT64_MIN\n"
1476 "#define INTPTR_MAX INT64_MAX\n"
1477 "#else\n"
1478 "#define INTPTR_MIN INT32_MIN\n"
1479 "#define INTPTR_MAX INT32_MAX\n"
1480 "#endif";
1484 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1486 fix = {
1487 hackname = darwin_stdint_3;
1488 mach = "*-*-darwin*";
1489 files = stdint-darwin.h, stdint.h;
1490 c_fix = format;
1491 c_fix_arg = "#if __WORDSIZE == 64\n"
1492 "#define UINTPTR_MAX 18446744073709551615UL\n"
1493 "#else\n"
1494 "#define UINTPTR_MAX 4294967295UL\n"
1495 "#endif";
1496 select = "#if __WORDSIZE == 64\n"
1497 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1498 "#else\n"
1499 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1500 "#endif";
1501 test_text = "#if __WORDSIZE == 64\n"
1502 "#define UINTPTR_MAX UINT64_MAX\n"
1503 "#else\n"
1504 "#define UINTPTR_MAX UINT32_MAX\n"
1505 "#endif";
1509 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1511 fix = {
1512 hackname = darwin_stdint_4;
1513 mach = "*-*-darwin*";
1514 files = stdint-darwin.h, stdint.h;
1515 c_fix = format;
1516 c_fix_arg = "#if __WORDSIZE == 64\n"
1517 "#define SIZE_MAX 18446744073709551615UL\n"
1518 "#else\n"
1519 "#define SIZE_MAX 4294967295UL\n"
1520 "#endif";
1521 select = "#if __WORDSIZE == 64\n"
1522 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1523 "#else\n"
1524 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1525 "#endif";
1526 test_text = "#if __WORDSIZE == 64\n"
1527 "#define SIZE_MAX UINT64_MAX\n"
1528 "#else\n"
1529 "#define SIZE_MAX UINT32_MAX\n"
1530 "#endif";
1534 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1535 * with a wrong type.
1537 fix = {
1538 hackname = darwin_stdint_5;
1539 mach = "*-*-darwin*";
1540 files = stdint-darwin.h, stdint.h;
1541 c_fix = format;
1542 c_fix_arg = "#if __WORDSIZE == 64\n"
1543 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1544 "#define INTMAX_MAX 9223372036854775807L\n"
1545 "#define UINTMAX_MAX 18446744073709551615UL\n"
1546 "#else\n"
1547 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1548 "#define INTMAX_MAX 9223372036854775807LL\n"
1549 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1550 "#endif";
1551 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1552 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1553 "\n"
1554 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1555 test_text = "#define INTMAX_MIN INT64_MIN\n"
1556 "#define INTMAX_MAX INT64_MAX\n"
1557 "\n"
1558 "#define UINTMAX_MAX UINT64_MAX";
1562 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1563 * with a wrong type.
1565 fix = {
1566 hackname = darwin_stdint_6;
1567 mach = "*-*-darwin*";
1568 files = stdint-darwin.h, stdint.h;
1569 c_fix = format;
1570 c_fix_arg = "#if __WORDSIZE == 64\n"
1571 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1572 "#define PTRDIFF_MAX 9223372036854775807L\n"
1573 "#else\n"
1574 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1575 "#define PTRDIFF_MAX 2147483647\n"
1576 "#endif";
1577 select = "#if __WORDSIZE == 64\n"
1578 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1579 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1580 "#else\n"
1581 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1582 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1583 "#endif";
1584 test_text = "#if __WORDSIZE == 64\n"
1585 "#define PTRDIFF_MIN INT64_MIN\n"
1586 "#define PTRDIFF_MAX INT64_MAX\n"
1587 "#else\n"
1588 "#define PTRDIFF_MIN INT32_MIN\n"
1589 "#define PTRDIFF_MAX INT32_MAX\n"
1590 "#endif";
1594 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1595 * with a wrong type.
1597 fix = {
1598 hackname = darwin_stdint_7;
1599 mach = "*-*-darwin*";
1600 files = stdint-darwin.h, stdint.h;
1601 c_fix = format;
1602 c_fix_arg = "#if __WORDSIZE == 64\n"
1603 "#define INTMAX_C(v) (v ## L)\n"
1604 "#define UINTMAX_C(v) (v ## UL)\n"
1605 "#else\n"
1606 "#define INTMAX_C(v) (v ## LL)\n"
1607 "#define UINTMAX_C(v) (v ## ULL)\n"
1608 "#endif";
1609 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1610 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1611 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1612 "#define UINTMAX_C(v) (v ## ULL)";
1616 * Fix <c_asm.h> on Digital UNIX V4.0:
1617 * It contains a prototype for a DEC C internal asm() function,
1618 * clashing with gcc's asm keyword. So protect this with __DECC.
1620 fix = {
1621 hackname = dec_intern_asm;
1622 files = c_asm.h;
1623 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1624 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1625 "#endif\n";
1626 test_text =
1627 "float fasm {\n"
1628 " ... asm stuff ...\n"
1629 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1633 * Fix typo in <wchar.h> on DJGPP 2.03.
1635 fix = {
1636 hackname = djgpp_wchar_h;
1637 file = wchar.h;
1638 select = "__DJ_wint_t";
1639 bypass = "sys/djtypes.h";
1640 c_fix = format;
1641 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1642 c_fix_arg = "#include <stddef.h>";
1643 test_text = "#include <stddef.h>\n"
1644 "extern __DJ_wint_t x;\n";
1648 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1650 fix = {
1651 hackname = ecd_cursor;
1652 files = "sunwindow/win_lock.h";
1653 files = "sunwindow/win_cursor.h";
1654 select = 'ecd\.cursor';
1655 c_fix = format;
1656 c_fix_arg = 'ecd_cursor';
1658 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1662 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1663 * that fails when compiling for SSE-less 32-bit x86.
1665 fix = {
1666 hackname = feraiseexcept_nosse_divbyzero;
1667 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1668 files = bits/fenv.h, '*/bits/fenv.h';
1669 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1670 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1671 bypass = "\"fdivp .*; fwait\"";
1673 c_fix = format;
1674 c_fix_arg = <<- _EOText_
1675 # ifdef __SSE_MATH__
1677 # else
1678 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1679 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1680 # endif
1681 _EOText_;
1683 test_text = <<- _EOText_
1684 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1685 _EOText_;
1689 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1690 * that fails when compiling for SSE-less 32-bit x86.
1692 fix = {
1693 hackname = feraiseexcept_nosse_invalid;
1694 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1695 files = bits/fenv.h, '*/bits/fenv.h';
1696 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1697 ": \"x\" \\(__f\\)\\);$";
1698 bypass = "\"fdiv .*; fwait\"";
1700 c_fix = format;
1701 c_fix_arg = <<- _EOText_
1702 # ifdef __SSE_MATH__
1704 # else
1705 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1706 %1 : "=t" (__f) : "0" (__f));
1707 # endif
1708 _EOText_;
1710 test_text = <<- _EOText_
1711 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1712 _EOText_;
1716 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1717 * neither the existence of GCC 3 nor its exact feature set yet break
1718 * (by design?) when __GNUC__ is set beyond 2.
1720 fix = {
1721 hackname = freebsd_gcc3_breakage;
1722 mach = "*-*-freebsd*";
1723 files = sys/cdefs.h;
1724 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1725 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1726 c_fix = format;
1727 c_fix_arg = '%0 || __GNUC__ >= 3';
1728 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1732 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1733 * neither the existence of GCC 4 nor its exact feature set yet break
1734 * (by design?) when __GNUC__ is set beyond 3.
1736 fix = {
1737 hackname = freebsd_gcc4_breakage;
1738 mach = "*-*-freebsd*";
1739 files = sys/cdefs.h;
1740 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1741 c_fix = format;
1742 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1743 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1747 * Some versions of glibc don't expect the C99 inline semantics.
1749 fix = {
1750 hackname = glibc_c99_inline_1;
1751 files = features.h, '*/features.h';
1752 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1753 c_fix = format;
1754 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1755 test_text = <<-EOT
1756 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1757 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1758 # define __USE_EXTERN_INLINES 1
1759 #endif
1760 EOT;
1764 * Similar, but a version that didn't have __NO_INLINE__
1766 fix = {
1767 hackname = glibc_c99_inline_1a;
1768 files = features.h, '*/features.h';
1769 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1770 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1771 c_fix = format;
1772 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1773 test_text = <<-EOT
1774 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1775 # define __USE_EXTERN_INLINES 1
1776 #endif
1777 EOT;
1781 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1782 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1783 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1785 fix = {
1786 hackname = glibc_c99_inline_2;
1787 files = sys/stat.h, '*/sys/stat.h';
1788 select = "extern __inline__ int";
1789 sed = "s/extern int \\(stat\\)/"
1790 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1791 "__inline__ int \\1/";
1792 sed = "s/extern int \\([lf]stat\\)/"
1793 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1794 "__inline__ int \\1/";
1795 sed = "s/extern int \\(mknod\\)/"
1796 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1797 "__inline__ int \\1/";
1798 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1799 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1800 "__inline__ int __REDIRECT\\1 (\\2/";
1801 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1802 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1803 "__inline__ int __REDIRECT\\1 (\\2/";
1804 sed = "s/^extern __inline__ int/"
1805 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1806 "__inline__ int/";
1807 test_text = <<-EOT
1808 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1809 extern __inline__ int
1810 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1812 EOT;
1816 * glibc_c99_inline_3
1818 fix = {
1819 hackname = glibc_c99_inline_3;
1820 files = bits/string2.h, '*/bits/string2.h';
1821 select = "extern __inline";
1822 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1823 c_fix = format;
1824 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1825 c_fix_arg = "^# ifdef __cplusplus$";
1826 test_text = <<-EOT
1827 # ifdef __cplusplus
1828 # define __STRING_INLINE inline
1829 # else
1830 # define __STRING_INLINE extern __inline
1831 # endif
1832 EOT;
1836 * glibc_c99_inline_4
1838 fix = {
1839 hackname = glibc_c99_inline_4;
1840 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1841 pthread.h, '*/pthread.h';
1842 bypass = "__extern_inline|__gnu_inline__";
1843 select = "(^| )extern __inline";
1844 c_fix = format;
1845 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1846 test_text = <<-EOT
1847 __extension__ extern __inline unsigned int
1848 extern __inline unsigned int
1849 EOT;
1852 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1853 * so we replace them with versions that correspond to the
1854 * definition.
1856 fix = {
1857 hackname = glibc_mutex_init;
1858 files = pthread.h;
1859 select = '\{ *\{ *0, *\} *\}';
1860 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1861 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1862 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1863 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1864 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1865 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1866 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1867 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1868 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1869 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1870 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1871 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1872 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1873 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1874 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1875 "N;s/^[ \t]*#[ \t]*"
1876 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1877 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1878 "# \\1\\\n"
1879 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1880 "# else\\\n"
1881 "# \\1\\\n"
1882 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1883 "# endif/";
1884 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1885 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1886 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1887 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1889 test_text = <<- _EOText_
1890 #define PTHREAD_MUTEX_INITIALIZER \\
1891 { { 0, } }
1892 #ifdef __USE_GNU
1893 # if __WORDSIZE == 64
1894 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1895 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1896 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1897 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1898 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1899 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1900 # else
1901 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1902 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1903 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1904 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1905 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1906 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1907 # endif
1908 #endif
1909 # define PTHREAD_RWLOCK_INITIALIZER \\
1910 { { 0, } }
1911 # ifdef __USE_GNU
1912 # if __WORDSIZE == 64
1913 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1914 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1915 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1916 # else
1917 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1918 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1919 # endif
1920 # endif
1921 #define PTHREAD_COND_INITIALIZER { { 0, } }
1922 _EOText_;
1925 /* glibc versions before 2.5 have a version of stdint.h that defines
1926 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1927 versions with stdint.h based on those glibc versions. */
1928 fix = {
1929 hackname = glibc_stdint;
1930 files = stdint.h;
1931 select = "GNU C Library";
1932 c_fix = format;
1933 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1934 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1935 test_text = "/* This file is part of the GNU C Library. */\n"
1936 "# define UINT8_C(c)\tc ## U\n"
1937 "# define UINT16_C(c)\tc ## U";
1940 /* Some versions of glibc have a version of bits/string2.h that
1941 produces "value computed is not used" warnings from strncpy; fix
1942 this definition by using __builtin_strncpy instead as in newer
1943 versions. */
1944 fix = {
1945 hackname = glibc_strncpy;
1946 files = bits/string2.h, '*/bits/string2.h';
1947 bypass = "__builtin_strncpy";
1948 c_fix = format;
1949 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1950 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1951 test_text = <<-EOT
1952 # define strncpy(dest, src, n) \
1953 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1954 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1955 ? (char *) memcpy (dest, src, n) \\
1956 : strncpy (dest, src, n)) \\
1957 : strncpy (dest, src, n)))
1958 EOT;
1962 /* glibc's tgmath.h relies on an expression that is not an integer
1963 constant expression being treated as it was by GCC 4.4 and
1964 earlier. */
1965 fix = {
1966 hackname = glibc_tgmath;
1967 files = tgmath.h;
1968 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1969 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1970 c_fix = format;
1971 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1972 "(__builtin_classify_type ((type) 0) == 9 && "
1973 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1974 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1978 * Fix these files to use the types we think they should for
1979 * ptrdiff_t, size_t, and wchar_t.
1981 * This defines the types in terms of macros predefined by our 'cpp'.
1982 * This is supposedly necessary for glibc's handling of these types.
1983 * It's probably not necessary for anyone else, but it doesn't hurt.
1985 fix = {
1986 hackname = gnu_types;
1987 files = "sys/types.h";
1988 files = "stdlib.h";
1989 files = "sys/stdtypes.h";
1990 files = "stddef.h";
1991 files = "memory.h";
1992 files = "unistd.h";
1993 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1994 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1995 c_fix = gnu_type;
1996 /* The Solaris 10 headers already define these types correctly. */
1997 mach = '*-*-solaris2.1[0-9]*';
1998 not_machine = true;
2000 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2001 "typedef uint_t size_t; /* uint_t */\n"
2002 "typedef ushort_t wchar_t; /* ushort_t */";
2006 * Fix HP & Sony's use of "../machine/xxx.h"
2007 * to refer to: <machine/xxx.h>
2009 fix = {
2010 hackname = hp_inline;
2011 files = sys/spinlock.h;
2012 files = machine/machparam.h;
2013 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2015 c_fix = format;
2016 c_fix_arg = "%1<machine/%2.h>";
2018 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2019 '([a-z]+)\.h"';
2021 test_text = ' # include "../machine/mumble.h"';
2025 * Check for (...) in C++ code in HP/UX sys/file.h.
2027 fix = {
2028 hackname = hp_sysfile;
2029 files = sys/file.h;
2030 select = "HPUX_SOURCE";
2032 c_fix = format;
2033 c_fix_arg = "(struct file *, ...)";
2034 c_fix_arg = '\(\.\.\.\)';
2036 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2040 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2041 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2043 fix = {
2044 hackname = hppa_hpux_fp_macros;
2045 mach = "hppa*-hp-hpux11*";
2046 files = math.h;
2047 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2048 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2049 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2050 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2051 "#[ \t]*define[ \t]*FP_NAN.*\n";
2052 c_fix = format;
2053 c_fix_arg = <<- _EOFix_
2054 #endif /* _INCLUDE_HPUX_SOURCE */
2056 #if defined(_INCLUDE_HPUX_SOURCE) || \
2057 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2058 %0#endif
2060 #ifdef _INCLUDE_HPUX_SOURCE
2062 _EOFix_;
2064 test_text =
2065 "# define FP_NORMAL 0\n"
2066 "# define FP_ZERO 1\n"
2067 "# define FP_INFINITE 2\n"
2068 "# define FP_SUBNORMAL 3\n"
2069 "# define FP_NAN 4\n";
2073 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2074 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2076 fix = {
2077 hackname = hpux10_cpp_pow_inline;
2078 files = fixinc-test-limits.h, math.h;
2079 select = <<- END_POW_INLINE
2080 ^# +ifdef +__cplusplus
2082 +inline +double +pow\(double +__d,int +__expon\) +\{
2083 [ ]+return +pow\(__d,\(double\)__expon\);
2085 +extern +"C" +\{
2086 #else
2087 # +endif
2088 END_POW_INLINE;
2090 c_fix = format;
2091 c_fix_arg = "";
2093 test_text =
2094 "# ifdef __cplusplus\n"
2095 " }\n"
2096 " inline double pow(double __d,int __expon) {\n"
2097 "\t return pow(__d,(double)__expon);\n"
2098 " }\n"
2099 ' extern "C"' " {\n"
2100 "#else\n"
2101 "# endif";
2104 fix = {
2105 hackname = hpux11_cpp_pow_inline;
2106 files = math.h;
2107 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2108 " +return pow\\(d, \\(double\\)expon\\);\n"
2109 " +\\}\n";
2110 c_fix = format;
2111 c_fix_arg = "";
2113 test_text =
2114 " inline double pow(double d,int expon) {\n"
2115 " return pow(d, (double)expon);\n"
2116 " }\n";
2120 * Fix hpux 10.X missing ctype declarations 1
2122 fix = {
2123 hackname = hpux10_ctype_declarations1;
2124 files = ctype.h;
2125 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2126 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2127 c_fix = format;
2128 c_fix_arg = "#ifdef _PROTOTYPES\n"
2129 "extern int __tolower(int);\n"
2130 "extern int __toupper(int);\n"
2131 "#else /* NOT _PROTOTYPES */\n"
2132 "extern int __tolower();\n"
2133 "extern int __toupper();\n"
2134 "#endif /* _PROTOTYPES */\n\n"
2135 "%0\n";
2137 test_text = "# define _toupper(__c) __toupper(__c)\n";
2141 * Fix hpux 10.X missing ctype declarations 2
2143 fix = {
2144 hackname = hpux10_ctype_declarations2;
2145 files = ctype.h;
2146 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2147 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2148 c_fix = format;
2149 c_fix_arg = "%0\n\n"
2150 "#ifdef _PROTOTYPES\n"
2151 " extern int _isalnum(int);\n"
2152 " extern int _isalpha(int);\n"
2153 " extern int _iscntrl(int);\n"
2154 " extern int _isdigit(int);\n"
2155 " extern int _isgraph(int);\n"
2156 " extern int _islower(int);\n"
2157 " extern int _isprint(int);\n"
2158 " extern int _ispunct(int);\n"
2159 " extern int _isspace(int);\n"
2160 " extern int _isupper(int);\n"
2161 " extern int _isxdigit(int);\n"
2162 "# else /* not _PROTOTYPES */\n"
2163 " extern int _isalnum();\n"
2164 " extern int _isalpha();\n"
2165 " extern int _iscntrl();\n"
2166 " extern int _isdigit();\n"
2167 " extern int _isgraph();\n"
2168 " extern int _islower();\n"
2169 " extern int _isprint();\n"
2170 " extern int _ispunct();\n"
2171 " extern int _isspace();\n"
2172 " extern int _isupper();\n"
2173 " extern int _isxdigit();\n"
2174 "#endif /* _PROTOTYPES */\n";
2176 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2177 " extern unsigned int *__SB_masks;\n";
2181 * Fix hpux 10.X missing stdio declarations
2183 fix = {
2184 hackname = hpux10_stdio_declarations;
2185 files = stdio.h;
2186 select = "^#[ \t]*define _iob[ \t]*__iob";
2187 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2188 c_fix = format;
2189 c_fix_arg = "%0\n\n"
2190 "# if defined(__STDC__) || defined(__cplusplus)\n"
2191 " extern int snprintf(char *, size_t, const char *, ...);\n"
2192 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2193 "# else /* not __STDC__) || __cplusplus */\n"
2194 " extern int snprintf();\n"
2195 " extern int vsnprintf();\n"
2196 "# endif /* __STDC__) || __cplusplus */\n";
2198 test_text = "# define _iob __iob\n";
2202 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2203 * As a result, we need to include sys/stdsyms.h in alloca.h.
2205 fix = {
2206 hackname = hppa_hpux11_alloca;
2207 mach = "hppa*-*-hpux11*";
2208 files = alloca.h;
2209 select = "#ifndef _STDDEF_INCLUDED";
2210 c_fix = format;
2211 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2212 "# include <sys/stdsyms.h>\n"
2213 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2214 "%0";
2216 test_text = "#ifndef _STDDEF_INCLUDED";
2220 * Make sure hpux defines abs in header.
2222 fix = {
2223 hackname = hpux11_abs;
2224 mach = "*-hp-hpux11*";
2225 files = stdlib.h;
2226 select = "ifndef _MATH_INCLUDED";
2227 c_fix = format;
2228 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2229 test_text = "#ifndef _MATH_INCLUDED";
2233 * Fix hpux11 __LWP_RWLOCK_VALID define
2235 fix = {
2236 hackname = hpux11_lwp_rwlock_valid;
2237 mach = "*-hp-hpux11*";
2238 files = sys/pthread.h;
2239 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2240 c_fix = format;
2241 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2242 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2246 * hpux sendfile()
2248 fix = {
2249 hackname = hpux11_extern_sendfile;
2250 mach = "*-hp-hpux11.[12]*";
2251 files = sys/socket.h;
2252 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2253 c_fix = format;
2254 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2255 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2256 " const struct iovec *, int));\n";
2260 * hpux sendpath()
2262 fix = {
2263 hackname = hpux11_extern_sendpath;
2264 mach = "*-hp-hpux11.[12]*";
2265 files = sys/socket.h;
2266 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2267 c_fix = format;
2268 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2269 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2270 " const struct iovec *, int));\n";
2274 * Keep HP-UX 11 from stomping on C++ math namespace
2275 * with defines for fabsf.
2277 fix = {
2278 hackname = hpux11_fabsf;
2279 mach = "*-hp-hpux11*";
2280 files = math.h;
2281 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2283 c_fix = format;
2284 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2286 test_text =
2287 "#ifdef _PA_RISC\n"
2288 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2289 "#endif";
2293 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2294 * in pthread.h need to be constant expressions to be standard complient.
2295 * As a result, we need to remove the void * casts in the initializers
2296 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2297 * to use the long type.
2299 fix = {
2300 hackname = hpux11_pthread_pointer;
2301 mach = "*-hp-hpux11.[0-3]*";
2302 files = sys/pthread.h;
2303 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2305 c_fix = format;
2306 c_fix_arg = "long\t%2%3";
2307 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2311 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2313 fix = {
2314 hackname = hpux11_pthread_const;
2315 mach = "*-hp-hpux11.[0-3]*";
2316 files = sys/pthread.h;
2317 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2319 c_fix = format;
2320 c_fix_arg = "%11";
2321 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2325 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2326 * being defined by having it define _hpux_size_t instead.
2328 fix = {
2329 hackname = hpux11_size_t;
2330 mach = "*-hp-hpux11*";
2331 select = "__size_t";
2333 c_fix = format;
2334 c_fix_arg = "_hpux_size_t";
2336 test_text =
2337 "#define __size_t size_t\n"
2338 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2342 * Fix hpux 11.00 broken snprintf declaration
2343 * (third argument is char *, needs to be const char * to prevent
2344 * spurious warnings with -Wwrite-strings or in C++).
2346 fix = {
2347 hackname = hpux11_snprintf;
2348 files = stdio.h;
2349 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2350 ' *(char *\*, *\.\.\.\);)';
2351 c_fix = format;
2352 c_fix_arg = '%1 const %3';
2354 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2355 "extern int snprintf(char *, __size_t, char *, ...);\n"
2356 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2360 * Fix hpux 11.00 broken vsnprintf declaration
2362 fix = {
2363 hackname = hpux11_vsnprintf;
2364 files = stdio.h;
2365 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2366 'const char \*,) __va__list\);';
2367 c_fix = format;
2368 c_fix_arg = "%1 __va_list);";
2370 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2371 ' __va__list);';
2375 * Fix missing const in hpux vsscanf declaration
2377 fix = {
2378 hackname = hpux_vsscanf;
2379 mach = "*-*-hpux*";
2380 files = stdio.h;
2381 select = '(extern int vsscanf\()char';
2382 c_fix = format;
2383 c_fix_arg = "%1const char";
2385 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2389 * get rid of bogus inline definitions in HP-UX 8.0
2391 fix = {
2392 hackname = hpux8_bogus_inlines;
2393 files = math.h;
2394 select = inline;
2395 bypass = "__GNUG__";
2396 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2397 "@extern \"C\" int abs(int);@";
2398 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2399 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2400 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2401 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2402 "inline double sqr(double v) { return v**0.5; }";
2406 * hpux intptr
2408 fix = {
2409 hackname = hpux_c99_intptr;
2410 mach = "*-hp-hpux11.3*";
2411 files = stdint-hpux11.h, stdint.h;
2412 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2413 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2414 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2415 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2416 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2417 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2418 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2419 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2420 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2421 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2422 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2423 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2424 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2425 "#define PTRDIFF_MIN INT32_MIN\n"
2426 "#define INTPTR_MAX INT32_MAX\n"
2427 "#define INTPTR_MIN INT32_MIN\n"
2428 "#define UINTPTR_MAX UINT32_MAX\n"
2429 "#define SIZE_MAX UINT32_MAX\n";
2433 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2435 fix = {
2436 hackname = hpux_c99_inttypes;
2437 mach = "*-hp-hpux11.[23]*";
2438 files = inttypes.h;
2439 files = stdint-hpux11.h, stdint.h;
2440 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2441 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2442 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2443 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2444 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2445 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2446 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2447 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2448 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2449 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2450 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2451 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2455 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2457 fix = {
2458 hackname = hpux_c99_inttypes2;
2459 mach = "*-hp-hpux11.2*";
2460 files = stdint-hpux11.h, stdint.h;
2461 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2462 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2463 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2464 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2465 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2466 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2467 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2468 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2469 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2470 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2471 "# define INT16_C(__c) ((short)(__c))\n"
2472 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2476 * Fix hpux broken ctype macros
2478 fix = {
2479 hackname = hpux_ctype_macros;
2480 files = ctype.h;
2481 select = '((: |\()__SB_masks \? )'
2482 '(__SB_masks\[__(alnum|c)\] & _IS)';
2483 c_fix = format;
2484 c_fix_arg = "%1(int)%3";
2486 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2487 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2491 * hpux errno()
2493 fix = {
2494 hackname = hpux_extern_errno;
2495 mach = "*-hp-hpux10.*";
2496 mach = "*-hp-hpux11.[0-2]*";
2497 files = errno.h;
2498 select = "^[ \t]*extern int errno;$";
2499 c_fix = format;
2500 c_fix_arg = "#ifdef __cplusplus\n"
2501 "extern \"C\" {\n"
2502 "#endif\n"
2503 "%0\n"
2504 "#ifdef __cplusplus\n"
2505 "}\n"
2506 "#endif";
2507 test_text = " extern int errno;\n";
2511 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2513 fix = {
2514 hackname = hpux_htonl;
2515 files = netinet/in.h;
2516 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2517 "(/\\*\n"
2518 " \\* Macros for number representation conversion\\.\n"
2519 " \\*/\n"
2520 "#ifndef ntohl)";
2521 c_fix = format;
2522 c_fix_arg = "#if 1\n%1";
2524 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2525 "/*\n"
2526 " * Macros for number representation conversion.\n"
2527 " */\n"
2528 "#ifndef ntohl\n"
2529 "#define ntohl(x) (x)\n"
2530 "#define ntohs(x) (x)\n"
2531 "#define htonl(x) (x)\n"
2532 "#define htons(x) (x)\n"
2533 "#endif\n"
2534 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2538 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2540 fix = {
2541 hackname = hpux_imaginary_i;
2542 mach = "ia64-hp-hpux11.*";
2543 files = complex.h;
2544 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2545 c_fix = format;
2546 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2547 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2551 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2553 fix = {
2554 hackname = hpux_inttype_int8_t;
2555 mach = "*-hp-hpux1[01].*";
2556 files = sys/_inttypes.h;
2557 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2558 c_fix = format;
2559 c_fix_arg = "typedef signed char int%18_t;";
2560 test_text = "typedef char int_least8_t;\n"
2561 "typedef char int8_t;\n";
2565 * HP-UX long_double
2567 fix = {
2568 hackname = hpux_long_double;
2569 mach = "*-*-hpux10*";
2570 mach = "*-*-hpux11.[012]*";
2571 files = stdlib.h;
2572 select = "extern[ \t]long_double[ \t]strtold";
2573 bypass = "long_double_t";
2574 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2575 sed = "s/long_double/long double/g";
2577 test_text = "# ifndef _LONG_DOUBLE\n"
2578 "# define _LONG_DOUBLE\n"
2579 " typedef struct {\n"
2580 " unsigned int word1, word2, word3, word4;\n"
2581 " } long_double;\n"
2582 "# endif /* _LONG_DOUBLE */\n"
2583 "extern long_double strtold(const char *, char **);\n";
2587 * We cannot use the above rule on 11.31 because it removes the strtold
2588 * definition. ia64 is OK with no hack, PA needs some help.
2590 fix = {
2591 hackname = hpux_long_double_2;
2592 mach = "hppa*-*-hpux11.3*";
2593 files = stdlib.h;
2594 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2595 "defined\\(_PROTOTYPES\\) \\|\\| "
2596 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2597 c_fix = format;
2598 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2600 test_text = "# if !defined(__ia64) || "
2601 "!defined(_PROTOTYPES) || "
2602 "defined(_LONG_DOUBLE_STRUCT)\n";
2606 * Add missing braces to pthread initializer defines.
2608 fix = {
2609 hackname = hpux_pthread_initializers;
2610 mach = "*-hp-hpux11.[0-3]*";
2611 files = sys/pthread.h;
2612 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2613 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2614 sed = "s@^[ \t]*1,[ \t]*\\\\"
2615 "@\t{ 1, 0 }@";
2616 sed = "/^[ \t]*0$/d";
2617 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2618 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2619 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2620 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2621 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2622 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2623 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2624 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2625 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2626 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2627 sed = "s@__PTHREAD_COND_VALID, 0"
2628 "@{ __PTHREAD_COND_VALID, 0 }@";
2629 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2630 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2631 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2632 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2633 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2634 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2635 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2636 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2637 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2638 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2639 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2640 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2641 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2642 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2643 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2644 "}\n";
2648 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2649 * type and mpinfou is only defined when _KERNEL is set.
2651 fix = {
2652 hackname = hpux_spu_info;
2653 mach = "*-hp-hpux*";
2655 * It is tempting to omit the first "files" entry. Do not.
2656 * The testing machinery will take the first "files" entry as the name
2657 * of a test file to play with. It would be a nuisance to have a directory
2658 * with the name "*".
2660 files = "ia64/sys/getppdp.h";
2661 files = "*/sys/getppdp.h";
2662 select = "^.*extern.*spu_info.*";
2664 c_fix = format;
2665 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2667 test_text = "extern union mpinfou spu_info[];";
2671 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2673 fix = {
2674 hackname = hpux_stdint_least_fast;
2675 mach = "*-hp-hpux11.2*";
2676 files = stdint-hpux11.h, stdint.h;
2677 select =
2678 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2679 c_fix = format;
2680 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2681 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2682 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2686 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2688 fix = {
2689 hackname = hpux_longjmp;
2690 mach = "*-hp-hpux*";
2691 files = setjmp.h;
2692 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2694 c_fix = format;
2695 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2697 test_text = 'extern void longjmp __((jmp_buf, int));';
2701 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2703 fix = {
2704 hackname = hpux_systime;
2705 files = sys/time.h;
2706 select = "^extern struct sigevent;";
2708 c_fix = format;
2709 c_fix_arg = "struct sigevent;";
2711 test_text = 'extern struct sigevent;';
2715 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2717 fix = {
2718 hackname = huge_val_hex;
2719 files = bits/huge_val.h, '*/bits/huge_val.h';
2720 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2721 bypass = "__builtin_huge_val";
2723 c_fix = format;
2724 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2726 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2730 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2732 fix = {
2733 hackname = huge_valf_hex;
2734 files = bits/huge_val.h, '*/bits/huge_val.h';
2735 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2736 bypass = "__builtin_huge_valf";
2738 c_fix = format;
2739 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2741 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2745 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2747 fix = {
2748 hackname = huge_vall_hex;
2749 files = bits/huge_val.h, '*/bits/huge_val.h';
2750 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2751 bypass = "__builtin_huge_vall";
2753 c_fix = format;
2754 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2756 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2760 * Fix return type of abort and free
2762 fix = {
2763 hackname = int_abort_free_and_exit;
2764 files = stdlib.h;
2765 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2766 bypass = "_CLASSIC_ANSI_TYPES";
2768 c_fix = format;
2769 c_fix_arg = "void\t%1(";
2771 test_text = "extern int abort(int);\n"
2772 "extern int free(void*);\n"
2773 "extern int exit(void*);";
2777 * Fix various macros used to define ioctl numbers.
2778 * The traditional syntax was:
2780 * #define _IO(n, x) (('n'<<8)+x)
2781 * #define TIOCFOO _IO(T, 1)
2783 * but this does not work with the C standard, which disallows macro
2784 * expansion inside strings. We have to rewrite it thus:
2786 * #define _IO(n, x) ((n<<8)+x)
2787 * #define TIOCFOO _IO('T', 1)
2789 * The select expressions match too much, but the c_fix code is cautious.
2791 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2793 fix = {
2794 hackname = io_quotes_def;
2795 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2796 c_fix = char_macro_def;
2797 c_fix_arg = "IO";
2798 test_text =
2799 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2800 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2801 "#define _IO(x,y) ('x'<<8|y)";
2802 test_text =
2803 "#define XX_IO(x) ('x'<<8|256)";
2807 * Fix the usage of the ioctl macro numbers.
2809 fix = {
2810 hackname = io_quotes_use;
2811 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2812 "\\( *[^,']";
2813 c_fix = char_macro_use;
2814 c_fix_arg = "IO";
2815 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2816 "#define TIOCFOO \\\\\n"
2817 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2821 * Check for missing ';' in struct
2823 fix = {
2824 hackname = ip_missing_semi;
2825 files = netinet/ip.h;
2826 select = "}$";
2827 sed = "/^struct/,/^};/s/}$/};/";
2828 test_text=
2829 "struct mumble {\n"
2830 " union {\n"
2831 " int x;\n"
2832 " }\n"
2833 "}; /* mumbled struct */\n";
2837 * Non-traditional "const" declaration in Irix's limits.h.
2839 fix = {
2840 hackname = irix_limits_const;
2841 files = fixinc-test-limits.h, limits.h;
2842 select = "^extern const ";
2843 c_fix = format;
2844 c_fix_arg = "extern __const ";
2845 test_text = "extern const char limit; /* test limits */";
2849 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2850 * taking char *. However, GCC uses void * for va_list, so
2851 * calling vfprintf with a va_list fails in C++. */
2852 fix = {
2853 hackname = irix_stdio_va_list;
2854 files = stdio.h;
2856 select = '/\* va_list \*/ char \*';
2857 c_fix = format;
2858 c_fix_arg = "__gnuc_va_list";
2859 test_text =
2860 "extern int printf( const char *, /* va_list */ char * );";
2864 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2865 * use / * * / to concatenate tokens.
2867 fix = {
2868 hackname = kandr_concat;
2869 files = "sparc/asm_linkage.h";
2870 files = "sun*/asm_linkage.h";
2871 files = "arm/as_support.h";
2872 files = "arm/mc_type.h";
2873 files = "arm/xcb.h";
2874 files = "dev/chardefmac.h";
2875 files = "dev/ps_irq.h";
2876 files = "dev/screen.h";
2877 files = "dev/scsi.h";
2878 files = "sys/tty.h";
2879 files = "Xm.acorn/XmP.h";
2880 files = bsd43/bsd43_.h;
2881 select = '/\*\*/';
2882 c_fix = format;
2883 c_fix_arg = '##';
2884 test_text = "#define __CONCAT__(a,b) a/**/b";
2888 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2889 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2890 * constant on recent versions of g++.
2892 fix = {
2893 hackname = linux_ia64_ucontext;
2894 files = "sys/ucontext.h";
2895 mach = "ia64-*-linux*";
2896 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2897 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2898 c_fix = format;
2899 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2900 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2901 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2905 * Remove header file warning from sys/time.h. Autoconf's
2906 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2907 * which causes warning on LynxOS. Remove the warning.
2909 fix = {
2910 hackname = lynxos_no_warning_in_sys_time_h;
2911 files = sys/time.h;
2912 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2913 c_fix = format;
2914 c_fix_arg = "";
2915 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2919 * Add missing declaration for putenv.
2921 fix = {
2922 hackname = lynxos_missing_putenv;
2923 mach = '*-*-lynxos*';
2924 files = stdlib.h;
2925 bypass = 'putenv[ \t]*\\(';
2926 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2927 c_fix = format;
2928 c_fix_arg = "%0\n"
2929 "extern int putenv _AP((char *));";
2930 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2931 test_text = "extern char *getenv _AP((const char *));";
2935 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2937 * On NetBSD, machine is a symbolic link to an architecture specific
2938 * directory name, so we can't match a specific file name here.
2940 fix = {
2941 hackname = machine_ansi_h_va_list;
2942 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2943 bypass = '__builtin_va_list';
2945 c_fix = format;
2946 c_fix_arg = "%1__builtin_va_list";
2947 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2949 test_text = " # define _BSD_VA_LIST_\tchar**";
2953 * Fix non-ansi machine name defines
2955 fix = {
2956 hackname = machine_name;
2957 c_test = machine_name;
2958 c_fix = machine_name;
2960 test_text = "/* MACH_DIFF: */\n"
2961 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2962 "\n/* no uniform test, so be careful :-) */";
2966 * Some math.h files define struct exception (it's in the System V
2967 * Interface Definition), which conflicts with the class exception defined
2968 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2969 * This is not a great fix, but I haven't been able to think of anything
2970 * better.
2972 fix = {
2973 hackname = math_exception;
2974 files = math.h;
2975 select = "struct exception";
2977 * This should be bypassed on __cplusplus, but some supposedly C++
2978 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2979 * exception either. So currently we bypass only for glibc, based on a
2980 * comment in the fixed glibc header. Ick.
2982 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2983 '_[a-z0-9A-Z_]+_exception; for C, exception';
2984 /* The Solaris 10 headers already get this right. */
2985 mach = '*-*-solaris2.1[0-9]*';
2986 not_machine = true;
2987 c_fix = wrap;
2989 c_fix_arg = "#ifdef __cplusplus\n"
2990 "#define exception __math_exception\n"
2991 "#endif\n";
2993 c_fix_arg = "#ifdef __cplusplus\n"
2994 "#undef exception\n"
2995 "#endif\n";
2997 test_text = "typedef struct exception t_math_exception;";
3001 * This looks pretty broken to me. ``dbl_max_def'' will contain
3002 * "define DBL_MAX " at the start, when what we really want is just
3003 * the value portion. Can't figure out how to write a test case
3004 * for this either :-(
3006 fix = {
3007 hackname = math_huge_val_from_dbl_max;
3008 files = math.h;
3011 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3012 * in math.h, this fix applies.
3014 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3015 bypass = "define[ \t]+DBL_MAX";
3017 shell =
3019 * See if we have a definition for DBL_MAX in float.h.
3020 * If we do, we will replace the one in math.h with that one.
3023 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3024 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3026 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3027 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3028 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3029 "\telse cat\n"
3030 "\tfi";
3032 test_text =
3033 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3034 "#define HUGE_VAL DBL_MAX";
3038 * nested comment
3040 fix = {
3041 hackname = nested_auth_des;
3042 files = rpc/rpc.h;
3043 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3044 c_fix = format;
3045 c_fix_arg = "%1*/ /*";
3046 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3050 * Some versions of NetBSD don't expect the C99 inline semantics.
3052 fix = {
3053 hackname = netbsd_c99_inline_1;
3054 mach = "*-*-netbsd*";
3055 files = signal.h;
3056 select = "extern __inline int";
3058 c_fix = format;
3059 c_fix_arg = "extern\n"
3060 "#ifdef __GNUC_STDC_INLINE__\n"
3061 "__attribute__((__gnu_inline__))\n"
3062 "#endif\n"
3063 "__inline int";
3065 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3069 * netbsd_c99_inline_2
3071 fix = {
3072 hackname = netbsd_c99_inline_2;
3073 mach = "*-*-netbsd*";
3074 files = signal.h;
3075 select = "#define _SIGINLINE extern __inline";
3077 c_fix = format;
3078 c_fix_arg = <<- _EOArg_
3079 #ifdef __GNUC_STDC_INLINE__
3080 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3081 #else
3083 #endif
3084 _EOArg_;
3086 test_text = "#define _SIGINLINE extern __inline";
3090 * NetBSD has a semicolon after the ending '}' for some extern "C".
3092 fix = {
3093 hackname = netbsd_extra_semicolon;
3094 mach = "*-*-netbsd*";
3095 files = sys/cdefs.h;
3096 select = "#define[ \t]*__END_DECLS[ \t]*};";
3098 c_fix = format;
3099 c_fix_arg = "#define __END_DECLS }";
3101 test_text = "#define __END_DECLS };";
3105 * newlib's stdint.h has several failures to conform to C99. The fix
3106 * for these removed a comment that can be matched to identify unfixed
3107 * versions.
3109 fix = {
3110 hackname = newlib_stdint_1;
3111 files = stdint-newlib.h, stdint.h;
3112 select = "@todo - Add support for wint_t types";
3113 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3114 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3115 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3116 sed = "s@#define INT_LEAST32_MIN.*@"
3117 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3118 sed = "s@#define INT_LEAST32_MAX.*@"
3119 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3120 sed = "s@#define UINT_LEAST32_MAX.*@"
3121 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3122 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3123 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3124 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3125 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3126 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3127 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3128 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3129 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3130 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3131 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3132 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3133 test_text = "/* @todo - Add support for wint_t types. */\n"
3134 "#define INT32_MIN (-2147483647-1)\n"
3135 "#define INT32_MAX 2147483647\n"
3136 "#define UINT32_MAX 4294967295U\n"
3137 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3138 "#define INT_LEAST32_MAX 2147483647\n"
3139 "#define UINT_LEAST32_MAX 4294967295U\n"
3140 "#define INT_FAST8_MIN INT8_MIN\n"
3141 "#define INT_FAST8_MAX INT8_MAX\n"
3142 "#define UINT_FAST8_MAX UINT8_MAX\n"
3143 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3144 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3145 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3146 "#define UINT8_C(x) x##U\n"
3147 "#define UINT16_C(x) x##U";
3151 * newlib_stdint_2
3153 fix = {
3154 hackname = newlib_stdint_2;
3155 files = stdint-newlib.h, stdint.h;
3156 select = "@todo - Add support for wint_t types";
3157 c_fix = format;
3158 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3159 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3160 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3161 "#define WCHAR_MAX __WCHAR_MAX__\n"
3162 "#define WCHAR_MIN __WCHAR_MIN__\n"
3163 "#define WINT_MAX __WINT_MAX__\n"
3164 "#define WINT_MIN __WINT_MIN__\n\n"
3165 "%0";
3166 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3167 test_text = "/* @todo - Add support for wint_t types. */\n"
3168 "/** Macros for minimum-width integer constant expressions */";
3172 * NeXT 3.2 adds const prefix to some math functions.
3173 * These conflict with the built-in functions.
3175 fix = {
3176 hackname = next_math_prefix;
3177 files = ansi/math.h;
3178 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3180 c_fix = format;
3181 c_fix_arg = "extern double %1(";
3182 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3184 test_text = "extern\tdouble\t__const__\tmumble();";
3188 * NeXT 3.2 uses the word "template" as a parameter for some
3189 * functions. GCC reports an invalid use of a reserved key word
3190 * with the built-in functions.
3192 fix = {
3193 hackname = next_template;
3194 files = bsd/libc.h;
3195 select = "[ \t]template\\)";
3197 c_fix = format;
3198 c_fix_arg = "(%1)";
3199 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3200 test_text = "extern mumble( char * template); /* fix */";
3204 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3205 * function prototypes. That conflicts with the built-in functions.
3207 fix = {
3208 hackname = next_volitile;
3209 files = ansi/stdlib.h;
3210 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3212 c_fix = format;
3213 c_fix_arg = "extern void %1(";
3214 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3216 test_text = "extern\tvolatile\tvoid\tabort();";
3220 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3221 * Note that version 3 of the NeXT system has wait.h in a different directory,
3222 * so that this code won't do anything. But wait.h in version 3 has a
3223 * conditional, so it doesn't need this fix. So everything is okay.
3225 fix = {
3226 hackname = next_wait_union;
3227 files = sys/wait.h;
3229 select = 'wait\(union wait';
3230 c_fix = format;
3231 c_fix_arg = "wait(void";
3232 test_text = "extern pid_d wait(union wait*);";
3236 * a missing semi-colon at the end of the nodeent structure definition.
3238 fix = {
3239 hackname = nodeent_syntax;
3240 files = netdnet/dnetdb.h;
3241 select = "char[ \t]*\\*na_addr[ \t]*$";
3242 c_fix = format;
3243 c_fix_arg = "%0;";
3244 test_text = "char *na_addr\t";
3248 * Fix OpenBSD's NULL definition.
3250 fix = {
3251 hackname = openbsd_null_definition;
3252 mach = "*-*-openbsd*";
3253 files = locale.h, stddef.h, stdio.h, string.h,
3254 time.h, unistd.h, wchar.h, sys/param.h;
3255 select = "__GNUG__";
3256 c_fix = format;
3257 c_fix_arg = "#ifndef NULL\n"
3258 "#ifdef __cplusplus\n"
3259 "#ifdef __GNUG__\n"
3260 "#define NULL\t__null\n"
3261 "#else\t /* ! __GNUG__ */\n"
3262 "#define NULL\t0L\n"
3263 "#endif\t /* __GNUG__ */\n"
3264 "#else\t /* ! __cplusplus */\n"
3265 "#define NULL\t((void *)0)\n"
3266 "#endif\t /* __cplusplus */\n"
3267 "#endif\t /* !NULL */";
3269 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3270 "^#ifdef[ \t]*__GNUG__\n"
3271 "^#define[ \t]*NULL[ \t]*__null\n"
3272 "^#else\n"
3273 "^#define[ \t]*NULL[ \t]*0L\n"
3274 "^#endif\n"
3275 "^#endif";
3276 test_text =
3277 "#ifndef NULL\n"
3278 "#ifdef __GNUG__\n"
3279 "#define NULL __null\n"
3280 "#else\n"
3281 "#define NULL 0L\n"
3282 "#endif\n"
3283 "#endif\n";
3287 * obstack.h used casts as lvalues.
3289 * We need to change postincrements of casted pointers (which are
3290 * then dereferenced and assigned into) of the form
3292 * *((TYPE*)PTRVAR)++ = (VALUE)
3294 * into expressions like
3296 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3298 * which is correct for the cases used in obstack.h since PTRVAR is
3299 * of type char * and the value of the expression is not used.
3301 fix = {
3302 hackname = obstack_lvalue_cast;
3303 files = obstack.h;
3304 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3305 c_fix = format;
3306 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3307 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3311 * Fix OpenBSD's va_start define.
3313 fix = {
3314 hackname = openbsd_va_start;
3315 mach = "*-*-openbsd*";
3316 files = stdarg.h;
3317 select = '__builtin_stdarg_start';
3318 c_fix = format;
3319 c_fix_arg = __builtin_va_start;
3321 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3325 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3326 * defining regex.h related types. This causes libg++ build and usage
3327 * failures. Fixing this correctly requires checking and modifying 3 files.
3329 fix = {
3330 hackname = osf_namespace_a;
3331 files = reg_types.h;
3332 files = sys/lc_core.h;
3333 test = " -r reg_types.h";
3334 test = " -r sys/lc_core.h";
3335 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3336 test = " -z \"`grep __regex_t regex.h`\"";
3338 c_fix = format;
3339 c_fix_arg = "__%0";
3340 c_fix_arg = "reg(ex|off|match)_t";
3342 test_text = "`touch sys/lc_core.h`"
3343 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3344 "extern regex_t re;\n"
3345 "extern regoff_t ro;\n"
3346 "extern regmatch_t rm;\n";
3349 fix = {
3350 hackname = osf_namespace_c;
3351 files = regex.h;
3352 test = " -r reg_types.h";
3353 test = " -r sys/lc_core.h";
3354 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3355 test = " -z \"`grep __regex_t regex.h`\"";
3357 select = "#include <reg_types\.h>.*";
3358 c_fix = format;
3359 c_fix_arg = "%0\n"
3360 "typedef __regex_t\tregex_t;\n"
3361 "typedef __regoff_t\tregoff_t;\n"
3362 "typedef __regmatch_t\tregmatch_t;";
3364 test_text = "#include <reg_types.h>";
3368 * On broken glibc-2.3.3 systems an array of incomplete structures is
3369 * passed to __sigsetjmp. Fix that to take a pointer instead.
3371 fix = {
3372 hackname = pthread_incomplete_struct_argument;
3373 files = pthread.h;
3374 select = "struct __jmp_buf_tag";
3375 c_fix = format;
3376 c_fix_arg = "%1 *%2%3";
3377 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3378 "(__env)\\[1\\](.*)$";
3379 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3380 "int __savemask);";
3384 * Fix return type of fread and fwrite on sysV68
3386 fix = {
3387 hackname = read_ret_type;
3388 files = stdio.h;
3389 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3390 c_fix = format;
3391 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3392 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3394 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3398 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3400 fix = {
3401 hackname = rpc_xdr_lvalue_cast_a;
3402 files = rpc/xdr.h;
3403 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3404 c_fix = format;
3405 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3406 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3407 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3411 * rpc_xdr_lvalue_cast_b
3413 fix = {
3414 hackname = rpc_xdr_lvalue_cast_b;
3415 files = rpc/xdr.h;
3416 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3417 c_fix = format;
3418 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3419 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3420 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3424 * function class(double x) conflicts with C++ keyword on rs/6000
3426 fix = {
3427 hackname = rs6000_double;
3428 files = math.h;
3429 select = '[^a-zA-Z_]class\(';
3431 c_fix = format;
3432 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3433 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3435 test_text = "extern int class();";
3439 * Wrong fchmod prototype on RS/6000.
3441 fix = {
3442 hackname = rs6000_fchmod;
3443 files = sys/stat.h;
3444 select = 'fchmod\(char \*';
3445 c_fix = format;
3446 c_fix_arg = "fchmod(int";
3447 test_text = "extern int fchmod(char *, mode_t);";
3451 * parameters conflict with C++ new on rs/6000
3453 fix = {
3454 hackname = rs6000_param;
3455 files = "stdio.h";
3456 files = "unistd.h";
3458 select = 'rename\(const char \*old, const char \*new\)';
3459 c_fix = format;
3460 c_fix_arg = 'rename(const char *_old, const char *_new)';
3462 test_text = 'extern int rename(const char *old, const char *new);';
3466 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3467 * for C99. This is wrong for C++, which needs many C99 features, but
3468 * only supports __restrict.
3470 fix = {
3471 hackname = solaris___restrict;
3472 files = sys/feature_tests.h;
3473 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3474 mach = "*-*-solaris2*";
3475 c_fix = format;
3476 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3477 "#else\n%0\n#endif";
3478 test_text = "#define _RESTRICT_KYWD restrict";
3482 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3483 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3484 * and imaginary definitions which are not supported by GCC.
3486 fix = {
3487 hackname = solaris_complex;
3488 mach = "*-*-solaris2.*";
3489 files = complex.h;
3490 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3491 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3492 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3493 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3494 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3495 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3496 test_text = "#define _Complex_I _Complex_I\n"
3497 "#define complex _Complex\n"
3498 "#define _Imaginary_I _Imaginary_I\n"
3499 "#define imaginary _Imaginary\n"
3500 "#undef I\n"
3501 "#define I _Imaginary_I";
3505 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3506 * extern "C" instead so libstdc++ can use it.
3508 fix = {
3509 hackname = solaris_complex_cxx;
3510 mach = "*-*-solaris2.*";
3511 files = complex.h;
3512 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3513 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3514 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3515 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3516 test_text = "#if !defined(__cplusplus)\n"
3517 "#endif /* !defined(__cplusplus) */";
3521 * g++ rejects functions declared with both C and C++ linkage.
3523 fix = {
3524 hackname = solaris_cxx_linkage;
3525 mach = '*-*-solaris2*';
3526 files = "iso/stdlib_iso.h";
3527 select = "(#if __cplusplus >= 199711L)\n"
3528 "(extern \"C\\+\\+\" \\{\n)"
3529 "(.*(bsearch|qsort).*)";
3530 c_fix = format;
3531 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3533 test_text =
3534 "#if __cplusplus >= 199711L\n"
3535 "extern \"C++\" {\n"
3536 " void *bsearch(const void *, const void *, size_t, size_t,";
3540 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3541 * _STRICT_STDC, but uses it.
3543 fix = {
3544 hackname = solaris_getc_strict_stdc;
3545 mach = "*-*-solaris2*";
3546 files = "iso/stdio_iso.h";
3547 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3548 c_fix = format;
3549 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3551 test_text =
3552 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3556 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3558 fix = {
3559 hackname = solaris_gets_c11;
3560 mach = "*-*-solaris2*";
3561 files = "iso/stdio_iso.h";
3562 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3564 c_fix = format;
3565 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3566 "%1 __attribute__((__deprecated__));\n"
3567 "#endif";
3569 test_text = "extern char *gets(char *);";
3573 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3575 fix = {
3576 hackname = solaris_gets_cxx14;
3577 mach = "*-*-solaris2*";
3578 files = "iso/stdio_iso.h";
3579 select = <<- _EOSelect_
3580 (#if __STDC_VERSION__ < 201112L)
3581 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3582 _EOSelect_;
3583 c_fix = format;
3584 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3586 test_text = <<- _EOText_
3587 #if __STDC_VERSION__ < 201112L
3588 extern char *gets(char *) __ATTR_DEPRECATED;
3589 _EOText_;
3593 * Sun Solaris 2 has a version of sys/int_const.h that defines
3594 * UINT8_C and UINT16_C to unsigned constants.
3596 fix = {
3597 hackname = solaris_int_const;
3598 files = sys/int_const.h;
3599 mach = '*-*-solaris2*';
3600 c_fix = format;
3601 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3602 "%1\n"
3603 "#define\tUINT16_C(c)\t(c)";
3604 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3605 "(/\*.*\*/)\n"
3606 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3607 test_text =
3608 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3609 "/* CSTYLED */\n"
3610 "#define UINT16_C(c) __CONCAT__(c,u)";
3614 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3615 * UINT8_MAX and UINT16_MAX to unsigned constants.
3617 fix = {
3618 hackname = solaris_int_limits_1;
3619 files = sys/int_limits.h;
3620 mach = '*-*-solaris2*';
3621 c_fix = format;
3622 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3623 "#define\tUINT16_MAX\t(65535)";
3624 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3625 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3626 test_text =
3627 "#define UINT8_MAX (255U)\n"
3628 "#define UINT16_MAX (65535U)";
3632 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3633 * INT_FAST16 limits to wrong values for sys/int_types.h.
3635 fix = {
3636 hackname = solaris_int_limits_2;
3637 files = sys/int_limits.h;
3638 mach = '*-*-solaris2*';
3639 c_fix = format;
3640 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3641 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3642 test_text =
3643 "#define INT_FAST16_MAX INT16_MAX\n"
3644 "#define UINT_FAST16_MAX UINT16_MAX\n"
3645 "#define INT_FAST16_MIN INT16_MIN";
3649 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3650 * SIZE_MAX as unsigned long.
3652 fix = {
3653 hackname = solaris_int_limits_3;
3654 files = sys/int_limits.h;
3655 mach = '*-*-solaris2*';
3656 c_fix = format;
3657 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3658 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3659 test_text =
3660 "#define SIZE_MAX 4294967295UL";
3664 * Sun Solaris 10 defines several C99 math macros in terms of
3665 * builtins specific to the Studio compiler, in particular not
3666 * compatible with the GNU compiler.
3668 fix = {
3669 hackname = solaris_math_1;
3670 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3671 bypass = "__GNUC__";
3672 files = iso/math_c99.h;
3673 c_fix = format;
3674 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3675 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3676 test_text =
3677 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3678 "#undef HUGE_VAL\n"
3679 "#define HUGE_VAL __builtin_huge_val\n"
3680 "#undef HUGE_VALF\n"
3681 "#define HUGE_VALF __builtin_huge_valf\n"
3682 "#undef HUGE_VALL\n"
3683 "#define HUGE_VALL __builtin_huge_vall";
3687 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3688 * exception. Provide an alternative using GCC's builtin.
3690 fix = {
3691 hackname = solaris_math_10;
3692 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3693 files = iso/math_c99.h;
3694 c_fix = format;
3695 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3696 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3697 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3698 "[ \t]*\\\\\n"
3699 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3700 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3701 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3702 "\\(-INFINITY\\);[ \t]*\\}\\)";
3703 test_text =
3704 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3705 "#undef isinf\n"
3706 "#define isinf(x) __extension__( \\\\\n"
3707 " { __typeof(x) __x_i = (x); \\\\\n"
3708 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3709 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3713 * Solaris math INFINITY
3715 fix = {
3716 hackname = solaris_math_2;
3717 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3718 bypass = "__GNUC__";
3719 files = iso/math_c99.h;
3720 c_fix = format;
3721 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3722 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3723 test_text =
3724 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3725 "#undef INFINITY\n"
3726 "#define INFINITY __builtin_infinity";
3730 * Solaris math NAN
3732 fix = {
3733 hackname = solaris_math_3;
3734 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3735 bypass = "__GNUC__";
3736 files = iso/math_c99.h;
3737 c_fix = format;
3738 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3739 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3740 test_text =
3741 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3742 "#undef NAN\n"
3743 "#define NAN __builtin_nan";
3747 * Solaris math fpclassify
3749 fix = {
3750 hackname = solaris_math_4;
3751 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3752 bypass = "__GNUC__";
3753 files = iso/math_c99.h;
3754 c_fix = format;
3755 c_fix_arg = "#define\tfpclassify(x) \\\n"
3756 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3757 "FP_SUBNORMAL, FP_ZERO, (x))";
3758 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3759 test_text =
3760 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3761 "#undef fpclassify\n"
3762 "#define fpclassify(x) __builtin_fpclassify(x)";
3766 * Solaris math signbit
3768 fix = {
3769 hackname = solaris_math_8;
3770 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3771 bypass = "__GNUC__";
3772 files = iso/math_c99.h;
3773 c_fix = format;
3774 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3775 "\t\t\t ? __builtin_signbitf(x) \\\n"
3776 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3777 "\t\t\t ? __builtin_signbitl(x) \\\n"
3778 "\t\t\t : __builtin_signbit(x))";
3779 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3780 test_text = <<- _EOText_
3781 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3782 #undef signbit
3783 #define signbit(x) __builtin_signbit(x)
3784 _EOText_;
3788 * Solaris math comparison macros
3790 fix = {
3791 hackname = solaris_math_9;
3792 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3793 bypass = "__GNUC__";
3794 files = iso/math_c99.h;
3795 c_fix = format;
3796 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3797 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3798 "__builtin_[a-z]+\\(y\\)\\)";
3799 test_text =
3800 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3801 "#undef isgreater\n"
3802 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3803 "#undef isgreaterequal\n"
3804 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3805 "#undef isless\n"
3806 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3807 "#undef islessequal\n"
3808 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3809 "#undef islessgreater\n"
3810 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3811 "#undef isunordered\n"
3812 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3816 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3817 * warnings.
3819 fix = {
3820 hackname = solaris_math_11;
3821 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3822 files = iso/math_c99.h;
3823 c_fix = format;
3824 c_fix_arg = << _EOArg_
3825 #undef signbit
3826 #define signbit(x) (sizeof(x) == sizeof(float) \
3827 ? __builtin_signbitf(x) \
3828 : sizeof(x) == sizeof(long double) \
3829 ? __builtin_signbitl(x) \
3830 : __builtin_signbit(x))
3831 _EOArg_;
3832 c_fix_arg = << _EOArg_
3833 ^#undef[ ]+signbit
3834 #if defined\(__sparc\)
3835 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3836 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3837 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3838 #elif defined\(__i386\) \|\| defined\(__amd64\)
3839 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3840 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3841 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3842 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3843 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3844 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3845 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3846 #endif
3847 _EOArg_;
3848 test_text = << _EOText_
3849 /* @(#)math_c99.h 1.14 13/03/27 */
3850 #undef signbit
3851 #if defined(__sparc)
3852 #define signbit(x) __extension__( \\
3853 { __typeof(x) __x_s = (x); \\
3854 (int) (*(unsigned *) &__x_s >> 31); })
3855 #elif defined(__i386) || defined(__amd64)
3856 #define signbit(x) __extension__( \\
3857 { __typeof(x) __x_s = (x); \\
3858 (sizeof (__x_s) == sizeof (float) ? \\
3859 (int) (*(unsigned *) &__x_s >> 31) : \\
3860 sizeof (__x_s) == sizeof (double) ? \\
3861 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3862 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3863 #endif
3864 _EOText_;
3868 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3870 fix = {
3871 hackname = solaris_math_12;
3872 files = math.h;
3873 mach = '*-*-solaris2*';
3874 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3875 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3876 test_text = << _EOText_
3877 #if __cplusplus >= 201103L
3878 #undef _GLIBCXX_USE_C99_MATH
3879 #undef _GLIBCXX_USE_C99_MATH_TR1
3880 #endif
3881 _EOText_;
3885 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3886 * structure. As such, it need two levels of brackets, but only
3887 * contains one. Wrap the macro definition in an extra layer.
3889 fix = {
3890 hackname = solaris_once_init_1;
3891 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3892 files = pthread.h;
3893 mach = '*-*-solaris*';
3894 c_fix = format;
3895 c_fix_arg = "%1{%2}%3";
3896 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3897 test_text =
3898 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3899 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3903 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3904 * posix_spawn declarations, which doesn't work with C++.
3906 fix = {
3907 hackname = solaris_posix_spawn_restrict;
3908 files = spawn.h;
3909 mach = '*-*-solaris2*';
3910 c_fix = format;
3911 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3912 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3913 test_text =
3914 "char *const argv[_RESTRICT_KYWD],\n"
3915 "char *const envp[_RESTRICT_KYWD]);";
3919 * The pow overloads with int were removed in C++ 2011 DR 550.
3921 fix = {
3922 hackname = solaris_pow_int_overload;
3923 mach = '*-*-solaris2*';
3924 files = "iso/math_iso.h";
3925 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3926 " *\\{[^{}]*\n[^{}]*\\}";
3927 c_fix = format;
3928 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3930 test_text =
3931 " inline long double pow(long double __X, int __Y) { return\n"
3932 " __powl(__X, (long double) (__Y)); }";
3936 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3937 * fields of the pthread_rwlock_t structure, which are of type
3938 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3939 * defined (e.g. by -ansi) it is a union. So change the initializer
3940 * to "{0}" instead.
3942 fix = {
3943 hackname = solaris_rwlock_init_1;
3944 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3945 files = pthread.h;
3946 mach = '*-*-solaris*';
3947 c_fix = format;
3948 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3949 "%0\n"
3950 "#else\n"
3951 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3952 "#endif";
3953 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3954 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3956 test_text =
3957 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3958 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3962 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3963 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3965 fix = {
3966 hackname = solaris_std___filbuf;
3967 files = stdio.h;
3968 mach = '*-*-solaris2*';
3969 bypass = "using std::__filbuf";
3970 select = "(using std::perror;\n)(#endif)";
3971 c_fix = format;
3972 c_fix_arg = "%1#ifndef _LP64\n"
3973 "using std::__filbuf;\n"
3974 "using std::__flsbuf;\n"
3975 "#endif\n%2";
3977 test_text = "using std::perror;\n"
3978 "#endif";
3982 * Solaris <stdio.h> shouldn't use std::gets for C++14.
3984 fix = {
3985 hackname = solaris_std_gets_cxx14;
3986 mach = "*-*-solaris2*";
3987 files = "stdio.h";
3988 select = "using std::gets;";
3990 c_fix = format;
3991 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
3993 test_text = "using std::gets;";
3997 * Sun Solaris 8 has what appears to be some gross workaround for
3998 * some old version of their c++ compiler. G++ doesn't want it
3999 * either, but doesn't want to be tied to SunPRO version numbers.
4001 fix = {
4002 hackname = solaris_stdio_tag;
4003 files = stdio_tag.h;
4005 select = '__cplusplus < 54321L';
4006 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4007 "!defined(__GNUC__)" so we no longer need to fix it. */
4008 bypass = '__GNUC__';
4009 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4011 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4015 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4017 fix = {
4018 hackname = solaris_stdlib_noreturn;
4019 mach = "*-*-solaris2*";
4020 files = "iso/stdlib_c99.h";
4021 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4023 c_fix = format;
4024 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4026 test_text = "extern _Noreturn void quick_exit(int);";
4030 * a missing semi-colon at the end of the statsswtch structure definition.
4032 fix = {
4033 hackname = statsswtch;
4034 files = rpcsvc/rstat.h;
4035 select = "boottime$";
4036 c_fix = format;
4037 c_fix_arg = "boottime;";
4038 test_text = "struct statswtch {\n int boottime\n};";
4042 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4043 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4044 * OK too.
4046 fix = {
4047 hackname = stdio_stdarg_h;
4048 files = stdio.h;
4049 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4051 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4052 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4054 mach = '*-*-solaris2.1[0-9]*';
4055 not_machine = true;
4057 c_fix = wrap;
4059 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4061 test_text = "";
4065 * Don't use or define the name va_list in stdio.h. This is for
4066 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4067 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4068 * indicate that the header knows what it's doing -- under SUSv2,
4069 * stdio.h is required to define va_list, and we shouldn't break
4070 * that.
4072 fix = {
4073 hackname = stdio_va_list;
4074 files = stdio.h;
4075 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4077 * On Solaris 10, the definition in
4078 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4079 * there is therefore no need for this fix there.
4081 mach = '*-*-solaris2.1[0-9]*';
4082 not_machine = true;
4085 * Use __gnuc_va_list in arg types in place of va_list.
4086 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4087 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4088 * trailing parentheses and semicolon save all other systems from this.
4089 * Define __not_va_list__ (something harmless and unused)
4090 * instead of va_list.
4091 * Don't claim to have defined va_list.
4093 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4094 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4095 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4096 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4097 "s@ va_list@ __not_va_list__@\n"
4098 "s@\\*va_list@*__not_va_list__@\n"
4099 "s@ __va_list)@ __gnuc_va_list)@\n"
4100 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4101 "@typedef \\1 __not_va_list__;@\n"
4102 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4103 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4104 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4105 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4106 "s@VA_LIST@DUMMY_VA_LIST@\n"
4107 "s@_Va_LIST@_VA_LIST@";
4108 test_text = "extern void mumble( va_list);";
4112 * Fix headers that use va_list from stdio.h to use the updated
4113 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4114 * dealt with elsewhere. The presence of __gnuc_va_list,
4115 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4116 * knows what it's doing.
4118 fix = {
4119 hackname = stdio_va_list_clients;
4120 files = com_err.h;
4121 files = cps.h;
4122 files = curses.h;
4123 files = krb5.h;
4124 files = lc_core.h;
4125 files = pfmt.h;
4126 files = wchar.h;
4127 files = curses_colr/curses.h;
4128 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4129 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4130 otherwise protected. */
4131 bypass = 'include <stdarg\.h>|#ifdef va_start';
4134 * Use __gnuc_va_list in arg types in place of va_list.
4135 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4136 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4137 * trailing parentheses and semicolon save all other systems from this.
4138 * Define __not_va_list__ (something harmless and unused)
4139 * instead of va_list.
4140 * Don't claim to have defined va_list.
4142 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4143 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4144 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4145 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4146 "s@ va_list@ __not_va_list__@\n"
4147 "s@\\*va_list@*__not_va_list__@\n"
4148 "s@ __va_list)@ __gnuc_va_list)@\n"
4149 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4150 "@typedef \\1 __not_va_list__;@\n"
4151 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4152 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4153 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4154 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4155 "s@VA_LIST@DUMMY_VA_LIST@\n"
4156 "s@_Va_LIST@_VA_LIST@";
4157 test_text = "extern void mumble( va_list);";
4161 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4162 * is "!defined( __STRICT_ANSI__ )"
4164 fix = {
4165 hackname = strict_ansi_not;
4166 select = "^([ \t]*#[ \t]*if.*)"
4167 "(!__STDC__"
4168 "|__STDC__[ \t]*==[ \t]*0"
4169 "|__STDC__[ \t]*!=[ \t]*1"
4170 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4171 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4172 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4173 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4174 is not defined by GCC, so it is safe. */
4175 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4176 c_test = stdc_0_in_system_headers;
4178 c_fix = format;
4179 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4181 test_text = "#if !__STDC__ \n"
4182 "#if __STDC__ == 0\n"
4183 "#if __STDC__ != 1\n"
4184 "#if __STDC__ - 0 == 0"
4185 "/* not std C */\nint foo;\n"
4186 "\n#end-end-end-end-if :-)";
4190 * "__STDC__-0==0"
4191 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4193 fix = {
4194 hackname = strict_ansi_not_ctd;
4195 files = math.h, limits.h, stdio.h, signal.h,
4196 stdlib.h, sys/signal.h, time.h;
4198 * Starting at the beginning of a line, skip white space and
4199 * a leading "(" or "&&" or "||". One of those must be found.
4200 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4201 * expression. If these are nested, then they must accumulate
4202 * because we won't match any closing parentheses. Finally,
4203 * after skipping over all that, we must then match our suspect
4204 * phrase: "__STDC__-0==0" with or without white space.
4206 select = "^([ \t]*" '(\(|&&|\|\|)'
4207 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4208 "[ \t(]*)"
4209 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4210 c_test = stdc_0_in_system_headers;
4212 c_fix = format;
4213 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4215 test_text = "#if 1 && \\\\\n"
4216 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4217 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4218 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4219 "int foo;\n#endif";
4223 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4224 * is "defined( __STRICT_ANSI__ )"
4226 fix = {
4227 hackname = strict_ansi_only;
4228 select = "^([ \t]*#[ \t]*if.*)"
4229 "(__STDC__[ \t]*!=[ \t]*0"
4230 "|__STDC__[ \t]*==[ \t]*1"
4231 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4232 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4233 c_test = stdc_0_in_system_headers;
4235 c_fix = format;
4236 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4238 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4242 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4243 * in prototype without previous definition.
4245 fix = {
4246 hackname = struct_file;
4247 files = rpc/xdr.h;
4248 select = '^.*xdrstdio_create.*struct __file_s';
4249 c_fix = format;
4250 c_fix_arg = "struct __file_s;\n%0";
4251 test_text = "extern void xdrstdio_create( struct __file_s* );";
4255 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4256 * in prototype without previous definition.
4258 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4259 * function, and does define it.
4261 fix = {
4262 hackname = struct_sockaddr;
4263 files = rpc/auth.h;
4264 select = "^.*authdes_create.*struct sockaddr[^_]";
4265 bypass = "<sys/socket\.h>";
4266 bypass = "struct sockaddr;\n";
4267 c_fix = format;
4268 c_fix_arg = "struct sockaddr;\n%0";
4269 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4273 * Apply fix this to all OSs since this problem seems to effect
4274 * more than just SunOS.
4276 fix = {
4277 hackname = sun_auth_proto;
4278 files = rpc/auth.h;
4279 files = rpc/clnt.h;
4280 files = rpc/svc.h;
4281 files = rpc/xdr.h;
4282 bypass = "__cplusplus";
4284 * Select those files containing '(*name)()'.
4286 select = '\(\*[a-z][a-z_]*\)\(\)';
4288 c_fix = format;
4289 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4290 "#else\n%1();%2\n#endif";
4291 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4293 test_text =
4294 "struct auth_t {\n"
4295 " int (*name)(); /* C++ bad */\n"
4296 "};";
4300 * Fix bogus #ifdef on SunOS 4.1.
4302 fix = {
4303 hackname = sun_bogus_ifdef;
4304 files = "hsfs/hsfs_spec.h";
4305 files = "hsfs/iso_spec.h";
4306 select = '#ifdef(.*\|\|.*)';
4307 c_fix = format;
4308 c_fix_arg = "#if%1";
4310 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4314 * Fix the CAT macro in SunOS memvar.h.
4316 fix = {
4317 hackname = sun_catmacro;
4318 files = pixrect/memvar.h;
4319 select = "^#define[ \t]+CAT\\(a,b\\).*";
4320 c_fix = format;
4322 c_fix_arg =
4323 "#ifdef __STDC__\n"
4324 "# define CAT(a,b) a##b\n"
4325 "#else\n%0\n#endif";
4327 test_text =
4328 "#define CAT(a,b)\ta/**/b";
4332 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4333 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4335 fix = {
4336 hackname = sun_malloc;
4337 files = malloc.h;
4338 bypass = "_CLASSIC_ANSI_TYPES";
4340 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4341 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4342 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4343 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4344 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4346 test_text =
4347 "typedef char *\tmalloc_t;\n"
4348 "int \tfree();\n"
4349 "char*\tmalloc();\n"
4350 "char*\tcalloc();\n"
4351 "char*\trealloc();";
4355 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4357 fix = {
4358 hackname = sun_rusers_semi;
4359 files = rpcsvc/rusers.h;
4360 select = "_cnt$";
4361 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4362 test_text = "struct mumble\n int _cnt\n};";
4366 * signal.h on SunOS defines signal using (),
4367 * which causes trouble when compiling with g++ -pedantic.
4369 fix = {
4370 hackname = sun_signal;
4371 files = sys/signal.h;
4372 files = signal.h;
4373 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4375 c_fix = format;
4376 c_fix_arg =
4377 "#ifdef __cplusplus\n"
4378 "void\t(*signal(...))(...);\n"
4379 "#else\n%0\n#endif";
4381 test_text = "void\t(*signal())();";
4385 * Correct the return type for strlen in strings.h in SunOS 4.
4387 fix = {
4388 hackname = sunos_strlen;
4389 files = strings.h;
4390 select = "int[ \t]*strlen\\(\\);(.*)";
4391 c_fix = format;
4392 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4393 test_text = " int\tstrlen(); /* string length */";
4397 * Linux kernel's vt.h breaks C++
4399 fix = {
4400 hackname = suse_linux_vt_cxx;
4401 files = linux/vt.h;
4403 select = "^[ \t]*unsigned int new;";
4404 c_fix = format;
4405 c_fix_arg = "unsigned int newev;";
4407 test_text = " unsigned int new; /* New console (if changing) */";
4411 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4412 * that is visible to any ANSI compiler using this include. Simply
4413 * delete the lines that #define some string functions to internal forms.
4415 fix = {
4416 hackname = svr4_disable_opt;
4417 files = string.h;
4418 select = '#define.*__std_hdr_';
4419 sed = '/#define.*__std_hdr_/d';
4420 test_text = "#define strlen __std_hdr_strlen\n";
4424 * Fix broken decl of getcwd present on some svr4 systems.
4426 fix = {
4427 hackname = svr4_getcwd;
4428 files = stdlib.h;
4429 files = unistd.h;
4430 files = prototypes.h;
4431 select = 'getcwd\(char \*, int\)';
4433 c_fix = format;
4434 c_fix_arg = "getcwd(char *, size_t)";
4436 test_text = "extern char* getcwd(char *, int);";
4440 * Fix broken decl of profil present on some svr4 systems.
4442 fix = {
4443 hackname = svr4_profil;
4444 files = stdlib.h;
4445 files = unistd.h;
4447 select =
4448 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4449 c_fix = format;
4450 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4452 test_text =
4453 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4457 * Correct types for signal handler constants like SIG_DFL; they might be
4458 * void (*) (), and should be void (*) (int). C++ doesn't like the
4459 * old style.
4461 fix = {
4462 hackname = svr4_sighandler_type;
4463 files = sys/signal.h;
4464 select = 'void *\(\*\)\(\)';
4465 c_fix = format;
4466 c_fix_arg = "void (*)(int)";
4467 test_text = "#define SIG_DFL (void(*)())0\n"
4468 "#define SIG_IGN (void (*)())0\n";
4472 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4473 * function 'getrnge' in <regexp.h> before they declare it. For these
4474 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4475 * early on.
4477 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4478 * so put the declaration right after the declaration of 'size'.
4480 * Don't do this if there is already a `static void getrnge' declaration
4481 * present, since this would cause a redeclaration error. Solaris 2.x has
4482 * such a declaration.
4484 fix = {
4485 hackname = svr4_undeclared_getrnge;
4486 files = regexp.h;
4487 select = "getrnge";
4488 bypass = "static void getrnge";
4489 c_fix = format;
4490 c_fix_arg = "%0\n"
4491 "static int getrnge ();";
4492 c_fix_arg = "^static int[ \t]+size;";
4493 test_text = "static int size;\n"
4494 "/* stuff which calls getrnge() */\n"
4495 "static getrnge()\n"
4496 "{}";
4500 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4501 * in string.h on sysV68
4502 * Correct the return type for strlen in string.h on Lynx.
4503 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4504 * Add missing const for strdup on OSF/1 V3.0.
4505 * On sysV88 layout is slightly different.
4507 fix = {
4508 hackname = sysv68_string;
4509 files = testing.h;
4510 files = string.h;
4511 bypass = "_CLASSIC_ANSI_TYPES";
4513 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4514 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4515 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4517 sed = "/^extern char$/N";
4518 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4520 sed = "/^extern int$/N";
4521 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4523 sed = "/^\tstrncmp(),$/N";
4524 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4525 '\1;' "\\\nextern unsigned int\\\n\\2/";
4527 test_text =
4528 "extern int strlen();\n"
4530 "extern int ffs(long);\n"
4532 "extern char\n"
4533 "\t*memccpy(),\n"
4534 "\tmemcpy();\n"
4536 "extern int\n"
4537 "\tstrcmp(),\n"
4538 "\tstrncmp(),\n"
4539 "\tstrlen(),\n"
4540 "\tstrspn();\n"
4542 "extern int\n"
4543 "\tstrlen(), strspn();";
4547 * Fix return type of calloc, malloc, realloc, bsearch and exit
4549 fix = {
4550 hackname = sysz_stdlib_for_sun;
4551 files = stdlib.h;
4552 bypass = "_CLASSIC_ANSI_TYPES";
4554 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4555 c_fix = format;
4556 c_fix_arg = "void *\t%1(";
4558 test_text =
4559 "extern char*\tcalloc(size_t);\n"
4560 "extern char*\tmalloc(size_t);\n"
4561 "extern char*\trealloc(void*,size_t);\n"
4562 "extern char*\tbsearch(void*,size_t,size_t);\n";
4566 * __thread is now a keyword.
4568 fix = {
4569 hackname = thread_keyword;
4570 files = "pthread.h";
4571 files = bits/sigthread.h, '*/bits/sigthread.h';
4572 select = "([* ])__thread([,)])";
4573 c_fix = format;
4574 c_fix_arg = "%1__thr%2";
4576 test_text =
4577 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4578 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4579 "extern int pthread_cancel (pthread_t __thread);";
4583 * if the #if says _cplusplus, not the double underscore __cplusplus
4584 * that it should be
4586 fix = {
4587 hackname = tinfo_cplusplus;
4588 files = tinfo.h;
4589 select = "[ \t]_cplusplus";
4591 c_fix = format;
4592 c_fix_arg = " __cplusplus";
4593 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4597 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4599 fix = {
4600 hackname = ultrix_const;
4601 files = stdio.h;
4602 select = 'perror\( char \*';
4604 c_fix = format;
4605 c_fix_arg = "%1 const %3 *__";
4606 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4607 "[ \t]+(char|void) \\*__";
4609 test_text =
4610 "extern void perror( char *__s );\n"
4611 "extern int fputs( char *__s, FILE *);\n"
4612 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4613 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4614 "extern int scanf( char *__format, ...);\n";
4618 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4620 fix = {
4621 hackname = ultrix_const2;
4622 files = stdio.h;
4624 select = '\*fopen\( char \*';
4625 c_fix = format;
4626 c_fix_arg = "%1( const char *%3, const char *";
4627 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4628 "[ \t]*char[ \t]*\\*([^,]*),"
4629 "[ \t]*char[ \t]*\\*[ \t]*";
4631 test_text =
4632 "extern FILE *fopen( char *__filename, char *__type );\n"
4633 "extern int sscanf( char *__s, char *__format, ...);\n"
4634 "extern FILE *popen(char *, char *);\n"
4635 "extern char *tempnam(char*,char*);\n";
4639 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4641 fix = {
4642 hackname = va_i960_macro;
4643 files = arch/i960/archI960.h;
4644 select = "__(vsiz|vali|vpad|alignof__)";
4646 c_fix = format;
4647 c_fix_arg = "__vx%1";
4649 test_text =
4650 "extern int __vsiz vsiz;\n"
4651 "extern int __vali vali;\n"
4652 "extern int __vpad vpad;\n"
4653 "#define __alignof__(x) ...";
4657 * On VMS, add missing braces around sigset_t constants.
4659 fix = {
4660 hackname = vms_add_missing_braces;
4661 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4662 mach = "*-*-*vms*";
4663 files = "rtldef/signal.h";
4664 c_fix = format;
4666 c_fix_arg = '%1 {%2} ';
4668 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4669 "{0x00000000, 0x00000000},\n"
4670 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4674 * On VMS, some DEC-C builtins are directly used.
4676 fix = {
4677 hackname = vms_decc_builtin;
4678 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4679 mach = "*-*-*vms*";
4680 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4681 rtldef/socket.h;
4682 sed = "s@__MEMSET@memset@";
4683 sed = "s@__MEMMOVE@memmove@";
4684 sed = "s@__MEMCPY@memcpy@";
4685 sed = "s@__STRLEN@strlen@";
4686 sed = "s@__STRCPY@strcpy@";
4688 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4692 * Define __CAN_USE_EXTERN_PREFIX on vms.
4694 fix = {
4695 hackname = vms_define_can_use_extern_prefix;
4696 files = "rtldef/decc$types.h";
4697 select = "#[ \t]*else\n"
4698 "#[ \t]*if defined\\(__DECCXX\\)\n"
4699 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4700 mach = "*-*-*vms*";
4701 c_fix = format;
4703 c_fix_arg = "%0"
4704 "# elif defined (__GNUC__)\n"
4705 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4707 test_text = "# else\n"
4708 "# if defined(__DECCXX)\n"
4709 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4710 "# endif\n"
4711 "# endif\n";
4715 * On VMS, disable the use of dec-c string builtins
4717 fix = {
4718 hackname = vms_disable_decc_string_builtins;
4719 select = "#if !defined\\(__VAX\\)\n";
4720 mach = "*-*-*vms*";
4721 files = "rtldef/string.h";
4722 c_fix = format;
4724 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4726 test_text = "#if !defined(__VAX)\n";
4730 * On VMS, fix incompatible redeclaration of hostalias.
4732 fix = {
4733 hackname = vms_do_not_redeclare_hostalias;
4734 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4735 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4736 mach = "*-*-*vms*";
4737 files = "rtldef/resolv.h";
4738 c_fix = format;
4740 c_fix_arg = "%1\n"
4741 "/* %2 */";
4743 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4744 "__char_ptr32 hostalias (const char *);\n";
4748 * On VMS, forward declare structure before referencing them in prototypes.
4750 fix = {
4751 hackname = vms_forward_declare_struct;
4752 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4753 "#ifdef __cplusplus\n";
4754 mach = "*-*-*vms*";
4755 files = rtldef/if.h;
4756 c_fix = format;
4758 c_fix_arg = "%1"
4759 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4761 test_text = "/* forward decls for C++ */\n"
4762 "#ifdef __cplusplus\n"
4763 "struct foo;\n"
4764 "#endif\n";
4768 * On VMS, do not declare getopt and al if pointers are 64 bit.
4770 fix = {
4771 hackname = vms_no_64bit_getopt;
4772 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4773 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4774 mach = "*-*-*vms*";
4775 files = rtldef/stdio.h, rtldef/unistd.h;
4776 c_fix = format;
4778 c_fix_arg = <<- _EOArg_
4779 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4780 %0#endif
4782 _EOArg_;
4784 test_text = "int getopt (int, char * const [], const char *);";
4788 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4789 * which is not yet fully supported by gcc.
4791 fix = {
4792 hackname = vms_use_fast_setjmp;
4793 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4794 mach = "*-*-*vms*";
4795 files = rtldef/setjmp.h;
4796 c_fix = format;
4798 c_fix_arg = "%0 defined (__GNUC__) ||";
4800 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4804 * On VMS, use pragma extern_model instead of VAX-C keywords.
4806 fix = {
4807 hackname = vms_use_pragma_extern_model;
4808 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4809 "# pragma extern_model __save\n";
4810 mach = "*-*-*vms*";
4811 c_fix = format;
4813 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4814 "# pragma extern_model __save\n";
4816 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4817 "# pragma extern_model __save\n"
4818 "# pragma extern_model strict_refdef\n"
4819 " extern struct x zz$yy;\n"
4820 "# pragma extern_model __restore\n"
4821 "#endif\n";
4825 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4826 * conflict while building gcc. Likewise for <builtins.h>
4828 fix = {
4829 hackname = vms_use_quoted_include;
4830 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4831 mach = "*-*-*vms*";
4832 files = rtldef/wait.h, starlet_c/pthread.h;
4833 c_fix = format;
4835 c_fix_arg = '%1<sys/%2.h>';
4837 test_text = "# include <resource.h>";
4841 * AIX and Interix headers define NULL to be cast to a void pointer,
4842 * which is illegal in ANSI C++.
4844 fix = {
4845 hackname = void_null;
4846 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4847 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4848 /* avoid changing C++ friendly NULL */
4849 bypass = __cplusplus;
4850 bypass = __null;
4851 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4852 c_fix = format;
4853 c_fix_arg = <<- _EOFix_
4854 #ifndef NULL
4855 #ifdef __cplusplus
4856 #ifdef __GNUG__
4857 #define NULL __null
4858 #else /* ! __GNUG__ */
4859 #define NULL 0L
4860 #endif /* __GNUG__ */
4861 #else /* ! __cplusplus */
4862 #define NULL ((void *)0)
4863 #endif /* __cplusplus */
4864 #endif /* !NULL */
4865 _EOFix_;
4866 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4870 * Make VxWorks header which is almost gcc ready fully gcc ready.
4872 fix = {
4873 hackname = vxworks_gcc_problem;
4874 files = types/vxTypesBase.h;
4875 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4877 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4878 "#if 1/";
4880 sed = "/[ \t]size_t/i\\\n"
4881 "#ifndef _GCC_SIZE_T\\\n"
4882 "#define _GCC_SIZE_T\n";
4884 sed = "/[ \t]size_t/a\\\n"
4885 "#endif\n";
4887 sed = "/[ \t]ptrdiff_t/i\\\n"
4888 "#ifndef _GCC_PTRDIFF_T\\\n"
4889 "#define _GCC_PTRDIFF_T\n";
4891 sed = "/[ \t]ptrdiff_t/a\\\n"
4892 "#endif\n";
4894 sed = "/[ \t]wchar_t/i\\\n"
4895 "#ifndef _GCC_WCHAR_T\\\n"
4896 "#define _GCC_WCHAR_T\n";
4898 sed = "/[ \t]wchar_t/a\\\n"
4899 "#endif\n";
4901 test_text =
4902 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4903 "typedef unsigned int size_t;\n"
4904 "typedef long ptrdiff_t;\n"
4905 "typedef unsigned short wchar_t;\n"
4906 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4910 * Wrap VxWorks ioctl to keep everything pretty
4912 fix = {
4913 hackname = vxworks_ioctl_macro;
4914 files = ioLib.h;
4915 mach = "*-*-vxworks*";
4917 c_fix = format;
4918 c_fix_arg = "%0\n"
4919 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4920 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4922 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4926 * Wrap VxWorks mkdir to be posix compliant
4928 fix = {
4929 hackname = vxworks_mkdir_macro;
4930 files = sys/stat.h;
4931 mach = "*-*-vxworks*";
4933 c_fix = format;
4934 c_fix_arg = "%0\n"
4935 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4936 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4937 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4938 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4939 "\\)[\t ]*;";
4941 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4945 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4947 fix = {
4948 hackname = vxworks_needs_vxtypes;
4949 files = time.h;
4950 select = "uint_t([ \t]+_clocks_per_sec)";
4951 c_fix = format;
4952 c_fix_arg = "unsigned int%1";
4953 test_text = "uint_t\t_clocks_per_sec;";
4957 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4959 fix = {
4960 hackname = vxworks_needs_vxworks;
4961 files = sys/stat.h;
4962 test = " -r types/vxTypesOld.h";
4963 test = " -n \"`egrep '#include' $file`\"";
4964 test = " -n \"`egrep ULONG $file`\"";
4965 select = "#[ \t]define[ \t]+__INCstath";
4967 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4968 "#include <types/vxTypesOld.h>\n";
4970 test_text = "`touch types/vxTypesOld.h`"
4971 "#include </dev/null> /* ULONG */\n"
4972 "# define\t__INCstath <sys/stat.h>";
4976 * Make it so VxWorks does not include gcc/regs.h accidentally
4978 fix = {
4979 hackname = vxworks_regs;
4980 mach = "*-*-vxworks*";
4982 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4983 c_fix = format;
4984 c_fix_arg = "#include <arch/../regs.h>";
4986 test_text = "#include <regs.h>\n";
4990 * Another bad dependency in VxWorks 5.2 <time.h>.
4992 fix = {
4993 hackname = vxworks_time;
4994 files = time.h;
4995 test = " -r vxWorks.h";
4997 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4998 c_fix = format;
5000 c_fix_arg =
5001 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5002 "#ifdef __cplusplus\n"
5003 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5004 "#else\n"
5005 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5006 "#endif\n"
5007 "#define __gcc_VOIDFUNCPTR_defined\n"
5008 "#endif\n"
5009 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5011 test_text = "`touch vxWorks.h`"
5012 "#define VOIDFUNCPTR (void(*)())";
5016 * This hack makes write const-correct on VxWorks
5018 fix = {
5019 hackname = vxworks_write_const;
5020 files = ioLib.h;
5021 mach = "*-*-vxworks*";
5023 c_fix = format;
5024 c_fix_arg = "extern int write (int, const char*, size_t);";
5025 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5026 "[\t ]*int[\t ]*,"
5027 "[\t ]*char[\t ]*\\*[\t ]*,"
5028 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5030 test_text = "extern int write ( int , char * , size_t ) ;";
5034 * This hack ensures the include_next in the fixed unistd.h actually
5035 * finds the system's unistd.h and not the fixed unistd.h again.
5037 fix = {
5038 hackname = vxworks_iolib_include_unistd;
5039 files = ioLib.h;
5040 mach = "*-*-vxworks*";
5041 select = "#include \"unistd.h\"";
5043 c_fix = format;
5044 c_fix_arg = "#include <unistd.h>";
5046 test_text = "#include \"unistd.h\"";
5050 * There are several name conflicts with C++ reserved words in X11 header
5051 * files. These are fixed in some versions, so don't do the fixes if
5052 * we find __cplusplus in the file. These were found on the RS/6000.
5054 fix = {
5055 hackname = x11_class;
5056 files = X11/ShellP.h;
5057 bypass = __cplusplus;
5058 select = "^([ \t]*char \\*)class;(.*)";
5059 c_fix = format;
5060 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5061 "#else\n%1class;%2\n#endif";
5062 test_text =
5063 "struct {\n"
5064 " char *class;\n"
5065 "} mumble;\n";
5069 * class in Xm/BaseClassI.h
5071 fix = {
5072 hackname = x11_class_usage;
5073 files = Xm/BaseClassI.h;
5074 bypass = "__cplusplus";
5076 select = " class\\)";
5077 c_fix = format;
5078 c_fix_arg = " c_class)";
5080 test_text = "extern mumble (int class);\n";
5084 * new in Xm/Traversal.h
5086 fix = {
5087 hackname = x11_new;
5088 files = Xm/Traversal.h;
5089 bypass = __cplusplus;
5091 sed = "/Widget\told, new;/i\\\n"
5092 "#ifdef __cplusplus\\\n"
5093 "\\\tWidget\told, c_new;\\\n"
5094 "#else\n";
5096 sed = "/Widget\told, new;/a\\\n"
5097 "#endif\n";
5099 sed = "s/Widget new,/Widget c_new,/g";
5100 test_text =
5101 "struct wedge {\n"
5102 " Widget\told, new;\n"
5103 "};\nextern Wedged( Widget new, Widget old );";
5107 * Incorrect sprintf declaration in X11/Xmu.h
5109 fix = {
5110 hackname = x11_sprintf;
5111 files = X11/Xmu.h;
5112 files = X11/Xmu/Xmu.h;
5113 select = "^extern char \\*\tsprintf\\(\\);$";
5115 c_fix = format;
5116 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5118 test_text = "extern char *\tsprintf();";
5120 /*EOF*/