2017-12-07 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / fixincludes / inclhack.def
blobfd0034f3aaa055f649a3828e41e3a25dc303a961
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key=$'hackname[ \t]*=[ \t]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
61 #endif
62 #endif
64 _EOArg_;
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
72 fix = {
73 hackname = AAB_aix_fcntl;
74 files = fcntl.h;
75 select = "define open[ \t]open64";
76 mach = "*-*-aix*";
77 test-text = ''; /* no way to test */
79 c_fix = wrap;
81 c_fix_arg = "";
83 c_fix_arg = <<- _EOArg_
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
88 #undef open
89 #undef creat
90 #undef openat
91 /* Alias the symbols using asm */
92 extern "C" {
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
97 #endif
99 #endif
100 #endif
102 _EOArg_;
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
109 fix = {
110 hackname = AAB_darwin7_9_long_double_funcs;
111 mach = "*-*-darwin7.9*";
112 files = architecture/ppc/math.h;
113 bypass = "powl";
114 replace = <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
116 10.3.9. */
117 #ifndef __MATH__
118 # undef __APPLE_CC__
119 # define __APPLE_CC__ 1345
120 # include_next <architecture/ppc/math.h>
121 # undef __APPLE_CC__
122 # define __APPLE_CC__ 1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
126 # else
127 # define __LIBMLDBL_COMPAT(sym)
128 # endif /* __LONG_DOUBLE_128__ */
129 # endif /* __LIBMLDBL_COMPAT */
130 # ifdef __cplusplus
131 extern "C" {
132 # endif
133 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
190 # ifdef __cplusplus
192 # endif
193 #endif /* __MATH__ */
194 _EndOfHeader_;
198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
200 fix = {
201 hackname = AAB_fd_zero_asm_posix_types_h;
202 files = asm/posix_types.h;
203 mach = 'i[34567]86-*-linux*';
204 bypass = '} while';
205 bypass = 'x86_64';
206 bypass = 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
210 * the start, so that if #include_next gets another instance of
211 * the wrapper, this will follow the #include_next chain until
212 * we arrive at the real <asm/posix_types.h>.
214 replace = <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel. */
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include <features.h>
219 #include_next <asm/posix_types.h>
221 #if defined(__FD_ZERO) && !defined(__GLIBC__)
222 #undef __FD_ZERO
223 #define __FD_ZERO(fdsetp) \
224 do { \
225 int __d0, __d1; \
226 __asm__ __volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0), "=&D" (__d1) \
228 : "a" (0), "0" (__FDSET_LONGS), \
229 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
230 } while (0)
231 #endif
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif /* _POSIX_TYPES_H_WRAPPER */
235 _EndOfHeader_;
239 * This fixes __FD_ZERO bug for glibc-1.x
241 fix = {
242 hackname = AAB_fd_zero_gnu_types_h;
243 files = gnu/types.h;
244 mach = 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
248 * the start, so that if #include_next gets another instance of
249 * the wrapper, this will follow the #include_next chain until
250 * we arrive at the real <gnu/types.h>.
252 replace = <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
254 #ifndef _TYPES_H_WRAPPER
255 #include <features.h>
256 #include_next <gnu/types.h>
258 #if defined(__FD_ZERO) && !defined(__GLIBC__)
259 #undef __FD_ZERO
260 # define __FD_ZERO(fdsetp) \
261 do { \
262 int __d0, __d1; \
263 __asm__ __volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0), "=&D" (__d1) \
265 : "a" (0), "0" (__FDSET_LONGS), \
266 "1" ((__fd_set *) (fdsetp)) :"memory"); \
267 } while (0)
268 #endif
270 #define _TYPES_H_WRAPPER
271 #endif /* _TYPES_H_WRAPPER */
272 _EndOfHeader_;
276 * This fixes __FD_ZERO bug for glibc-2.0.x
278 fix = {
279 hackname = AAB_fd_zero_selectbits_h;
280 files = selectbits.h;
281 mach = 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
285 * the start, so that if #include_next gets another instance of
286 * the wrapper, this will follow the #include_next chain until
287 * we arrive at the real <selectbits.h>.
289 replace = <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include <features.h>
293 #include_next <selectbits.h>
295 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
296 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
297 && __GLIBC_MINOR__ == 0
298 #undef __FD_ZERO
299 #define __FD_ZERO(fdsetp) \\
300 do { \\
301 int __d0, __d1; \\
302 __asm__ __volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0), "=&D" (__d1) \\
304 : "a" (0), "0" (sizeof (__fd_set) \\
305 / sizeof (__fd_mask)), \\
306 "1" ((__fd_mask *) (fdsetp)) \\
307 : "memory"); \\
308 } while (0)
309 #endif
311 #define _SELECTBITS_H_WRAPPER
312 #endif /* _SELECTBITS_H_WRAPPER */
313 _EndOfHeader_;
317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
318 * the same interface as <stdarg.h>. No idea why they couldn't have just
319 * used the standard header.
321 fix = {
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris*';
325 replace = <<- _EndOfHeader_
326 #ifdef __STDC__
327 #include <stdarg.h>
328 #else
329 #include <varargs.h>
330 #endif
331 _EndOfHeader_;
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
341 fix = {
342 hackname = AAB_sun_memcpy;
343 files = memory.h;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
350 #ifndef __memory_h__
351 #define __memory_h__
353 #ifdef __STDC__
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
358 #else
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
365 extern int memcmp();
367 #endif /* __memory_h__ */
368 _EndOfHeader_;
372 * Fix assert.h on VxWorks:
374 fix = {
375 hackname = AAB_vxworks_assert;
376 files = assert.h;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
380 #ifndef _ASSERT_H
381 #define _ASSERT_H
383 #ifdef assert
384 #undef assert
385 #endif
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
389 #else
390 extern void __assert ();
391 #endif
393 #ifdef NDEBUG
394 #define assert(ign) ((void)0)
395 #else
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
405 #endif
407 #endif
408 _EndOfHeader_;
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
415 fix = {
416 hackname = AAB_vxworks_regs_vxtypes;
417 files = regs.h;
418 mach = "*-*-vxworks*";
420 replace = <<- _EndOfHeader_
421 #ifndef _REGS_H
422 #define _REGS_H
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
425 #endif
426 _EndOfHeader_;
430 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
432 fix = {
433 hackname = AAB_vxworks_unistd;
434 files = unistd.h;
435 mach = "*-*-vxworks*";
437 replace = <<- _EndOfHeader_
438 #ifndef _UNISTD_H
439 #define _UNISTD_H
440 #include_next <unistd.h>
441 #include <ioLib.h>
442 #ifndef STDIN_FILENO
443 #define STDIN_FILENO 0
444 #endif
445 #ifndef STDOUT_FILENO
446 #define STDOUT_FILENO 1
447 #endif
448 #ifndef STDERR_FILENO
449 #define STDERR_FILENO 2
450 #endif
451 #endif /* _UNISTD_H */
452 _EndOfHeader_;
456 * assert.h on AIX 7 redefines static_assert as _Static_assert without
457 * protecting C++.
459 fix = {
460 hackname = aix_assert;
461 mach = "*-*-aix*";
462 files = assert.h;
463 select = "#define[ \t]static_assert[ \t]_Static_assert";
464 c_fix = format;
465 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
466 test_text = "#define static_assert _Static_assert";
470 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
471 * which only is provided by AIX xlc C99.
473 fix = {
474 hackname = aix_complex;
475 mach = "*-*-aix*";
476 files = complex.h;
477 select = "#define[ \t]_Complex_I[ \t]__I";
478 c_fix = format;
479 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
480 test_text = "#define _Complex_I __I\n";
484 * On AIX some headers are not properly guarded by 'extern "C"'.
486 fix = {
487 hackname = aix_externc;
488 mach = "*-*-aix*";
489 files = ctype.h;
490 files = fcntl.h;
491 files = langinfo.h;
492 files = ldfcn.h;
493 files = sys/localedef.h;
494 files = sys/times.h;
495 bypass = "extern \"C\"";
496 c_fix = wrap;
497 c_fix_arg = "#ifdef __cplusplus\n"
498 "extern \"C\" {\n"
499 "#endif\n";
500 c_fix_arg = "#ifdef __cplusplus\n"
501 "}\n"
502 "#endif\n";
503 test_text = "extern int __n_pthreads;\n";
507 * On AIX sys/socket.h assumes C++.
509 fix = {
510 hackname = aix_externcpp1;
511 mach = "*-*-aix*";
512 files = "sys/socket.h";
513 select = "#ifdef __cplusplus";
514 c_fix = format;
515 c_fix_arg = "#ifdef __cplusplus\n"
516 "extern \"C++\" {";
517 test_text = "#ifdef __cplusplus";
521 fix = {
522 hackname = aix_externcpp2;
523 mach = "*-*-aix*";
524 files = "sys/socket.h";
525 select = "#else /\\* __cplusplus \\*/";
526 c_fix = format;
527 c_fix_arg = "} /* extern \"C++\" */\n"
528 "#else /* __cplusplus */";
529 test_text = "#else /* __cplusplus */";
534 * malloc.h on AIX6 uses XLC++ specific builtin syntax
536 fix = {
537 hackname = aix_malloc;
538 mach = "*-*-aix*";
539 files = "malloc.h";
540 select = "#ifdef __cplusplus";
541 c_fix = format;
542 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
543 test_text = "#ifdef __cplusplus";
547 * net/if_arp.h defines a variable fc_softc instead of adding a
548 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
550 fix = {
551 hackname = aix_net_if_arp;
552 mach = "*-*-aix*";
553 files = "net/if_arp.h";
554 select = "^struct fc_softc \\{";
555 c_fix = format;
556 c_fix_arg = "typedef struct _fc_softc {";
557 test_text = "struct fc_softc {\n int a;\n};";
561 * Fix AIX definition of NULL for G++.
563 fix = {
564 hackname = aix_null;
565 mach = "*-*-aix*";
566 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
567 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
568 bypass = __null;
569 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
570 c_fix = format;
571 c_fix_arg = <<- _EOFix_
572 #ifndef NULL
573 #ifdef __cplusplus
574 #ifdef __GNUG__
575 #define NULL __null
576 #else /* ! __GNUG__ */
577 #define NULL 0L
578 #endif /* __GNUG__ */
579 #else /* ! __cplusplus */
580 #define NULL ((void *)0)
581 #endif /* __cplusplus */
582 #endif /* !NULL */
583 _EOFix_;
584 test_text = "# define\tNULL \t(0L) /* typed NULL */";
588 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
589 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
590 * braces.
592 fix = {
593 hackname = aix_once_init_1;
594 mach = "*-*-aix*";
595 files = "pthread.h";
596 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
597 "\\{ \\\\\n";
598 c_fix = format;
599 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
600 "{{ \\\n";
601 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
602 "{ \\\\\n";
605 fix = {
606 hackname = aix_once_init_2;
607 mach = "*-*-aix*";
608 files = "pthread.h";
609 select = "[ \t]0 \\\\\n"
610 "\\}\n";
611 c_fix = format;
612 c_fix_arg = " 0 \\\n"
613 "}}\n";
614 test_text = " 0 \\\\\n"
615 "}\n";
618 fix = {
619 hackname = aix_mutex_initializer_1;
620 mach = "*-*-aix*";
621 files = "pthread.h";
622 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
623 "\\{ \\\\\n";
624 c_fix = format;
625 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
626 "{{ \\\n";
627 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
628 "{ \\\\\n";
631 fix = {
632 hackname = aix_cond_initializer_1;
633 mach = "*-*-aix*";
634 files = "pthread.h";
635 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
636 "\\{ \\\\\n";
637 c_fix = format;
638 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
639 "{{ \\\n";
640 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
641 "{ \\\\\n";
644 fix = {
645 hackname = aix_rwlock_initializer_1;
646 mach = "*-*-aix*";
647 files = "pthread.h";
648 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
649 "\\{ \\\\\n";
650 c_fix = format;
651 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
652 "{{ \\\n";
653 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
654 "{ \\\\\n";
658 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
659 * which violates a requirement of ISO C.
661 fix = {
662 hackname = aix_pthread;
663 files = "pthread.h";
664 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
665 c_fix = format;
666 c_fix_arg = "%1 %2";
667 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
668 "{...init stuff...}";
672 * AIX stdint.h fixes.
674 fix = {
675 hackname = aix_stdint_1;
676 mach = "*-*-aix*";
677 files = stdint-aix.h, stdint.h;
678 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
679 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
680 c_fix = format;
681 c_fix_arg = "#define UINT8_MAX (255)\n"
682 "#define UINT16_MAX (65535)";
683 test_text = "#define UINT8_MAX (255U)\n"
684 "#define UINT16_MAX (65535U)";
688 * aix_stdint_2
690 fix = {
691 hackname = aix_stdint_2;
692 mach = "*-*-aix*";
693 files = stdint-aix.h, stdint.h;
694 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
695 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
696 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
697 "#else\n"
698 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
699 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
700 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
701 c_fix = format;
702 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
703 "#define INTPTR_MAX 9223372036854775807L\n"
704 "#define UINTPTR_MAX 18446744073709551615UL\n"
705 "#else\n"
706 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
707 "#define INTPTR_MAX 2147483647L\n"
708 "#define UINTPTR_MAX 4294967295UL";
709 test_text = "#define INTPTR_MIN INT64_MIN\n"
710 "#define INTPTR_MAX INT64_MAX\n"
711 "#define UINTPTR_MAX UINT64_MAX\n"
712 "#else\n"
713 "#define INTPTR_MIN INT32_MIN\n"
714 "#define INTPTR_MAX INT32_MAX\n"
715 "#define UINTPTR_MAX UINT32_MAX";
719 * aix_stdint_3
721 fix = {
722 hackname = aix_stdint_3;
723 mach = "*-*-aix*";
724 files = stdint-aix.h, stdint.h;
725 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
726 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
727 "#else\n"
728 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
729 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
730 c_fix = format;
731 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
732 "#define PTRDIFF_MAX 9223372036854775807L\n"
733 "#else\n"
734 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
735 "#define PTRDIFF_MAX 2147483647L";
736 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
737 "#define PTRDIFF_MAX INT64_MAX\n"
738 "#else\n"
739 "#define PTRDIFF_MIN INT32_MIN\n"
740 "#define PTRDIFF_MAX INT32_MAX";
744 * aix_stdint_4
746 fix = {
747 hackname = aix_stdint_4;
748 mach = "*-*-aix*";
749 files = stdint-aix.h, stdint.h;
750 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
751 "#else\n"
752 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
753 c_fix = format;
754 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
755 "#else\n"
756 "#define SIZE_MAX 4294967295UL";
757 test_text = "#define SIZE_MAX UINT64_MAX\n"
758 "#else\n"
759 "#define SIZE_MAX UINT32_MAX";
763 * aix_stdint_5
765 fix = {
766 hackname = aix_stdint_5;
767 mach = "*-*-aix*";
768 files = stdint-aix.h, stdint.h;
769 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
770 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
771 c_fix = format;
772 c_fix_arg = "#define UINT8_C(c) c\n"
773 "#define UINT16_C(c) c";
774 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
775 "#define UINT16_C(c) __CONCAT__(c,U)";
779 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
780 produces wrong code with G++.
782 fix = {
783 hackname = aix_stdio_inline;
784 mach = "*-*-aix*";
785 files = stdio.h;
786 select = "#ifdef __cplusplus\\\n"
787 "}\\\n\\\n"
788 "#ifdef ferror\\\n";
789 c_fix = format;
790 c_fix_arg = "#ifdef __cplusplus\n"
791 "}\n"
792 "#endif\n\n"
793 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
794 "#ifdef ferror\n";
795 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
799 * stdlib.h on AIX uses #define on malloc and friends.
801 fix = {
802 hackname = aix_stdlib_malloc;
803 mach = "*-*-aix*";
804 files = stdlib.h;
805 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
806 c_fix = format;
807 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
808 test_text = "#define malloc __linux_malloc";
811 fix = {
812 hackname = aix_stdlib_realloc;
813 mach = "*-*-aix*";
814 files = stdlib.h;
815 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
816 c_fix = format;
817 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
818 test_text = "#define realloc __linux_realloc";
821 fix = {
822 hackname = aix_stdlib_calloc;
823 mach = "*-*-aix*";
824 files = stdlib.h;
825 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
826 c_fix = format;
827 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
828 test_text = "#define calloc __linux_calloc";
831 fix = {
832 hackname = aix_stdlib_valloc;
833 mach = "*-*-aix*";
834 files = stdlib.h;
835 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
836 c_fix = format;
837 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
838 test_text = "#define valloc __linux_valloc";
842 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
844 fix = {
845 hackname = aix_strtof_const;
846 mach = "*-*-aix*";
847 files = stdlib.h;
848 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
849 c_fix = format;
850 c_fix_arg = "%1(const char *, char **);";
851 test_text = "extern float strtof(char *, char **);";
855 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
856 * in an otherwise harmless (and #ifed out) macro definition
858 fix = {
859 hackname = aix_sysmachine;
860 mach = "*-*-aix*";
861 files = sys/machine.h;
862 select = "\\\\ +\n";
863 c_fix = format;
864 c_fix_arg = "\\\n";
865 test_text = "#define FOO \\\n"
866 " bar \\ \n baz \\ \n bat";
870 * sys/wait.h on AIX 5.2 defines macros that have both signed and
871 * unsigned types in conditional expressions.
873 fix = {
874 hackname = aix_syswait_2;
875 mach = "*-*-aix*";
876 files = sys/wait.h;
877 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
878 c_fix = format;
879 c_fix_arg = "? (int)%1";
880 test_text = "#define WSTOPSIG(__x) "
881 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
885 * sys/signal.h on some versions of AIX uses volatile in the typedef of
886 * sig_atomic_t, which causes gcc to generate a warning about duplicate
887 * volatile when a sig_atomic_t variable is declared volatile, as
888 * required by ANSI C.
890 fix = {
891 hackname = aix_volatile;
892 mach = "*-*-aix*";
893 files = sys/signal.h;
894 select = "typedef volatile int sig_atomic_t";
895 c_fix = format;
896 c_fix_arg = "typedef int sig_atomic_t";
897 test_text = "typedef volatile int sig_atomic_t;";
901 * Fix __assert declaration in assert.h on Alpha OSF/1.
903 fix = {
904 hackname = alpha___assert;
905 files = "assert.h";
906 select = '__assert\(char \*, char \*, int\)';
907 c_fix = format;
908 c_fix_arg = "__assert(const char *, const char *, int)";
909 test_text = 'extern void __assert(char *, char *, int);';
913 * Fix assert macro in assert.h on Alpha OSF/1.
914 * The superfluous int cast breaks C++.
916 fix = {
917 hackname = alpha_assert;
918 files = "assert.h";
919 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
920 c_fix = format;
921 c_fix_arg = "%1(EX)";
922 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
923 ': __assert(#EX, __FILE__, __LINE__))';
927 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
929 fix = {
930 hackname = alpha_getopt;
931 files = "stdio.h";
932 files = "stdlib.h";
933 select = 'getopt\(int, char \*\[\], *char \*\)';
934 c_fix = format;
935 c_fix_arg = "getopt(int, char *const[], const char *)";
936 test_text = 'extern int getopt(int, char *[], char *);';
940 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
942 fix = {
943 hackname = alpha_if_semicolon;
944 files = net/if.h;
945 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
946 c_fix = format;
947 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
948 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
952 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
954 fix = {
955 hackname = alpha_parens;
956 files = sym.h;
957 select = '#ifndef\(__mips64\)';
958 c_fix = format;
959 c_fix_arg = "#ifndef __mips64";
960 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
964 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
965 * And OpenBSD.
967 fix = {
968 hackname = alpha_sbrk;
969 files = unistd.h;
970 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
971 c_fix = format;
972 c_fix_arg = "void *sbrk(";
973 test_text = "extern char* sbrk(ptrdiff_t increment);";
977 * For C++, avoid any typedef or macro definition of bool,
978 * and use the built in type instead.
979 * HP/UX 10.20 also has it in curses_colr/curses.h.
981 fix = {
982 hackname = avoid_bool_define;
983 files = curses.h;
984 files = curses_colr/curses.h;
985 files = term.h;
986 files = tinfo.h;
988 select = "#[ \t]*define[ \t]+bool[ \t]";
989 bypass = "__cplusplus";
991 c_fix = format;
992 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
993 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
995 test_text = "# define bool\t char \n";
999 * avoid_bool_type
1001 fix = {
1002 hackname = avoid_bool_type;
1003 files = curses.h;
1004 files = curses_colr/curses.h;
1005 files = term.h;
1006 files = tinfo.h;
1008 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1009 bypass = "__cplusplus";
1011 c_fix = format;
1012 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1014 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1018 * For C++, avoid any typedef definition of wchar_t,
1019 * and use the built in type instead.
1020 * Don't do this for headers that are smart enough to do the right
1021 * thing (recent [n]curses.h and Xlib.h).
1022 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1023 * and will be broken by the edit.
1026 fix = {
1027 hackname = avoid_wchar_t_type;
1029 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1030 bypass = "__cplusplus";
1031 bypass = "_LINUX_NLS_H";
1032 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1034 c_fix = format;
1035 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1037 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1041 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1043 fix = {
1044 hackname = bad_struct_term;
1045 files = curses.h;
1046 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1047 c_fix = format;
1048 c_fix_arg = "struct term;";
1050 test_text = 'typedef struct term;';
1054 * Fix one other error in this file:
1055 * a mismatched quote not inside a C comment.
1057 fix = {
1058 hackname = badquote;
1059 files = sundev/vuid_event.h;
1060 select = "doesn't";
1061 c_fix = format;
1062 c_fix_arg = "does not";
1064 test_text = "/* doesn't have matched single quotes */";
1068 * check for broken assert.h that needs stdio.h
1070 fix = {
1071 hackname = broken_assert_stdio;
1072 files = assert.h;
1073 select = stderr;
1074 bypass = "include.*stdio\\.h";
1075 c_fix = wrap;
1076 c_fix_arg = "#include <stdio.h>\n";
1077 test_text = "extern FILE* stderr;";
1081 * check for broken assert.h that needs stdlib.h
1083 fix = {
1084 hackname = broken_assert_stdlib;
1085 files = assert.h;
1086 select = 'exit *\(|abort *\(';
1087 bypass = "include.*stdlib\\.h";
1088 c_fix = wrap;
1089 c_fix_arg = "#ifdef __cplusplus\n"
1090 "#include <stdlib.h>\n"
1091 "#endif\n";
1092 test_text = "extern void exit ( int );";
1096 * Remove `extern double cabs' declarations from math.h.
1097 * This conflicts with C99. Discovered on AIX.
1098 * Darwin hides its broken cabs in architecture-specific subdirs.
1100 fix = {
1101 hackname = broken_cabs;
1102 files = math.h, "architecture/*/math.h";
1103 select = "^extern[ \t]+double[ \t]+cabs";
1105 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1106 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1108 test_text = "#ifdef __STDC__\n"
1109 "extern double cabs(struct dbl_hypot);\n"
1110 "#else\n"
1111 "extern double cabs();\n"
1112 "#endif\n"
1113 "extern double cabs ( _Complex z );";
1117 * Fixup Darwin's broken check for __builtin_nanf.
1119 fix = {
1120 hackname = broken_nan;
1122 * It is tempting to omit the first "files" entry. Do not.
1123 * The testing machinery will take the first "files" entry as the name
1124 * of a test file to play with. It would be a nuisance to have a directory
1125 * with the name "*".
1127 files = "architecture/ppc/math.h";
1128 files = "architecture/*/math.h";
1129 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1130 bypass = "powl";
1131 c_fix = format;
1132 c_fix_arg = "#if 1";
1133 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1137 * Various systems derived from BSD4.4 contain a macro definition
1138 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1139 * Known to be fixed in FreeBSD 5 system headers.
1141 fix = {
1142 hackname = bsd_stdio_attrs_conflict;
1143 mach = "*-*-*bsd*";
1144 mach = "*-*-*darwin*";
1145 files = stdio.h;
1146 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1147 c_fix = format;
1148 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1149 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1150 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1151 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1152 test_text = '#define vfscanf __svfscanf';
1156 * Fix various macros used to define ioctl numbers.
1157 * The traditional syntax was:
1159 * #define _CTRL(n, x) (('n'<<8)+x)
1160 * #define TCTRLCFOO _CTRL(T, 1)
1162 * but this does not work with the C standard, which disallows macro
1163 * expansion inside strings. We have to rewrite it thus:
1165 * #define _CTRL(n, x) ((n<<8)+x)
1166 * #define TCTRLCFOO _CTRL('T', 1)
1168 * The select expressions match too much, but the c_fix code is cautious.
1170 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1172 fix = {
1173 hackname = ctrl_quotes_def;
1174 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1175 c_fix = char_macro_def;
1176 c_fix_arg = "CTRL";
1179 * This is two tests in order to ensure that the "CTRL(c)" can
1180 * be selected in isolation from the multi-arg format
1182 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1183 test_text = "#define _CTRL(c) ('c'&037)";
1187 * Fix various macros used to define ioctl numbers.
1189 fix = {
1190 hackname = ctrl_quotes_use;
1191 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1192 c_fix = char_macro_use;
1193 c_fix_arg = "CTRL";
1194 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1198 * sys/mman.h on HP/UX is not C++ ready,
1199 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1201 * rpc/types.h on OSF1/2.0 is not C++ ready,
1202 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1204 * The problem is the declaration of malloc.
1206 fix = {
1207 hackname = cxx_unready;
1208 files = sys/mman.h;
1209 files = rpc/types.h;
1210 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1211 not within a macro. */
1212 bypass = '"C"|__BEGIN_DECLS';
1214 c_fix = wrap;
1215 c_fix_arg = "#ifdef __cplusplus\n"
1216 "extern \"C\" {\n"
1217 "#endif\n";
1218 c_fix_arg = "#ifdef __cplusplus\n"
1219 "}\n"
1220 "#endif\n";
1221 test_text = "extern void* malloc( size_t );";
1225 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1226 * unconditionally.
1228 fix = {
1229 hackname = darwin_availabilityinternal;
1230 mach = "*-*-darwin*";
1231 files = AvailabilityInternal.h;
1232 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1233 c_fix = format;
1234 c_fix_arg = <<- _EOFix_
1235 #if defined(__has_attribute)
1236 #if __has_attribute(availability)
1238 #else
1239 #define %1
1240 #endif
1241 #else
1242 #define %1
1243 #endif
1244 _EOFix_;
1246 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1247 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1251 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1252 * you have to not use "" includes.
1254 fix = {
1255 hackname = darwin_9_long_double_funcs_2;
1256 mach = "*-*-darwin7.9*";
1257 files = math.h;
1258 select = '#include[ \t]+\"';
1259 c_fix = format;
1260 c_fix_arg = "%1<%2.h>";
1262 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1264 test_text = '#include "architecture/ppc/math.h"';
1268 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1269 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1271 fix = {
1272 hackname = darwin_externc;
1273 mach = "*-*-darwin*";
1274 files = mach-o/swap.h;
1275 files = mach/mach_time.h;
1276 files = mach/mach_traps.h;
1277 files = mach/message.h;
1278 files = mach/mig.h;
1279 files = mach/semaphore.h;
1280 bypass = "extern \"C\"";
1281 bypass = "__BEGIN_DECLS";
1282 c_fix = wrap;
1283 c_fix_arg = "#ifdef __cplusplus\n"
1284 "extern \"C\" {\n"
1285 "#endif\n";
1286 c_fix_arg = "#ifdef __cplusplus\n"
1287 "}\n"
1288 "#endif\n";
1289 test_text = "extern void swap_fat_header();\n";
1293 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1294 * bad __GNUC__ tests.
1296 fix = {
1297 hackname = darwin_gcc4_breakage;
1298 mach = "*-*-darwin*";
1299 files = AvailabilityMacros.h;
1300 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1301 c_fix = format;
1302 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1303 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1304 "(__GNUC_MINOR__ >= 1)\n";
1308 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1310 fix = {
1311 hackname = darwin_longjmp_noreturn;
1312 mach = "*-*-darwin*";
1313 files = "i386/setjmp.h";
1314 bypass = "__dead2";
1315 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1316 c_fix = format;
1317 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1319 test_text = "void siglongjmp(sigjmp_buf, int);";
1323 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1325 fix = {
1326 hackname = darwin_os_trace_1;
1327 mach = "*-*-darwin*";
1328 files = os/trace.h;
1329 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1330 c_fix = format;
1331 c_fix_arg = "%1";
1332 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1336 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1337 * extension without guard.
1339 fix = {
1340 hackname = darwin_os_trace_2;
1341 mach = "*-*-darwin*";
1342 files = os/trace.h;
1343 select = "typedef.*\\^os_trace_payload_t.*";
1344 c_fix = format;
1345 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1346 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1350 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1351 * os_trace_payload_t typedef, too.
1353 fix = {
1354 hackname = darwin_os_trace_3;
1355 mach = "*-*-darwin*";
1356 files = os/trace.h;
1357 select = <<- _EOSelect_
1358 __(API|OSX)_.*
1359 OS_EXPORT.*
1361 _os_trace.*os_trace_payload_t payload);
1362 _EOSelect_;
1363 c_fix = format;
1364 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1365 test_text = <<- _EOText_
1366 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1367 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1368 void
1369 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1371 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1372 OS_EXPORT OS_NOTHROW
1373 void
1374 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1375 _EOText_;
1379 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1380 * why would you ever put it in a system header file?
1382 fix = {
1383 hackname = darwin_private_extern;
1384 mach = "*-*-darwin*";
1385 files = mach-o/dyld.h;
1386 select = "__private_extern__ [a-z_]+ _dyld_";
1387 c_fix = format;
1388 c_fix_arg = "extern";
1389 c_fix_arg = "__private_extern__";
1390 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1391 "const char *dyld_func_name,\n"
1392 "unsigned long *address);\n";
1396 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1397 * unsigned constants.
1399 fix = {
1400 hackname = darwin_stdint_1;
1401 mach = "*-*-darwin*";
1402 files = stdint-darwin.h, stdint.h;
1403 c_fix = format;
1404 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1405 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1406 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1407 test_text = "#define UINT8_C(v) (v ## U)\n"
1408 "#define UINT16_C(v) (v ## U)";
1412 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1413 * with wrong types.
1415 fix = {
1416 hackname = darwin_stdint_2;
1417 mach = "*-*-darwin*";
1418 files = stdint-darwin.h, stdint.h;
1419 c_fix = format;
1420 c_fix_arg = "#if __WORDSIZE == 64\n"
1421 "#define INTPTR_MAX 9223372036854775807L\n"
1422 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1423 "#else\n"
1424 "#define INTPTR_MAX 2147483647L\n"
1425 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1426 "#endif";
1427 select = "#if __WORDSIZE == 64\n"
1428 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1429 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1430 "#else\n"
1431 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1432 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1433 "#endif";
1434 test_text = "#if __WORDSIZE == 64\n"
1435 "#define INTPTR_MIN INT64_MIN\n"
1436 "#define INTPTR_MAX INT64_MAX\n"
1437 "#else\n"
1438 "#define INTPTR_MIN INT32_MIN\n"
1439 "#define INTPTR_MAX INT32_MAX\n"
1440 "#endif";
1444 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1446 fix = {
1447 hackname = darwin_stdint_3;
1448 mach = "*-*-darwin*";
1449 files = stdint-darwin.h, stdint.h;
1450 c_fix = format;
1451 c_fix_arg = "#if __WORDSIZE == 64\n"
1452 "#define UINTPTR_MAX 18446744073709551615UL\n"
1453 "#else\n"
1454 "#define UINTPTR_MAX 4294967295UL\n"
1455 "#endif";
1456 select = "#if __WORDSIZE == 64\n"
1457 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1458 "#else\n"
1459 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1460 "#endif";
1461 test_text = "#if __WORDSIZE == 64\n"
1462 "#define UINTPTR_MAX UINT64_MAX\n"
1463 "#else\n"
1464 "#define UINTPTR_MAX UINT32_MAX\n"
1465 "#endif";
1469 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1471 fix = {
1472 hackname = darwin_stdint_4;
1473 mach = "*-*-darwin*";
1474 files = stdint-darwin.h, stdint.h;
1475 c_fix = format;
1476 c_fix_arg = "#if __WORDSIZE == 64\n"
1477 "#define SIZE_MAX 18446744073709551615UL\n"
1478 "#else\n"
1479 "#define SIZE_MAX 4294967295UL\n"
1480 "#endif";
1481 select = "#if __WORDSIZE == 64\n"
1482 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1483 "#else\n"
1484 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1485 "#endif";
1486 test_text = "#if __WORDSIZE == 64\n"
1487 "#define SIZE_MAX UINT64_MAX\n"
1488 "#else\n"
1489 "#define SIZE_MAX UINT32_MAX\n"
1490 "#endif";
1494 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1495 * with a wrong type.
1497 fix = {
1498 hackname = darwin_stdint_5;
1499 mach = "*-*-darwin*";
1500 files = stdint-darwin.h, stdint.h;
1501 c_fix = format;
1502 c_fix_arg = "#if __WORDSIZE == 64\n"
1503 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1504 "#define INTMAX_MAX 9223372036854775807L\n"
1505 "#define UINTMAX_MAX 18446744073709551615UL\n"
1506 "#else\n"
1507 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1508 "#define INTMAX_MAX 9223372036854775807LL\n"
1509 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1510 "#endif";
1511 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1512 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1513 "\n"
1514 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1515 test_text = "#define INTMAX_MIN INT64_MIN\n"
1516 "#define INTMAX_MAX INT64_MAX\n"
1517 "\n"
1518 "#define UINTMAX_MAX UINT64_MAX";
1522 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1523 * with a wrong type.
1525 fix = {
1526 hackname = darwin_stdint_6;
1527 mach = "*-*-darwin*";
1528 files = stdint-darwin.h, stdint.h;
1529 c_fix = format;
1530 c_fix_arg = "#if __WORDSIZE == 64\n"
1531 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1532 "#define PTRDIFF_MAX 9223372036854775807L\n"
1533 "#else\n"
1534 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1535 "#define PTRDIFF_MAX 2147483647\n"
1536 "#endif";
1537 select = "#if __WORDSIZE == 64\n"
1538 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1539 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1540 "#else\n"
1541 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1542 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1543 "#endif";
1544 test_text = "#if __WORDSIZE == 64\n"
1545 "#define PTRDIFF_MIN INT64_MIN\n"
1546 "#define PTRDIFF_MAX INT64_MAX\n"
1547 "#else\n"
1548 "#define PTRDIFF_MIN INT32_MIN\n"
1549 "#define PTRDIFF_MAX INT32_MAX\n"
1550 "#endif";
1554 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1555 * with a wrong type.
1557 fix = {
1558 hackname = darwin_stdint_7;
1559 mach = "*-*-darwin*";
1560 files = stdint-darwin.h, stdint.h;
1561 c_fix = format;
1562 c_fix_arg = "#if __WORDSIZE == 64\n"
1563 "#define INTMAX_C(v) (v ## L)\n"
1564 "#define UINTMAX_C(v) (v ## UL)\n"
1565 "#else\n"
1566 "#define INTMAX_C(v) (v ## LL)\n"
1567 "#define UINTMAX_C(v) (v ## ULL)\n"
1568 "#endif";
1569 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1570 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1571 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1572 "#define UINTMAX_C(v) (v ## ULL)";
1576 * Fix <c_asm.h> on Digital UNIX V4.0:
1577 * It contains a prototype for a DEC C internal asm() function,
1578 * clashing with gcc's asm keyword. So protect this with __DECC.
1580 fix = {
1581 hackname = dec_intern_asm;
1582 files = c_asm.h;
1583 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1584 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1585 "#endif\n";
1586 test_text =
1587 "float fasm {\n"
1588 " ... asm stuff ...\n"
1589 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1593 * Fix typo in <wchar.h> on DJGPP 2.03.
1595 fix = {
1596 hackname = djgpp_wchar_h;
1597 file = wchar.h;
1598 select = "__DJ_wint_t";
1599 bypass = "sys/djtypes.h";
1600 c_fix = format;
1601 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1602 c_fix_arg = "#include <stddef.h>";
1603 test_text = "#include <stddef.h>\n"
1604 "extern __DJ_wint_t x;\n";
1608 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1610 fix = {
1611 hackname = ecd_cursor;
1612 files = "sunwindow/win_lock.h";
1613 files = "sunwindow/win_cursor.h";
1614 select = 'ecd\.cursor';
1615 c_fix = format;
1616 c_fix_arg = 'ecd_cursor';
1618 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1622 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1623 * that fails when compiling for SSE-less 32-bit x86.
1625 fix = {
1626 hackname = feraiseexcept_nosse_divbyzero;
1627 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1628 files = bits/fenv.h, '*/bits/fenv.h';
1629 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1630 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1631 bypass = "\"fdivp .*; fwait\"";
1633 c_fix = format;
1634 c_fix_arg = <<- _EOText_
1635 # ifdef __SSE_MATH__
1637 # else
1638 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1639 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1640 # endif
1641 _EOText_;
1643 test_text = <<- _EOText_
1644 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1645 _EOText_;
1649 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1650 * that fails when compiling for SSE-less 32-bit x86.
1652 fix = {
1653 hackname = feraiseexcept_nosse_invalid;
1654 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1655 files = bits/fenv.h, '*/bits/fenv.h';
1656 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1657 ": \"x\" \\(__f\\)\\);$";
1658 bypass = "\"fdiv .*; fwait\"";
1660 c_fix = format;
1661 c_fix_arg = <<- _EOText_
1662 # ifdef __SSE_MATH__
1664 # else
1665 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1666 %1 : "=t" (__f) : "0" (__f));
1667 # endif
1668 _EOText_;
1670 test_text = <<- _EOText_
1671 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1672 _EOText_;
1676 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1677 * neither the existence of GCC 3 nor its exact feature set yet break
1678 * (by design?) when __GNUC__ is set beyond 2.
1680 fix = {
1681 hackname = freebsd_gcc3_breakage;
1682 mach = "*-*-freebsd*";
1683 files = sys/cdefs.h;
1684 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1685 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1686 c_fix = format;
1687 c_fix_arg = '%0 || __GNUC__ >= 3';
1688 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1692 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1693 * neither the existence of GCC 4 nor its exact feature set yet break
1694 * (by design?) when __GNUC__ is set beyond 3.
1696 fix = {
1697 hackname = freebsd_gcc4_breakage;
1698 mach = "*-*-freebsd*";
1699 files = sys/cdefs.h;
1700 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1701 c_fix = format;
1702 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1703 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1707 * Some versions of glibc don't expect the C99 inline semantics.
1709 fix = {
1710 hackname = glibc_c99_inline_1;
1711 files = features.h, '*/features.h';
1712 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1713 c_fix = format;
1714 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1715 test_text = <<-EOT
1716 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1717 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1718 # define __USE_EXTERN_INLINES 1
1719 #endif
1720 EOT;
1724 * Similar, but a version that didn't have __NO_INLINE__
1726 fix = {
1727 hackname = glibc_c99_inline_1a;
1728 files = features.h, '*/features.h';
1729 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1730 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1731 c_fix = format;
1732 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1733 test_text = <<-EOT
1734 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1735 # define __USE_EXTERN_INLINES 1
1736 #endif
1737 EOT;
1741 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1742 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1743 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1745 fix = {
1746 hackname = glibc_c99_inline_2;
1747 files = sys/stat.h, '*/sys/stat.h';
1748 select = "extern __inline__ int";
1749 sed = "s/extern int \\(stat\\)/"
1750 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1751 "__inline__ int \\1/";
1752 sed = "s/extern int \\([lf]stat\\)/"
1753 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1754 "__inline__ int \\1/";
1755 sed = "s/extern int \\(mknod\\)/"
1756 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1757 "__inline__ int \\1/";
1758 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1759 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1760 "__inline__ int __REDIRECT\\1 (\\2/";
1761 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1762 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1763 "__inline__ int __REDIRECT\\1 (\\2/";
1764 sed = "s/^extern __inline__ int/"
1765 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1766 "__inline__ int/";
1767 test_text = <<-EOT
1768 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1769 extern __inline__ int
1770 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1772 EOT;
1776 * glibc_c99_inline_3
1778 fix = {
1779 hackname = glibc_c99_inline_3;
1780 files = bits/string2.h, '*/bits/string2.h';
1781 select = "extern __inline";
1782 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1783 c_fix = format;
1784 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1785 c_fix_arg = "^# ifdef __cplusplus$";
1786 test_text = <<-EOT
1787 # ifdef __cplusplus
1788 # define __STRING_INLINE inline
1789 # else
1790 # define __STRING_INLINE extern __inline
1791 # endif
1792 EOT;
1796 * glibc_c99_inline_4
1798 fix = {
1799 hackname = glibc_c99_inline_4;
1800 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1801 pthread.h, '*/pthread.h';
1802 bypass = "__extern_inline|__gnu_inline__";
1803 select = "(^| )extern __inline";
1804 c_fix = format;
1805 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1806 test_text = <<-EOT
1807 __extension__ extern __inline unsigned int
1808 extern __inline unsigned int
1809 EOT;
1812 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1813 * so we replace them with versions that correspond to the
1814 * definition.
1816 fix = {
1817 hackname = glibc_mutex_init;
1818 files = pthread.h;
1819 select = '\{ *\{ *0, *\} *\}';
1820 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1821 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1822 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1823 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1824 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1825 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1826 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1827 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1828 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1829 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1830 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1831 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1832 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1833 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1834 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1835 "N;s/^[ \t]*#[ \t]*"
1836 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1837 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1838 "# \\1\\\n"
1839 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1840 "# else\\\n"
1841 "# \\1\\\n"
1842 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1843 "# endif/";
1844 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1845 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1846 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1847 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1849 test_text = <<- _EOText_
1850 #define PTHREAD_MUTEX_INITIALIZER \\
1851 { { 0, } }
1852 #ifdef __USE_GNU
1853 # if __WORDSIZE == 64
1854 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1855 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1856 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1857 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1858 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1859 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1860 # else
1861 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1862 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1863 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1864 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1865 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1866 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1867 # endif
1868 #endif
1869 # define PTHREAD_RWLOCK_INITIALIZER \\
1870 { { 0, } }
1871 # ifdef __USE_GNU
1872 # if __WORDSIZE == 64
1873 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1874 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1875 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1876 # else
1877 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1878 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1879 # endif
1880 # endif
1881 #define PTHREAD_COND_INITIALIZER { { 0, } }
1882 _EOText_;
1885 /* glibc versions before 2.5 have a version of stdint.h that defines
1886 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1887 versions with stdint.h based on those glibc versions. */
1888 fix = {
1889 hackname = glibc_stdint;
1890 files = stdint.h;
1891 select = "GNU C Library";
1892 c_fix = format;
1893 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1894 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1895 test_text = "/* This file is part of the GNU C Library. */\n"
1896 "# define UINT8_C(c)\tc ## U\n"
1897 "# define UINT16_C(c)\tc ## U";
1900 /* Some versions of glibc have a version of bits/string2.h that
1901 produces "value computed is not used" warnings from strncpy; fix
1902 this definition by using __builtin_strncpy instead as in newer
1903 versions. */
1904 fix = {
1905 hackname = glibc_strncpy;
1906 files = bits/string2.h, '*/bits/string2.h';
1907 bypass = "__builtin_strncpy";
1908 c_fix = format;
1909 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1910 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1911 test_text = <<-EOT
1912 # define strncpy(dest, src, n) \
1913 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1914 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1915 ? (char *) memcpy (dest, src, n) \\
1916 : strncpy (dest, src, n)) \\
1917 : strncpy (dest, src, n)))
1918 EOT;
1922 /* glibc's tgmath.h relies on an expression that is not an integer
1923 constant expression being treated as it was by GCC 4.4 and
1924 earlier. */
1925 fix = {
1926 hackname = glibc_tgmath;
1927 files = tgmath.h;
1928 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1929 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1930 c_fix = format;
1931 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1932 "(__builtin_classify_type ((type) 0) == 9 && "
1933 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1934 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1938 * Fix these files to use the types we think they should for
1939 * ptrdiff_t, size_t, and wchar_t.
1941 * This defines the types in terms of macros predefined by our 'cpp'.
1942 * This is supposedly necessary for glibc's handling of these types.
1943 * It's probably not necessary for anyone else, but it doesn't hurt.
1945 fix = {
1946 hackname = gnu_types;
1947 files = "sys/types.h";
1948 files = "stdlib.h";
1949 files = "sys/stdtypes.h";
1950 files = "stddef.h";
1951 files = "memory.h";
1952 files = "unistd.h";
1953 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1954 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1955 c_fix = gnu_type;
1956 /* The Solaris 10 headers already define these types correctly. */
1957 mach = '*-*-solaris2.1[0-9]*';
1958 not_machine = true;
1960 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1961 "typedef uint_t size_t; /* uint_t */\n"
1962 "typedef ushort_t wchar_t; /* ushort_t */";
1966 * Fix HP & Sony's use of "../machine/xxx.h"
1967 * to refer to: <machine/xxx.h>
1969 fix = {
1970 hackname = hp_inline;
1971 files = sys/spinlock.h;
1972 files = machine/machparam.h;
1973 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1975 c_fix = format;
1976 c_fix_arg = "%1<machine/%2.h>";
1978 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1979 '([a-z]+)\.h"';
1981 test_text = ' # include "../machine/mumble.h"';
1985 * Check for (...) in C++ code in HP/UX sys/file.h.
1987 fix = {
1988 hackname = hp_sysfile;
1989 files = sys/file.h;
1990 select = "HPUX_SOURCE";
1992 c_fix = format;
1993 c_fix_arg = "(struct file *, ...)";
1994 c_fix_arg = '\(\.\.\.\)';
1996 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2000 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2001 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2003 fix = {
2004 hackname = hppa_hpux_fp_macros;
2005 mach = "hppa*-hp-hpux11*";
2006 files = math.h;
2007 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2008 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2009 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2010 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2011 "#[ \t]*define[ \t]*FP_NAN.*\n";
2012 c_fix = format;
2013 c_fix_arg = <<- _EOFix_
2014 #endif /* _INCLUDE_HPUX_SOURCE */
2016 #if defined(_INCLUDE_HPUX_SOURCE) || \
2017 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2018 %0#endif
2020 #ifdef _INCLUDE_HPUX_SOURCE
2022 _EOFix_;
2024 test_text =
2025 "# define FP_NORMAL 0\n"
2026 "# define FP_ZERO 1\n"
2027 "# define FP_INFINITE 2\n"
2028 "# define FP_SUBNORMAL 3\n"
2029 "# define FP_NAN 4\n";
2033 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2034 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2036 fix = {
2037 hackname = hpux10_cpp_pow_inline;
2038 files = fixinc-test-limits.h, math.h;
2039 select = <<- END_POW_INLINE
2040 ^# +ifdef +__cplusplus
2042 +inline +double +pow\(double +__d,int +__expon\) +\{
2043 [ ]+return +pow\(__d,\(double\)__expon\);
2045 +extern +"C" +\{
2046 #else
2047 # +endif
2048 END_POW_INLINE;
2050 c_fix = format;
2051 c_fix_arg = "";
2053 test_text =
2054 "# ifdef __cplusplus\n"
2055 " }\n"
2056 " inline double pow(double __d,int __expon) {\n"
2057 "\t return pow(__d,(double)__expon);\n"
2058 " }\n"
2059 ' extern "C"' " {\n"
2060 "#else\n"
2061 "# endif";
2064 fix = {
2065 hackname = hpux11_cpp_pow_inline;
2066 files = math.h;
2067 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2068 " +return pow\\(d, \\(double\\)expon\\);\n"
2069 " +\\}\n";
2070 c_fix = format;
2071 c_fix_arg = "";
2073 test_text =
2074 " inline double pow(double d,int expon) {\n"
2075 " return pow(d, (double)expon);\n"
2076 " }\n";
2080 * Fix hpux 10.X missing ctype declarations 1
2082 fix = {
2083 hackname = hpux10_ctype_declarations1;
2084 files = ctype.h;
2085 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2086 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2087 c_fix = format;
2088 c_fix_arg = "#ifdef _PROTOTYPES\n"
2089 "extern int __tolower(int);\n"
2090 "extern int __toupper(int);\n"
2091 "#else /* NOT _PROTOTYPES */\n"
2092 "extern int __tolower();\n"
2093 "extern int __toupper();\n"
2094 "#endif /* _PROTOTYPES */\n\n"
2095 "%0\n";
2097 test_text = "# define _toupper(__c) __toupper(__c)\n";
2101 * Fix hpux 10.X missing ctype declarations 2
2103 fix = {
2104 hackname = hpux10_ctype_declarations2;
2105 files = ctype.h;
2106 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2107 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2108 c_fix = format;
2109 c_fix_arg = "%0\n\n"
2110 "#ifdef _PROTOTYPES\n"
2111 " extern int _isalnum(int);\n"
2112 " extern int _isalpha(int);\n"
2113 " extern int _iscntrl(int);\n"
2114 " extern int _isdigit(int);\n"
2115 " extern int _isgraph(int);\n"
2116 " extern int _islower(int);\n"
2117 " extern int _isprint(int);\n"
2118 " extern int _ispunct(int);\n"
2119 " extern int _isspace(int);\n"
2120 " extern int _isupper(int);\n"
2121 " extern int _isxdigit(int);\n"
2122 "# else /* not _PROTOTYPES */\n"
2123 " extern int _isalnum();\n"
2124 " extern int _isalpha();\n"
2125 " extern int _iscntrl();\n"
2126 " extern int _isdigit();\n"
2127 " extern int _isgraph();\n"
2128 " extern int _islower();\n"
2129 " extern int _isprint();\n"
2130 " extern int _ispunct();\n"
2131 " extern int _isspace();\n"
2132 " extern int _isupper();\n"
2133 " extern int _isxdigit();\n"
2134 "#endif /* _PROTOTYPES */\n";
2136 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2137 " extern unsigned int *__SB_masks;\n";
2141 * Fix hpux 10.X missing stdio declarations
2143 fix = {
2144 hackname = hpux10_stdio_declarations;
2145 files = stdio.h;
2146 select = "^#[ \t]*define _iob[ \t]*__iob";
2147 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2148 c_fix = format;
2149 c_fix_arg = "%0\n\n"
2150 "# if defined(__STDC__) || defined(__cplusplus)\n"
2151 " extern int snprintf(char *, size_t, const char *, ...);\n"
2152 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2153 "# else /* not __STDC__) || __cplusplus */\n"
2154 " extern int snprintf();\n"
2155 " extern int vsnprintf();\n"
2156 "# endif /* __STDC__) || __cplusplus */\n";
2158 test_text = "# define _iob __iob\n";
2162 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2163 * As a result, we need to include sys/stdsyms.h in alloca.h.
2165 fix = {
2166 hackname = hppa_hpux11_alloca;
2167 mach = "hppa*-*-hpux11*";
2168 files = alloca.h;
2169 select = "#ifndef _STDDEF_INCLUDED";
2170 c_fix = format;
2171 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2172 "# include <sys/stdsyms.h>\n"
2173 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2174 "%0";
2176 test_text = "#ifndef _STDDEF_INCLUDED";
2180 * Make sure hpux defines abs in header.
2182 fix = {
2183 hackname = hpux11_abs;
2184 mach = "*-hp-hpux11*";
2185 files = stdlib.h;
2186 select = "ifndef _MATH_INCLUDED";
2187 c_fix = format;
2188 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2189 test_text = "#ifndef _MATH_INCLUDED";
2193 * Fix hpux11 __LWP_RWLOCK_VALID define
2195 fix = {
2196 hackname = hpux11_lwp_rwlock_valid;
2197 mach = "*-hp-hpux11*";
2198 files = sys/pthread.h;
2199 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2200 c_fix = format;
2201 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2202 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2206 * hpux sendfile()
2208 fix = {
2209 hackname = hpux11_extern_sendfile;
2210 mach = "*-hp-hpux11.[12]*";
2211 files = sys/socket.h;
2212 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2213 c_fix = format;
2214 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2215 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2216 " const struct iovec *, int));\n";
2220 * hpux sendpath()
2222 fix = {
2223 hackname = hpux11_extern_sendpath;
2224 mach = "*-hp-hpux11.[12]*";
2225 files = sys/socket.h;
2226 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2227 c_fix = format;
2228 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2229 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2230 " const struct iovec *, int));\n";
2234 * Keep HP-UX 11 from stomping on C++ math namespace
2235 * with defines for fabsf.
2237 fix = {
2238 hackname = hpux11_fabsf;
2239 mach = "*-hp-hpux11*";
2240 files = math.h;
2241 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2243 c_fix = format;
2244 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2246 test_text =
2247 "#ifdef _PA_RISC\n"
2248 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2249 "#endif";
2253 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2254 * in pthread.h need to be constant expressions to be standard complient.
2255 * As a result, we need to remove the void * casts in the initializers
2256 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2257 * to use the long type.
2259 fix = {
2260 hackname = hpux11_pthread_pointer;
2261 mach = "*-hp-hpux11.[0-3]*";
2262 files = sys/pthread.h;
2263 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2265 c_fix = format;
2266 c_fix_arg = "long\t%2%3";
2267 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2271 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2273 fix = {
2274 hackname = hpux11_pthread_const;
2275 mach = "*-hp-hpux11.[0-3]*";
2276 files = sys/pthread.h;
2277 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2279 c_fix = format;
2280 c_fix_arg = "%11";
2281 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2285 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2286 * being defined by having it define _hpux_size_t instead.
2288 fix = {
2289 hackname = hpux11_size_t;
2290 mach = "*-hp-hpux11*";
2291 select = "__size_t";
2293 c_fix = format;
2294 c_fix_arg = "_hpux_size_t";
2296 test_text =
2297 "#define __size_t size_t\n"
2298 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2302 * Fix hpux 11.00 broken snprintf declaration
2303 * (third argument is char *, needs to be const char * to prevent
2304 * spurious warnings with -Wwrite-strings or in C++).
2306 fix = {
2307 hackname = hpux11_snprintf;
2308 files = stdio.h;
2309 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2310 ' *(char *\*, *\.\.\.\);)';
2311 c_fix = format;
2312 c_fix_arg = '%1 const %3';
2314 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2315 "extern int snprintf(char *, __size_t, char *, ...);\n"
2316 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2320 * Fix hpux 11.00 broken vsnprintf declaration
2322 fix = {
2323 hackname = hpux11_vsnprintf;
2324 files = stdio.h;
2325 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2326 'const char \*,) __va__list\);';
2327 c_fix = format;
2328 c_fix_arg = "%1 __va_list);";
2330 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2331 ' __va__list);';
2335 * Fix missing const in hpux vsscanf declaration
2337 fix = {
2338 hackname = hpux_vsscanf;
2339 mach = "*-*-hpux*";
2340 files = stdio.h;
2341 select = '(extern int vsscanf\()char';
2342 c_fix = format;
2343 c_fix_arg = "%1const char";
2345 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2349 * get rid of bogus inline definitions in HP-UX 8.0
2351 fix = {
2352 hackname = hpux8_bogus_inlines;
2353 files = math.h;
2354 select = inline;
2355 bypass = "__GNUG__";
2356 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2357 "@extern \"C\" int abs(int);@";
2358 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2359 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2360 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2361 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2362 "inline double sqr(double v) { return v**0.5; }";
2366 * hpux intptr
2368 fix = {
2369 hackname = hpux_c99_intptr;
2370 mach = "*-hp-hpux11.3*";
2371 files = stdint-hpux11.h, stdint.h;
2372 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2373 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2374 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2375 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2376 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2377 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2378 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2379 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2380 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2381 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2382 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2383 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2384 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2385 "#define PTRDIFF_MIN INT32_MIN\n"
2386 "#define INTPTR_MAX INT32_MAX\n"
2387 "#define INTPTR_MIN INT32_MIN\n"
2388 "#define UINTPTR_MAX UINT32_MAX\n"
2389 "#define SIZE_MAX UINT32_MAX\n";
2393 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2395 fix = {
2396 hackname = hpux_c99_inttypes;
2397 mach = "*-hp-hpux11.[23]*";
2398 files = inttypes.h;
2399 files = stdint-hpux11.h, stdint.h;
2400 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2401 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2402 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2403 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2404 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2405 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2406 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2407 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2408 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2409 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2410 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2411 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2415 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2417 fix = {
2418 hackname = hpux_c99_inttypes2;
2419 mach = "*-hp-hpux11.2*";
2420 files = stdint-hpux11.h, stdint.h;
2421 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2422 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2423 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2424 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2425 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2426 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2427 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2428 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2429 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2430 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2431 "# define INT16_C(__c) ((short)(__c))\n"
2432 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2436 * Fix hpux broken ctype macros
2438 fix = {
2439 hackname = hpux_ctype_macros;
2440 files = ctype.h;
2441 select = '((: |\()__SB_masks \? )'
2442 '(__SB_masks\[__(alnum|c)\] & _IS)';
2443 c_fix = format;
2444 c_fix_arg = "%1(int)%3";
2446 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2447 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2451 * hpux errno()
2453 fix = {
2454 hackname = hpux_extern_errno;
2455 mach = "*-hp-hpux10.*";
2456 mach = "*-hp-hpux11.[0-2]*";
2457 files = errno.h;
2458 select = "^[ \t]*extern int errno;$";
2459 c_fix = format;
2460 c_fix_arg = "#ifdef __cplusplus\n"
2461 "extern \"C\" {\n"
2462 "#endif\n"
2463 "%0\n"
2464 "#ifdef __cplusplus\n"
2465 "}\n"
2466 "#endif";
2467 test_text = " extern int errno;\n";
2471 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2473 fix = {
2474 hackname = hpux_htonl;
2475 files = netinet/in.h;
2476 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2477 "(/\\*\n"
2478 " \\* Macros for number representation conversion\\.\n"
2479 " \\*/\n"
2480 "#ifndef ntohl)";
2481 c_fix = format;
2482 c_fix_arg = "#if 1\n%1";
2484 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2485 "/*\n"
2486 " * Macros for number representation conversion.\n"
2487 " */\n"
2488 "#ifndef ntohl\n"
2489 "#define ntohl(x) (x)\n"
2490 "#define ntohs(x) (x)\n"
2491 "#define htonl(x) (x)\n"
2492 "#define htons(x) (x)\n"
2493 "#endif\n"
2494 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2498 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2500 fix = {
2501 hackname = hpux_imaginary_i;
2502 mach = "ia64-hp-hpux11.*";
2503 files = complex.h;
2504 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2505 c_fix = format;
2506 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2507 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2511 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2513 fix = {
2514 hackname = hpux_inttype_int8_t;
2515 mach = "*-hp-hpux1[01].*";
2516 files = sys/_inttypes.h;
2517 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2518 c_fix = format;
2519 c_fix_arg = "typedef signed char int%18_t;";
2520 test_text = "typedef char int_least8_t;\n"
2521 "typedef char int8_t;\n";
2525 * HP-UX long_double
2527 fix = {
2528 hackname = hpux_long_double;
2529 mach = "*-*-hpux10*";
2530 mach = "*-*-hpux11.[012]*";
2531 files = stdlib.h;
2532 select = "extern[ \t]long_double[ \t]strtold";
2533 bypass = "long_double_t";
2534 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2535 sed = "s/long_double/long double/g";
2537 test_text = "# ifndef _LONG_DOUBLE\n"
2538 "# define _LONG_DOUBLE\n"
2539 " typedef struct {\n"
2540 " unsigned int word1, word2, word3, word4;\n"
2541 " } long_double;\n"
2542 "# endif /* _LONG_DOUBLE */\n"
2543 "extern long_double strtold(const char *, char **);\n";
2547 * We cannot use the above rule on 11.31 because it removes the strtold
2548 * definition. ia64 is OK with no hack, PA needs some help.
2550 fix = {
2551 hackname = hpux_long_double_2;
2552 mach = "hppa*-*-hpux11.3*";
2553 files = stdlib.h;
2554 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2555 "defined\\(_PROTOTYPES\\) \\|\\| "
2556 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2557 c_fix = format;
2558 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2560 test_text = "# if !defined(__ia64) || "
2561 "!defined(_PROTOTYPES) || "
2562 "defined(_LONG_DOUBLE_STRUCT)\n";
2566 * Add missing braces to pthread initializer defines.
2568 fix = {
2569 hackname = hpux_pthread_initializers;
2570 mach = "*-hp-hpux11.[0-3]*";
2571 files = sys/pthread.h;
2572 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2573 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2574 sed = "s@^[ \t]*1,[ \t]*\\\\"
2575 "@\t{ 1, 0 }@";
2576 sed = "/^[ \t]*0$/d";
2577 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2578 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2579 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2580 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2581 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2582 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2583 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2584 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2585 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2586 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2587 sed = "s@__PTHREAD_COND_VALID, 0"
2588 "@{ __PTHREAD_COND_VALID, 0 }@";
2589 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2590 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2591 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2592 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2593 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2594 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2595 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2596 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2597 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2598 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2599 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2600 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2601 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2602 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2603 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2604 "}\n";
2608 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2609 * type and mpinfou is only defined when _KERNEL is set.
2611 fix = {
2612 hackname = hpux_spu_info;
2613 mach = "*-hp-hpux*";
2615 * It is tempting to omit the first "files" entry. Do not.
2616 * The testing machinery will take the first "files" entry as the name
2617 * of a test file to play with. It would be a nuisance to have a directory
2618 * with the name "*".
2620 files = "ia64/sys/getppdp.h";
2621 files = "*/sys/getppdp.h";
2622 select = "^.*extern.*spu_info.*";
2624 c_fix = format;
2625 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2627 test_text = "extern union mpinfou spu_info[];";
2631 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2633 fix = {
2634 hackname = hpux_stdint_least_fast;
2635 mach = "*-hp-hpux11.2*";
2636 files = stdint-hpux11.h, stdint.h;
2637 select =
2638 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2639 c_fix = format;
2640 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2641 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2642 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2646 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2648 fix = {
2649 hackname = hpux_longjmp;
2650 mach = "*-hp-hpux*";
2651 files = setjmp.h;
2652 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2654 c_fix = format;
2655 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2657 test_text = 'extern void longjmp __((jmp_buf, int));';
2661 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2663 fix = {
2664 hackname = hpux_systime;
2665 files = sys/time.h;
2666 select = "^extern struct sigevent;";
2668 c_fix = format;
2669 c_fix_arg = "struct sigevent;";
2671 test_text = 'extern struct sigevent;';
2675 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2677 fix = {
2678 hackname = huge_val_hex;
2679 files = bits/huge_val.h, '*/bits/huge_val.h';
2680 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2681 bypass = "__builtin_huge_val";
2683 c_fix = format;
2684 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2686 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2690 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2692 fix = {
2693 hackname = huge_valf_hex;
2694 files = bits/huge_val.h, '*/bits/huge_val.h';
2695 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2696 bypass = "__builtin_huge_valf";
2698 c_fix = format;
2699 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2701 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2705 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2707 fix = {
2708 hackname = huge_vall_hex;
2709 files = bits/huge_val.h, '*/bits/huge_val.h';
2710 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2711 bypass = "__builtin_huge_vall";
2713 c_fix = format;
2714 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2716 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2720 * Fix return type of abort and free
2722 fix = {
2723 hackname = int_abort_free_and_exit;
2724 files = stdlib.h;
2725 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2726 bypass = "_CLASSIC_ANSI_TYPES";
2728 c_fix = format;
2729 c_fix_arg = "void\t%1(";
2731 test_text = "extern int abort(int);\n"
2732 "extern int free(void*);\n"
2733 "extern int exit(void*);";
2737 * Fix various macros used to define ioctl numbers.
2738 * The traditional syntax was:
2740 * #define _IO(n, x) (('n'<<8)+x)
2741 * #define TIOCFOO _IO(T, 1)
2743 * but this does not work with the C standard, which disallows macro
2744 * expansion inside strings. We have to rewrite it thus:
2746 * #define _IO(n, x) ((n<<8)+x)
2747 * #define TIOCFOO _IO('T', 1)
2749 * The select expressions match too much, but the c_fix code is cautious.
2751 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2753 fix = {
2754 hackname = io_quotes_def;
2755 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2756 c_fix = char_macro_def;
2757 c_fix_arg = "IO";
2758 test_text =
2759 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2760 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2761 "#define _IO(x,y) ('x'<<8|y)";
2762 test_text =
2763 "#define XX_IO(x) ('x'<<8|256)";
2767 * Fix the usage of the ioctl macro numbers.
2769 fix = {
2770 hackname = io_quotes_use;
2771 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2772 "\\( *[^,']";
2773 c_fix = char_macro_use;
2774 c_fix_arg = "IO";
2775 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2776 "#define TIOCFOO \\\\\n"
2777 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2781 * Check for missing ';' in struct
2783 fix = {
2784 hackname = ip_missing_semi;
2785 files = netinet/ip.h;
2786 select = "}$";
2787 sed = "/^struct/,/^};/s/}$/};/";
2788 test_text=
2789 "struct mumble {\n"
2790 " union {\n"
2791 " int x;\n"
2792 " }\n"
2793 "}; /* mumbled struct */\n";
2797 * Non-traditional "const" declaration in Irix's limits.h.
2799 fix = {
2800 hackname = irix_limits_const;
2801 files = fixinc-test-limits.h, limits.h;
2802 select = "^extern const ";
2803 c_fix = format;
2804 c_fix_arg = "extern __const ";
2805 test_text = "extern const char limit; /* test limits */";
2809 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2810 * taking char *. However, GCC uses void * for va_list, so
2811 * calling vfprintf with a va_list fails in C++. */
2812 fix = {
2813 hackname = irix_stdio_va_list;
2814 files = stdio.h;
2816 select = '/\* va_list \*/ char \*';
2817 c_fix = format;
2818 c_fix_arg = "__gnuc_va_list";
2819 test_text =
2820 "extern int printf( const char *, /* va_list */ char * );";
2824 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2825 * use / * * / to concatenate tokens.
2827 fix = {
2828 hackname = kandr_concat;
2829 files = "sparc/asm_linkage.h";
2830 files = "sun*/asm_linkage.h";
2831 files = "arm/as_support.h";
2832 files = "arm/mc_type.h";
2833 files = "arm/xcb.h";
2834 files = "dev/chardefmac.h";
2835 files = "dev/ps_irq.h";
2836 files = "dev/screen.h";
2837 files = "dev/scsi.h";
2838 files = "sys/tty.h";
2839 files = "Xm.acorn/XmP.h";
2840 files = bsd43/bsd43_.h;
2841 select = '/\*\*/';
2842 c_fix = format;
2843 c_fix_arg = '##';
2844 test_text = "#define __CONCAT__(a,b) a/**/b";
2848 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2849 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2850 * constant on recent versions of g++.
2852 fix = {
2853 hackname = linux_ia64_ucontext;
2854 files = "sys/ucontext.h";
2855 mach = "ia64-*-linux*";
2856 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2857 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2858 c_fix = format;
2859 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2860 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2861 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2865 * Remove header file warning from sys/time.h. Autoconf's
2866 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2867 * which causes warning on LynxOS. Remove the warning.
2869 fix = {
2870 hackname = lynxos_no_warning_in_sys_time_h;
2871 files = sys/time.h;
2872 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2873 c_fix = format;
2874 c_fix_arg = "";
2875 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2879 * Add missing declaration for putenv.
2881 fix = {
2882 hackname = lynxos_missing_putenv;
2883 mach = '*-*-lynxos*';
2884 files = stdlib.h;
2885 bypass = 'putenv[ \t]*\\(';
2886 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2887 c_fix = format;
2888 c_fix_arg = "%0\n"
2889 "extern int putenv _AP((char *));";
2890 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2891 test_text = "extern char *getenv _AP((const char *));";
2895 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2897 * On NetBSD, machine is a symbolic link to an architecture specific
2898 * directory name, so we can't match a specific file name here.
2900 fix = {
2901 hackname = machine_ansi_h_va_list;
2902 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2903 bypass = '__builtin_va_list';
2905 c_fix = format;
2906 c_fix_arg = "%1__builtin_va_list";
2907 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2909 test_text = " # define _BSD_VA_LIST_\tchar**";
2913 * Fix non-ansi machine name defines
2915 fix = {
2916 hackname = machine_name;
2917 c_test = machine_name;
2918 c_fix = machine_name;
2920 test_text = "/* MACH_DIFF: */\n"
2921 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2922 "\n/* no uniform test, so be careful :-) */";
2926 * Some math.h files define struct exception (it's in the System V
2927 * Interface Definition), which conflicts with the class exception defined
2928 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2929 * This is not a great fix, but I haven't been able to think of anything
2930 * better.
2932 fix = {
2933 hackname = math_exception;
2934 files = math.h;
2935 select = "struct exception";
2937 * This should be bypassed on __cplusplus, but some supposedly C++
2938 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2939 * exception either. So currently we bypass only for glibc, based on a
2940 * comment in the fixed glibc header. Ick.
2942 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2943 '_[a-z0-9A-Z_]+_exception; for C, exception';
2944 /* The Solaris 10 headers already get this right. */
2945 mach = '*-*-solaris2.1[0-9]*';
2946 not_machine = true;
2947 c_fix = wrap;
2949 c_fix_arg = "#ifdef __cplusplus\n"
2950 "#define exception __math_exception\n"
2951 "#endif\n";
2953 c_fix_arg = "#ifdef __cplusplus\n"
2954 "#undef exception\n"
2955 "#endif\n";
2957 test_text = "typedef struct exception t_math_exception;";
2961 * This looks pretty broken to me. ``dbl_max_def'' will contain
2962 * "define DBL_MAX " at the start, when what we really want is just
2963 * the value portion. Can't figure out how to write a test case
2964 * for this either :-(
2966 fix = {
2967 hackname = math_huge_val_from_dbl_max;
2968 files = math.h;
2971 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2972 * in math.h, this fix applies.
2974 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2975 bypass = "define[ \t]+DBL_MAX";
2977 shell =
2979 * See if we have a definition for DBL_MAX in float.h.
2980 * If we do, we will replace the one in math.h with that one.
2983 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2984 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2986 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2987 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2988 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2989 "\telse cat\n"
2990 "\tfi";
2992 test_text =
2993 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2994 "#define HUGE_VAL DBL_MAX";
2998 * nested comment
3000 fix = {
3001 hackname = nested_auth_des;
3002 files = rpc/rpc.h;
3003 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3004 c_fix = format;
3005 c_fix_arg = "%1*/ /*";
3006 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3010 * Some versions of NetBSD don't expect the C99 inline semantics.
3012 fix = {
3013 hackname = netbsd_c99_inline_1;
3014 mach = "*-*-netbsd*";
3015 files = signal.h;
3016 select = "extern __inline int";
3018 c_fix = format;
3019 c_fix_arg = "extern\n"
3020 "#ifdef __GNUC_STDC_INLINE__\n"
3021 "__attribute__((__gnu_inline__))\n"
3022 "#endif\n"
3023 "__inline int";
3025 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3029 * netbsd_c99_inline_2
3031 fix = {
3032 hackname = netbsd_c99_inline_2;
3033 mach = "*-*-netbsd*";
3034 files = signal.h;
3035 select = "#define _SIGINLINE extern __inline";
3037 c_fix = format;
3038 c_fix_arg = <<- _EOArg_
3039 #ifdef __GNUC_STDC_INLINE__
3040 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3041 #else
3043 #endif
3044 _EOArg_;
3046 test_text = "#define _SIGINLINE extern __inline";
3050 * NetBSD has a semicolon after the ending '}' for some extern "C".
3052 fix = {
3053 hackname = netbsd_extra_semicolon;
3054 mach = "*-*-netbsd*";
3055 files = sys/cdefs.h;
3056 select = "#define[ \t]*__END_DECLS[ \t]*};";
3058 c_fix = format;
3059 c_fix_arg = "#define __END_DECLS }";
3061 test_text = "#define __END_DECLS };";
3065 * newlib's stdint.h has several failures to conform to C99. The fix
3066 * for these removed a comment that can be matched to identify unfixed
3067 * versions.
3069 fix = {
3070 hackname = newlib_stdint_1;
3071 files = stdint-newlib.h, stdint.h;
3072 select = "@todo - Add support for wint_t types";
3073 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3074 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3075 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3076 sed = "s@#define INT_LEAST32_MIN.*@"
3077 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3078 sed = "s@#define INT_LEAST32_MAX.*@"
3079 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3080 sed = "s@#define UINT_LEAST32_MAX.*@"
3081 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3082 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3083 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3084 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3085 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3086 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3087 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3088 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3089 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3090 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3091 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3092 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3093 test_text = "/* @todo - Add support for wint_t types. */\n"
3094 "#define INT32_MIN (-2147483647-1)\n"
3095 "#define INT32_MAX 2147483647\n"
3096 "#define UINT32_MAX 4294967295U\n"
3097 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3098 "#define INT_LEAST32_MAX 2147483647\n"
3099 "#define UINT_LEAST32_MAX 4294967295U\n"
3100 "#define INT_FAST8_MIN INT8_MIN\n"
3101 "#define INT_FAST8_MAX INT8_MAX\n"
3102 "#define UINT_FAST8_MAX UINT8_MAX\n"
3103 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3104 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3105 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3106 "#define UINT8_C(x) x##U\n"
3107 "#define UINT16_C(x) x##U";
3111 * newlib_stdint_2
3113 fix = {
3114 hackname = newlib_stdint_2;
3115 files = stdint-newlib.h, stdint.h;
3116 select = "@todo - Add support for wint_t types";
3117 c_fix = format;
3118 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3119 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3120 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3121 "#define WCHAR_MAX __WCHAR_MAX__\n"
3122 "#define WCHAR_MIN __WCHAR_MIN__\n"
3123 "#define WINT_MAX __WINT_MAX__\n"
3124 "#define WINT_MIN __WINT_MIN__\n\n"
3125 "%0";
3126 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3127 test_text = "/* @todo - Add support for wint_t types. */\n"
3128 "/** Macros for minimum-width integer constant expressions */";
3132 * NeXT 3.2 adds const prefix to some math functions.
3133 * These conflict with the built-in functions.
3135 fix = {
3136 hackname = next_math_prefix;
3137 files = ansi/math.h;
3138 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3140 c_fix = format;
3141 c_fix_arg = "extern double %1(";
3142 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3144 test_text = "extern\tdouble\t__const__\tmumble();";
3148 * NeXT 3.2 uses the word "template" as a parameter for some
3149 * functions. GCC reports an invalid use of a reserved key word
3150 * with the built-in functions.
3152 fix = {
3153 hackname = next_template;
3154 files = bsd/libc.h;
3155 select = "[ \t]template\\)";
3157 c_fix = format;
3158 c_fix_arg = "(%1)";
3159 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3160 test_text = "extern mumble( char * template); /* fix */";
3164 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3165 * function prototypes. That conflicts with the built-in functions.
3167 fix = {
3168 hackname = next_volitile;
3169 files = ansi/stdlib.h;
3170 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3172 c_fix = format;
3173 c_fix_arg = "extern void %1(";
3174 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3176 test_text = "extern\tvolatile\tvoid\tabort();";
3180 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3181 * Note that version 3 of the NeXT system has wait.h in a different directory,
3182 * so that this code won't do anything. But wait.h in version 3 has a
3183 * conditional, so it doesn't need this fix. So everything is okay.
3185 fix = {
3186 hackname = next_wait_union;
3187 files = sys/wait.h;
3189 select = 'wait\(union wait';
3190 c_fix = format;
3191 c_fix_arg = "wait(void";
3192 test_text = "extern pid_d wait(union wait*);";
3196 * a missing semi-colon at the end of the nodeent structure definition.
3198 fix = {
3199 hackname = nodeent_syntax;
3200 files = netdnet/dnetdb.h;
3201 select = "char[ \t]*\\*na_addr[ \t]*$";
3202 c_fix = format;
3203 c_fix_arg = "%0;";
3204 test_text = "char *na_addr\t";
3208 * Fix OpenBSD's NULL definition.
3210 fix = {
3211 hackname = openbsd_null_definition;
3212 mach = "*-*-openbsd*";
3213 files = locale.h, stddef.h, stdio.h, string.h,
3214 time.h, unistd.h, wchar.h, sys/param.h;
3215 select = "__GNUG__";
3216 c_fix = format;
3217 c_fix_arg = "#ifndef NULL\n"
3218 "#ifdef __cplusplus\n"
3219 "#ifdef __GNUG__\n"
3220 "#define NULL\t__null\n"
3221 "#else\t /* ! __GNUG__ */\n"
3222 "#define NULL\t0L\n"
3223 "#endif\t /* __GNUG__ */\n"
3224 "#else\t /* ! __cplusplus */\n"
3225 "#define NULL\t((void *)0)\n"
3226 "#endif\t /* __cplusplus */\n"
3227 "#endif\t /* !NULL */";
3229 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3230 "^#ifdef[ \t]*__GNUG__\n"
3231 "^#define[ \t]*NULL[ \t]*__null\n"
3232 "^#else\n"
3233 "^#define[ \t]*NULL[ \t]*0L\n"
3234 "^#endif\n"
3235 "^#endif";
3236 test_text =
3237 "#ifndef NULL\n"
3238 "#ifdef __GNUG__\n"
3239 "#define NULL __null\n"
3240 "#else\n"
3241 "#define NULL 0L\n"
3242 "#endif\n"
3243 "#endif\n";
3247 * obstack.h used casts as lvalues.
3249 * We need to change postincrements of casted pointers (which are
3250 * then dereferenced and assigned into) of the form
3252 * *((TYPE*)PTRVAR)++ = (VALUE)
3254 * into expressions like
3256 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3258 * which is correct for the cases used in obstack.h since PTRVAR is
3259 * of type char * and the value of the expression is not used.
3261 fix = {
3262 hackname = obstack_lvalue_cast;
3263 files = obstack.h;
3264 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3265 c_fix = format;
3266 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3267 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3271 * Fix OpenBSD's va_start define.
3273 fix = {
3274 hackname = openbsd_va_start;
3275 mach = "*-*-openbsd*";
3276 files = stdarg.h;
3277 select = '__builtin_stdarg_start';
3278 c_fix = format;
3279 c_fix_arg = __builtin_va_start;
3281 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3285 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3286 * defining regex.h related types. This causes libg++ build and usage
3287 * failures. Fixing this correctly requires checking and modifying 3 files.
3289 fix = {
3290 hackname = osf_namespace_a;
3291 files = reg_types.h;
3292 files = sys/lc_core.h;
3293 test = " -r reg_types.h";
3294 test = " -r sys/lc_core.h";
3295 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3296 test = " -z \"`grep __regex_t regex.h`\"";
3298 c_fix = format;
3299 c_fix_arg = "__%0";
3300 c_fix_arg = "reg(ex|off|match)_t";
3302 test_text = "`touch sys/lc_core.h`"
3303 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3304 "extern regex_t re;\n"
3305 "extern regoff_t ro;\n"
3306 "extern regmatch_t rm;\n";
3309 fix = {
3310 hackname = osf_namespace_c;
3311 files = regex.h;
3312 test = " -r reg_types.h";
3313 test = " -r sys/lc_core.h";
3314 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3315 test = " -z \"`grep __regex_t regex.h`\"";
3317 select = "#include <reg_types\.h>.*";
3318 c_fix = format;
3319 c_fix_arg = "%0\n"
3320 "typedef __regex_t\tregex_t;\n"
3321 "typedef __regoff_t\tregoff_t;\n"
3322 "typedef __regmatch_t\tregmatch_t;";
3324 test_text = "#include <reg_types.h>";
3328 * On broken glibc-2.3.3 systems an array of incomplete structures is
3329 * passed to __sigsetjmp. Fix that to take a pointer instead.
3331 fix = {
3332 hackname = pthread_incomplete_struct_argument;
3333 files = pthread.h;
3334 select = "struct __jmp_buf_tag";
3335 c_fix = format;
3336 c_fix_arg = "%1 *%2%3";
3337 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3338 "(__env)\\[1\\](.*)$";
3339 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3340 "int __savemask);";
3344 * Fix return type of fread and fwrite on sysV68
3346 fix = {
3347 hackname = read_ret_type;
3348 files = stdio.h;
3349 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3350 c_fix = format;
3351 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3352 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3354 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3358 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3360 fix = {
3361 hackname = rpc_xdr_lvalue_cast_a;
3362 files = rpc/xdr.h;
3363 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3364 c_fix = format;
3365 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3366 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3367 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3371 * rpc_xdr_lvalue_cast_b
3373 fix = {
3374 hackname = rpc_xdr_lvalue_cast_b;
3375 files = rpc/xdr.h;
3376 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3377 c_fix = format;
3378 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3379 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3380 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3384 * function class(double x) conflicts with C++ keyword on rs/6000
3386 fix = {
3387 hackname = rs6000_double;
3388 files = math.h;
3389 select = '[^a-zA-Z_]class\(';
3391 c_fix = format;
3392 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3393 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3395 test_text = "extern int class();";
3399 * Wrong fchmod prototype on RS/6000.
3401 fix = {
3402 hackname = rs6000_fchmod;
3403 files = sys/stat.h;
3404 select = 'fchmod\(char \*';
3405 c_fix = format;
3406 c_fix_arg = "fchmod(int";
3407 test_text = "extern int fchmod(char *, mode_t);";
3411 * parameters conflict with C++ new on rs/6000
3413 fix = {
3414 hackname = rs6000_param;
3415 files = "stdio.h";
3416 files = "unistd.h";
3418 select = 'rename\(const char \*old, const char \*new\)';
3419 c_fix = format;
3420 c_fix_arg = 'rename(const char *_old, const char *_new)';
3422 test_text = 'extern int rename(const char *old, const char *new);';
3426 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3427 * for C99. This is wrong for C++, which needs many C99 features, but
3428 * only supports __restrict.
3430 fix = {
3431 hackname = solaris___restrict;
3432 files = sys/feature_tests.h;
3433 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3434 mach = "*-*-solaris2*";
3435 c_fix = format;
3436 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3437 "#else\n%0\n#endif";
3438 test_text = "#define _RESTRICT_KYWD restrict";
3442 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3443 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3444 * and imaginary definitions which are not supported by GCC.
3446 fix = {
3447 hackname = solaris_complex;
3448 mach = "*-*-solaris2.*";
3449 files = complex.h;
3450 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3451 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3452 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3453 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3454 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3455 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3456 test_text = "#define _Complex_I _Complex_I\n"
3457 "#define complex _Complex\n"
3458 "#define _Imaginary_I _Imaginary_I\n"
3459 "#define imaginary _Imaginary\n"
3460 "#undef I\n"
3461 "#define I _Imaginary_I";
3465 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3466 * extern "C" instead so libstdc++ can use it.
3468 fix = {
3469 hackname = solaris_complex_cxx;
3470 mach = "*-*-solaris2.*";
3471 files = complex.h;
3472 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3473 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3474 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3475 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3476 test_text = "#if !defined(__cplusplus)\n"
3477 "#endif /* !defined(__cplusplus) */";
3481 * g++ rejects functions declared with both C and C++ linkage.
3483 fix = {
3484 hackname = solaris_cxx_linkage;
3485 mach = '*-*-solaris2*';
3486 files = "iso/stdlib_iso.h";
3487 select = "(#if __cplusplus >= 199711L)\n"
3488 "(extern \"C\\+\\+\" \\{\n)"
3489 "(.*(bsearch|qsort).*)";
3490 c_fix = format;
3491 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3493 test_text =
3494 "#if __cplusplus >= 199711L\n"
3495 "extern \"C++\" {\n"
3496 " void *bsearch(const void *, const void *, size_t, size_t,";
3500 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3501 * _STRICT_STDC, but uses it.
3503 fix = {
3504 hackname = solaris_getc_strict_stdc;
3505 mach = "*-*-solaris2*";
3506 files = "iso/stdio_iso.h";
3507 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3508 c_fix = format;
3509 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3511 test_text =
3512 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3516 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3518 fix = {
3519 hackname = solaris_gets_c11;
3520 mach = "*-*-solaris2*";
3521 files = "iso/stdio_iso.h";
3522 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3524 c_fix = format;
3525 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3526 "%1 __attribute__((__deprecated__));\n"
3527 "#endif";
3529 test_text = "extern char *gets(char *);";
3533 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3535 fix = {
3536 hackname = solaris_gets_cxx14;
3537 mach = "*-*-solaris2*";
3538 files = "iso/stdio_iso.h";
3539 select = <<- _EOSelect_
3540 (#if __STDC_VERSION__ < 201112L)
3541 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3542 _EOSelect_;
3543 c_fix = format;
3544 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3546 test_text = <<- _EOText_
3547 #if __STDC_VERSION__ < 201112L
3548 extern char *gets(char *) __ATTR_DEPRECATED;
3549 _EOText_;
3553 * Sun Solaris 2 has a version of sys/int_const.h that defines
3554 * UINT8_C and UINT16_C to unsigned constants.
3556 fix = {
3557 hackname = solaris_int_const;
3558 files = sys/int_const.h;
3559 mach = '*-*-solaris2*';
3560 c_fix = format;
3561 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3562 "%1\n"
3563 "#define\tUINT16_C(c)\t(c)";
3564 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3565 "(/\*.*\*/)\n"
3566 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3567 test_text =
3568 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3569 "/* CSTYLED */\n"
3570 "#define UINT16_C(c) __CONCAT__(c,u)";
3574 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3575 * UINT8_MAX and UINT16_MAX to unsigned constants.
3577 fix = {
3578 hackname = solaris_int_limits_1;
3579 files = sys/int_limits.h;
3580 mach = '*-*-solaris2*';
3581 c_fix = format;
3582 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3583 "#define\tUINT16_MAX\t(65535)";
3584 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3585 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3586 test_text =
3587 "#define UINT8_MAX (255U)\n"
3588 "#define UINT16_MAX (65535U)";
3592 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3593 * INT_FAST16 limits to wrong values for sys/int_types.h.
3595 fix = {
3596 hackname = solaris_int_limits_2;
3597 files = sys/int_limits.h;
3598 mach = '*-*-solaris2*';
3599 c_fix = format;
3600 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3601 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3602 test_text =
3603 "#define INT_FAST16_MAX INT16_MAX\n"
3604 "#define UINT_FAST16_MAX UINT16_MAX\n"
3605 "#define INT_FAST16_MIN INT16_MIN";
3609 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3610 * SIZE_MAX as unsigned long.
3612 fix = {
3613 hackname = solaris_int_limits_3;
3614 files = sys/int_limits.h;
3615 mach = '*-*-solaris2*';
3616 c_fix = format;
3617 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3618 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3619 test_text =
3620 "#define SIZE_MAX 4294967295UL";
3624 * Sun Solaris 10 defines several C99 math macros in terms of
3625 * builtins specific to the Studio compiler, in particular not
3626 * compatible with the GNU compiler.
3628 fix = {
3629 hackname = solaris_math_1;
3630 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3631 bypass = "__GNUC__";
3632 files = iso/math_c99.h;
3633 c_fix = format;
3634 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3635 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3636 test_text =
3637 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3638 "#undef HUGE_VAL\n"
3639 "#define HUGE_VAL __builtin_huge_val\n"
3640 "#undef HUGE_VALF\n"
3641 "#define HUGE_VALF __builtin_huge_valf\n"
3642 "#undef HUGE_VALL\n"
3643 "#define HUGE_VALL __builtin_huge_vall";
3647 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3648 * exception. Provide an alternative using GCC's builtin.
3650 fix = {
3651 hackname = solaris_math_10;
3652 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3653 files = iso/math_c99.h;
3654 c_fix = format;
3655 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3656 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3657 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3658 "[ \t]*\\\\\n"
3659 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3660 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3661 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3662 "\\(-INFINITY\\);[ \t]*\\}\\)";
3663 test_text =
3664 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3665 "#undef isinf\n"
3666 "#define isinf(x) __extension__( \\\\\n"
3667 " { __typeof(x) __x_i = (x); \\\\\n"
3668 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3669 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3673 * Solaris math INFINITY
3675 fix = {
3676 hackname = solaris_math_2;
3677 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3678 bypass = "__GNUC__";
3679 files = iso/math_c99.h;
3680 c_fix = format;
3681 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3682 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3683 test_text =
3684 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3685 "#undef INFINITY\n"
3686 "#define INFINITY __builtin_infinity";
3690 * Solaris math NAN
3692 fix = {
3693 hackname = solaris_math_3;
3694 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3695 bypass = "__GNUC__";
3696 files = iso/math_c99.h;
3697 c_fix = format;
3698 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3699 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3700 test_text =
3701 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3702 "#undef NAN\n"
3703 "#define NAN __builtin_nan";
3707 * Solaris math fpclassify
3709 fix = {
3710 hackname = solaris_math_4;
3711 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3712 bypass = "__GNUC__";
3713 files = iso/math_c99.h;
3714 c_fix = format;
3715 c_fix_arg = "#define\tfpclassify(x) \\\n"
3716 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3717 "FP_SUBNORMAL, FP_ZERO, (x))";
3718 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3719 test_text =
3720 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3721 "#undef fpclassify\n"
3722 "#define fpclassify(x) __builtin_fpclassify(x)";
3726 * Solaris math signbit
3728 fix = {
3729 hackname = solaris_math_8;
3730 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3731 bypass = "__GNUC__";
3732 files = iso/math_c99.h;
3733 c_fix = format;
3734 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3735 "\t\t\t ? __builtin_signbitf(x) \\\n"
3736 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3737 "\t\t\t ? __builtin_signbitl(x) \\\n"
3738 "\t\t\t : __builtin_signbit(x))";
3739 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3740 test_text = <<- _EOText_
3741 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3742 #undef signbit
3743 #define signbit(x) __builtin_signbit(x)
3744 _EOText_;
3748 * Solaris math comparison macros
3750 fix = {
3751 hackname = solaris_math_9;
3752 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3753 bypass = "__GNUC__";
3754 files = iso/math_c99.h;
3755 c_fix = format;
3756 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3757 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3758 "__builtin_[a-z]+\\(y\\)\\)";
3759 test_text =
3760 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3761 "#undef isgreater\n"
3762 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3763 "#undef isgreaterequal\n"
3764 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3765 "#undef isless\n"
3766 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3767 "#undef islessequal\n"
3768 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3769 "#undef islessgreater\n"
3770 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3771 "#undef isunordered\n"
3772 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3776 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3777 * warnings.
3779 fix = {
3780 hackname = solaris_math_11;
3781 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3782 files = iso/math_c99.h;
3783 c_fix = format;
3784 c_fix_arg = << _EOArg_
3785 #undef signbit
3786 #define signbit(x) (sizeof(x) == sizeof(float) \
3787 ? __builtin_signbitf(x) \
3788 : sizeof(x) == sizeof(long double) \
3789 ? __builtin_signbitl(x) \
3790 : __builtin_signbit(x))
3791 _EOArg_;
3792 c_fix_arg = << _EOArg_
3793 ^#undef[ ]+signbit
3794 #if defined\(__sparc\)
3795 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3796 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3797 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3798 #elif defined\(__i386\) \|\| defined\(__amd64\)
3799 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3800 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3801 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3802 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3803 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3804 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3805 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3806 #endif
3807 _EOArg_;
3808 test_text = << _EOText_
3809 /* @(#)math_c99.h 1.14 13/03/27 */
3810 #undef signbit
3811 #if defined(__sparc)
3812 #define signbit(x) __extension__( \\
3813 { __typeof(x) __x_s = (x); \\
3814 (int) (*(unsigned *) &__x_s >> 31); })
3815 #elif defined(__i386) || defined(__amd64)
3816 #define signbit(x) __extension__( \\
3817 { __typeof(x) __x_s = (x); \\
3818 (sizeof (__x_s) == sizeof (float) ? \\
3819 (int) (*(unsigned *) &__x_s >> 31) : \\
3820 sizeof (__x_s) == sizeof (double) ? \\
3821 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3822 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3823 #endif
3824 _EOText_;
3828 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3830 fix = {
3831 hackname = solaris_math_12;
3832 files = math.h;
3833 mach = '*-*-solaris2*';
3834 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3835 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3836 test_text = << _EOText_
3837 #if __cplusplus >= 201103L
3838 #undef _GLIBCXX_USE_C99_MATH
3839 #undef _GLIBCXX_USE_C99_MATH_TR1
3840 #endif
3841 _EOText_;
3845 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3846 * structure. As such, it need two levels of brackets, but only
3847 * contains one. Wrap the macro definition in an extra layer.
3849 fix = {
3850 hackname = solaris_once_init_1;
3851 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3852 files = pthread.h;
3853 mach = '*-*-solaris*';
3854 c_fix = format;
3855 c_fix_arg = "%1{%2}%3";
3856 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3857 test_text =
3858 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3859 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3863 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3864 * posix_spawn declarations, which doesn't work with C++.
3866 fix = {
3867 hackname = solaris_posix_spawn_restrict;
3868 files = spawn.h;
3869 mach = '*-*-solaris2*';
3870 c_fix = format;
3871 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3872 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3873 test_text =
3874 "char *const argv[_RESTRICT_KYWD],\n"
3875 "char *const envp[_RESTRICT_KYWD]);";
3879 * The pow overloads with int were removed in C++ 2011 DR 550.
3881 fix = {
3882 hackname = solaris_pow_int_overload;
3883 mach = '*-*-solaris2*';
3884 files = "iso/math_iso.h";
3885 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3886 " *\\{[^{}]*\n[^{}]*\\}";
3887 c_fix = format;
3888 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3890 test_text =
3891 " inline long double pow(long double __X, int __Y) { return\n"
3892 " __powl(__X, (long double) (__Y)); }";
3896 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3897 * fields of the pthread_rwlock_t structure, which are of type
3898 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3899 * defined (e.g. by -ansi) it is a union. So change the initializer
3900 * to "{0}" instead.
3902 fix = {
3903 hackname = solaris_rwlock_init_1;
3904 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3905 files = pthread.h;
3906 mach = '*-*-solaris*';
3907 c_fix = format;
3908 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3909 "%0\n"
3910 "#else\n"
3911 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3912 "#endif";
3913 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3914 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3916 test_text =
3917 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3918 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3922 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3923 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3925 fix = {
3926 hackname = solaris_std___filbuf;
3927 files = stdio.h;
3928 mach = '*-*-solaris2*';
3929 bypass = "using std::__filbuf";
3930 select = "(using std::perror;\n)(#endif)";
3931 c_fix = format;
3932 c_fix_arg = "%1#ifndef _LP64\n"
3933 "using std::__filbuf;\n"
3934 "using std::__flsbuf;\n"
3935 "#endif\n%2";
3937 test_text = "using std::perror;\n"
3938 "#endif";
3942 * Solaris <stdio.h> shouldn't use std::gets for C++14.
3944 fix = {
3945 hackname = solaris_std_gets_cxx14;
3946 mach = "*-*-solaris2*";
3947 files = "stdio.h";
3948 select = "using std::gets;";
3950 c_fix = format;
3951 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
3953 test_text = "using std::gets;";
3957 * Sun Solaris 8 has what appears to be some gross workaround for
3958 * some old version of their c++ compiler. G++ doesn't want it
3959 * either, but doesn't want to be tied to SunPRO version numbers.
3961 fix = {
3962 hackname = solaris_stdio_tag;
3963 files = stdio_tag.h;
3965 select = '__cplusplus < 54321L';
3966 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3967 "!defined(__GNUC__)" so we no longer need to fix it. */
3968 bypass = '__GNUC__';
3969 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3971 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3975 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
3977 fix = {
3978 hackname = solaris_stdlib_noreturn;
3979 mach = "*-*-solaris2*";
3980 files = "iso/stdlib_c99.h";
3981 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
3983 c_fix = format;
3984 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
3986 test_text = "extern _Noreturn void quick_exit(int);";
3990 * a missing semi-colon at the end of the statsswtch structure definition.
3992 fix = {
3993 hackname = statsswtch;
3994 files = rpcsvc/rstat.h;
3995 select = "boottime$";
3996 c_fix = format;
3997 c_fix_arg = "boottime;";
3998 test_text = "struct statswtch {\n int boottime\n};";
4002 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4003 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4004 * OK too.
4006 fix = {
4007 hackname = stdio_stdarg_h;
4008 files = stdio.h;
4009 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4011 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4012 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4014 mach = '*-*-solaris2.1[0-9]*';
4015 not_machine = true;
4017 c_fix = wrap;
4019 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4021 test_text = "";
4025 * Don't use or define the name va_list in stdio.h. This is for
4026 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4027 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4028 * indicate that the header knows what it's doing -- under SUSv2,
4029 * stdio.h is required to define va_list, and we shouldn't break
4030 * that.
4032 fix = {
4033 hackname = stdio_va_list;
4034 files = stdio.h;
4035 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4037 * On Solaris 10, the definition in
4038 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4039 * there is therefore no need for this fix there.
4041 mach = '*-*-solaris2.1[0-9]*';
4042 not_machine = true;
4045 * Use __gnuc_va_list in arg types in place of va_list.
4046 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4047 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4048 * trailing parentheses and semicolon save all other systems from this.
4049 * Define __not_va_list__ (something harmless and unused)
4050 * instead of va_list.
4051 * Don't claim to have defined va_list.
4053 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4054 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4055 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4056 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4057 "s@ va_list@ __not_va_list__@\n"
4058 "s@\\*va_list@*__not_va_list__@\n"
4059 "s@ __va_list)@ __gnuc_va_list)@\n"
4060 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4061 "@typedef \\1 __not_va_list__;@\n"
4062 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4063 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4064 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4065 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4066 "s@VA_LIST@DUMMY_VA_LIST@\n"
4067 "s@_Va_LIST@_VA_LIST@";
4068 test_text = "extern void mumble( va_list);";
4072 * Fix headers that use va_list from stdio.h to use the updated
4073 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4074 * dealt with elsewhere. The presence of __gnuc_va_list,
4075 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4076 * knows what it's doing.
4078 fix = {
4079 hackname = stdio_va_list_clients;
4080 files = com_err.h;
4081 files = cps.h;
4082 files = curses.h;
4083 files = krb5.h;
4084 files = lc_core.h;
4085 files = pfmt.h;
4086 files = wchar.h;
4087 files = curses_colr/curses.h;
4088 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4089 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4090 otherwise protected. */
4091 bypass = 'include <stdarg\.h>|#ifdef va_start';
4094 * Use __gnuc_va_list in arg types in place of va_list.
4095 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4096 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4097 * trailing parentheses and semicolon save all other systems from this.
4098 * Define __not_va_list__ (something harmless and unused)
4099 * instead of va_list.
4100 * Don't claim to have defined va_list.
4102 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4103 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4104 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4105 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4106 "s@ va_list@ __not_va_list__@\n"
4107 "s@\\*va_list@*__not_va_list__@\n"
4108 "s@ __va_list)@ __gnuc_va_list)@\n"
4109 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4110 "@typedef \\1 __not_va_list__;@\n"
4111 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4112 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4113 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4114 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4115 "s@VA_LIST@DUMMY_VA_LIST@\n"
4116 "s@_Va_LIST@_VA_LIST@";
4117 test_text = "extern void mumble( va_list);";
4121 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4122 * is "!defined( __STRICT_ANSI__ )"
4124 fix = {
4125 hackname = strict_ansi_not;
4126 select = "^([ \t]*#[ \t]*if.*)"
4127 "(!__STDC__"
4128 "|__STDC__[ \t]*==[ \t]*0"
4129 "|__STDC__[ \t]*!=[ \t]*1"
4130 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4131 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4132 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4133 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4134 is not defined by GCC, so it is safe. */
4135 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4136 c_test = stdc_0_in_system_headers;
4138 c_fix = format;
4139 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4141 test_text = "#if !__STDC__ \n"
4142 "#if __STDC__ == 0\n"
4143 "#if __STDC__ != 1\n"
4144 "#if __STDC__ - 0 == 0"
4145 "/* not std C */\nint foo;\n"
4146 "\n#end-end-end-end-if :-)";
4150 * "__STDC__-0==0"
4151 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4153 fix = {
4154 hackname = strict_ansi_not_ctd;
4155 files = math.h, limits.h, stdio.h, signal.h,
4156 stdlib.h, sys/signal.h, time.h;
4158 * Starting at the beginning of a line, skip white space and
4159 * a leading "(" or "&&" or "||". One of those must be found.
4160 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4161 * expression. If these are nested, then they must accumulate
4162 * because we won't match any closing parentheses. Finally,
4163 * after skipping over all that, we must then match our suspect
4164 * phrase: "__STDC__-0==0" with or without white space.
4166 select = "^([ \t]*" '(\(|&&|\|\|)'
4167 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4168 "[ \t(]*)"
4169 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4170 c_test = stdc_0_in_system_headers;
4172 c_fix = format;
4173 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4175 test_text = "#if 1 && \\\\\n"
4176 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4177 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4178 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4179 "int foo;\n#endif";
4183 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4184 * is "defined( __STRICT_ANSI__ )"
4186 fix = {
4187 hackname = strict_ansi_only;
4188 select = "^([ \t]*#[ \t]*if.*)"
4189 "(__STDC__[ \t]*!=[ \t]*0"
4190 "|__STDC__[ \t]*==[ \t]*1"
4191 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4192 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4193 c_test = stdc_0_in_system_headers;
4195 c_fix = format;
4196 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4198 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4202 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4203 * in prototype without previous definition.
4205 fix = {
4206 hackname = struct_file;
4207 files = rpc/xdr.h;
4208 select = '^.*xdrstdio_create.*struct __file_s';
4209 c_fix = format;
4210 c_fix_arg = "struct __file_s;\n%0";
4211 test_text = "extern void xdrstdio_create( struct __file_s* );";
4215 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4216 * in prototype without previous definition.
4218 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4219 * function, and does define it.
4221 fix = {
4222 hackname = struct_sockaddr;
4223 files = rpc/auth.h;
4224 select = "^.*authdes_create.*struct sockaddr[^_]";
4225 bypass = "<sys/socket\.h>";
4226 bypass = "struct sockaddr;\n";
4227 c_fix = format;
4228 c_fix_arg = "struct sockaddr;\n%0";
4229 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4233 * Apply fix this to all OSs since this problem seems to effect
4234 * more than just SunOS.
4236 fix = {
4237 hackname = sun_auth_proto;
4238 files = rpc/auth.h;
4239 files = rpc/clnt.h;
4240 files = rpc/svc.h;
4241 files = rpc/xdr.h;
4242 bypass = "__cplusplus";
4244 * Select those files containing '(*name)()'.
4246 select = '\(\*[a-z][a-z_]*\)\(\)';
4248 c_fix = format;
4249 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4250 "#else\n%1();%2\n#endif";
4251 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4253 test_text =
4254 "struct auth_t {\n"
4255 " int (*name)(); /* C++ bad */\n"
4256 "};";
4260 * Fix bogus #ifdef on SunOS 4.1.
4262 fix = {
4263 hackname = sun_bogus_ifdef;
4264 files = "hsfs/hsfs_spec.h";
4265 files = "hsfs/iso_spec.h";
4266 select = '#ifdef(.*\|\|.*)';
4267 c_fix = format;
4268 c_fix_arg = "#if%1";
4270 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4274 * Fix the CAT macro in SunOS memvar.h.
4276 fix = {
4277 hackname = sun_catmacro;
4278 files = pixrect/memvar.h;
4279 select = "^#define[ \t]+CAT\\(a,b\\).*";
4280 c_fix = format;
4282 c_fix_arg =
4283 "#ifdef __STDC__\n"
4284 "# define CAT(a,b) a##b\n"
4285 "#else\n%0\n#endif";
4287 test_text =
4288 "#define CAT(a,b)\ta/**/b";
4292 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4293 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4295 fix = {
4296 hackname = sun_malloc;
4297 files = malloc.h;
4298 bypass = "_CLASSIC_ANSI_TYPES";
4300 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4301 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4302 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4303 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4304 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4306 test_text =
4307 "typedef char *\tmalloc_t;\n"
4308 "int \tfree();\n"
4309 "char*\tmalloc();\n"
4310 "char*\tcalloc();\n"
4311 "char*\trealloc();";
4315 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4317 fix = {
4318 hackname = sun_rusers_semi;
4319 files = rpcsvc/rusers.h;
4320 select = "_cnt$";
4321 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4322 test_text = "struct mumble\n int _cnt\n};";
4326 * signal.h on SunOS defines signal using (),
4327 * which causes trouble when compiling with g++ -pedantic.
4329 fix = {
4330 hackname = sun_signal;
4331 files = sys/signal.h;
4332 files = signal.h;
4333 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4335 c_fix = format;
4336 c_fix_arg =
4337 "#ifdef __cplusplus\n"
4338 "void\t(*signal(...))(...);\n"
4339 "#else\n%0\n#endif";
4341 test_text = "void\t(*signal())();";
4345 * Correct the return type for strlen in strings.h in SunOS 4.
4347 fix = {
4348 hackname = sunos_strlen;
4349 files = strings.h;
4350 select = "int[ \t]*strlen\\(\\);(.*)";
4351 c_fix = format;
4352 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4353 test_text = " int\tstrlen(); /* string length */";
4357 * Linux kernel's vt.h breaks C++
4359 fix = {
4360 hackname = suse_linux_vt_cxx;
4361 files = linux/vt.h;
4363 select = "^[ \t]*unsigned int new;";
4364 c_fix = format;
4365 c_fix_arg = "unsigned int newev;";
4367 test_text = " unsigned int new; /* New console (if changing) */";
4371 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4372 * that is visible to any ANSI compiler using this include. Simply
4373 * delete the lines that #define some string functions to internal forms.
4375 fix = {
4376 hackname = svr4_disable_opt;
4377 files = string.h;
4378 select = '#define.*__std_hdr_';
4379 sed = '/#define.*__std_hdr_/d';
4380 test_text = "#define strlen __std_hdr_strlen\n";
4384 * Fix broken decl of getcwd present on some svr4 systems.
4386 fix = {
4387 hackname = svr4_getcwd;
4388 files = stdlib.h;
4389 files = unistd.h;
4390 files = prototypes.h;
4391 select = 'getcwd\(char \*, int\)';
4393 c_fix = format;
4394 c_fix_arg = "getcwd(char *, size_t)";
4396 test_text = "extern char* getcwd(char *, int);";
4400 * Fix broken decl of profil present on some svr4 systems.
4402 fix = {
4403 hackname = svr4_profil;
4404 files = stdlib.h;
4405 files = unistd.h;
4407 select =
4408 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4409 c_fix = format;
4410 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4412 test_text =
4413 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4417 * Correct types for signal handler constants like SIG_DFL; they might be
4418 * void (*) (), and should be void (*) (int). C++ doesn't like the
4419 * old style.
4421 fix = {
4422 hackname = svr4_sighandler_type;
4423 files = sys/signal.h;
4424 select = 'void *\(\*\)\(\)';
4425 c_fix = format;
4426 c_fix_arg = "void (*)(int)";
4427 test_text = "#define SIG_DFL (void(*)())0\n"
4428 "#define SIG_IGN (void (*)())0\n";
4432 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4433 * function 'getrnge' in <regexp.h> before they declare it. For these
4434 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4435 * early on.
4437 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4438 * so put the declaration right after the declaration of 'size'.
4440 * Don't do this if there is already a `static void getrnge' declaration
4441 * present, since this would cause a redeclaration error. Solaris 2.x has
4442 * such a declaration.
4444 fix = {
4445 hackname = svr4_undeclared_getrnge;
4446 files = regexp.h;
4447 select = "getrnge";
4448 bypass = "static void getrnge";
4449 c_fix = format;
4450 c_fix_arg = "%0\n"
4451 "static int getrnge ();";
4452 c_fix_arg = "^static int[ \t]+size;";
4453 test_text = "static int size;\n"
4454 "/* stuff which calls getrnge() */\n"
4455 "static getrnge()\n"
4456 "{}";
4460 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4461 * in string.h on sysV68
4462 * Correct the return type for strlen in string.h on Lynx.
4463 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4464 * Add missing const for strdup on OSF/1 V3.0.
4465 * On sysV88 layout is slightly different.
4467 fix = {
4468 hackname = sysv68_string;
4469 files = testing.h;
4470 files = string.h;
4471 bypass = "_CLASSIC_ANSI_TYPES";
4473 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4474 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4475 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4477 sed = "/^extern char$/N";
4478 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4480 sed = "/^extern int$/N";
4481 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4483 sed = "/^\tstrncmp(),$/N";
4484 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4485 '\1;' "\\\nextern unsigned int\\\n\\2/";
4487 test_text =
4488 "extern int strlen();\n"
4490 "extern int ffs(long);\n"
4492 "extern char\n"
4493 "\t*memccpy(),\n"
4494 "\tmemcpy();\n"
4496 "extern int\n"
4497 "\tstrcmp(),\n"
4498 "\tstrncmp(),\n"
4499 "\tstrlen(),\n"
4500 "\tstrspn();\n"
4502 "extern int\n"
4503 "\tstrlen(), strspn();";
4507 * Fix return type of calloc, malloc, realloc, bsearch and exit
4509 fix = {
4510 hackname = sysz_stdlib_for_sun;
4511 files = stdlib.h;
4512 bypass = "_CLASSIC_ANSI_TYPES";
4514 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4515 c_fix = format;
4516 c_fix_arg = "void *\t%1(";
4518 test_text =
4519 "extern char*\tcalloc(size_t);\n"
4520 "extern char*\tmalloc(size_t);\n"
4521 "extern char*\trealloc(void*,size_t);\n"
4522 "extern char*\tbsearch(void*,size_t,size_t);\n";
4526 * __thread is now a keyword.
4528 fix = {
4529 hackname = thread_keyword;
4530 files = "pthread.h";
4531 files = bits/sigthread.h, '*/bits/sigthread.h';
4532 select = "([* ])__thread([,)])";
4533 c_fix = format;
4534 c_fix_arg = "%1__thr%2";
4536 test_text =
4537 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4538 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4539 "extern int pthread_cancel (pthread_t __thread);";
4543 * if the #if says _cplusplus, not the double underscore __cplusplus
4544 * that it should be
4546 fix = {
4547 hackname = tinfo_cplusplus;
4548 files = tinfo.h;
4549 select = "[ \t]_cplusplus";
4551 c_fix = format;
4552 c_fix_arg = " __cplusplus";
4553 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4557 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4559 fix = {
4560 hackname = ultrix_const;
4561 files = stdio.h;
4562 select = 'perror\( char \*';
4564 c_fix = format;
4565 c_fix_arg = "%1 const %3 *__";
4566 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4567 "[ \t]+(char|void) \\*__";
4569 test_text =
4570 "extern void perror( char *__s );\n"
4571 "extern int fputs( char *__s, FILE *);\n"
4572 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4573 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4574 "extern int scanf( char *__format, ...);\n";
4578 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4580 fix = {
4581 hackname = ultrix_const2;
4582 files = stdio.h;
4584 select = '\*fopen\( char \*';
4585 c_fix = format;
4586 c_fix_arg = "%1( const char *%3, const char *";
4587 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4588 "[ \t]*char[ \t]*\\*([^,]*),"
4589 "[ \t]*char[ \t]*\\*[ \t]*";
4591 test_text =
4592 "extern FILE *fopen( char *__filename, char *__type );\n"
4593 "extern int sscanf( char *__s, char *__format, ...);\n"
4594 "extern FILE *popen(char *, char *);\n"
4595 "extern char *tempnam(char*,char*);\n";
4599 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4601 fix = {
4602 hackname = va_i960_macro;
4603 files = arch/i960/archI960.h;
4604 select = "__(vsiz|vali|vpad|alignof__)";
4606 c_fix = format;
4607 c_fix_arg = "__vx%1";
4609 test_text =
4610 "extern int __vsiz vsiz;\n"
4611 "extern int __vali vali;\n"
4612 "extern int __vpad vpad;\n"
4613 "#define __alignof__(x) ...";
4617 * On VMS, add missing braces around sigset_t constants.
4619 fix = {
4620 hackname = vms_add_missing_braces;
4621 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4622 mach = "*-*-*vms*";
4623 files = "rtldef/signal.h";
4624 c_fix = format;
4626 c_fix_arg = '%1 {%2} ';
4628 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4629 "{0x00000000, 0x00000000},\n"
4630 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4634 * On VMS, some DEC-C builtins are directly used.
4636 fix = {
4637 hackname = vms_decc_builtin;
4638 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4639 mach = "*-*-*vms*";
4640 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4641 rtldef/socket.h;
4642 sed = "s@__MEMSET@memset@";
4643 sed = "s@__MEMMOVE@memmove@";
4644 sed = "s@__MEMCPY@memcpy@";
4645 sed = "s@__STRLEN@strlen@";
4646 sed = "s@__STRCPY@strcpy@";
4648 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4652 * Define __CAN_USE_EXTERN_PREFIX on vms.
4654 fix = {
4655 hackname = vms_define_can_use_extern_prefix;
4656 files = "rtldef/decc$types.h";
4657 select = "#[ \t]*else\n"
4658 "#[ \t]*if defined\\(__DECCXX\\)\n"
4659 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4660 mach = "*-*-*vms*";
4661 c_fix = format;
4663 c_fix_arg = "%0"
4664 "# elif defined (__GNUC__)\n"
4665 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4667 test_text = "# else\n"
4668 "# if defined(__DECCXX)\n"
4669 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4670 "# endif\n"
4671 "# endif\n";
4675 * On VMS, disable the use of dec-c string builtins
4677 fix = {
4678 hackname = vms_disable_decc_string_builtins;
4679 select = "#if !defined\\(__VAX\\)\n";
4680 mach = "*-*-*vms*";
4681 files = "rtldef/string.h";
4682 c_fix = format;
4684 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4686 test_text = "#if !defined(__VAX)\n";
4690 * On VMS, fix incompatible redeclaration of hostalias.
4692 fix = {
4693 hackname = vms_do_not_redeclare_hostalias;
4694 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4695 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4696 mach = "*-*-*vms*";
4697 files = "rtldef/resolv.h";
4698 c_fix = format;
4700 c_fix_arg = "%1\n"
4701 "/* %2 */";
4703 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4704 "__char_ptr32 hostalias (const char *);\n";
4708 * On VMS, forward declare structure before referencing them in prototypes.
4710 fix = {
4711 hackname = vms_forward_declare_struct;
4712 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4713 "#ifdef __cplusplus\n";
4714 mach = "*-*-*vms*";
4715 files = rtldef/if.h;
4716 c_fix = format;
4718 c_fix_arg = "%1"
4719 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4721 test_text = "/* forward decls for C++ */\n"
4722 "#ifdef __cplusplus\n"
4723 "struct foo;\n"
4724 "#endif\n";
4728 * On VMS, do not declare getopt and al if pointers are 64 bit.
4730 fix = {
4731 hackname = vms_no_64bit_getopt;
4732 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4733 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4734 mach = "*-*-*vms*";
4735 files = rtldef/stdio.h, rtldef/unistd.h;
4736 c_fix = format;
4738 c_fix_arg = <<- _EOArg_
4739 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4740 %0#endif
4742 _EOArg_;
4744 test_text = "int getopt (int, char * const [], const char *);";
4748 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4749 * which is not yet fully supported by gcc.
4751 fix = {
4752 hackname = vms_use_fast_setjmp;
4753 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4754 mach = "*-*-*vms*";
4755 files = rtldef/setjmp.h;
4756 c_fix = format;
4758 c_fix_arg = "%0 defined (__GNUC__) ||";
4760 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4764 * On VMS, use pragma extern_model instead of VAX-C keywords.
4766 fix = {
4767 hackname = vms_use_pragma_extern_model;
4768 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4769 "# pragma extern_model __save\n";
4770 mach = "*-*-*vms*";
4771 c_fix = format;
4773 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4774 "# pragma extern_model __save\n";
4776 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4777 "# pragma extern_model __save\n"
4778 "# pragma extern_model strict_refdef\n"
4779 " extern struct x zz$yy;\n"
4780 "# pragma extern_model __restore\n"
4781 "#endif\n";
4785 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4786 * conflict while building gcc. Likewise for <builtins.h>
4788 fix = {
4789 hackname = vms_use_quoted_include;
4790 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4791 mach = "*-*-*vms*";
4792 files = rtldef/wait.h, starlet_c/pthread.h;
4793 c_fix = format;
4795 c_fix_arg = '%1<sys/%2.h>';
4797 test_text = "# include <resource.h>";
4801 * AIX and Interix headers define NULL to be cast to a void pointer,
4802 * which is illegal in ANSI C++.
4804 fix = {
4805 hackname = void_null;
4806 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4807 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4808 /* avoid changing C++ friendly NULL */
4809 bypass = __cplusplus;
4810 bypass = __null;
4811 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4812 c_fix = format;
4813 c_fix_arg = <<- _EOFix_
4814 #ifndef NULL
4815 #ifdef __cplusplus
4816 #ifdef __GNUG__
4817 #define NULL __null
4818 #else /* ! __GNUG__ */
4819 #define NULL 0L
4820 #endif /* __GNUG__ */
4821 #else /* ! __cplusplus */
4822 #define NULL ((void *)0)
4823 #endif /* __cplusplus */
4824 #endif /* !NULL */
4825 _EOFix_;
4826 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4830 * Make VxWorks header which is almost gcc ready fully gcc ready.
4832 fix = {
4833 hackname = vxworks_gcc_problem;
4834 files = types/vxTypesBase.h;
4835 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4837 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4838 "#if 1/";
4840 sed = "/[ \t]size_t/i\\\n"
4841 "#ifndef _GCC_SIZE_T\\\n"
4842 "#define _GCC_SIZE_T\n";
4844 sed = "/[ \t]size_t/a\\\n"
4845 "#endif\n";
4847 sed = "/[ \t]ptrdiff_t/i\\\n"
4848 "#ifndef _GCC_PTRDIFF_T\\\n"
4849 "#define _GCC_PTRDIFF_T\n";
4851 sed = "/[ \t]ptrdiff_t/a\\\n"
4852 "#endif\n";
4854 sed = "/[ \t]wchar_t/i\\\n"
4855 "#ifndef _GCC_WCHAR_T\\\n"
4856 "#define _GCC_WCHAR_T\n";
4858 sed = "/[ \t]wchar_t/a\\\n"
4859 "#endif\n";
4861 test_text =
4862 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4863 "typedef unsigned int size_t;\n"
4864 "typedef long ptrdiff_t;\n"
4865 "typedef unsigned short wchar_t;\n"
4866 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4870 * Wrap VxWorks ioctl to keep everything pretty
4872 fix = {
4873 hackname = vxworks_ioctl_macro;
4874 files = ioLib.h;
4875 mach = "*-*-vxworks*";
4877 c_fix = format;
4878 c_fix_arg = "%0\n"
4879 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4880 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4882 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4886 * Wrap VxWorks mkdir to be posix compliant
4888 fix = {
4889 hackname = vxworks_mkdir_macro;
4890 files = sys/stat.h;
4891 mach = "*-*-vxworks*";
4893 c_fix = format;
4894 c_fix_arg = "%0\n"
4895 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4896 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4897 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4898 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4899 "\\)[\t ]*;";
4901 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4905 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4907 fix = {
4908 hackname = vxworks_needs_vxtypes;
4909 files = time.h;
4910 select = "uint_t([ \t]+_clocks_per_sec)";
4911 c_fix = format;
4912 c_fix_arg = "unsigned int%1";
4913 test_text = "uint_t\t_clocks_per_sec;";
4917 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4919 fix = {
4920 hackname = vxworks_needs_vxworks;
4921 files = sys/stat.h;
4922 test = " -r types/vxTypesOld.h";
4923 test = " -n \"`egrep '#include' $file`\"";
4924 test = " -n \"`egrep ULONG $file`\"";
4925 select = "#[ \t]define[ \t]+__INCstath";
4927 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4928 "#include <types/vxTypesOld.h>\n";
4930 test_text = "`touch types/vxTypesOld.h`"
4931 "#include </dev/null> /* ULONG */\n"
4932 "# define\t__INCstath <sys/stat.h>";
4936 * Make it so VxWorks does not include gcc/regs.h accidentally
4938 fix = {
4939 hackname = vxworks_regs;
4940 mach = "*-*-vxworks*";
4942 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4943 c_fix = format;
4944 c_fix_arg = "#include <arch/../regs.h>";
4946 test_text = "#include <regs.h>\n";
4950 * Another bad dependency in VxWorks 5.2 <time.h>.
4952 fix = {
4953 hackname = vxworks_time;
4954 files = time.h;
4955 test = " -r vxWorks.h";
4957 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4958 c_fix = format;
4960 c_fix_arg =
4961 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4962 "#ifdef __cplusplus\n"
4963 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4964 "#else\n"
4965 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4966 "#endif\n"
4967 "#define __gcc_VOIDFUNCPTR_defined\n"
4968 "#endif\n"
4969 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4971 test_text = "`touch vxWorks.h`"
4972 "#define VOIDFUNCPTR (void(*)())";
4976 * This hack makes write const-correct on VxWorks
4978 fix = {
4979 hackname = vxworks_write_const;
4980 files = ioLib.h;
4981 mach = "*-*-vxworks*";
4983 c_fix = format;
4984 c_fix_arg = "extern int write (int, const char*, size_t);";
4985 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4986 "[\t ]*int[\t ]*,"
4987 "[\t ]*char[\t ]*\\*[\t ]*,"
4988 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4990 test_text = "extern int write ( int , char * , size_t ) ;";
4994 * There are several name conflicts with C++ reserved words in X11 header
4995 * files. These are fixed in some versions, so don't do the fixes if
4996 * we find __cplusplus in the file. These were found on the RS/6000.
4998 fix = {
4999 hackname = x11_class;
5000 files = X11/ShellP.h;
5001 bypass = __cplusplus;
5002 select = "^([ \t]*char \\*)class;(.*)";
5003 c_fix = format;
5004 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5005 "#else\n%1class;%2\n#endif";
5006 test_text =
5007 "struct {\n"
5008 " char *class;\n"
5009 "} mumble;\n";
5013 * class in Xm/BaseClassI.h
5015 fix = {
5016 hackname = x11_class_usage;
5017 files = Xm/BaseClassI.h;
5018 bypass = "__cplusplus";
5020 select = " class\\)";
5021 c_fix = format;
5022 c_fix_arg = " c_class)";
5024 test_text = "extern mumble (int class);\n";
5028 * new in Xm/Traversal.h
5030 fix = {
5031 hackname = x11_new;
5032 files = Xm/Traversal.h;
5033 bypass = __cplusplus;
5035 sed = "/Widget\told, new;/i\\\n"
5036 "#ifdef __cplusplus\\\n"
5037 "\\\tWidget\told, c_new;\\\n"
5038 "#else\n";
5040 sed = "/Widget\told, new;/a\\\n"
5041 "#endif\n";
5043 sed = "s/Widget new,/Widget c_new,/g";
5044 test_text =
5045 "struct wedge {\n"
5046 " Widget\told, new;\n"
5047 "};\nextern Wedged( Widget new, Widget old );";
5051 * Incorrect sprintf declaration in X11/Xmu.h
5053 fix = {
5054 hackname = x11_sprintf;
5055 files = X11/Xmu.h;
5056 files = X11/Xmu/Xmu.h;
5057 select = "^extern char \\*\tsprintf\\(\\);$";
5059 c_fix = format;
5060 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5062 test_text = "extern char *\tsprintf();";
5064 /*EOF*/