Fix build on sparc64-linux-gnu.
[official-gcc.git] / fixincludes / inclhack.def
blob8fd9f7ef295e2bb5f0c5872b529fc813ea8bee9f
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 /* regs.h depends on CPU_FAMILY being properly defined, which
430 is done by vxCpu.h. */
431 #include <types/vxCpu.h>
432 /* regs.h includes a CPU_FAMILY-specific header that requires
433 vxTypesOld.h to already have been included. Those headers
434 contain proper _ASMLANGUAGE guards around their typedefs,
435 but vxTypesOld.h itself does not. So we avoid including
436 vxTypesOld.h from assembly. */
437 #ifndef _ASMLANGUAGE
438 #include <types/vxTypesOld.h>
439 #endif
440 #include_next <arch/../regs.h>
441 #endif
442 _EndOfHeader_;
446 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
448 fix = {
449 hackname = AAB_vxworks_unistd;
450 files = unistd.h;
451 mach = "*-*-vxworks*";
453 replace = <<- _EndOfHeader_
454 #ifndef _UNISTD_H
455 #define _UNISTD_H
456 #include_next <unistd.h>
457 #include <ioLib.h>
458 #ifndef STDIN_FILENO
459 #define STDIN_FILENO 0
460 #endif
461 #ifndef STDOUT_FILENO
462 #define STDOUT_FILENO 1
463 #endif
464 #ifndef STDERR_FILENO
465 #define STDERR_FILENO 2
466 #endif
467 #endif /* _UNISTD_H */
468 _EndOfHeader_;
472 * assert.h on AIX 7 redefines static_assert as _Static_assert without
473 * protecting C++.
475 fix = {
476 hackname = aix_assert;
477 mach = "*-*-aix*";
478 files = assert.h;
479 select = "#define[ \t]static_assert[ \t]_Static_assert";
480 c_fix = format;
481 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
482 test_text = "#define static_assert _Static_assert";
486 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
487 * which only is provided by AIX xlc C99.
489 fix = {
490 hackname = aix_complex;
491 mach = "*-*-aix*";
492 files = complex.h;
493 select = "#define[ \t]_Complex_I[ \t]__I";
494 c_fix = format;
495 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
496 test_text = "#define _Complex_I __I\n";
500 * On AIX some headers are not properly guarded by 'extern "C"'.
502 fix = {
503 hackname = aix_externc;
504 mach = "*-*-aix*";
505 files = ctype.h;
506 files = fcntl.h;
507 files = langinfo.h;
508 files = ldfcn.h;
509 files = sys/localedef.h;
510 files = sys/times.h;
511 bypass = "extern \"C\"";
512 c_fix = wrap;
513 c_fix_arg = "#ifdef __cplusplus\n"
514 "extern \"C\" {\n"
515 "#endif\n";
516 c_fix_arg = "#ifdef __cplusplus\n"
517 "}\n"
518 "#endif\n";
519 test_text = "extern int __n_pthreads;\n";
523 * On AIX sys/socket.h assumes C++.
525 fix = {
526 hackname = aix_externcpp1;
527 mach = "*-*-aix*";
528 files = "sys/socket.h";
529 select = "#ifdef __cplusplus";
530 c_fix = format;
531 c_fix_arg = "#ifdef __cplusplus\n"
532 "extern \"C++\" {";
533 test_text = "#ifdef __cplusplus";
537 fix = {
538 hackname = aix_externcpp2;
539 mach = "*-*-aix*";
540 files = "sys/socket.h";
541 select = "#else /\\* __cplusplus \\*/";
542 c_fix = format;
543 c_fix_arg = "} /* extern \"C++\" */\n"
544 "#else /* __cplusplus */";
545 test_text = "#else /* __cplusplus */";
550 * malloc.h on AIX6 uses XLC++ specific builtin syntax
552 fix = {
553 hackname = aix_malloc;
554 mach = "*-*-aix*";
555 files = "malloc.h";
556 select = "#ifdef __cplusplus";
557 c_fix = format;
558 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
559 test_text = "#ifdef __cplusplus";
563 * net/if_arp.h defines a variable fc_softc instead of adding a
564 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
566 fix = {
567 hackname = aix_net_if_arp;
568 mach = "*-*-aix*";
569 files = "net/if_arp.h";
570 select = "^struct fc_softc \\{";
571 c_fix = format;
572 c_fix_arg = "typedef struct _fc_softc {";
573 test_text = "struct fc_softc {\n int a;\n};";
577 * Fix AIX definition of NULL for G++.
579 fix = {
580 hackname = aix_null;
581 mach = "*-*-aix*";
582 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
583 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
584 bypass = __null;
585 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
586 c_fix = format;
587 c_fix_arg = <<- _EOFix_
588 #ifndef NULL
589 #ifdef __cplusplus
590 #ifdef __GNUG__
591 #define NULL __null
592 #else /* ! __GNUG__ */
593 #define NULL 0L
594 #endif /* __GNUG__ */
595 #else /* ! __cplusplus */
596 #define NULL ((void *)0)
597 #endif /* __cplusplus */
598 #endif /* !NULL */
599 _EOFix_;
600 test_text = "# define\tNULL \t(0L) /* typed NULL */";
604 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
605 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
606 * braces.
608 fix = {
609 hackname = aix_once_init_1;
610 mach = "*-*-aix*";
611 files = "pthread.h";
612 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
613 "\\{ \\\\\n";
614 c_fix = format;
615 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
616 "{{ \\\n";
617 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
618 "{ \\\\\n";
621 fix = {
622 hackname = aix_once_init_2;
623 mach = "*-*-aix*";
624 files = "pthread.h";
625 select = "[ \t]0 \\\\\n"
626 "\\}\n";
627 c_fix = format;
628 c_fix_arg = " 0 \\\n"
629 "}}\n";
630 test_text = " 0 \\\\\n"
631 "}\n";
634 fix = {
635 hackname = aix_mutex_initializer_1;
636 mach = "*-*-aix*";
637 files = "pthread.h";
638 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
639 "\\{ \\\\\n";
640 c_fix = format;
641 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
642 "{{ \\\n";
643 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
644 "{ \\\\\n";
647 fix = {
648 hackname = aix_cond_initializer_1;
649 mach = "*-*-aix*";
650 files = "pthread.h";
651 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
652 "\\{ \\\\\n";
653 c_fix = format;
654 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
655 "{{ \\\n";
656 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
657 "{ \\\\\n";
660 fix = {
661 hackname = aix_rwlock_initializer_1;
662 mach = "*-*-aix*";
663 files = "pthread.h";
664 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
665 "\\{ \\\\\n";
666 c_fix = format;
667 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
668 "{{ \\\n";
669 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
670 "{ \\\\\n";
674 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
675 * which violates a requirement of ISO C.
677 fix = {
678 hackname = aix_pthread;
679 files = "pthread.h";
680 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
681 c_fix = format;
682 c_fix_arg = "%1 %2";
683 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
684 "{...init stuff...}";
688 * AIX stdint.h fixes.
690 fix = {
691 hackname = aix_stdint_1;
692 mach = "*-*-aix*";
693 files = stdint-aix.h, stdint.h;
694 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
695 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
696 c_fix = format;
697 c_fix_arg = "#define UINT8_MAX (255)\n"
698 "#define UINT16_MAX (65535)";
699 test_text = "#define UINT8_MAX (255U)\n"
700 "#define UINT16_MAX (65535U)";
704 * aix_stdint_2
706 fix = {
707 hackname = aix_stdint_2;
708 mach = "*-*-aix*";
709 files = stdint-aix.h, stdint.h;
710 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
711 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
712 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
713 "#else\n"
714 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
715 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
716 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
717 c_fix = format;
718 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
719 "#define INTPTR_MAX 9223372036854775807L\n"
720 "#define UINTPTR_MAX 18446744073709551615UL\n"
721 "#else\n"
722 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
723 "#define INTPTR_MAX 2147483647L\n"
724 "#define UINTPTR_MAX 4294967295UL";
725 test_text = "#define INTPTR_MIN INT64_MIN\n"
726 "#define INTPTR_MAX INT64_MAX\n"
727 "#define UINTPTR_MAX UINT64_MAX\n"
728 "#else\n"
729 "#define INTPTR_MIN INT32_MIN\n"
730 "#define INTPTR_MAX INT32_MAX\n"
731 "#define UINTPTR_MAX UINT32_MAX";
735 * aix_stdint_3
737 fix = {
738 hackname = aix_stdint_3;
739 mach = "*-*-aix*";
740 files = stdint-aix.h, stdint.h;
741 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
742 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
743 "#else\n"
744 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
745 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
746 c_fix = format;
747 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
748 "#define PTRDIFF_MAX 9223372036854775807L\n"
749 "#else\n"
750 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
751 "#define PTRDIFF_MAX 2147483647L";
752 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
753 "#define PTRDIFF_MAX INT64_MAX\n"
754 "#else\n"
755 "#define PTRDIFF_MIN INT32_MIN\n"
756 "#define PTRDIFF_MAX INT32_MAX";
760 * aix_stdint_4
762 fix = {
763 hackname = aix_stdint_4;
764 mach = "*-*-aix*";
765 files = stdint-aix.h, stdint.h;
766 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
767 "#else\n"
768 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
769 c_fix = format;
770 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
771 "#else\n"
772 "#define SIZE_MAX 4294967295UL";
773 test_text = "#define SIZE_MAX UINT64_MAX\n"
774 "#else\n"
775 "#define SIZE_MAX UINT32_MAX";
779 * aix_stdint_5
781 fix = {
782 hackname = aix_stdint_5;
783 mach = "*-*-aix*";
784 files = stdint-aix.h, stdint.h;
785 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
786 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
787 c_fix = format;
788 c_fix_arg = "#define UINT8_C(c) c\n"
789 "#define UINT16_C(c) c";
790 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
791 "#define UINT16_C(c) __CONCAT__(c,U)";
795 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
796 produces wrong code with G++.
798 fix = {
799 hackname = aix_stdio_inline;
800 mach = "*-*-aix*";
801 files = stdio.h;
802 select = "#ifdef __cplusplus\\\n"
803 "}\\\n\\\n"
804 "#ifdef ferror\\\n";
805 c_fix = format;
806 c_fix_arg = "#ifdef __cplusplus\n"
807 "}\n"
808 "#endif\n\n"
809 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
810 "#ifdef ferror\n";
811 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
815 * stdlib.h on AIX uses #define on malloc and friends.
817 fix = {
818 hackname = aix_stdlib_malloc;
819 mach = "*-*-aix*";
820 files = stdlib.h;
821 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
822 c_fix = format;
823 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
824 test_text = "#define malloc __linux_malloc";
827 fix = {
828 hackname = aix_stdlib_realloc;
829 mach = "*-*-aix*";
830 files = stdlib.h;
831 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
832 c_fix = format;
833 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
834 test_text = "#define realloc __linux_realloc";
837 fix = {
838 hackname = aix_stdlib_calloc;
839 mach = "*-*-aix*";
840 files = stdlib.h;
841 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
842 c_fix = format;
843 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
844 test_text = "#define calloc __linux_calloc";
847 fix = {
848 hackname = aix_stdlib_valloc;
849 mach = "*-*-aix*";
850 files = stdlib.h;
851 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
852 c_fix = format;
853 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
854 test_text = "#define valloc __linux_valloc";
857 fix = {
858 hackname = aix_stdlib_vec_malloc;
859 mach = "*-*-aix*";
860 files = stdlib.h;
861 select = "#define[ \t]+malloc[ \t]+vec_malloc";
862 c_fix = format;
863 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
864 test_text = "#define malloc vec_malloc";
867 fix = {
868 hackname = aix_stdlib_vec_calloc;
869 mach = "*-*-aix*";
870 files = stdlib.h;
871 select = "#define[ \t]+calloc[ \t]+vec_calloc";
872 c_fix = format;
873 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
874 test_text = "#define calloc vec_calloc";
878 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
880 fix = {
881 hackname = aix_strtof_const;
882 mach = "*-*-aix*";
883 files = stdlib.h;
884 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
885 c_fix = format;
886 c_fix_arg = "%1(const char *, char **);";
887 test_text = "extern float strtof(char *, char **);";
891 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
892 * in an otherwise harmless (and #ifed out) macro definition
894 fix = {
895 hackname = aix_sysmachine;
896 mach = "*-*-aix*";
897 files = sys/machine.h;
898 select = "\\\\ +\n";
899 c_fix = format;
900 c_fix_arg = "\\\n";
901 test_text = "#define FOO \\\n"
902 " bar \\ \n baz \\ \n bat";
906 * sys/wait.h on AIX 5.2 defines macros that have both signed and
907 * unsigned types in conditional expressions.
909 fix = {
910 hackname = aix_syswait_2;
911 mach = "*-*-aix*";
912 files = sys/wait.h;
913 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
914 c_fix = format;
915 c_fix_arg = "? (int)%1";
916 test_text = "#define WSTOPSIG(__x) "
917 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
921 * sys/signal.h on some versions of AIX uses volatile in the typedef of
922 * sig_atomic_t, which causes gcc to generate a warning about duplicate
923 * volatile when a sig_atomic_t variable is declared volatile, as
924 * required by ANSI C.
926 fix = {
927 hackname = aix_volatile;
928 mach = "*-*-aix*";
929 files = sys/signal.h;
930 select = "typedef volatile int sig_atomic_t";
931 c_fix = format;
932 c_fix_arg = "typedef int sig_atomic_t";
933 test_text = "typedef volatile int sig_atomic_t;";
937 * AIX unistd.h defines a static function with an empty parameter list.
939 fix = {
940 hackname = aix_unistd;
941 mach = "*-*-aix*";
942 files = unistd.h;
944 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
945 c_fix = format;
946 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
947 test_text = " static int getdtablesize()";
951 * Fix __assert declaration in assert.h on Alpha OSF/1.
953 fix = {
954 hackname = alpha___assert;
955 files = "assert.h";
956 select = '__assert\(char \*, char \*, int\)';
957 c_fix = format;
958 c_fix_arg = "__assert(const char *, const char *, int)";
959 test_text = 'extern void __assert(char *, char *, int);';
963 * Fix assert macro in assert.h on Alpha OSF/1.
964 * The superfluous int cast breaks C++.
966 fix = {
967 hackname = alpha_assert;
968 files = "assert.h";
969 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
970 c_fix = format;
971 c_fix_arg = "%1(EX)";
972 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
973 ': __assert(#EX, __FILE__, __LINE__))';
977 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
979 fix = {
980 hackname = alpha_getopt;
981 files = "stdio.h";
982 files = "stdlib.h";
983 select = 'getopt\(int, char \*\[\], *char \*\)';
984 c_fix = format;
985 c_fix_arg = "getopt(int, char *const[], const char *)";
986 test_text = 'extern int getopt(int, char *[], char *);';
990 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
992 fix = {
993 hackname = alpha_if_semicolon;
994 files = net/if.h;
995 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
996 c_fix = format;
997 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
998 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1002 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1004 fix = {
1005 hackname = alpha_parens;
1006 files = sym.h;
1007 select = '#ifndef\(__mips64\)';
1008 c_fix = format;
1009 c_fix_arg = "#ifndef __mips64";
1010 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1014 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1015 * And OpenBSD.
1017 fix = {
1018 hackname = alpha_sbrk;
1019 files = unistd.h;
1020 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1021 c_fix = format;
1022 c_fix_arg = "void *sbrk(";
1023 test_text = "extern char* sbrk(ptrdiff_t increment);";
1027 * For C++, avoid any typedef or macro definition of bool,
1028 * and use the built in type instead.
1029 * HP/UX 10.20 also has it in curses_colr/curses.h.
1031 fix = {
1032 hackname = avoid_bool_define;
1033 files = curses.h;
1034 files = curses_colr/curses.h;
1035 files = term.h;
1036 files = tinfo.h;
1038 select = "#[ \t]*define[ \t]+bool[ \t]";
1039 bypass = "__cplusplus";
1041 c_fix = format;
1042 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1043 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1045 test_text = "# define bool\t char \n";
1049 * avoid_bool_type
1051 fix = {
1052 hackname = avoid_bool_type;
1053 files = curses.h;
1054 files = curses_colr/curses.h;
1055 files = term.h;
1056 files = tinfo.h;
1058 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1059 bypass = "__cplusplus";
1061 c_fix = format;
1062 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1064 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1068 * For C++, avoid any typedef definition of wchar_t,
1069 * and use the built in type instead.
1070 * Don't do this for headers that are smart enough to do the right
1071 * thing (recent [n]curses.h and Xlib.h).
1072 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1073 * and will be broken by the edit.
1076 fix = {
1077 hackname = avoid_wchar_t_type;
1079 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1080 bypass = "__cplusplus";
1081 bypass = "_LINUX_NLS_H";
1082 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1084 c_fix = format;
1085 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1087 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1091 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1093 fix = {
1094 hackname = bad_struct_term;
1095 files = curses.h;
1096 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1097 c_fix = format;
1098 c_fix_arg = "struct term;";
1100 test_text = 'typedef struct term;';
1104 * Fix one other error in this file:
1105 * a mismatched quote not inside a C comment.
1107 fix = {
1108 hackname = badquote;
1109 files = sundev/vuid_event.h;
1110 select = "doesn't";
1111 c_fix = format;
1112 c_fix_arg = "does not";
1114 test_text = "/* doesn't have matched single quotes */";
1118 * check for broken assert.h that needs stdio.h
1120 fix = {
1121 hackname = broken_assert_stdio;
1122 files = assert.h;
1123 select = stderr;
1124 bypass = "include.*stdio\\.h";
1125 c_fix = wrap;
1126 c_fix_arg = "#include <stdio.h>\n";
1127 test_text = "extern FILE* stderr;";
1131 * check for broken assert.h that needs stdlib.h
1133 fix = {
1134 hackname = broken_assert_stdlib;
1135 files = assert.h;
1136 select = 'exit *\(|abort *\(';
1137 bypass = "include.*stdlib\\.h";
1138 c_fix = wrap;
1139 c_fix_arg = "#ifdef __cplusplus\n"
1140 "#include <stdlib.h>\n"
1141 "#endif\n";
1142 test_text = "extern void exit ( int );";
1146 * Remove `extern double cabs' declarations from math.h.
1147 * This conflicts with C99. Discovered on AIX.
1148 * Darwin hides its broken cabs in architecture-specific subdirs.
1150 fix = {
1151 hackname = broken_cabs;
1152 files = math.h, "architecture/*/math.h";
1153 select = "^extern[ \t]+double[ \t]+cabs";
1155 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1156 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1158 test_text = "#ifdef __STDC__\n"
1159 "extern double cabs(struct dbl_hypot);\n"
1160 "#else\n"
1161 "extern double cabs();\n"
1162 "#endif\n"
1163 "extern double cabs ( _Complex z );";
1167 * Fixup Darwin's broken check for __builtin_nanf.
1169 fix = {
1170 hackname = broken_nan;
1172 * It is tempting to omit the first "files" entry. Do not.
1173 * The testing machinery will take the first "files" entry as the name
1174 * of a test file to play with. It would be a nuisance to have a directory
1175 * with the name "*".
1177 files = "architecture/ppc/math.h";
1178 files = "architecture/*/math.h";
1179 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1180 bypass = "powl";
1181 c_fix = format;
1182 c_fix_arg = "#if 1";
1183 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1187 * Various systems derived from BSD4.4 contain a macro definition
1188 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1189 * Known to be fixed in FreeBSD 5 system headers.
1191 fix = {
1192 hackname = bsd_stdio_attrs_conflict;
1193 mach = "*-*-*bsd*";
1194 mach = "*-*-*darwin*";
1195 files = stdio.h;
1196 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1197 c_fix = format;
1198 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1199 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1200 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1201 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1202 test_text = '#define vfscanf __svfscanf';
1206 * Fix various macros used to define ioctl numbers.
1207 * The traditional syntax was:
1209 * #define _CTRL(n, x) (('n'<<8)+x)
1210 * #define TCTRLCFOO _CTRL(T, 1)
1212 * but this does not work with the C standard, which disallows macro
1213 * expansion inside strings. We have to rewrite it thus:
1215 * #define _CTRL(n, x) ((n<<8)+x)
1216 * #define TCTRLCFOO _CTRL('T', 1)
1218 * The select expressions match too much, but the c_fix code is cautious.
1220 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1222 fix = {
1223 hackname = ctrl_quotes_def;
1224 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1225 c_fix = char_macro_def;
1226 c_fix_arg = "CTRL";
1229 * This is two tests in order to ensure that the "CTRL(c)" can
1230 * be selected in isolation from the multi-arg format
1232 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1233 test_text = "#define _CTRL(c) ('c'&037)";
1237 * Fix various macros used to define ioctl numbers.
1239 fix = {
1240 hackname = ctrl_quotes_use;
1241 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1242 c_fix = char_macro_use;
1243 c_fix_arg = "CTRL";
1244 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1248 * sys/mman.h on HP/UX is not C++ ready,
1249 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1251 * rpc/types.h on OSF1/2.0 is not C++ ready,
1252 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1254 * The problem is the declaration of malloc.
1256 fix = {
1257 hackname = cxx_unready;
1258 files = sys/mman.h;
1259 files = rpc/types.h;
1260 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1261 not within a macro. */
1262 bypass = '"C"|__BEGIN_DECLS';
1264 c_fix = wrap;
1265 c_fix_arg = "#ifdef __cplusplus\n"
1266 "extern \"C\" {\n"
1267 "#endif\n";
1268 c_fix_arg = "#ifdef __cplusplus\n"
1269 "}\n"
1270 "#endif\n";
1271 test_text = "extern void* malloc( size_t );";
1275 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1276 * unconditionally.
1278 fix = {
1279 hackname = darwin_availabilityinternal;
1280 mach = "*-*-darwin*";
1281 files = AvailabilityInternal.h;
1282 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1283 c_fix = format;
1284 c_fix_arg = <<- _EOFix_
1285 #if defined(__has_attribute)
1286 #if __has_attribute(availability)
1288 #else
1289 #define %1
1290 #endif
1291 #else
1292 #define %1
1293 #endif
1294 _EOFix_;
1296 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1297 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1301 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1302 * you have to not use "" includes.
1304 fix = {
1305 hackname = darwin_9_long_double_funcs_2;
1306 mach = "*-*-darwin7.9*";
1307 files = math.h;
1308 select = '#include[ \t]+\"';
1309 c_fix = format;
1310 c_fix_arg = "%1<%2.h>";
1312 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1314 test_text = '#include "architecture/ppc/math.h"';
1318 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1319 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1321 fix = {
1322 hackname = darwin_externc;
1323 mach = "*-*-darwin*";
1324 files = mach-o/swap.h;
1325 files = mach/mach_time.h;
1326 files = mach/mach_traps.h;
1327 files = mach/message.h;
1328 files = mach/mig.h;
1329 files = mach/semaphore.h;
1330 bypass = "extern \"C\"";
1331 bypass = "__BEGIN_DECLS";
1332 c_fix = wrap;
1333 c_fix_arg = "#ifdef __cplusplus\n"
1334 "extern \"C\" {\n"
1335 "#endif\n";
1336 c_fix_arg = "#ifdef __cplusplus\n"
1337 "}\n"
1338 "#endif\n";
1339 test_text = "extern void swap_fat_header();\n";
1343 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1344 * bad __GNUC__ tests.
1346 fix = {
1347 hackname = darwin_gcc4_breakage;
1348 mach = "*-*-darwin*";
1349 files = AvailabilityMacros.h;
1350 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1351 c_fix = format;
1352 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1353 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1354 "(__GNUC_MINOR__ >= 1)\n";
1358 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1360 fix = {
1361 hackname = darwin_longjmp_noreturn;
1362 mach = "*-*-darwin*";
1363 files = "i386/setjmp.h";
1364 bypass = "__dead2";
1365 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1366 c_fix = format;
1367 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1369 test_text = "void siglongjmp(sigjmp_buf, int);";
1373 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1375 fix = {
1376 hackname = darwin_os_trace_1;
1377 mach = "*-*-darwin*";
1378 files = os/trace.h;
1379 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1380 c_fix = format;
1381 c_fix_arg = "%1";
1382 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1386 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1387 * extension without guard.
1389 fix = {
1390 hackname = darwin_os_trace_2;
1391 mach = "*-*-darwin*";
1392 files = os/trace.h;
1393 select = "typedef.*\\^os_trace_payload_t.*";
1394 c_fix = format;
1395 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1396 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1400 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1401 * os_trace_payload_t typedef, too.
1403 fix = {
1404 hackname = darwin_os_trace_3;
1405 mach = "*-*-darwin*";
1406 files = os/trace.h;
1407 select = <<- _EOSelect_
1408 __(API|OSX)_.*
1409 OS_EXPORT.*
1411 _os_trace.*os_trace_payload_t payload);
1412 _EOSelect_;
1413 c_fix = format;
1414 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1415 test_text = <<- _EOText_
1416 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1417 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1418 void
1419 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1421 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1422 OS_EXPORT OS_NOTHROW
1423 void
1424 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1425 _EOText_;
1429 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1430 * why would you ever put it in a system header file?
1432 fix = {
1433 hackname = darwin_private_extern;
1434 mach = "*-*-darwin*";
1435 files = mach-o/dyld.h;
1436 select = "__private_extern__ [a-z_]+ _dyld_";
1437 c_fix = format;
1438 c_fix_arg = "extern";
1439 c_fix_arg = "__private_extern__";
1440 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1441 "const char *dyld_func_name,\n"
1442 "unsigned long *address);\n";
1446 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1447 * unsigned constants.
1449 fix = {
1450 hackname = darwin_stdint_1;
1451 mach = "*-*-darwin*";
1452 files = stdint-darwin.h, stdint.h;
1453 c_fix = format;
1454 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1455 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1456 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1457 test_text = "#define UINT8_C(v) (v ## U)\n"
1458 "#define UINT16_C(v) (v ## U)";
1462 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1463 * with wrong types.
1465 fix = {
1466 hackname = darwin_stdint_2;
1467 mach = "*-*-darwin*";
1468 files = stdint-darwin.h, stdint.h;
1469 c_fix = format;
1470 c_fix_arg = "#if __WORDSIZE == 64\n"
1471 "#define INTPTR_MAX 9223372036854775807L\n"
1472 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1473 "#else\n"
1474 "#define INTPTR_MAX 2147483647L\n"
1475 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1476 "#endif";
1477 select = "#if __WORDSIZE == 64\n"
1478 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1479 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1480 "#else\n"
1481 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1482 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1483 "#endif";
1484 test_text = "#if __WORDSIZE == 64\n"
1485 "#define INTPTR_MIN INT64_MIN\n"
1486 "#define INTPTR_MAX INT64_MAX\n"
1487 "#else\n"
1488 "#define INTPTR_MIN INT32_MIN\n"
1489 "#define INTPTR_MAX INT32_MAX\n"
1490 "#endif";
1494 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1496 fix = {
1497 hackname = darwin_stdint_3;
1498 mach = "*-*-darwin*";
1499 files = stdint-darwin.h, stdint.h;
1500 c_fix = format;
1501 c_fix_arg = "#if __WORDSIZE == 64\n"
1502 "#define UINTPTR_MAX 18446744073709551615UL\n"
1503 "#else\n"
1504 "#define UINTPTR_MAX 4294967295UL\n"
1505 "#endif";
1506 select = "#if __WORDSIZE == 64\n"
1507 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1508 "#else\n"
1509 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1510 "#endif";
1511 test_text = "#if __WORDSIZE == 64\n"
1512 "#define UINTPTR_MAX UINT64_MAX\n"
1513 "#else\n"
1514 "#define UINTPTR_MAX UINT32_MAX\n"
1515 "#endif";
1519 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1521 fix = {
1522 hackname = darwin_stdint_4;
1523 mach = "*-*-darwin*";
1524 files = stdint-darwin.h, stdint.h;
1525 c_fix = format;
1526 c_fix_arg = "#if __WORDSIZE == 64\n"
1527 "#define SIZE_MAX 18446744073709551615UL\n"
1528 "#else\n"
1529 "#define SIZE_MAX 4294967295UL\n"
1530 "#endif";
1531 select = "#if __WORDSIZE == 64\n"
1532 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1533 "#else\n"
1534 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1535 "#endif";
1536 test_text = "#if __WORDSIZE == 64\n"
1537 "#define SIZE_MAX UINT64_MAX\n"
1538 "#else\n"
1539 "#define SIZE_MAX UINT32_MAX\n"
1540 "#endif";
1544 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1545 * with a wrong type.
1547 fix = {
1548 hackname = darwin_stdint_5;
1549 mach = "*-*-darwin*";
1550 files = stdint-darwin.h, stdint.h;
1551 c_fix = format;
1552 c_fix_arg = "#if __WORDSIZE == 64\n"
1553 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1554 "#define INTMAX_MAX 9223372036854775807L\n"
1555 "#define UINTMAX_MAX 18446744073709551615UL\n"
1556 "#else\n"
1557 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1558 "#define INTMAX_MAX 9223372036854775807LL\n"
1559 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1560 "#endif";
1561 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1562 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1563 "\n"
1564 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1565 test_text = "#define INTMAX_MIN INT64_MIN\n"
1566 "#define INTMAX_MAX INT64_MAX\n"
1567 "\n"
1568 "#define UINTMAX_MAX UINT64_MAX";
1572 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1573 * with a wrong type.
1575 fix = {
1576 hackname = darwin_stdint_6;
1577 mach = "*-*-darwin*";
1578 files = stdint-darwin.h, stdint.h;
1579 c_fix = format;
1580 c_fix_arg = "#if __WORDSIZE == 64\n"
1581 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1582 "#define PTRDIFF_MAX 9223372036854775807L\n"
1583 "#else\n"
1584 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1585 "#define PTRDIFF_MAX 2147483647\n"
1586 "#endif";
1587 select = "#if __WORDSIZE == 64\n"
1588 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1589 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1590 "#else\n"
1591 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1592 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1593 "#endif";
1594 test_text = "#if __WORDSIZE == 64\n"
1595 "#define PTRDIFF_MIN INT64_MIN\n"
1596 "#define PTRDIFF_MAX INT64_MAX\n"
1597 "#else\n"
1598 "#define PTRDIFF_MIN INT32_MIN\n"
1599 "#define PTRDIFF_MAX INT32_MAX\n"
1600 "#endif";
1604 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1605 * with a wrong type.
1607 fix = {
1608 hackname = darwin_stdint_7;
1609 mach = "*-*-darwin*";
1610 files = stdint-darwin.h, stdint.h;
1611 c_fix = format;
1612 c_fix_arg = "#if __WORDSIZE == 64\n"
1613 "#define INTMAX_C(v) (v ## L)\n"
1614 "#define UINTMAX_C(v) (v ## UL)\n"
1615 "#else\n"
1616 "#define INTMAX_C(v) (v ## LL)\n"
1617 "#define UINTMAX_C(v) (v ## ULL)\n"
1618 "#endif";
1619 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1620 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1621 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1622 "#define UINTMAX_C(v) (v ## ULL)";
1626 * Fix <c_asm.h> on Digital UNIX V4.0:
1627 * It contains a prototype for a DEC C internal asm() function,
1628 * clashing with gcc's asm keyword. So protect this with __DECC.
1630 fix = {
1631 hackname = dec_intern_asm;
1632 files = c_asm.h;
1633 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1634 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1635 "#endif\n";
1636 test_text =
1637 "float fasm {\n"
1638 " ... asm stuff ...\n"
1639 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1643 * Fix typo in <wchar.h> on DJGPP 2.03.
1645 fix = {
1646 hackname = djgpp_wchar_h;
1647 file = wchar.h;
1648 select = "__DJ_wint_t";
1649 bypass = "sys/djtypes.h";
1650 c_fix = format;
1651 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1652 c_fix_arg = "#include <stddef.h>";
1653 test_text = "#include <stddef.h>\n"
1654 "extern __DJ_wint_t x;\n";
1658 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1660 fix = {
1661 hackname = ecd_cursor;
1662 files = "sunwindow/win_lock.h";
1663 files = "sunwindow/win_cursor.h";
1664 select = 'ecd\.cursor';
1665 c_fix = format;
1666 c_fix_arg = 'ecd_cursor';
1668 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1672 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1673 * that fails when compiling for SSE-less 32-bit x86.
1675 fix = {
1676 hackname = feraiseexcept_nosse_divbyzero;
1677 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1678 files = bits/fenv.h, '*/bits/fenv.h';
1679 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1680 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1681 bypass = "\"fdivp .*; fwait\"";
1683 c_fix = format;
1684 c_fix_arg = <<- _EOText_
1685 # ifdef __SSE_MATH__
1687 # else
1688 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1689 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1690 # endif
1691 _EOText_;
1693 test_text = <<- _EOText_
1694 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1695 _EOText_;
1699 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1700 * that fails when compiling for SSE-less 32-bit x86.
1702 fix = {
1703 hackname = feraiseexcept_nosse_invalid;
1704 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1705 files = bits/fenv.h, '*/bits/fenv.h';
1706 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1707 ": \"x\" \\(__f\\)\\);$";
1708 bypass = "\"fdiv .*; fwait\"";
1710 c_fix = format;
1711 c_fix_arg = <<- _EOText_
1712 # ifdef __SSE_MATH__
1714 # else
1715 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1716 %1 : "=t" (__f) : "0" (__f));
1717 # endif
1718 _EOText_;
1720 test_text = <<- _EOText_
1721 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1722 _EOText_;
1726 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1727 * neither the existence of GCC 3 nor its exact feature set yet break
1728 * (by design?) when __GNUC__ is set beyond 2.
1730 fix = {
1731 hackname = freebsd_gcc3_breakage;
1732 mach = "*-*-freebsd*";
1733 files = sys/cdefs.h;
1734 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1735 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1736 c_fix = format;
1737 c_fix_arg = '%0 || __GNUC__ >= 3';
1738 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1742 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1743 * neither the existence of GCC 4 nor its exact feature set yet break
1744 * (by design?) when __GNUC__ is set beyond 3.
1746 fix = {
1747 hackname = freebsd_gcc4_breakage;
1748 mach = "*-*-freebsd*";
1749 files = sys/cdefs.h;
1750 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1751 c_fix = format;
1752 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1753 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1757 * Some versions of glibc don't expect the C99 inline semantics.
1759 fix = {
1760 hackname = glibc_c99_inline_1;
1761 files = features.h, '*/features.h';
1762 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1763 c_fix = format;
1764 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1765 test_text = <<-EOT
1766 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1767 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1768 # define __USE_EXTERN_INLINES 1
1769 #endif
1770 EOT;
1774 * Similar, but a version that didn't have __NO_INLINE__
1776 fix = {
1777 hackname = glibc_c99_inline_1a;
1778 files = features.h, '*/features.h';
1779 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1780 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1781 c_fix = format;
1782 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1783 test_text = <<-EOT
1784 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1785 # define __USE_EXTERN_INLINES 1
1786 #endif
1787 EOT;
1791 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1792 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1793 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1795 fix = {
1796 hackname = glibc_c99_inline_2;
1797 files = sys/stat.h, '*/sys/stat.h';
1798 select = "extern __inline__ int";
1799 sed = "s/extern int \\(stat\\)/"
1800 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1801 "__inline__ int \\1/";
1802 sed = "s/extern int \\([lf]stat\\)/"
1803 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1804 "__inline__ int \\1/";
1805 sed = "s/extern int \\(mknod\\)/"
1806 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1807 "__inline__ int \\1/";
1808 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1809 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1810 "__inline__ int __REDIRECT\\1 (\\2/";
1811 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1812 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1813 "__inline__ int __REDIRECT\\1 (\\2/";
1814 sed = "s/^extern __inline__ int/"
1815 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1816 "__inline__ int/";
1817 test_text = <<-EOT
1818 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1819 extern __inline__ int
1820 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1822 EOT;
1826 * glibc_c99_inline_3
1828 fix = {
1829 hackname = glibc_c99_inline_3;
1830 files = bits/string2.h, '*/bits/string2.h';
1831 select = "extern __inline";
1832 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1833 c_fix = format;
1834 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1835 c_fix_arg = "^# ifdef __cplusplus$";
1836 test_text = <<-EOT
1837 # ifdef __cplusplus
1838 # define __STRING_INLINE inline
1839 # else
1840 # define __STRING_INLINE extern __inline
1841 # endif
1842 EOT;
1846 * glibc_c99_inline_4
1848 fix = {
1849 hackname = glibc_c99_inline_4;
1850 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1851 pthread.h, '*/pthread.h';
1852 bypass = "__extern_inline|__gnu_inline__";
1853 select = "(^| )extern __inline";
1854 c_fix = format;
1855 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1856 test_text = <<-EOT
1857 __extension__ extern __inline unsigned int
1858 extern __inline unsigned int
1859 EOT;
1862 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1863 * so we replace them with versions that correspond to the
1864 * definition.
1866 fix = {
1867 hackname = glibc_mutex_init;
1868 files = pthread.h;
1869 select = '\{ *\{ *0, *\} *\}';
1870 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1871 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1872 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1873 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1874 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1875 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1876 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1877 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1878 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1879 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1880 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1881 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1882 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1883 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1884 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1885 "N;s/^[ \t]*#[ \t]*"
1886 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1887 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1888 "# \\1\\\n"
1889 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1890 "# else\\\n"
1891 "# \\1\\\n"
1892 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1893 "# endif/";
1894 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1895 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1896 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1897 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1899 test_text = <<- _EOText_
1900 #define PTHREAD_MUTEX_INITIALIZER \\
1901 { { 0, } }
1902 #ifdef __USE_GNU
1903 # if __WORDSIZE == 64
1904 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1905 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1906 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1907 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1908 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1909 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1910 # else
1911 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1912 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1913 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1914 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1915 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1916 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1917 # endif
1918 #endif
1919 # define PTHREAD_RWLOCK_INITIALIZER \\
1920 { { 0, } }
1921 # ifdef __USE_GNU
1922 # if __WORDSIZE == 64
1923 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1924 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1925 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1926 # else
1927 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1928 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1929 # endif
1930 # endif
1931 #define PTHREAD_COND_INITIALIZER { { 0, } }
1932 _EOText_;
1935 /* glibc versions before 2.5 have a version of stdint.h that defines
1936 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1937 versions with stdint.h based on those glibc versions. */
1938 fix = {
1939 hackname = glibc_stdint;
1940 files = stdint.h;
1941 select = "GNU C Library";
1942 c_fix = format;
1943 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1944 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1945 test_text = "/* This file is part of the GNU C Library. */\n"
1946 "# define UINT8_C(c)\tc ## U\n"
1947 "# define UINT16_C(c)\tc ## U";
1950 /* Some versions of glibc have a version of bits/string2.h that
1951 produces "value computed is not used" warnings from strncpy; fix
1952 this definition by using __builtin_strncpy instead as in newer
1953 versions. */
1954 fix = {
1955 hackname = glibc_strncpy;
1956 files = bits/string2.h, '*/bits/string2.h';
1957 bypass = "__builtin_strncpy";
1958 c_fix = format;
1959 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1960 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1961 test_text = <<-EOT
1962 # define strncpy(dest, src, n) \
1963 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1964 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1965 ? (char *) memcpy (dest, src, n) \\
1966 : strncpy (dest, src, n)) \\
1967 : strncpy (dest, src, n)))
1968 EOT;
1972 /* glibc's tgmath.h relies on an expression that is not an integer
1973 constant expression being treated as it was by GCC 4.4 and
1974 earlier. */
1975 fix = {
1976 hackname = glibc_tgmath;
1977 files = tgmath.h;
1978 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1979 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1980 c_fix = format;
1981 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1982 "(__builtin_classify_type ((type) 0) == 9 && "
1983 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1984 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1988 * Fix these files to use the types we think they should for
1989 * ptrdiff_t, size_t, and wchar_t.
1991 * This defines the types in terms of macros predefined by our 'cpp'.
1992 * This is supposedly necessary for glibc's handling of these types.
1993 * It's probably not necessary for anyone else, but it doesn't hurt.
1995 fix = {
1996 hackname = gnu_types;
1997 files = "sys/types.h";
1998 files = "stdlib.h";
1999 files = "sys/stdtypes.h";
2000 files = "stddef.h";
2001 files = "memory.h";
2002 files = "unistd.h";
2003 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2004 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2005 c_fix = gnu_type;
2006 /* The Solaris 10 headers already define these types correctly. */
2007 mach = '*-*-solaris2.1[0-9]*';
2008 not_machine = true;
2010 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2011 "typedef uint_t size_t; /* uint_t */\n"
2012 "typedef ushort_t wchar_t; /* ushort_t */";
2016 * Fix HP & Sony's use of "../machine/xxx.h"
2017 * to refer to: <machine/xxx.h>
2019 fix = {
2020 hackname = hp_inline;
2021 files = sys/spinlock.h;
2022 files = machine/machparam.h;
2023 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2025 c_fix = format;
2026 c_fix_arg = "%1<machine/%2.h>";
2028 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2029 '([a-z]+)\.h"';
2031 test_text = ' # include "../machine/mumble.h"';
2035 * Check for (...) in C++ code in HP/UX sys/file.h.
2037 fix = {
2038 hackname = hp_sysfile;
2039 files = sys/file.h;
2040 select = "HPUX_SOURCE";
2042 c_fix = format;
2043 c_fix_arg = "(struct file *, ...)";
2044 c_fix_arg = '\(\.\.\.\)';
2046 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2050 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2051 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2053 fix = {
2054 hackname = hppa_hpux_fp_macros;
2055 mach = "hppa*-hp-hpux11*";
2056 files = math.h;
2057 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2058 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2059 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2060 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2061 "#[ \t]*define[ \t]*FP_NAN.*\n";
2062 c_fix = format;
2063 c_fix_arg = <<- _EOFix_
2064 #endif /* _INCLUDE_HPUX_SOURCE */
2066 #if defined(_INCLUDE_HPUX_SOURCE) || \
2067 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2068 %0#endif
2070 #ifdef _INCLUDE_HPUX_SOURCE
2072 _EOFix_;
2074 test_text =
2075 "# define FP_NORMAL 0\n"
2076 "# define FP_ZERO 1\n"
2077 "# define FP_INFINITE 2\n"
2078 "# define FP_SUBNORMAL 3\n"
2079 "# define FP_NAN 4\n";
2083 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2084 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2086 fix = {
2087 hackname = hpux10_cpp_pow_inline;
2088 files = fixinc-test-limits.h, math.h;
2089 select = <<- END_POW_INLINE
2090 ^# +ifdef +__cplusplus
2092 +inline +double +pow\(double +__d,int +__expon\) +\{
2093 [ ]+return +pow\(__d,\(double\)__expon\);
2095 +extern +"C" +\{
2096 #else
2097 # +endif
2098 END_POW_INLINE;
2100 c_fix = format;
2101 c_fix_arg = "";
2103 test_text =
2104 "# ifdef __cplusplus\n"
2105 " }\n"
2106 " inline double pow(double __d,int __expon) {\n"
2107 "\t return pow(__d,(double)__expon);\n"
2108 " }\n"
2109 ' extern "C"' " {\n"
2110 "#else\n"
2111 "# endif";
2114 fix = {
2115 hackname = hpux11_cpp_pow_inline;
2116 files = math.h;
2117 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2118 " +return pow\\(d, \\(double\\)expon\\);\n"
2119 " +\\}\n";
2120 c_fix = format;
2121 c_fix_arg = "";
2123 test_text =
2124 " inline double pow(double d,int expon) {\n"
2125 " return pow(d, (double)expon);\n"
2126 " }\n";
2130 * Fix hpux 10.X missing ctype declarations 1
2132 fix = {
2133 hackname = hpux10_ctype_declarations1;
2134 files = ctype.h;
2135 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2136 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2137 c_fix = format;
2138 c_fix_arg = "#ifdef _PROTOTYPES\n"
2139 "extern int __tolower(int);\n"
2140 "extern int __toupper(int);\n"
2141 "#else /* NOT _PROTOTYPES */\n"
2142 "extern int __tolower();\n"
2143 "extern int __toupper();\n"
2144 "#endif /* _PROTOTYPES */\n\n"
2145 "%0\n";
2147 test_text = "# define _toupper(__c) __toupper(__c)\n";
2151 * Fix hpux 10.X missing ctype declarations 2
2153 fix = {
2154 hackname = hpux10_ctype_declarations2;
2155 files = ctype.h;
2156 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2157 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2158 c_fix = format;
2159 c_fix_arg = "%0\n\n"
2160 "#ifdef _PROTOTYPES\n"
2161 " extern int _isalnum(int);\n"
2162 " extern int _isalpha(int);\n"
2163 " extern int _iscntrl(int);\n"
2164 " extern int _isdigit(int);\n"
2165 " extern int _isgraph(int);\n"
2166 " extern int _islower(int);\n"
2167 " extern int _isprint(int);\n"
2168 " extern int _ispunct(int);\n"
2169 " extern int _isspace(int);\n"
2170 " extern int _isupper(int);\n"
2171 " extern int _isxdigit(int);\n"
2172 "# else /* not _PROTOTYPES */\n"
2173 " extern int _isalnum();\n"
2174 " extern int _isalpha();\n"
2175 " extern int _iscntrl();\n"
2176 " extern int _isdigit();\n"
2177 " extern int _isgraph();\n"
2178 " extern int _islower();\n"
2179 " extern int _isprint();\n"
2180 " extern int _ispunct();\n"
2181 " extern int _isspace();\n"
2182 " extern int _isupper();\n"
2183 " extern int _isxdigit();\n"
2184 "#endif /* _PROTOTYPES */\n";
2186 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2187 " extern unsigned int *__SB_masks;\n";
2191 * Fix hpux 10.X missing stdio declarations
2193 fix = {
2194 hackname = hpux10_stdio_declarations;
2195 files = stdio.h;
2196 select = "^#[ \t]*define _iob[ \t]*__iob";
2197 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2198 c_fix = format;
2199 c_fix_arg = "%0\n\n"
2200 "# if defined(__STDC__) || defined(__cplusplus)\n"
2201 " extern int snprintf(char *, size_t, const char *, ...);\n"
2202 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2203 "# else /* not __STDC__) || __cplusplus */\n"
2204 " extern int snprintf();\n"
2205 " extern int vsnprintf();\n"
2206 "# endif /* __STDC__) || __cplusplus */\n";
2208 test_text = "# define _iob __iob\n";
2212 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2213 * As a result, we need to include sys/stdsyms.h in alloca.h.
2215 fix = {
2216 hackname = hppa_hpux11_alloca;
2217 mach = "hppa*-*-hpux11*";
2218 files = alloca.h;
2219 select = "#ifndef _STDDEF_INCLUDED";
2220 c_fix = format;
2221 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2222 "# include <sys/stdsyms.h>\n"
2223 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2224 "%0";
2226 test_text = "#ifndef _STDDEF_INCLUDED";
2230 * Make sure hpux defines abs in header.
2232 fix = {
2233 hackname = hpux11_abs;
2234 mach = "*-hp-hpux11*";
2235 files = stdlib.h;
2236 select = "ifndef _MATH_INCLUDED";
2237 c_fix = format;
2238 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2239 test_text = "#ifndef _MATH_INCLUDED";
2243 * Fix hpux11 __LWP_RWLOCK_VALID define
2245 fix = {
2246 hackname = hpux11_lwp_rwlock_valid;
2247 mach = "*-hp-hpux11*";
2248 files = sys/pthread.h;
2249 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2250 c_fix = format;
2251 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2252 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2256 * hpux sendfile()
2258 fix = {
2259 hackname = hpux11_extern_sendfile;
2260 mach = "*-hp-hpux11.[12]*";
2261 files = sys/socket.h;
2262 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2263 c_fix = format;
2264 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2265 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2266 " const struct iovec *, int));\n";
2270 * hpux sendpath()
2272 fix = {
2273 hackname = hpux11_extern_sendpath;
2274 mach = "*-hp-hpux11.[12]*";
2275 files = sys/socket.h;
2276 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2277 c_fix = format;
2278 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2279 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2280 " const struct iovec *, int));\n";
2284 * Keep HP-UX 11 from stomping on C++ math namespace
2285 * with defines for fabsf.
2287 fix = {
2288 hackname = hpux11_fabsf;
2289 mach = "*-hp-hpux11*";
2290 files = math.h;
2291 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2293 c_fix = format;
2294 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2296 test_text =
2297 "#ifdef _PA_RISC\n"
2298 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2299 "#endif";
2303 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2304 * in pthread.h need to be constant expressions to be standard complient.
2305 * As a result, we need to remove the void * casts in the initializers
2306 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2307 * to use the long type.
2309 fix = {
2310 hackname = hpux11_pthread_pointer;
2311 mach = "*-hp-hpux11.[0-3]*";
2312 files = sys/pthread.h;
2313 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2315 c_fix = format;
2316 c_fix_arg = "long\t%2%3";
2317 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2321 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2323 fix = {
2324 hackname = hpux11_pthread_const;
2325 mach = "*-hp-hpux11.[0-3]*";
2326 files = sys/pthread.h;
2327 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2329 c_fix = format;
2330 c_fix_arg = "%11";
2331 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2335 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2336 * being defined by having it define _hpux_size_t instead.
2338 fix = {
2339 hackname = hpux11_size_t;
2340 mach = "*-hp-hpux11*";
2341 select = "__size_t";
2343 c_fix = format;
2344 c_fix_arg = "_hpux_size_t";
2346 test_text =
2347 "#define __size_t size_t\n"
2348 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2352 * Fix hpux 11.00 broken snprintf declaration
2353 * (third argument is char *, needs to be const char * to prevent
2354 * spurious warnings with -Wwrite-strings or in C++).
2356 fix = {
2357 hackname = hpux11_snprintf;
2358 files = stdio.h;
2359 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2360 ' *(char *\*, *\.\.\.\);)';
2361 c_fix = format;
2362 c_fix_arg = '%1 const %3';
2364 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2365 "extern int snprintf(char *, __size_t, char *, ...);\n"
2366 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2370 * Fix hpux 11.00 broken vsnprintf declaration
2372 fix = {
2373 hackname = hpux11_vsnprintf;
2374 files = stdio.h;
2375 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2376 'const char \*,) __va__list\);';
2377 c_fix = format;
2378 c_fix_arg = "%1 __va_list);";
2380 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2381 ' __va__list);';
2385 * Fix missing const in hpux vsscanf declaration
2387 fix = {
2388 hackname = hpux_vsscanf;
2389 mach = "*-*-hpux*";
2390 files = stdio.h;
2391 select = '(extern int vsscanf\()char';
2392 c_fix = format;
2393 c_fix_arg = "%1const char";
2395 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2399 * get rid of bogus inline definitions in HP-UX 8.0
2401 fix = {
2402 hackname = hpux8_bogus_inlines;
2403 files = math.h;
2404 select = inline;
2405 bypass = "__GNUG__";
2406 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2407 "@extern \"C\" int abs(int);@";
2408 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2409 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2410 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2411 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2412 "inline double sqr(double v) { return v**0.5; }";
2416 * hpux intptr
2418 fix = {
2419 hackname = hpux_c99_intptr;
2420 mach = "*-hp-hpux11.3*";
2421 files = stdint-hpux11.h, stdint.h;
2422 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2423 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2424 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2425 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2426 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2427 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2428 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2429 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2430 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2431 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2432 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2433 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2434 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2435 "#define PTRDIFF_MIN INT32_MIN\n"
2436 "#define INTPTR_MAX INT32_MAX\n"
2437 "#define INTPTR_MIN INT32_MIN\n"
2438 "#define UINTPTR_MAX UINT32_MAX\n"
2439 "#define SIZE_MAX UINT32_MAX\n";
2443 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2445 fix = {
2446 hackname = hpux_c99_inttypes;
2447 mach = "*-hp-hpux11.[23]*";
2448 files = inttypes.h;
2449 files = stdint-hpux11.h, stdint.h;
2450 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2451 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2452 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2453 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2454 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2455 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2456 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2457 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2458 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2459 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2460 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2461 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2465 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2467 fix = {
2468 hackname = hpux_c99_inttypes2;
2469 mach = "*-hp-hpux11.2*";
2470 files = stdint-hpux11.h, stdint.h;
2471 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2472 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2473 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2474 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2475 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2476 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2477 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2478 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2479 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2480 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2481 "# define INT16_C(__c) ((short)(__c))\n"
2482 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2486 * Fix hpux broken ctype macros
2488 fix = {
2489 hackname = hpux_ctype_macros;
2490 files = ctype.h;
2491 select = '((: |\()__SB_masks \? )'
2492 '(__SB_masks\[__(alnum|c)\] & _IS)';
2493 c_fix = format;
2494 c_fix_arg = "%1(int)%3";
2496 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2497 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2501 * hpux errno()
2503 fix = {
2504 hackname = hpux_extern_errno;
2505 mach = "*-hp-hpux10.*";
2506 mach = "*-hp-hpux11.[0-2]*";
2507 files = errno.h;
2508 select = "^[ \t]*extern int errno;$";
2509 c_fix = format;
2510 c_fix_arg = "#ifdef __cplusplus\n"
2511 "extern \"C\" {\n"
2512 "#endif\n"
2513 "%0\n"
2514 "#ifdef __cplusplus\n"
2515 "}\n"
2516 "#endif";
2517 test_text = " extern int errno;\n";
2521 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2523 fix = {
2524 hackname = hpux_htonl;
2525 files = netinet/in.h;
2526 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2527 "(/\\*\n"
2528 " \\* Macros for number representation conversion\\.\n"
2529 " \\*/\n"
2530 "#ifndef ntohl)";
2531 c_fix = format;
2532 c_fix_arg = "#if 1\n%1";
2534 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2535 "/*\n"
2536 " * Macros for number representation conversion.\n"
2537 " */\n"
2538 "#ifndef ntohl\n"
2539 "#define ntohl(x) (x)\n"
2540 "#define ntohs(x) (x)\n"
2541 "#define htonl(x) (x)\n"
2542 "#define htons(x) (x)\n"
2543 "#endif\n"
2544 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2548 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2550 fix = {
2551 hackname = hpux_imaginary_i;
2552 mach = "ia64-hp-hpux11.*";
2553 files = complex.h;
2554 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2555 c_fix = format;
2556 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2557 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2561 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2563 fix = {
2564 hackname = hpux_inttype_int8_t;
2565 mach = "*-hp-hpux1[01].*";
2566 files = sys/_inttypes.h;
2567 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2568 c_fix = format;
2569 c_fix_arg = "typedef signed char int%18_t;";
2570 test_text = "typedef char int_least8_t;\n"
2571 "typedef char int8_t;\n";
2575 * HP-UX long_double
2577 fix = {
2578 hackname = hpux_long_double;
2579 mach = "*-*-hpux10*";
2580 mach = "*-*-hpux11.[012]*";
2581 files = stdlib.h;
2582 select = "extern[ \t]long_double[ \t]strtold";
2583 bypass = "long_double_t";
2584 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2585 sed = "s/long_double/long double/g";
2587 test_text = "# ifndef _LONG_DOUBLE\n"
2588 "# define _LONG_DOUBLE\n"
2589 " typedef struct {\n"
2590 " unsigned int word1, word2, word3, word4;\n"
2591 " } long_double;\n"
2592 "# endif /* _LONG_DOUBLE */\n"
2593 "extern long_double strtold(const char *, char **);\n";
2597 * We cannot use the above rule on 11.31 because it removes the strtold
2598 * definition. ia64 is OK with no hack, PA needs some help.
2600 fix = {
2601 hackname = hpux_long_double_2;
2602 mach = "hppa*-*-hpux11.3*";
2603 files = stdlib.h;
2604 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2605 "defined\\(_PROTOTYPES\\) \\|\\| "
2606 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2607 c_fix = format;
2608 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2610 test_text = "# if !defined(__ia64) || "
2611 "!defined(_PROTOTYPES) || "
2612 "defined(_LONG_DOUBLE_STRUCT)\n";
2616 * Add missing braces to pthread initializer defines.
2618 fix = {
2619 hackname = hpux_pthread_initializers;
2620 mach = "*-hp-hpux11.[0-3]*";
2621 files = sys/pthread.h;
2622 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2623 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2624 sed = "s@^[ \t]*1,[ \t]*\\\\"
2625 "@\t{ 1, 0 }@";
2626 sed = "/^[ \t]*0$/d";
2627 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2628 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2629 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2630 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2631 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2632 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2633 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2634 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2635 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2636 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2637 sed = "s@__PTHREAD_COND_VALID, 0"
2638 "@{ __PTHREAD_COND_VALID, 0 }@";
2639 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2640 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2641 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2642 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2643 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2644 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2645 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2646 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2647 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2648 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2649 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2650 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2651 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2652 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2653 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2654 "}\n";
2658 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2659 * type and mpinfou is only defined when _KERNEL is set.
2661 fix = {
2662 hackname = hpux_spu_info;
2663 mach = "*-hp-hpux*";
2665 * It is tempting to omit the first "files" entry. Do not.
2666 * The testing machinery will take the first "files" entry as the name
2667 * of a test file to play with. It would be a nuisance to have a directory
2668 * with the name "*".
2670 files = "ia64/sys/getppdp.h";
2671 files = "*/sys/getppdp.h";
2672 select = "^.*extern.*spu_info.*";
2674 c_fix = format;
2675 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2677 test_text = "extern union mpinfou spu_info[];";
2681 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2683 fix = {
2684 hackname = hpux_stdint_least_fast;
2685 mach = "*-hp-hpux11.2*";
2686 files = stdint-hpux11.h, stdint.h;
2687 select =
2688 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2689 c_fix = format;
2690 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2691 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2692 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2696 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2698 fix = {
2699 hackname = hpux_longjmp;
2700 mach = "*-hp-hpux*";
2701 files = setjmp.h;
2702 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2704 c_fix = format;
2705 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2707 test_text = 'extern void longjmp __((jmp_buf, int));';
2711 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2713 fix = {
2714 hackname = hpux_systime;
2715 files = sys/time.h;
2716 select = "^extern struct sigevent;";
2718 c_fix = format;
2719 c_fix_arg = "struct sigevent;";
2721 test_text = 'extern struct sigevent;';
2725 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2727 fix = {
2728 hackname = huge_val_hex;
2729 files = bits/huge_val.h, '*/bits/huge_val.h';
2730 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2731 bypass = "__builtin_huge_val";
2733 c_fix = format;
2734 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2736 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2740 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2742 fix = {
2743 hackname = huge_valf_hex;
2744 files = bits/huge_val.h, '*/bits/huge_val.h';
2745 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2746 bypass = "__builtin_huge_valf";
2748 c_fix = format;
2749 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2751 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2755 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2757 fix = {
2758 hackname = huge_vall_hex;
2759 files = bits/huge_val.h, '*/bits/huge_val.h';
2760 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2761 bypass = "__builtin_huge_vall";
2763 c_fix = format;
2764 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2766 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2770 * Fix return type of abort and free
2772 fix = {
2773 hackname = int_abort_free_and_exit;
2774 files = stdlib.h;
2775 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2776 bypass = "_CLASSIC_ANSI_TYPES";
2778 c_fix = format;
2779 c_fix_arg = "void\t%1(";
2781 test_text = "extern int abort(int);\n"
2782 "extern int free(void*);\n"
2783 "extern int exit(void*);";
2787 * Fix various macros used to define ioctl numbers.
2788 * The traditional syntax was:
2790 * #define _IO(n, x) (('n'<<8)+x)
2791 * #define TIOCFOO _IO(T, 1)
2793 * but this does not work with the C standard, which disallows macro
2794 * expansion inside strings. We have to rewrite it thus:
2796 * #define _IO(n, x) ((n<<8)+x)
2797 * #define TIOCFOO _IO('T', 1)
2799 * The select expressions match too much, but the c_fix code is cautious.
2801 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2803 fix = {
2804 hackname = io_quotes_def;
2805 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2806 c_fix = char_macro_def;
2807 c_fix_arg = "IO";
2808 test_text =
2809 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2810 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2811 "#define _IO(x,y) ('x'<<8|y)";
2812 test_text =
2813 "#define XX_IO(x) ('x'<<8|256)";
2817 * Fix the usage of the ioctl macro numbers.
2819 fix = {
2820 hackname = io_quotes_use;
2821 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2822 "\\( *[^,']";
2823 c_fix = char_macro_use;
2824 c_fix_arg = "IO";
2825 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2826 "#define TIOCFOO \\\\\n"
2827 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2831 * Check for missing ';' in struct
2833 fix = {
2834 hackname = ip_missing_semi;
2835 files = netinet/ip.h;
2836 select = "}$";
2837 sed = "/^struct/,/^};/s/}$/};/";
2838 test_text=
2839 "struct mumble {\n"
2840 " union {\n"
2841 " int x;\n"
2842 " }\n"
2843 "}; /* mumbled struct */\n";
2847 * Non-traditional "const" declaration in Irix's limits.h.
2849 fix = {
2850 hackname = irix_limits_const;
2851 files = fixinc-test-limits.h, limits.h;
2852 select = "^extern const ";
2853 c_fix = format;
2854 c_fix_arg = "extern __const ";
2855 test_text = "extern const char limit; /* test limits */";
2859 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2860 * taking char *. However, GCC uses void * for va_list, so
2861 * calling vfprintf with a va_list fails in C++. */
2862 fix = {
2863 hackname = irix_stdio_va_list;
2864 files = stdio.h;
2866 select = '/\* va_list \*/ char \*';
2867 c_fix = format;
2868 c_fix_arg = "__gnuc_va_list";
2869 test_text =
2870 "extern int printf( const char *, /* va_list */ char * );";
2874 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2875 * use / * * / to concatenate tokens.
2877 fix = {
2878 hackname = kandr_concat;
2879 files = "sparc/asm_linkage.h";
2880 files = "sun*/asm_linkage.h";
2881 files = "arm/as_support.h";
2882 files = "arm/mc_type.h";
2883 files = "arm/xcb.h";
2884 files = "dev/chardefmac.h";
2885 files = "dev/ps_irq.h";
2886 files = "dev/screen.h";
2887 files = "dev/scsi.h";
2888 files = "sys/tty.h";
2889 files = "Xm.acorn/XmP.h";
2890 files = bsd43/bsd43_.h;
2891 select = '/\*\*/';
2892 c_fix = format;
2893 c_fix_arg = '##';
2894 test_text = "#define __CONCAT__(a,b) a/**/b";
2898 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2899 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2900 * constant on recent versions of g++.
2902 fix = {
2903 hackname = linux_ia64_ucontext;
2904 files = "sys/ucontext.h";
2905 mach = "ia64-*-linux*";
2906 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2907 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2908 c_fix = format;
2909 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2910 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2911 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2915 * Remove header file warning from sys/time.h. Autoconf's
2916 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2917 * which causes warning on LynxOS. Remove the warning.
2919 fix = {
2920 hackname = lynxos_no_warning_in_sys_time_h;
2921 files = sys/time.h;
2922 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2923 c_fix = format;
2924 c_fix_arg = "";
2925 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2929 * Add missing declaration for putenv.
2931 fix = {
2932 hackname = lynxos_missing_putenv;
2933 mach = '*-*-lynxos*';
2934 files = stdlib.h;
2935 bypass = 'putenv[ \t]*\\(';
2936 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2937 c_fix = format;
2938 c_fix_arg = "%0\n"
2939 "extern int putenv _AP((char *));";
2940 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2941 test_text = "extern char *getenv _AP((const char *));";
2945 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2947 * On NetBSD, machine is a symbolic link to an architecture specific
2948 * directory name, so we can't match a specific file name here.
2950 fix = {
2951 hackname = machine_ansi_h_va_list;
2952 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2953 bypass = '__builtin_va_list';
2955 c_fix = format;
2956 c_fix_arg = "%1__builtin_va_list";
2957 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2959 test_text = " # define _BSD_VA_LIST_\tchar**";
2963 * Fix non-ansi machine name defines
2965 fix = {
2966 hackname = machine_name;
2967 c_test = machine_name;
2968 c_fix = machine_name;
2970 test_text = "/* MACH_DIFF: */\n"
2971 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2972 "\n/* no uniform test, so be careful :-) */";
2976 * Some math.h files define struct exception (it's in the System V
2977 * Interface Definition), which conflicts with the class exception defined
2978 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2979 * This is not a great fix, but I haven't been able to think of anything
2980 * better.
2982 fix = {
2983 hackname = math_exception;
2984 files = math.h;
2985 select = "struct exception";
2987 * This should be bypassed on __cplusplus, but some supposedly C++
2988 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2989 * exception either. So currently we bypass only for glibc, based on a
2990 * comment in the fixed glibc header. Ick.
2992 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2993 '_[a-z0-9A-Z_]+_exception; for C, exception';
2994 /* The Solaris 10 headers already get this right. */
2995 mach = '*-*-solaris2.1[0-9]*';
2996 not_machine = true;
2997 c_fix = wrap;
2999 c_fix_arg = "#ifdef __cplusplus\n"
3000 "#define exception __math_exception\n"
3001 "#endif\n";
3003 c_fix_arg = "#ifdef __cplusplus\n"
3004 "#undef exception\n"
3005 "#endif\n";
3007 test_text = "typedef struct exception t_math_exception;";
3011 * This looks pretty broken to me. ``dbl_max_def'' will contain
3012 * "define DBL_MAX " at the start, when what we really want is just
3013 * the value portion. Can't figure out how to write a test case
3014 * for this either :-(
3016 fix = {
3017 hackname = math_huge_val_from_dbl_max;
3018 files = math.h;
3021 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3022 * in math.h, this fix applies.
3024 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3025 bypass = "define[ \t]+DBL_MAX";
3027 shell =
3029 * See if we have a definition for DBL_MAX in float.h.
3030 * If we do, we will replace the one in math.h with that one.
3033 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3034 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3036 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3037 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3038 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3039 "\telse cat\n"
3040 "\tfi";
3042 test_text =
3043 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3044 "#define HUGE_VAL DBL_MAX";
3048 * nested comment
3050 fix = {
3051 hackname = nested_auth_des;
3052 files = rpc/rpc.h;
3053 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3054 c_fix = format;
3055 c_fix_arg = "%1*/ /*";
3056 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3060 * Some versions of NetBSD don't expect the C99 inline semantics.
3062 fix = {
3063 hackname = netbsd_c99_inline_1;
3064 mach = "*-*-netbsd*";
3065 files = signal.h;
3066 select = "extern __inline int";
3068 c_fix = format;
3069 c_fix_arg = "extern\n"
3070 "#ifdef __GNUC_STDC_INLINE__\n"
3071 "__attribute__((__gnu_inline__))\n"
3072 "#endif\n"
3073 "__inline int";
3075 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3079 * netbsd_c99_inline_2
3081 fix = {
3082 hackname = netbsd_c99_inline_2;
3083 mach = "*-*-netbsd*";
3084 files = signal.h;
3085 select = "#define _SIGINLINE extern __inline";
3087 c_fix = format;
3088 c_fix_arg = <<- _EOArg_
3089 #ifdef __GNUC_STDC_INLINE__
3090 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3091 #else
3093 #endif
3094 _EOArg_;
3096 test_text = "#define _SIGINLINE extern __inline";
3100 * NetBSD has a semicolon after the ending '}' for some extern "C".
3102 fix = {
3103 hackname = netbsd_extra_semicolon;
3104 mach = "*-*-netbsd*";
3105 files = sys/cdefs.h;
3106 select = "#define[ \t]*__END_DECLS[ \t]*};";
3108 c_fix = format;
3109 c_fix_arg = "#define __END_DECLS }";
3111 test_text = "#define __END_DECLS };";
3115 * newlib's stdint.h has several failures to conform to C99. The fix
3116 * for these removed a comment that can be matched to identify unfixed
3117 * versions.
3119 fix = {
3120 hackname = newlib_stdint_1;
3121 files = stdint-newlib.h, stdint.h;
3122 select = "@todo - Add support for wint_t types";
3123 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3124 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3125 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3126 sed = "s@#define INT_LEAST32_MIN.*@"
3127 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3128 sed = "s@#define INT_LEAST32_MAX.*@"
3129 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3130 sed = "s@#define UINT_LEAST32_MAX.*@"
3131 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3132 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3133 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3134 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3135 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3136 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3137 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3138 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3139 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3140 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3141 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3142 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3143 test_text = "/* @todo - Add support for wint_t types. */\n"
3144 "#define INT32_MIN (-2147483647-1)\n"
3145 "#define INT32_MAX 2147483647\n"
3146 "#define UINT32_MAX 4294967295U\n"
3147 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3148 "#define INT_LEAST32_MAX 2147483647\n"
3149 "#define UINT_LEAST32_MAX 4294967295U\n"
3150 "#define INT_FAST8_MIN INT8_MIN\n"
3151 "#define INT_FAST8_MAX INT8_MAX\n"
3152 "#define UINT_FAST8_MAX UINT8_MAX\n"
3153 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3154 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3155 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3156 "#define UINT8_C(x) x##U\n"
3157 "#define UINT16_C(x) x##U";
3161 * newlib_stdint_2
3163 fix = {
3164 hackname = newlib_stdint_2;
3165 files = stdint-newlib.h, stdint.h;
3166 select = "@todo - Add support for wint_t types";
3167 c_fix = format;
3168 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3169 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3170 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3171 "#define WCHAR_MAX __WCHAR_MAX__\n"
3172 "#define WCHAR_MIN __WCHAR_MIN__\n"
3173 "#define WINT_MAX __WINT_MAX__\n"
3174 "#define WINT_MIN __WINT_MIN__\n\n"
3175 "%0";
3176 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3177 test_text = "/* @todo - Add support for wint_t types. */\n"
3178 "/** Macros for minimum-width integer constant expressions */";
3182 * NeXT 3.2 adds const prefix to some math functions.
3183 * These conflict with the built-in functions.
3185 fix = {
3186 hackname = next_math_prefix;
3187 files = ansi/math.h;
3188 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3190 c_fix = format;
3191 c_fix_arg = "extern double %1(";
3192 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3194 test_text = "extern\tdouble\t__const__\tmumble();";
3198 * NeXT 3.2 uses the word "template" as a parameter for some
3199 * functions. GCC reports an invalid use of a reserved key word
3200 * with the built-in functions.
3202 fix = {
3203 hackname = next_template;
3204 files = bsd/libc.h;
3205 select = "[ \t]template\\)";
3207 c_fix = format;
3208 c_fix_arg = "(%1)";
3209 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3210 test_text = "extern mumble( char * template); /* fix */";
3214 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3215 * function prototypes. That conflicts with the built-in functions.
3217 fix = {
3218 hackname = next_volitile;
3219 files = ansi/stdlib.h;
3220 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3222 c_fix = format;
3223 c_fix_arg = "extern void %1(";
3224 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3226 test_text = "extern\tvolatile\tvoid\tabort();";
3230 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3231 * Note that version 3 of the NeXT system has wait.h in a different directory,
3232 * so that this code won't do anything. But wait.h in version 3 has a
3233 * conditional, so it doesn't need this fix. So everything is okay.
3235 fix = {
3236 hackname = next_wait_union;
3237 files = sys/wait.h;
3239 select = 'wait\(union wait';
3240 c_fix = format;
3241 c_fix_arg = "wait(void";
3242 test_text = "extern pid_d wait(union wait*);";
3246 * a missing semi-colon at the end of the nodeent structure definition.
3248 fix = {
3249 hackname = nodeent_syntax;
3250 files = netdnet/dnetdb.h;
3251 select = "char[ \t]*\\*na_addr[ \t]*$";
3252 c_fix = format;
3253 c_fix_arg = "%0;";
3254 test_text = "char *na_addr\t";
3258 * Fix OpenBSD's NULL definition.
3260 fix = {
3261 hackname = openbsd_null_definition;
3262 mach = "*-*-openbsd*";
3263 files = locale.h, stddef.h, stdio.h, string.h,
3264 time.h, unistd.h, wchar.h, sys/param.h;
3265 select = "__GNUG__";
3266 c_fix = format;
3267 c_fix_arg = "#ifndef NULL\n"
3268 "#ifdef __cplusplus\n"
3269 "#ifdef __GNUG__\n"
3270 "#define NULL\t__null\n"
3271 "#else\t /* ! __GNUG__ */\n"
3272 "#define NULL\t0L\n"
3273 "#endif\t /* __GNUG__ */\n"
3274 "#else\t /* ! __cplusplus */\n"
3275 "#define NULL\t((void *)0)\n"
3276 "#endif\t /* __cplusplus */\n"
3277 "#endif\t /* !NULL */";
3279 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3280 "^#ifdef[ \t]*__GNUG__\n"
3281 "^#define[ \t]*NULL[ \t]*__null\n"
3282 "^#else\n"
3283 "^#define[ \t]*NULL[ \t]*0L\n"
3284 "^#endif\n"
3285 "^#endif";
3286 test_text =
3287 "#ifndef NULL\n"
3288 "#ifdef __GNUG__\n"
3289 "#define NULL __null\n"
3290 "#else\n"
3291 "#define NULL 0L\n"
3292 "#endif\n"
3293 "#endif\n";
3297 * obstack.h used casts as lvalues.
3299 * We need to change postincrements of casted pointers (which are
3300 * then dereferenced and assigned into) of the form
3302 * *((TYPE*)PTRVAR)++ = (VALUE)
3304 * into expressions like
3306 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3308 * which is correct for the cases used in obstack.h since PTRVAR is
3309 * of type char * and the value of the expression is not used.
3311 fix = {
3312 hackname = obstack_lvalue_cast;
3313 files = obstack.h;
3314 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3315 c_fix = format;
3316 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3317 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3321 * Fix OpenBSD's va_start define.
3323 fix = {
3324 hackname = openbsd_va_start;
3325 mach = "*-*-openbsd*";
3326 files = stdarg.h;
3327 select = '__builtin_stdarg_start';
3328 c_fix = format;
3329 c_fix_arg = __builtin_va_start;
3331 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3335 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3336 * defining regex.h related types. This causes libg++ build and usage
3337 * failures. Fixing this correctly requires checking and modifying 3 files.
3339 fix = {
3340 hackname = osf_namespace_a;
3341 files = reg_types.h;
3342 files = sys/lc_core.h;
3343 test = " -r reg_types.h";
3344 test = " -r sys/lc_core.h";
3345 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3346 test = " -z \"`grep __regex_t regex.h`\"";
3348 c_fix = format;
3349 c_fix_arg = "__%0";
3350 c_fix_arg = "reg(ex|off|match)_t";
3352 test_text = "`touch sys/lc_core.h`"
3353 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3354 "extern regex_t re;\n"
3355 "extern regoff_t ro;\n"
3356 "extern regmatch_t rm;\n";
3359 fix = {
3360 hackname = osf_namespace_c;
3361 files = regex.h;
3362 test = " -r reg_types.h";
3363 test = " -r sys/lc_core.h";
3364 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3365 test = " -z \"`grep __regex_t regex.h`\"";
3367 select = "#include <reg_types\.h>.*";
3368 c_fix = format;
3369 c_fix_arg = "%0\n"
3370 "typedef __regex_t\tregex_t;\n"
3371 "typedef __regoff_t\tregoff_t;\n"
3372 "typedef __regmatch_t\tregmatch_t;";
3374 test_text = "#include <reg_types.h>";
3378 * On broken glibc-2.3.3 systems an array of incomplete structures is
3379 * passed to __sigsetjmp. Fix that to take a pointer instead.
3381 fix = {
3382 hackname = pthread_incomplete_struct_argument;
3383 files = pthread.h;
3384 select = "struct __jmp_buf_tag";
3385 c_fix = format;
3386 c_fix_arg = "%1 *%2%3";
3387 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3388 "(__env)\\[1\\](.*)$";
3389 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3390 "int __savemask);";
3394 * Fix return type of fread and fwrite on sysV68
3396 fix = {
3397 hackname = read_ret_type;
3398 files = stdio.h;
3399 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3400 c_fix = format;
3401 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3402 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3404 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3408 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3410 fix = {
3411 hackname = rpc_xdr_lvalue_cast_a;
3412 files = rpc/xdr.h;
3413 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3414 c_fix = format;
3415 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3416 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3417 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3421 * rpc_xdr_lvalue_cast_b
3423 fix = {
3424 hackname = rpc_xdr_lvalue_cast_b;
3425 files = rpc/xdr.h;
3426 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3427 c_fix = format;
3428 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3429 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3430 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3434 * function class(double x) conflicts with C++ keyword on rs/6000
3436 fix = {
3437 hackname = rs6000_double;
3438 files = math.h;
3439 select = '[^a-zA-Z_]class\(';
3441 c_fix = format;
3442 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3443 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3445 test_text = "extern int class();";
3449 * Wrong fchmod prototype on RS/6000.
3451 fix = {
3452 hackname = rs6000_fchmod;
3453 files = sys/stat.h;
3454 select = 'fchmod\(char \*';
3455 c_fix = format;
3456 c_fix_arg = "fchmod(int";
3457 test_text = "extern int fchmod(char *, mode_t);";
3461 * parameters conflict with C++ new on rs/6000
3463 fix = {
3464 hackname = rs6000_param;
3465 files = "stdio.h";
3466 files = "unistd.h";
3468 select = 'rename\(const char \*old, const char \*new\)';
3469 c_fix = format;
3470 c_fix_arg = 'rename(const char *_old, const char *_new)';
3472 test_text = 'extern int rename(const char *old, const char *new);';
3476 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3477 * for C99. This is wrong for C++, which needs many C99 features, but
3478 * only supports __restrict.
3480 fix = {
3481 hackname = solaris___restrict;
3482 files = sys/feature_tests.h;
3483 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3484 mach = "*-*-solaris2*";
3485 c_fix = format;
3486 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3487 "#else\n%0\n#endif";
3488 test_text = "#define _RESTRICT_KYWD restrict";
3492 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3493 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3494 * and imaginary definitions which are not supported by GCC.
3496 fix = {
3497 hackname = solaris_complex;
3498 mach = "*-*-solaris2.*";
3499 files = complex.h;
3500 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3501 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3502 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3503 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3504 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3505 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3506 test_text = "#define _Complex_I _Complex_I\n"
3507 "#define complex _Complex\n"
3508 "#define _Imaginary_I _Imaginary_I\n"
3509 "#define imaginary _Imaginary\n"
3510 "#undef I\n"
3511 "#define I _Imaginary_I";
3515 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3516 * extern "C" instead so libstdc++ can use it.
3518 fix = {
3519 hackname = solaris_complex_cxx;
3520 mach = "*-*-solaris2.*";
3521 files = complex.h;
3522 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3523 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3524 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3525 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3526 test_text = "#if !defined(__cplusplus)\n"
3527 "#endif /* !defined(__cplusplus) */";
3531 * g++ rejects functions declared with both C and C++ linkage.
3533 fix = {
3534 hackname = solaris_cxx_linkage;
3535 mach = '*-*-solaris2*';
3536 files = "iso/stdlib_iso.h";
3537 select = "(#if __cplusplus >= 199711L)\n"
3538 "(extern \"C\\+\\+\" \\{\n)"
3539 "(.*(bsearch|qsort).*)";
3540 c_fix = format;
3541 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3543 test_text =
3544 "#if __cplusplus >= 199711L\n"
3545 "extern \"C++\" {\n"
3546 " void *bsearch(const void *, const void *, size_t, size_t,";
3550 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3551 * _STRICT_STDC, but uses it.
3553 fix = {
3554 hackname = solaris_getc_strict_stdc;
3555 mach = "*-*-solaris2*";
3556 files = "iso/stdio_iso.h";
3557 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3558 c_fix = format;
3559 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3561 test_text =
3562 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3566 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3568 fix = {
3569 hackname = solaris_gets_c11;
3570 mach = "*-*-solaris2*";
3571 files = "iso/stdio_iso.h";
3572 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3574 c_fix = format;
3575 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3576 "%1 __attribute__((__deprecated__));\n"
3577 "#endif";
3579 test_text = "extern char *gets(char *);";
3583 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3585 fix = {
3586 hackname = solaris_gets_cxx14;
3587 mach = "*-*-solaris2*";
3588 files = "iso/stdio_iso.h";
3589 select = <<- _EOSelect_
3590 (#if __STDC_VERSION__ < 201112L)
3591 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3592 _EOSelect_;
3593 c_fix = format;
3594 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3596 test_text = <<- _EOText_
3597 #if __STDC_VERSION__ < 201112L
3598 extern char *gets(char *) __ATTR_DEPRECATED;
3599 _EOText_;
3603 * Sun Solaris 2 has a version of sys/int_const.h that defines
3604 * UINT8_C and UINT16_C to unsigned constants.
3606 fix = {
3607 hackname = solaris_int_const;
3608 files = sys/int_const.h;
3609 mach = '*-*-solaris2*';
3610 c_fix = format;
3611 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3612 "%1\n"
3613 "#define\tUINT16_C(c)\t(c)";
3614 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3615 "(/\*.*\*/)\n"
3616 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3617 test_text =
3618 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3619 "/* CSTYLED */\n"
3620 "#define UINT16_C(c) __CONCAT__(c,u)";
3624 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3625 * UINT8_MAX and UINT16_MAX to unsigned constants.
3627 fix = {
3628 hackname = solaris_int_limits_1;
3629 files = sys/int_limits.h;
3630 mach = '*-*-solaris2*';
3631 c_fix = format;
3632 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3633 "#define\tUINT16_MAX\t(65535)";
3634 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3635 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3636 test_text =
3637 "#define UINT8_MAX (255U)\n"
3638 "#define UINT16_MAX (65535U)";
3642 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3643 * INT_FAST16 limits to wrong values for sys/int_types.h.
3645 fix = {
3646 hackname = solaris_int_limits_2;
3647 files = sys/int_limits.h;
3648 mach = '*-*-solaris2*';
3649 c_fix = format;
3650 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3651 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3652 test_text =
3653 "#define INT_FAST16_MAX INT16_MAX\n"
3654 "#define UINT_FAST16_MAX UINT16_MAX\n"
3655 "#define INT_FAST16_MIN INT16_MIN";
3659 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3660 * SIZE_MAX as unsigned long.
3662 fix = {
3663 hackname = solaris_int_limits_3;
3664 files = sys/int_limits.h;
3665 mach = '*-*-solaris2*';
3666 c_fix = format;
3667 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3668 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3669 test_text =
3670 "#define SIZE_MAX 4294967295UL";
3674 * Sun Solaris 10 defines several C99 math macros in terms of
3675 * builtins specific to the Studio compiler, in particular not
3676 * compatible with the GNU compiler.
3678 fix = {
3679 hackname = solaris_math_1;
3680 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3681 bypass = "__GNUC__";
3682 files = iso/math_c99.h;
3683 c_fix = format;
3684 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3685 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3686 test_text =
3687 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3688 "#undef HUGE_VAL\n"
3689 "#define HUGE_VAL __builtin_huge_val\n"
3690 "#undef HUGE_VALF\n"
3691 "#define HUGE_VALF __builtin_huge_valf\n"
3692 "#undef HUGE_VALL\n"
3693 "#define HUGE_VALL __builtin_huge_vall";
3697 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3698 * exception. Provide an alternative using GCC's builtin.
3700 fix = {
3701 hackname = solaris_math_10;
3702 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3703 files = iso/math_c99.h;
3704 c_fix = format;
3705 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3706 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3707 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3708 "[ \t]*\\\\\n"
3709 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3710 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3711 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3712 "\\(-INFINITY\\);[ \t]*\\}\\)";
3713 test_text =
3714 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3715 "#undef isinf\n"
3716 "#define isinf(x) __extension__( \\\\\n"
3717 " { __typeof(x) __x_i = (x); \\\\\n"
3718 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3719 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3723 * Solaris math INFINITY
3725 fix = {
3726 hackname = solaris_math_2;
3727 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3728 bypass = "__GNUC__";
3729 files = iso/math_c99.h;
3730 c_fix = format;
3731 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3732 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3733 test_text =
3734 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3735 "#undef INFINITY\n"
3736 "#define INFINITY __builtin_infinity";
3740 * Solaris math NAN
3742 fix = {
3743 hackname = solaris_math_3;
3744 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3745 bypass = "__GNUC__";
3746 files = iso/math_c99.h;
3747 c_fix = format;
3748 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3749 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3750 test_text =
3751 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3752 "#undef NAN\n"
3753 "#define NAN __builtin_nan";
3757 * Solaris math fpclassify
3759 fix = {
3760 hackname = solaris_math_4;
3761 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3762 bypass = "__GNUC__";
3763 files = iso/math_c99.h;
3764 c_fix = format;
3765 c_fix_arg = "#define\tfpclassify(x) \\\n"
3766 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3767 "FP_SUBNORMAL, FP_ZERO, (x))";
3768 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3769 test_text =
3770 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3771 "#undef fpclassify\n"
3772 "#define fpclassify(x) __builtin_fpclassify(x)";
3776 * Solaris math signbit
3778 fix = {
3779 hackname = solaris_math_8;
3780 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3781 bypass = "__GNUC__";
3782 files = iso/math_c99.h;
3783 c_fix = format;
3784 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3785 "\t\t\t ? __builtin_signbitf(x) \\\n"
3786 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3787 "\t\t\t ? __builtin_signbitl(x) \\\n"
3788 "\t\t\t : __builtin_signbit(x))";
3789 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3790 test_text = <<- _EOText_
3791 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3792 #undef signbit
3793 #define signbit(x) __builtin_signbit(x)
3794 _EOText_;
3798 * Solaris math comparison macros
3800 fix = {
3801 hackname = solaris_math_9;
3802 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3803 bypass = "__GNUC__";
3804 files = iso/math_c99.h;
3805 c_fix = format;
3806 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3807 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3808 "__builtin_[a-z]+\\(y\\)\\)";
3809 test_text =
3810 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3811 "#undef isgreater\n"
3812 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3813 "#undef isgreaterequal\n"
3814 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3815 "#undef isless\n"
3816 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3817 "#undef islessequal\n"
3818 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3819 "#undef islessgreater\n"
3820 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3821 "#undef isunordered\n"
3822 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3826 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3827 * warnings.
3829 fix = {
3830 hackname = solaris_math_11;
3831 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3832 files = iso/math_c99.h;
3833 c_fix = format;
3834 c_fix_arg = << _EOArg_
3835 #undef signbit
3836 #define signbit(x) (sizeof(x) == sizeof(float) \
3837 ? __builtin_signbitf(x) \
3838 : sizeof(x) == sizeof(long double) \
3839 ? __builtin_signbitl(x) \
3840 : __builtin_signbit(x))
3841 _EOArg_;
3842 c_fix_arg = << _EOArg_
3843 ^#undef[ ]+signbit
3844 #if defined\(__sparc\)
3845 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3846 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3847 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3848 #elif defined\(__i386\) \|\| defined\(__amd64\)
3849 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3850 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3851 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3852 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3853 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3854 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3855 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3856 #endif
3857 _EOArg_;
3858 test_text = << _EOText_
3859 /* @(#)math_c99.h 1.14 13/03/27 */
3860 #undef signbit
3861 #if defined(__sparc)
3862 #define signbit(x) __extension__( \\
3863 { __typeof(x) __x_s = (x); \\
3864 (int) (*(unsigned *) &__x_s >> 31); })
3865 #elif defined(__i386) || defined(__amd64)
3866 #define signbit(x) __extension__( \\
3867 { __typeof(x) __x_s = (x); \\
3868 (sizeof (__x_s) == sizeof (float) ? \\
3869 (int) (*(unsigned *) &__x_s >> 31) : \\
3870 sizeof (__x_s) == sizeof (double) ? \\
3871 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3872 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3873 #endif
3874 _EOText_;
3878 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3880 fix = {
3881 hackname = solaris_math_12;
3882 files = math.h;
3883 mach = '*-*-solaris2*';
3884 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3885 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3886 test_text = << _EOText_
3887 #if __cplusplus >= 201103L
3888 #undef _GLIBCXX_USE_C99_MATH
3889 #undef _GLIBCXX_USE_C99_MATH_TR1
3890 #endif
3891 _EOText_;
3895 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3896 * structure. As such, it need two levels of brackets, but only
3897 * contains one. Wrap the macro definition in an extra layer.
3899 fix = {
3900 hackname = solaris_once_init_1;
3901 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3902 files = pthread.h;
3903 mach = '*-*-solaris*';
3904 c_fix = format;
3905 c_fix_arg = "%1{%2}%3";
3906 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3907 test_text =
3908 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3909 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3913 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3914 * posix_spawn declarations, which doesn't work with C++.
3916 fix = {
3917 hackname = solaris_posix_spawn_restrict;
3918 files = spawn.h;
3919 mach = '*-*-solaris2*';
3920 c_fix = format;
3921 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3922 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3923 test_text =
3924 "char *const argv[_RESTRICT_KYWD],\n"
3925 "char *const envp[_RESTRICT_KYWD]);";
3929 * The pow overloads with int were removed in C++ 2011 DR 550.
3931 fix = {
3932 hackname = solaris_pow_int_overload;
3933 mach = '*-*-solaris2*';
3934 files = "iso/math_iso.h";
3935 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3936 " *\\{[^{}]*\n[^{}]*\\}";
3937 c_fix = format;
3938 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3940 test_text =
3941 " inline long double pow(long double __X, int __Y) { return\n"
3942 " __powl(__X, (long double) (__Y)); }";
3946 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3947 * fields of the pthread_rwlock_t structure, which are of type
3948 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3949 * defined (e.g. by -ansi) it is a union. So change the initializer
3950 * to "{0}" instead.
3952 fix = {
3953 hackname = solaris_rwlock_init_1;
3954 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3955 files = pthread.h;
3956 mach = '*-*-solaris*';
3957 c_fix = format;
3958 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3959 "%0\n"
3960 "#else\n"
3961 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3962 "#endif";
3963 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3964 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3966 test_text =
3967 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3968 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3972 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3973 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3975 fix = {
3976 hackname = solaris_std___filbuf;
3977 files = stdio.h;
3978 mach = '*-*-solaris2*';
3979 bypass = "using std::__filbuf";
3980 select = "(using std::perror;\n)(#endif)";
3981 c_fix = format;
3982 c_fix_arg = "%1#ifndef _LP64\n"
3983 "using std::__filbuf;\n"
3984 "using std::__flsbuf;\n"
3985 "#endif\n%2";
3987 test_text = "using std::perror;\n"
3988 "#endif";
3992 * Solaris <stdio.h> shouldn't use std::gets for C++14.
3994 fix = {
3995 hackname = solaris_std_gets_cxx14;
3996 mach = "*-*-solaris2*";
3997 files = "stdio.h";
3998 select = "using std::gets;";
4000 c_fix = format;
4001 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4003 test_text = "using std::gets;";
4007 * Sun Solaris 8 has what appears to be some gross workaround for
4008 * some old version of their c++ compiler. G++ doesn't want it
4009 * either, but doesn't want to be tied to SunPRO version numbers.
4011 fix = {
4012 hackname = solaris_stdio_tag;
4013 files = stdio_tag.h;
4015 select = '__cplusplus < 54321L';
4016 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4017 "!defined(__GNUC__)" so we no longer need to fix it. */
4018 bypass = '__GNUC__';
4019 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4021 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4025 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4027 fix = {
4028 hackname = solaris_stdlib_noreturn;
4029 mach = "*-*-solaris2*";
4030 files = "iso/stdlib_c99.h";
4031 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4033 c_fix = format;
4034 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4036 test_text = "extern _Noreturn void quick_exit(int);";
4040 * a missing semi-colon at the end of the statsswtch structure definition.
4042 fix = {
4043 hackname = statsswtch;
4044 files = rpcsvc/rstat.h;
4045 select = "boottime$";
4046 c_fix = format;
4047 c_fix_arg = "boottime;";
4048 test_text = "struct statswtch {\n int boottime\n};";
4052 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4053 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4054 * OK too.
4056 fix = {
4057 hackname = stdio_stdarg_h;
4058 files = stdio.h;
4059 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4061 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4062 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4064 mach = '*-*-solaris2.1[0-9]*';
4065 not_machine = true;
4067 c_fix = wrap;
4069 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4071 test_text = "";
4075 * Don't use or define the name va_list in stdio.h. This is for
4076 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4077 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4078 * indicate that the header knows what it's doing -- under SUSv2,
4079 * stdio.h is required to define va_list, and we shouldn't break
4080 * that.
4082 fix = {
4083 hackname = stdio_va_list;
4084 files = stdio.h;
4085 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4087 * On Solaris 10, the definition in
4088 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4089 * there is therefore no need for this fix there.
4091 mach = '*-*-solaris2.1[0-9]*';
4092 not_machine = true;
4095 * Use __gnuc_va_list in arg types in place of va_list.
4096 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4097 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4098 * trailing parentheses and semicolon save all other systems from this.
4099 * Define __not_va_list__ (something harmless and unused)
4100 * instead of va_list.
4101 * Don't claim to have defined va_list.
4103 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4104 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4105 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4106 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4107 "s@ va_list@ __not_va_list__@\n"
4108 "s@\\*va_list@*__not_va_list__@\n"
4109 "s@ __va_list)@ __gnuc_va_list)@\n"
4110 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4111 "@typedef \\1 __not_va_list__;@\n"
4112 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4113 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4114 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4115 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4116 "s@VA_LIST@DUMMY_VA_LIST@\n"
4117 "s@_Va_LIST@_VA_LIST@";
4118 test_text = "extern void mumble( va_list);";
4122 * Fix headers that use va_list from stdio.h to use the updated
4123 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4124 * dealt with elsewhere. The presence of __gnuc_va_list,
4125 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4126 * knows what it's doing.
4128 fix = {
4129 hackname = stdio_va_list_clients;
4130 files = com_err.h;
4131 files = cps.h;
4132 files = curses.h;
4133 files = krb5.h;
4134 files = lc_core.h;
4135 files = pfmt.h;
4136 files = wchar.h;
4137 files = curses_colr/curses.h;
4138 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4139 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4140 otherwise protected. */
4141 bypass = 'include <stdarg\.h>|#ifdef va_start';
4144 * Use __gnuc_va_list in arg types in place of va_list.
4145 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4146 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4147 * trailing parentheses and semicolon save all other systems from this.
4148 * Define __not_va_list__ (something harmless and unused)
4149 * instead of va_list.
4150 * Don't claim to have defined va_list.
4152 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4153 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4154 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4155 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4156 "s@ va_list@ __not_va_list__@\n"
4157 "s@\\*va_list@*__not_va_list__@\n"
4158 "s@ __va_list)@ __gnuc_va_list)@\n"
4159 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4160 "@typedef \\1 __not_va_list__;@\n"
4161 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4162 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4163 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4164 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4165 "s@VA_LIST@DUMMY_VA_LIST@\n"
4166 "s@_Va_LIST@_VA_LIST@";
4167 test_text = "extern void mumble( va_list);";
4171 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4172 * is "!defined( __STRICT_ANSI__ )"
4174 fix = {
4175 hackname = strict_ansi_not;
4176 select = "^([ \t]*#[ \t]*if.*)"
4177 "(!__STDC__"
4178 "|__STDC__[ \t]*==[ \t]*0"
4179 "|__STDC__[ \t]*!=[ \t]*1"
4180 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4181 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4182 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4183 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4184 is not defined by GCC, so it is safe. */
4185 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4186 c_test = stdc_0_in_system_headers;
4188 c_fix = format;
4189 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4191 test_text = "#if !__STDC__ \n"
4192 "#if __STDC__ == 0\n"
4193 "#if __STDC__ != 1\n"
4194 "#if __STDC__ - 0 == 0"
4195 "/* not std C */\nint foo;\n"
4196 "\n#end-end-end-end-if :-)";
4200 * "__STDC__-0==0"
4201 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4203 fix = {
4204 hackname = strict_ansi_not_ctd;
4205 files = math.h, limits.h, stdio.h, signal.h,
4206 stdlib.h, sys/signal.h, time.h;
4208 * Starting at the beginning of a line, skip white space and
4209 * a leading "(" or "&&" or "||". One of those must be found.
4210 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4211 * expression. If these are nested, then they must accumulate
4212 * because we won't match any closing parentheses. Finally,
4213 * after skipping over all that, we must then match our suspect
4214 * phrase: "__STDC__-0==0" with or without white space.
4216 select = "^([ \t]*" '(\(|&&|\|\|)'
4217 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4218 "[ \t(]*)"
4219 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4220 c_test = stdc_0_in_system_headers;
4222 c_fix = format;
4223 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4225 test_text = "#if 1 && \\\\\n"
4226 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4227 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4228 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4229 "int foo;\n#endif";
4233 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4234 * is "defined( __STRICT_ANSI__ )"
4236 fix = {
4237 hackname = strict_ansi_only;
4238 select = "^([ \t]*#[ \t]*if.*)"
4239 "(__STDC__[ \t]*!=[ \t]*0"
4240 "|__STDC__[ \t]*==[ \t]*1"
4241 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4242 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4243 c_test = stdc_0_in_system_headers;
4245 c_fix = format;
4246 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4248 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4252 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4253 * in prototype without previous definition.
4255 fix = {
4256 hackname = struct_file;
4257 files = rpc/xdr.h;
4258 select = '^.*xdrstdio_create.*struct __file_s';
4259 c_fix = format;
4260 c_fix_arg = "struct __file_s;\n%0";
4261 test_text = "extern void xdrstdio_create( struct __file_s* );";
4265 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4266 * in prototype without previous definition.
4268 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4269 * function, and does define it.
4271 fix = {
4272 hackname = struct_sockaddr;
4273 files = rpc/auth.h;
4274 select = "^.*authdes_create.*struct sockaddr[^_]";
4275 bypass = "<sys/socket\.h>";
4276 bypass = "struct sockaddr;\n";
4277 c_fix = format;
4278 c_fix_arg = "struct sockaddr;\n%0";
4279 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4283 * Apply fix this to all OSs since this problem seems to effect
4284 * more than just SunOS.
4286 fix = {
4287 hackname = sun_auth_proto;
4288 files = rpc/auth.h;
4289 files = rpc/clnt.h;
4290 files = rpc/svc.h;
4291 files = rpc/xdr.h;
4292 bypass = "__cplusplus";
4294 * Select those files containing '(*name)()'.
4296 select = '\(\*[a-z][a-z_]*\)\(\)';
4298 c_fix = format;
4299 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4300 "#else\n%1();%2\n#endif";
4301 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4303 test_text =
4304 "struct auth_t {\n"
4305 " int (*name)(); /* C++ bad */\n"
4306 "};";
4310 * Fix bogus #ifdef on SunOS 4.1.
4312 fix = {
4313 hackname = sun_bogus_ifdef;
4314 files = "hsfs/hsfs_spec.h";
4315 files = "hsfs/iso_spec.h";
4316 select = '#ifdef(.*\|\|.*)';
4317 c_fix = format;
4318 c_fix_arg = "#if%1";
4320 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4324 * Fix the CAT macro in SunOS memvar.h.
4326 fix = {
4327 hackname = sun_catmacro;
4328 files = pixrect/memvar.h;
4329 select = "^#define[ \t]+CAT\\(a,b\\).*";
4330 c_fix = format;
4332 c_fix_arg =
4333 "#ifdef __STDC__\n"
4334 "# define CAT(a,b) a##b\n"
4335 "#else\n%0\n#endif";
4337 test_text =
4338 "#define CAT(a,b)\ta/**/b";
4342 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4343 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4345 fix = {
4346 hackname = sun_malloc;
4347 files = malloc.h;
4348 bypass = "_CLASSIC_ANSI_TYPES";
4350 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4351 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4352 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4353 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4354 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4356 test_text =
4357 "typedef char *\tmalloc_t;\n"
4358 "int \tfree();\n"
4359 "char*\tmalloc();\n"
4360 "char*\tcalloc();\n"
4361 "char*\trealloc();";
4365 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4367 fix = {
4368 hackname = sun_rusers_semi;
4369 files = rpcsvc/rusers.h;
4370 select = "_cnt$";
4371 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4372 test_text = "struct mumble\n int _cnt\n};";
4376 * signal.h on SunOS defines signal using (),
4377 * which causes trouble when compiling with g++ -pedantic.
4379 fix = {
4380 hackname = sun_signal;
4381 files = sys/signal.h;
4382 files = signal.h;
4383 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4385 c_fix = format;
4386 c_fix_arg =
4387 "#ifdef __cplusplus\n"
4388 "void\t(*signal(...))(...);\n"
4389 "#else\n%0\n#endif";
4391 test_text = "void\t(*signal())();";
4395 * Correct the return type for strlen in strings.h in SunOS 4.
4397 fix = {
4398 hackname = sunos_strlen;
4399 files = strings.h;
4400 select = "int[ \t]*strlen\\(\\);(.*)";
4401 c_fix = format;
4402 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4403 test_text = " int\tstrlen(); /* string length */";
4407 * Linux kernel's vt.h breaks C++
4409 fix = {
4410 hackname = suse_linux_vt_cxx;
4411 files = linux/vt.h;
4413 select = "^[ \t]*unsigned int new;";
4414 c_fix = format;
4415 c_fix_arg = "unsigned int newev;";
4417 test_text = " unsigned int new; /* New console (if changing) */";
4421 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4422 * that is visible to any ANSI compiler using this include. Simply
4423 * delete the lines that #define some string functions to internal forms.
4425 fix = {
4426 hackname = svr4_disable_opt;
4427 files = string.h;
4428 select = '#define.*__std_hdr_';
4429 sed = '/#define.*__std_hdr_/d';
4430 test_text = "#define strlen __std_hdr_strlen\n";
4434 * Fix broken decl of getcwd present on some svr4 systems.
4436 fix = {
4437 hackname = svr4_getcwd;
4438 files = stdlib.h;
4439 files = unistd.h;
4440 files = prototypes.h;
4441 select = 'getcwd\(char \*, int\)';
4443 c_fix = format;
4444 c_fix_arg = "getcwd(char *, size_t)";
4446 test_text = "extern char* getcwd(char *, int);";
4450 * Fix broken decl of profil present on some svr4 systems.
4452 fix = {
4453 hackname = svr4_profil;
4454 files = stdlib.h;
4455 files = unistd.h;
4457 select =
4458 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4459 c_fix = format;
4460 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4462 test_text =
4463 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4467 * Correct types for signal handler constants like SIG_DFL; they might be
4468 * void (*) (), and should be void (*) (int). C++ doesn't like the
4469 * old style.
4471 fix = {
4472 hackname = svr4_sighandler_type;
4473 files = sys/signal.h;
4474 select = 'void *\(\*\)\(\)';
4475 c_fix = format;
4476 c_fix_arg = "void (*)(int)";
4477 test_text = "#define SIG_DFL (void(*)())0\n"
4478 "#define SIG_IGN (void (*)())0\n";
4482 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4483 * function 'getrnge' in <regexp.h> before they declare it. For these
4484 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4485 * early on.
4487 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4488 * so put the declaration right after the declaration of 'size'.
4490 * Don't do this if there is already a `static void getrnge' declaration
4491 * present, since this would cause a redeclaration error. Solaris 2.x has
4492 * such a declaration.
4494 fix = {
4495 hackname = svr4_undeclared_getrnge;
4496 files = regexp.h;
4497 select = "getrnge";
4498 bypass = "static void getrnge";
4499 c_fix = format;
4500 c_fix_arg = "%0\n"
4501 "static int getrnge ();";
4502 c_fix_arg = "^static int[ \t]+size;";
4503 test_text = "static int size;\n"
4504 "/* stuff which calls getrnge() */\n"
4505 "static getrnge()\n"
4506 "{}";
4510 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4511 * in string.h on sysV68
4512 * Correct the return type for strlen in string.h on Lynx.
4513 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4514 * Add missing const for strdup on OSF/1 V3.0.
4515 * On sysV88 layout is slightly different.
4517 fix = {
4518 hackname = sysv68_string;
4519 files = testing.h;
4520 files = string.h;
4521 bypass = "_CLASSIC_ANSI_TYPES";
4523 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4524 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4525 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4527 sed = "/^extern char$/N";
4528 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4530 sed = "/^extern int$/N";
4531 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4533 sed = "/^\tstrncmp(),$/N";
4534 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4535 '\1;' "\\\nextern unsigned int\\\n\\2/";
4537 test_text =
4538 "extern int strlen();\n"
4540 "extern int ffs(long);\n"
4542 "extern char\n"
4543 "\t*memccpy(),\n"
4544 "\tmemcpy();\n"
4546 "extern int\n"
4547 "\tstrcmp(),\n"
4548 "\tstrncmp(),\n"
4549 "\tstrlen(),\n"
4550 "\tstrspn();\n"
4552 "extern int\n"
4553 "\tstrlen(), strspn();";
4557 * Fix return type of calloc, malloc, realloc, bsearch and exit
4559 fix = {
4560 hackname = sysz_stdlib_for_sun;
4561 files = stdlib.h;
4562 bypass = "_CLASSIC_ANSI_TYPES";
4564 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4565 c_fix = format;
4566 c_fix_arg = "void *\t%1(";
4568 test_text =
4569 "extern char*\tcalloc(size_t);\n"
4570 "extern char*\tmalloc(size_t);\n"
4571 "extern char*\trealloc(void*,size_t);\n"
4572 "extern char*\tbsearch(void*,size_t,size_t);\n";
4576 * __thread is now a keyword.
4578 fix = {
4579 hackname = thread_keyword;
4580 files = "pthread.h";
4581 files = bits/sigthread.h, '*/bits/sigthread.h';
4582 select = "([* ])__thread([,)])";
4583 c_fix = format;
4584 c_fix_arg = "%1__thr%2";
4586 test_text =
4587 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4588 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4589 "extern int pthread_cancel (pthread_t __thread);";
4593 * if the #if says _cplusplus, not the double underscore __cplusplus
4594 * that it should be
4596 fix = {
4597 hackname = tinfo_cplusplus;
4598 files = tinfo.h;
4599 select = "[ \t]_cplusplus";
4601 c_fix = format;
4602 c_fix_arg = " __cplusplus";
4603 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4607 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4609 fix = {
4610 hackname = ultrix_const;
4611 files = stdio.h;
4612 select = 'perror\( char \*';
4614 c_fix = format;
4615 c_fix_arg = "%1 const %3 *__";
4616 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4617 "[ \t]+(char|void) \\*__";
4619 test_text =
4620 "extern void perror( char *__s );\n"
4621 "extern int fputs( char *__s, FILE *);\n"
4622 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4623 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4624 "extern int scanf( char *__format, ...);\n";
4628 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4630 fix = {
4631 hackname = ultrix_const2;
4632 files = stdio.h;
4634 select = '\*fopen\( char \*';
4635 c_fix = format;
4636 c_fix_arg = "%1( const char *%3, const char *";
4637 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4638 "[ \t]*char[ \t]*\\*([^,]*),"
4639 "[ \t]*char[ \t]*\\*[ \t]*";
4641 test_text =
4642 "extern FILE *fopen( char *__filename, char *__type );\n"
4643 "extern int sscanf( char *__s, char *__format, ...);\n"
4644 "extern FILE *popen(char *, char *);\n"
4645 "extern char *tempnam(char*,char*);\n";
4649 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4651 fix = {
4652 hackname = va_i960_macro;
4653 files = arch/i960/archI960.h;
4654 select = "__(vsiz|vali|vpad|alignof__)";
4656 c_fix = format;
4657 c_fix_arg = "__vx%1";
4659 test_text =
4660 "extern int __vsiz vsiz;\n"
4661 "extern int __vali vali;\n"
4662 "extern int __vpad vpad;\n"
4663 "#define __alignof__(x) ...";
4667 * On VMS, add missing braces around sigset_t constants.
4669 fix = {
4670 hackname = vms_add_missing_braces;
4671 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4672 mach = "*-*-*vms*";
4673 files = "rtldef/signal.h";
4674 c_fix = format;
4676 c_fix_arg = '%1 {%2} ';
4678 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4679 "{0x00000000, 0x00000000},\n"
4680 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4684 * On VMS, some DEC-C builtins are directly used.
4686 fix = {
4687 hackname = vms_decc_builtin;
4688 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4689 mach = "*-*-*vms*";
4690 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4691 rtldef/socket.h;
4692 sed = "s@__MEMSET@memset@";
4693 sed = "s@__MEMMOVE@memmove@";
4694 sed = "s@__MEMCPY@memcpy@";
4695 sed = "s@__STRLEN@strlen@";
4696 sed = "s@__STRCPY@strcpy@";
4698 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4702 * Define __CAN_USE_EXTERN_PREFIX on vms.
4704 fix = {
4705 hackname = vms_define_can_use_extern_prefix;
4706 files = "rtldef/decc$types.h";
4707 select = "#[ \t]*else\n"
4708 "#[ \t]*if defined\\(__DECCXX\\)\n"
4709 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4710 mach = "*-*-*vms*";
4711 c_fix = format;
4713 c_fix_arg = "%0"
4714 "# elif defined (__GNUC__)\n"
4715 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4717 test_text = "# else\n"
4718 "# if defined(__DECCXX)\n"
4719 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4720 "# endif\n"
4721 "# endif\n";
4725 * On VMS, disable the use of dec-c string builtins
4727 fix = {
4728 hackname = vms_disable_decc_string_builtins;
4729 select = "#if !defined\\(__VAX\\)\n";
4730 mach = "*-*-*vms*";
4731 files = "rtldef/string.h";
4732 c_fix = format;
4734 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4736 test_text = "#if !defined(__VAX)\n";
4740 * On VMS, fix incompatible redeclaration of hostalias.
4742 fix = {
4743 hackname = vms_do_not_redeclare_hostalias;
4744 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4745 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4746 mach = "*-*-*vms*";
4747 files = "rtldef/resolv.h";
4748 c_fix = format;
4750 c_fix_arg = "%1\n"
4751 "/* %2 */";
4753 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4754 "__char_ptr32 hostalias (const char *);\n";
4758 * On VMS, forward declare structure before referencing them in prototypes.
4760 fix = {
4761 hackname = vms_forward_declare_struct;
4762 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4763 "#ifdef __cplusplus\n";
4764 mach = "*-*-*vms*";
4765 files = rtldef/if.h;
4766 c_fix = format;
4768 c_fix_arg = "%1"
4769 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4771 test_text = "/* forward decls for C++ */\n"
4772 "#ifdef __cplusplus\n"
4773 "struct foo;\n"
4774 "#endif\n";
4778 * On VMS, do not declare getopt and al if pointers are 64 bit.
4780 fix = {
4781 hackname = vms_no_64bit_getopt;
4782 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4783 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4784 mach = "*-*-*vms*";
4785 files = rtldef/stdio.h, rtldef/unistd.h;
4786 c_fix = format;
4788 c_fix_arg = <<- _EOArg_
4789 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4790 %0#endif
4792 _EOArg_;
4794 test_text = "int getopt (int, char * const [], const char *);";
4798 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4799 * which is not yet fully supported by gcc.
4801 fix = {
4802 hackname = vms_use_fast_setjmp;
4803 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4804 mach = "*-*-*vms*";
4805 files = rtldef/setjmp.h;
4806 c_fix = format;
4808 c_fix_arg = "%0 defined (__GNUC__) ||";
4810 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4814 * On VMS, use pragma extern_model instead of VAX-C keywords.
4816 fix = {
4817 hackname = vms_use_pragma_extern_model;
4818 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4819 "# pragma extern_model __save\n";
4820 mach = "*-*-*vms*";
4821 c_fix = format;
4823 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4824 "# pragma extern_model __save\n";
4826 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4827 "# pragma extern_model __save\n"
4828 "# pragma extern_model strict_refdef\n"
4829 " extern struct x zz$yy;\n"
4830 "# pragma extern_model __restore\n"
4831 "#endif\n";
4835 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4836 * conflict while building gcc. Likewise for <builtins.h>
4838 fix = {
4839 hackname = vms_use_quoted_include;
4840 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4841 mach = "*-*-*vms*";
4842 files = rtldef/wait.h, starlet_c/pthread.h;
4843 c_fix = format;
4845 c_fix_arg = '%1<sys/%2.h>';
4847 test_text = "# include <resource.h>";
4851 * AIX and Interix headers define NULL to be cast to a void pointer,
4852 * which is illegal in ANSI C++.
4854 fix = {
4855 hackname = void_null;
4856 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4857 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4858 /* avoid changing C++ friendly NULL */
4859 bypass = __cplusplus;
4860 bypass = __null;
4861 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4862 c_fix = format;
4863 c_fix_arg = <<- _EOFix_
4864 #ifndef NULL
4865 #ifdef __cplusplus
4866 #ifdef __GNUG__
4867 #define NULL __null
4868 #else /* ! __GNUG__ */
4869 #define NULL 0L
4870 #endif /* __GNUG__ */
4871 #else /* ! __cplusplus */
4872 #define NULL ((void *)0)
4873 #endif /* __cplusplus */
4874 #endif /* !NULL */
4875 _EOFix_;
4876 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4880 * Make VxWorks header which is almost gcc ready fully gcc ready.
4882 fix = {
4883 hackname = vxworks_gcc_problem;
4884 files = types/vxTypesBase.h;
4885 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4887 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4888 "#if 1/";
4890 sed = "/[ \t]size_t/i\\\n"
4891 "#ifndef _GCC_SIZE_T\\\n"
4892 "#define _GCC_SIZE_T\n";
4894 sed = "/[ \t]size_t/a\\\n"
4895 "#endif\n";
4897 sed = "/[ \t]ptrdiff_t/i\\\n"
4898 "#ifndef _GCC_PTRDIFF_T\\\n"
4899 "#define _GCC_PTRDIFF_T\n";
4901 sed = "/[ \t]ptrdiff_t/a\\\n"
4902 "#endif\n";
4904 sed = "/[ \t]wchar_t/i\\\n"
4905 "#ifndef _GCC_WCHAR_T\\\n"
4906 "#define _GCC_WCHAR_T\n";
4908 sed = "/[ \t]wchar_t/a\\\n"
4909 "#endif\n";
4911 test_text =
4912 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4913 "typedef unsigned int size_t;\n"
4914 "typedef long ptrdiff_t;\n"
4915 "typedef unsigned short wchar_t;\n"
4916 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4920 * Wrap VxWorks ioctl to keep everything pretty
4922 fix = {
4923 hackname = vxworks_ioctl_macro;
4924 files = ioLib.h;
4925 mach = "*-*-vxworks*";
4927 c_fix = format;
4928 c_fix_arg = "%0\n"
4929 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
4930 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4932 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4936 * Wrap VxWorks mkdir to be posix compliant
4938 fix = {
4939 hackname = vxworks_mkdir_macro;
4940 files = sys/stat.h;
4941 mach = "*-*-vxworks*";
4943 c_fix = format;
4944 c_fix_arg = "%0\n"
4945 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4946 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4947 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4948 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4949 "\\)[\t ]*;";
4951 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4955 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4957 fix = {
4958 hackname = vxworks_needs_vxtypes;
4959 files = time.h;
4960 select = "uint_t([ \t]+_clocks_per_sec)";
4961 c_fix = format;
4962 c_fix_arg = "unsigned int%1";
4963 test_text = "uint_t\t_clocks_per_sec;";
4967 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4969 fix = {
4970 hackname = vxworks_needs_vxworks;
4971 files = sys/stat.h;
4972 test = " -r types/vxTypesOld.h";
4973 test = " -n \"`egrep '#include' $file`\"";
4974 test = " -n \"`egrep ULONG $file`\"";
4975 select = "#[ \t]define[ \t]+__INCstath";
4977 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4978 "#include <types/vxTypesOld.h>\n";
4980 test_text = "`touch types/vxTypesOld.h`"
4981 "#include </dev/null> /* ULONG */\n"
4982 "# define\t__INCstath <sys/stat.h>";
4986 * Make it so VxWorks does not include gcc/regs.h accidentally
4988 fix = {
4989 hackname = vxworks_regs;
4990 mach = "*-*-vxworks*";
4992 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4993 c_fix = format;
4994 c_fix_arg = "#include <arch/../regs.h>";
4996 test_text = "#include <regs.h>\n";
5000 * Another bad dependency in VxWorks 5.2 <time.h>.
5002 fix = {
5003 hackname = vxworks_time;
5004 files = time.h;
5005 test = " -r vxWorks.h";
5007 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5008 c_fix = format;
5010 c_fix_arg =
5011 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5012 "#ifdef __cplusplus\n"
5013 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5014 "#else\n"
5015 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5016 "#endif\n"
5017 "#define __gcc_VOIDFUNCPTR_defined\n"
5018 "#endif\n"
5019 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5021 test_text = "`touch vxWorks.h`"
5022 "#define VOIDFUNCPTR (void(*)())";
5026 * This hack makes write const-correct on VxWorks
5028 fix = {
5029 hackname = vxworks_write_const;
5030 files = ioLib.h;
5031 mach = "*-*-vxworks*";
5033 c_fix = format;
5034 c_fix_arg = "extern int write (int, const char*, size_t);";
5035 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5036 "[\t ]*int[\t ]*,"
5037 "[\t ]*char[\t ]*\\*[\t ]*,"
5038 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5040 test_text = "extern int write ( int , char * , size_t ) ;";
5044 * This hack ensures the include_next in the fixed unistd.h actually
5045 * finds the system's unistd.h and not the fixed unistd.h again.
5047 fix = {
5048 hackname = vxworks_iolib_include_unistd;
5049 files = ioLib.h;
5050 mach = "*-*-vxworks*";
5051 select = "#include \"unistd.h\"";
5053 c_fix = format;
5054 c_fix_arg = "#include <unistd.h>";
5056 test_text = "#include \"unistd.h\"";
5060 * There are several name conflicts with C++ reserved words in X11 header
5061 * files. These are fixed in some versions, so don't do the fixes if
5062 * we find __cplusplus in the file. These were found on the RS/6000.
5064 fix = {
5065 hackname = x11_class;
5066 files = X11/ShellP.h;
5067 bypass = __cplusplus;
5068 select = "^([ \t]*char \\*)class;(.*)";
5069 c_fix = format;
5070 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5071 "#else\n%1class;%2\n#endif";
5072 test_text =
5073 "struct {\n"
5074 " char *class;\n"
5075 "} mumble;\n";
5079 * class in Xm/BaseClassI.h
5081 fix = {
5082 hackname = x11_class_usage;
5083 files = Xm/BaseClassI.h;
5084 bypass = "__cplusplus";
5086 select = " class\\)";
5087 c_fix = format;
5088 c_fix_arg = " c_class)";
5090 test_text = "extern mumble (int class);\n";
5094 * new in Xm/Traversal.h
5096 fix = {
5097 hackname = x11_new;
5098 files = Xm/Traversal.h;
5099 bypass = __cplusplus;
5101 sed = "/Widget\told, new;/i\\\n"
5102 "#ifdef __cplusplus\\\n"
5103 "\\\tWidget\told, c_new;\\\n"
5104 "#else\n";
5106 sed = "/Widget\told, new;/a\\\n"
5107 "#endif\n";
5109 sed = "s/Widget new,/Widget c_new,/g";
5110 test_text =
5111 "struct wedge {\n"
5112 " Widget\told, new;\n"
5113 "};\nextern Wedged( Widget new, Widget old );";
5117 * Incorrect sprintf declaration in X11/Xmu.h
5119 fix = {
5120 hackname = x11_sprintf;
5121 files = X11/Xmu.h;
5122 files = X11/Xmu/Xmu.h;
5123 select = "^extern char \\*\tsprintf\\(\\);$";
5125 c_fix = format;
5126 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5128 test_text = "extern char *\tsprintf();";
5130 /*EOF*/