predicates.md (cint34_operand): Update SIGNED_34BIT_OFFSET_P call.
[official-gcc.git] / fixincludes / inclhack.def
blob861532c2a1d8f2c625f06e7211ee77f72c26540c
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key=$'hackname[ \t]*=[ \t]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
30 fix = {
31 hackname = AAB_aix_stdio;
32 files = stdio.h;
33 select = "define fopen fopen64";
34 mach = "*-*-aix*";
35 test-text = ''; /* no way to test */
37 c_fix = wrap;
39 c_fix_arg = "";
41 c_fix_arg = <<- _EOArg_
43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
46 #undef fseeko
47 #undef ftello
48 #undef fgetpos
49 #undef fsetpos
50 #undef fopen
51 #undef freopen
52 /* Alias the symbols using asm */
53 extern "C" {
54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55 extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59 extern off64_t ftello(FILE *) __asm__("ftello64");
61 #endif
62 #endif
64 _EOArg_;
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
72 fix = {
73 hackname = AAB_aix_fcntl;
74 files = fcntl.h;
75 select = "define open[ \t]open64";
76 mach = "*-*-aix*";
77 test-text = ''; /* no way to test */
79 c_fix = wrap;
81 c_fix_arg = "";
83 c_fix_arg = <<- _EOArg_
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
88 #undef open
89 #undef creat
90 #undef openat
91 /* Alias the symbols using asm */
92 extern "C" {
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
97 #endif
99 #endif
100 #endif
102 _EOArg_;
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
109 fix = {
110 hackname = AAB_darwin7_9_long_double_funcs;
111 mach = "*-*-darwin7.9*";
112 files = architecture/ppc/math.h;
113 bypass = "powl";
114 replace = <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
116 10.3.9. */
117 #ifndef __MATH__
118 # undef __APPLE_CC__
119 # define __APPLE_CC__ 1345
120 # include_next <architecture/ppc/math.h>
121 # undef __APPLE_CC__
122 # define __APPLE_CC__ 1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
126 # else
127 # define __LIBMLDBL_COMPAT(sym)
128 # endif /* __LONG_DOUBLE_128__ */
129 # endif /* __LIBMLDBL_COMPAT */
130 # ifdef __cplusplus
131 extern "C" {
132 # endif
133 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
134 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
135 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
136 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
137 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
138 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
139 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
140 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
141 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
142 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
143 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
144 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
145 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
146 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
147 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
148 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
149 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
150 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
151 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
152 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
153 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
154 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
155 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
156 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
157 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
158 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
159 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
160 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
161 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
162 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
163 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
164 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
165 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
166 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
167 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
168 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
169 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
170 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
171 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
172 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
173 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
174 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
175 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
176 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
177 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
178 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
179 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
180 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
181 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
182 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
183 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
184 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
185 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
186 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
187 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
188 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
189 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
190 # ifdef __cplusplus
192 # endif
193 #endif /* __MATH__ */
194 _EndOfHeader_;
198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
200 fix = {
201 hackname = AAB_fd_zero_asm_posix_types_h;
202 files = asm/posix_types.h;
203 mach = 'i[34567]86-*-linux*';
204 bypass = '} while';
205 bypass = 'x86_64';
206 bypass = 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
210 * the start, so that if #include_next gets another instance of
211 * the wrapper, this will follow the #include_next chain until
212 * we arrive at the real <asm/posix_types.h>.
214 replace = <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel. */
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include <features.h>
219 #include_next <asm/posix_types.h>
221 #if defined(__FD_ZERO) && !defined(__GLIBC__)
222 #undef __FD_ZERO
223 #define __FD_ZERO(fdsetp) \
224 do { \
225 int __d0, __d1; \
226 __asm__ __volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0), "=&D" (__d1) \
228 : "a" (0), "0" (__FDSET_LONGS), \
229 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
230 } while (0)
231 #endif
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif /* _POSIX_TYPES_H_WRAPPER */
235 _EndOfHeader_;
239 * This fixes __FD_ZERO bug for glibc-1.x
241 fix = {
242 hackname = AAB_fd_zero_gnu_types_h;
243 files = gnu/types.h;
244 mach = 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
248 * the start, so that if #include_next gets another instance of
249 * the wrapper, this will follow the #include_next chain until
250 * we arrive at the real <gnu/types.h>.
252 replace = <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
254 #ifndef _TYPES_H_WRAPPER
255 #include <features.h>
256 #include_next <gnu/types.h>
258 #if defined(__FD_ZERO) && !defined(__GLIBC__)
259 #undef __FD_ZERO
260 # define __FD_ZERO(fdsetp) \
261 do { \
262 int __d0, __d1; \
263 __asm__ __volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0), "=&D" (__d1) \
265 : "a" (0), "0" (__FDSET_LONGS), \
266 "1" ((__fd_set *) (fdsetp)) :"memory"); \
267 } while (0)
268 #endif
270 #define _TYPES_H_WRAPPER
271 #endif /* _TYPES_H_WRAPPER */
272 _EndOfHeader_;
276 * This fixes __FD_ZERO bug for glibc-2.0.x
278 fix = {
279 hackname = AAB_fd_zero_selectbits_h;
280 files = selectbits.h;
281 mach = 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
285 * the start, so that if #include_next gets another instance of
286 * the wrapper, this will follow the #include_next chain until
287 * we arrive at the real <selectbits.h>.
289 replace = <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include <features.h>
293 #include_next <selectbits.h>
295 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
296 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
297 && __GLIBC_MINOR__ == 0
298 #undef __FD_ZERO
299 #define __FD_ZERO(fdsetp) \\
300 do { \\
301 int __d0, __d1; \\
302 __asm__ __volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0), "=&D" (__d1) \\
304 : "a" (0), "0" (sizeof (__fd_set) \\
305 / sizeof (__fd_mask)), \\
306 "1" ((__fd_mask *) (fdsetp)) \\
307 : "memory"); \\
308 } while (0)
309 #endif
311 #define _SELECTBITS_H_WRAPPER
312 #endif /* _SELECTBITS_H_WRAPPER */
313 _EndOfHeader_;
317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
318 * the same interface as <stdarg.h>. No idea why they couldn't have just
319 * used the standard header.
321 fix = {
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris*';
325 replace = <<- _EndOfHeader_
326 #ifdef __STDC__
327 #include <stdarg.h>
328 #else
329 #include <varargs.h>
330 #endif
331 _EndOfHeader_;
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
341 fix = {
342 hackname = AAB_sun_memcpy;
343 files = memory.h;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
350 #ifndef __memory_h__
351 #define __memory_h__
353 #ifdef __STDC__
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
358 #else
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
365 extern int memcmp();
367 #endif /* __memory_h__ */
368 _EndOfHeader_;
372 * Fix assert.h on VxWorks:
374 fix = {
375 hackname = AAB_vxworks_assert;
376 files = assert.h;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
380 #ifdef _ASSERT_H
381 #undef _ASSERT_H
382 #undef assert
383 #endif
385 #define _ASSERT_H
387 #ifdef __cplusplus
388 extern "C" {
389 #endif
391 #if defined(__STDC__) || defined(__cplusplus)
392 extern void __assert (const char*);
393 #else
394 extern void __assert ();
395 #endif
397 #ifdef NDEBUG
398 #define assert(ign) ((void)0)
399 #else
401 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
402 #define ASSERT_STRINGIFY_HELPER(str) #str
404 #define assert(test) ((void) \
405 ((test) ? ((void)0) : \
406 __assert("Assertion failed: " #test ", file " \
407 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
409 #endif
411 #ifdef __cplusplus
413 #endif
414 _EndOfHeader_;
418 * Add needed include to regs.h (NOT the gcc header) on VxWorks
421 fix = {
422 hackname = AAB_vxworks_regs_vxtypes;
423 files = regs.h;
424 mach = "*-*-vxworks*";
426 replace = <<- _EndOfHeader_
427 #ifndef _REGS_H
428 #define _REGS_H
429 /* regs.h depends on CPU_FAMILY being properly defined, which
430 is done by vxCpu.h. */
431 #include <types/vxCpu.h>
432 /* regs.h includes a CPU_FAMILY-specific header that requires
433 vxTypesOld.h to already have been included. Those headers
434 contain proper _ASMLANGUAGE guards around their typedefs,
435 but vxTypesOld.h itself does not. So we avoid including
436 vxTypesOld.h from assembly. */
437 #ifndef _ASMLANGUAGE
438 #include <types/vxTypesOld.h>
439 #endif
440 #include_next <arch/../regs.h>
441 #endif
442 _EndOfHeader_;
446 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
448 fix = {
449 hackname = AAB_vxworks_unistd;
450 files = unistd.h;
451 mach = "*-*-vxworks*";
453 replace = <<- _EndOfHeader_
454 #ifndef _UNISTD_H
455 #define _UNISTD_H
456 #include_next <unistd.h>
457 #include <ioLib.h>
458 #ifndef STDIN_FILENO
459 #define STDIN_FILENO 0
460 #endif
461 #ifndef STDOUT_FILENO
462 #define STDOUT_FILENO 1
463 #endif
464 #ifndef STDERR_FILENO
465 #define STDERR_FILENO 2
466 #endif
467 #endif /* _UNISTD_H */
468 _EndOfHeader_;
472 * assert.h on AIX 7 redefines static_assert as _Static_assert without
473 * protecting C++.
475 fix = {
476 hackname = aix_assert;
477 mach = "*-*-aix*";
478 files = assert.h;
479 select = "#define[ \t]static_assert[ \t]_Static_assert";
480 c_fix = format;
481 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
482 test_text = "#define static_assert _Static_assert";
486 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
487 * which only is provided by AIX xlc C99.
489 fix = {
490 hackname = aix_complex;
491 mach = "*-*-aix*";
492 files = complex.h;
493 select = "#define[ \t]_Complex_I[ \t]__I";
494 c_fix = format;
495 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
496 test_text = "#define _Complex_I __I\n";
500 * On AIX some headers are not properly guarded by 'extern "C"'.
502 fix = {
503 hackname = aix_externc;
504 mach = "*-*-aix*";
505 files = ctype.h;
506 files = fcntl.h;
507 files = langinfo.h;
508 files = ldfcn.h;
509 files = sys/localedef.h;
510 files = sys/times.h;
511 bypass = "extern \"C\"";
512 c_fix = wrap;
513 c_fix_arg = "#ifdef __cplusplus\n"
514 "extern \"C\" {\n"
515 "#endif\n";
516 c_fix_arg = "#ifdef __cplusplus\n"
517 "}\n"
518 "#endif\n";
519 test_text = "extern int __n_pthreads;\n";
523 * On AIX sys/socket.h assumes C++.
525 fix = {
526 hackname = aix_externcpp1;
527 mach = "*-*-aix*";
528 files = "sys/socket.h";
529 select = "#ifdef __cplusplus";
530 c_fix = format;
531 c_fix_arg = "#ifdef __cplusplus\n"
532 "extern \"C++\" {";
533 test_text = "#ifdef __cplusplus";
537 fix = {
538 hackname = aix_externcpp2;
539 mach = "*-*-aix*";
540 files = "sys/socket.h";
541 select = "#else /\\* __cplusplus \\*/";
542 c_fix = format;
543 c_fix_arg = "} /* extern \"C++\" */\n"
544 "#else /* __cplusplus */";
545 test_text = "#else /* __cplusplus */";
550 * malloc.h on AIX6 uses XLC++ specific builtin syntax
552 fix = {
553 hackname = aix_malloc;
554 mach = "*-*-aix*";
555 files = "malloc.h";
556 select = "#ifdef __cplusplus";
557 c_fix = format;
558 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
559 test_text = "#ifdef __cplusplus";
563 * net/if_arp.h defines a variable fc_softc instead of adding a
564 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
566 fix = {
567 hackname = aix_net_if_arp;
568 mach = "*-*-aix*";
569 files = "net/if_arp.h";
570 select = "^struct fc_softc \\{";
571 c_fix = format;
572 c_fix_arg = "typedef struct _fc_softc {";
573 test_text = "struct fc_softc {\n int a;\n};";
577 * Fix AIX definition of NULL for G++.
579 fix = {
580 hackname = aix_null;
581 mach = "*-*-aix*";
582 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
583 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
584 bypass = __null;
585 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
586 c_fix = format;
587 c_fix_arg = <<- _EOFix_
588 #ifndef NULL
589 #ifdef __cplusplus
590 #ifdef __GNUG__
591 #define NULL __null
592 #else /* ! __GNUG__ */
593 #define NULL 0L
594 #endif /* __GNUG__ */
595 #else /* ! __cplusplus */
596 #define NULL ((void *)0)
597 #endif /* __cplusplus */
598 #endif /* !NULL */
599 _EOFix_;
600 test_text = "# define\tNULL \t(0L) /* typed NULL */";
604 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
605 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
606 * braces.
608 fix = {
609 hackname = aix_once_init_1;
610 mach = "*-*-aix*";
611 files = "pthread.h";
612 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
613 "\\{ \\\\\n";
614 c_fix = format;
615 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
616 "{{ \\\n";
617 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
618 "{ \\\\\n";
621 fix = {
622 hackname = aix_once_init_2;
623 mach = "*-*-aix*";
624 files = "pthread.h";
625 select = "[ \t]0 \\\\\n"
626 "\\}\n";
627 c_fix = format;
628 c_fix_arg = " 0 \\\n"
629 "}}\n";
630 test_text = " 0 \\\\\n"
631 "}\n";
634 fix = {
635 hackname = aix_mutex_initializer_1;
636 mach = "*-*-aix*";
637 files = "pthread.h";
638 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
639 "\\{ \\\\\n";
640 c_fix = format;
641 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
642 "{{ \\\n";
643 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
644 "{ \\\\\n";
647 fix = {
648 hackname = aix_cond_initializer_1;
649 mach = "*-*-aix*";
650 files = "pthread.h";
651 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
652 "\\{ \\\\\n";
653 c_fix = format;
654 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
655 "{{ \\\n";
656 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
657 "{ \\\\\n";
660 fix = {
661 hackname = aix_rwlock_initializer_1;
662 mach = "*-*-aix*";
663 files = "pthread.h";
664 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
665 "\\{ \\\\\n";
666 c_fix = format;
667 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
668 "{{ \\\n";
669 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
670 "{ \\\\\n";
674 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
675 * which violates a requirement of ISO C.
677 fix = {
678 hackname = aix_pthread;
679 files = "pthread.h";
680 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
681 c_fix = format;
682 c_fix_arg = "%1 %2";
683 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
684 "{...init stuff...}";
688 * AIX stdint.h fixes.
690 fix = {
691 hackname = aix_stdint_1;
692 mach = "*-*-aix*";
693 files = stdint-aix.h, stdint.h;
694 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
695 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
696 c_fix = format;
697 c_fix_arg = "#define UINT8_MAX (255)\n"
698 "#define UINT16_MAX (65535)";
699 test_text = "#define UINT8_MAX (255U)\n"
700 "#define UINT16_MAX (65535U)";
704 * aix_stdint_2
706 fix = {
707 hackname = aix_stdint_2;
708 mach = "*-*-aix*";
709 files = stdint-aix.h, stdint.h;
710 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
711 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
712 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
713 "#else\n"
714 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
715 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
716 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
717 c_fix = format;
718 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
719 "#define INTPTR_MAX 9223372036854775807L\n"
720 "#define UINTPTR_MAX 18446744073709551615UL\n"
721 "#else\n"
722 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
723 "#define INTPTR_MAX 2147483647L\n"
724 "#define UINTPTR_MAX 4294967295UL";
725 test_text = "#define INTPTR_MIN INT64_MIN\n"
726 "#define INTPTR_MAX INT64_MAX\n"
727 "#define UINTPTR_MAX UINT64_MAX\n"
728 "#else\n"
729 "#define INTPTR_MIN INT32_MIN\n"
730 "#define INTPTR_MAX INT32_MAX\n"
731 "#define UINTPTR_MAX UINT32_MAX";
735 * aix_stdint_3
737 fix = {
738 hackname = aix_stdint_3;
739 mach = "*-*-aix*";
740 files = stdint-aix.h, stdint.h;
741 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
742 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
743 "#else\n"
744 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
745 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
746 c_fix = format;
747 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
748 "#define PTRDIFF_MAX 9223372036854775807L\n"
749 "#else\n"
750 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
751 "#define PTRDIFF_MAX 2147483647L";
752 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
753 "#define PTRDIFF_MAX INT64_MAX\n"
754 "#else\n"
755 "#define PTRDIFF_MIN INT32_MIN\n"
756 "#define PTRDIFF_MAX INT32_MAX";
760 * aix_stdint_4
762 fix = {
763 hackname = aix_stdint_4;
764 mach = "*-*-aix*";
765 files = stdint-aix.h, stdint.h;
766 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
767 "#else\n"
768 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
769 c_fix = format;
770 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
771 "#else\n"
772 "#define SIZE_MAX 4294967295UL";
773 test_text = "#define SIZE_MAX UINT64_MAX\n"
774 "#else\n"
775 "#define SIZE_MAX UINT32_MAX";
779 * aix_stdint_5
781 fix = {
782 hackname = aix_stdint_5;
783 mach = "*-*-aix*";
784 files = stdint-aix.h, stdint.h;
785 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
786 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
787 c_fix = format;
788 c_fix_arg = "#define UINT8_C(c) c\n"
789 "#define UINT16_C(c) c";
790 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
791 "#define UINT16_C(c) __CONCAT__(c,U)";
795 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
796 produces wrong code with G++.
798 fix = {
799 hackname = aix_stdio_inline;
800 mach = "*-*-aix*";
801 files = stdio.h;
802 select = "#ifdef __cplusplus\\\n"
803 "}\\\n\\\n"
804 "#ifdef ferror\\\n";
805 c_fix = format;
806 c_fix_arg = "#ifdef __cplusplus\n"
807 "}\n"
808 "#endif\n\n"
809 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
810 "#ifdef ferror\n";
811 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
815 * stdlib.h on AIX uses #define on malloc and friends.
817 fix = {
818 hackname = aix_stdlib_malloc;
819 mach = "*-*-aix*";
820 files = stdlib.h;
821 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
822 c_fix = format;
823 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
824 test_text = "#define malloc __linux_malloc";
827 fix = {
828 hackname = aix_stdlib_realloc;
829 mach = "*-*-aix*";
830 files = stdlib.h;
831 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
832 c_fix = format;
833 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
834 test_text = "#define realloc __linux_realloc";
837 fix = {
838 hackname = aix_stdlib_calloc;
839 mach = "*-*-aix*";
840 files = stdlib.h;
841 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
842 c_fix = format;
843 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
844 test_text = "#define calloc __linux_calloc";
847 fix = {
848 hackname = aix_stdlib_valloc;
849 mach = "*-*-aix*";
850 files = stdlib.h;
851 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
852 c_fix = format;
853 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
854 test_text = "#define valloc __linux_valloc";
857 fix = {
858 hackname = aix_stdlib_vec_malloc;
859 mach = "*-*-aix*";
860 files = stdlib.h;
861 select = "#define[ \t]+malloc[ \t]+vec_malloc";
862 c_fix = format;
863 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
864 test_text = "#define malloc vec_malloc";
867 fix = {
868 hackname = aix_stdlib_vec_calloc;
869 mach = "*-*-aix*";
870 files = stdlib.h;
871 select = "#define[ \t]+calloc[ \t]+vec_calloc";
872 c_fix = format;
873 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
874 test_text = "#define calloc vec_calloc";
878 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
880 fix = {
881 hackname = aix_strtof_const;
882 mach = "*-*-aix*";
883 files = stdlib.h;
884 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
885 c_fix = format;
886 c_fix_arg = "%1(const char *, char **);";
887 test_text = "extern float strtof(char *, char **);";
891 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
892 * in an otherwise harmless (and #ifed out) macro definition
894 fix = {
895 hackname = aix_sysmachine;
896 mach = "*-*-aix*";
897 files = sys/machine.h;
898 select = "\\\\ +\n";
899 c_fix = format;
900 c_fix_arg = "\\\n";
901 test_text = "#define FOO \\\n"
902 " bar \\ \n baz \\ \n bat";
906 * sys/wait.h on AIX 5.2 defines macros that have both signed and
907 * unsigned types in conditional expressions.
909 fix = {
910 hackname = aix_syswait_2;
911 mach = "*-*-aix*";
912 files = sys/wait.h;
913 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
914 c_fix = format;
915 c_fix_arg = "? (int)%1";
916 test_text = "#define WSTOPSIG(__x) "
917 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
921 * sys/signal.h on some versions of AIX uses volatile in the typedef of
922 * sig_atomic_t, which causes gcc to generate a warning about duplicate
923 * volatile when a sig_atomic_t variable is declared volatile, as
924 * required by ANSI C.
926 fix = {
927 hackname = aix_volatile;
928 mach = "*-*-aix*";
929 files = sys/signal.h;
930 select = "typedef volatile int sig_atomic_t";
931 c_fix = format;
932 c_fix_arg = "typedef int sig_atomic_t";
933 test_text = "typedef volatile int sig_atomic_t;";
937 * AIX unistd.h defines a static function with an empty parameter list.
939 fix = {
940 hackname = aix_unistd;
941 mach = "*-*-aix*";
942 files = unistd.h;
944 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
945 c_fix = format;
946 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
947 test_text = " static int getdtablesize()";
951 * Fix __assert declaration in assert.h on Alpha OSF/1.
953 fix = {
954 hackname = alpha___assert;
955 files = "assert.h";
956 select = '__assert\(char \*, char \*, int\)';
957 c_fix = format;
958 c_fix_arg = "__assert(const char *, const char *, int)";
959 test_text = 'extern void __assert(char *, char *, int);';
963 * Fix assert macro in assert.h on Alpha OSF/1.
964 * The superfluous int cast breaks C++.
966 fix = {
967 hackname = alpha_assert;
968 files = "assert.h";
969 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
970 c_fix = format;
971 c_fix_arg = "%1(EX)";
972 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
973 ': __assert(#EX, __FILE__, __LINE__))';
977 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
979 fix = {
980 hackname = alpha_getopt;
981 files = "stdio.h";
982 files = "stdlib.h";
983 select = 'getopt\(int, char \*\[\], *char \*\)';
984 c_fix = format;
985 c_fix_arg = "getopt(int, char *const[], const char *)";
986 test_text = 'extern int getopt(int, char *[], char *);';
990 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
992 fix = {
993 hackname = alpha_if_semicolon;
994 files = net/if.h;
995 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
996 c_fix = format;
997 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
998 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1002 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1004 fix = {
1005 hackname = alpha_parens;
1006 files = sym.h;
1007 select = '#ifndef\(__mips64\)';
1008 c_fix = format;
1009 c_fix_arg = "#ifndef __mips64";
1010 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1014 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1015 * And OpenBSD.
1017 fix = {
1018 hackname = alpha_sbrk;
1019 files = unistd.h;
1020 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1021 c_fix = format;
1022 c_fix_arg = "void *sbrk(";
1023 test_text = "extern char* sbrk(ptrdiff_t increment);";
1027 * For C++, avoid any typedef or macro definition of bool,
1028 * and use the built in type instead.
1029 * HP/UX 10.20 also has it in curses_colr/curses.h.
1031 fix = {
1032 hackname = avoid_bool_define;
1033 files = curses.h;
1034 files = curses_colr/curses.h;
1035 files = term.h;
1036 files = tinfo.h;
1038 select = "#[ \t]*define[ \t]+bool[ \t]";
1039 bypass = "__cplusplus";
1041 c_fix = format;
1042 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1043 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1045 test_text = "# define bool\t char \n";
1049 * avoid_bool_type
1051 fix = {
1052 hackname = avoid_bool_type;
1053 files = curses.h;
1054 files = curses_colr/curses.h;
1055 files = term.h;
1056 files = tinfo.h;
1058 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1059 bypass = "__cplusplus";
1061 c_fix = format;
1062 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1064 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1068 * For C++, avoid any typedef definition of wchar_t,
1069 * and use the built in type instead.
1070 * Don't do this for headers that are smart enough to do the right
1071 * thing (recent [n]curses.h and Xlib.h).
1072 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1073 * and will be broken by the edit.
1076 fix = {
1077 hackname = avoid_wchar_t_type;
1079 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1080 bypass = "__cplusplus";
1081 bypass = "_LINUX_NLS_H";
1082 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1084 c_fix = format;
1085 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1087 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1091 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1093 fix = {
1094 hackname = bad_struct_term;
1095 files = curses.h;
1096 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1097 c_fix = format;
1098 c_fix_arg = "struct term;";
1100 test_text = 'typedef struct term;';
1104 * Fix one other error in this file:
1105 * a mismatched quote not inside a C comment.
1107 fix = {
1108 hackname = badquote;
1109 files = sundev/vuid_event.h;
1110 select = "doesn't";
1111 c_fix = format;
1112 c_fix_arg = "does not";
1114 test_text = "/* doesn't have matched single quotes */";
1118 * check for broken assert.h that needs stdio.h
1120 fix = {
1121 hackname = broken_assert_stdio;
1122 files = assert.h;
1123 select = stderr;
1124 bypass = "include.*stdio\\.h";
1125 c_fix = wrap;
1126 c_fix_arg = "#include <stdio.h>\n";
1127 test_text = "extern FILE* stderr;";
1131 * check for broken assert.h that needs stdlib.h
1133 fix = {
1134 hackname = broken_assert_stdlib;
1135 files = assert.h;
1136 select = 'exit *\(|abort *\(';
1137 bypass = "include.*stdlib\\.h";
1138 c_fix = wrap;
1139 c_fix_arg = "#ifdef __cplusplus\n"
1140 "#include <stdlib.h>\n"
1141 "#endif\n";
1142 test_text = "extern void exit ( int );";
1146 * Remove `extern double cabs' declarations from math.h.
1147 * This conflicts with C99. Discovered on AIX.
1148 * Darwin hides its broken cabs in architecture-specific subdirs.
1150 fix = {
1151 hackname = broken_cabs;
1152 files = math.h, "architecture/*/math.h";
1153 select = "^extern[ \t]+double[ \t]+cabs";
1155 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1156 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1158 test_text = "#ifdef __STDC__\n"
1159 "extern double cabs(struct dbl_hypot);\n"
1160 "#else\n"
1161 "extern double cabs();\n"
1162 "#endif\n"
1163 "extern double cabs ( _Complex z );";
1167 * Fixup Darwin's broken check for __builtin_nanf.
1169 fix = {
1170 hackname = broken_nan;
1172 * It is tempting to omit the first "files" entry. Do not.
1173 * The testing machinery will take the first "files" entry as the name
1174 * of a test file to play with. It would be a nuisance to have a directory
1175 * with the name "*".
1177 files = "architecture/ppc/math.h";
1178 files = "architecture/*/math.h";
1179 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1180 bypass = "powl";
1181 c_fix = format;
1182 c_fix_arg = "#if 1";
1183 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1187 * Various systems derived from BSD4.4 contain a macro definition
1188 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1189 * Known to be fixed in FreeBSD 5 system headers.
1191 fix = {
1192 hackname = bsd_stdio_attrs_conflict;
1193 mach = "*-*-*bsd*";
1194 mach = "*-*-*darwin*";
1195 files = stdio.h;
1196 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1197 c_fix = format;
1198 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1199 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1200 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1201 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1202 test_text = '#define vfscanf __svfscanf';
1206 * Fix various macros used to define ioctl numbers.
1207 * The traditional syntax was:
1209 * #define _CTRL(n, x) (('n'<<8)+x)
1210 * #define TCTRLCFOO _CTRL(T, 1)
1212 * but this does not work with the C standard, which disallows macro
1213 * expansion inside strings. We have to rewrite it thus:
1215 * #define _CTRL(n, x) ((n<<8)+x)
1216 * #define TCTRLCFOO _CTRL('T', 1)
1218 * The select expressions match too much, but the c_fix code is cautious.
1220 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1222 fix = {
1223 hackname = ctrl_quotes_def;
1224 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1225 c_fix = char_macro_def;
1226 c_fix_arg = "CTRL";
1229 * This is two tests in order to ensure that the "CTRL(c)" can
1230 * be selected in isolation from the multi-arg format
1232 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1233 test_text = "#define _CTRL(c) ('c'&037)";
1237 * Fix various macros used to define ioctl numbers.
1239 fix = {
1240 hackname = ctrl_quotes_use;
1241 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1242 c_fix = char_macro_use;
1243 c_fix_arg = "CTRL";
1244 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1248 * sys/mman.h on HP/UX is not C++ ready,
1249 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1251 * rpc/types.h on OSF1/2.0 is not C++ ready,
1252 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1254 * The problem is the declaration of malloc.
1256 fix = {
1257 hackname = cxx_unready;
1258 files = sys/mman.h;
1259 files = rpc/types.h;
1260 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1261 not within a macro. */
1262 bypass = '"C"|__BEGIN_DECLS';
1264 c_fix = wrap;
1265 c_fix_arg = "#ifdef __cplusplus\n"
1266 "extern \"C\" {\n"
1267 "#endif\n";
1268 c_fix_arg = "#ifdef __cplusplus\n"
1269 "}\n"
1270 "#endif\n";
1271 test_text = "extern void* malloc( size_t );";
1275 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1276 * unconditionally.
1278 fix = {
1279 hackname = darwin_availabilityinternal;
1280 mach = "*-*-darwin*";
1281 files = AvailabilityInternal.h;
1282 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1283 c_fix = format;
1284 c_fix_arg = <<- _EOFix_
1285 #if defined(__has_attribute)
1286 #if __has_attribute(availability)
1288 #else
1289 #define %1
1290 #endif
1291 #else
1292 #define %1
1293 #endif
1294 _EOFix_;
1296 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1297 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1301 * For the AAB_darwin7_9_long_double_funcs fix (and later fixes for long long)
1302 * to be useful, the main math.h must use <> and not "" includes.
1304 fix = {
1305 hackname = darwin_9_long_double_funcs_2;
1306 mach = "*-*-darwin*";
1307 files = math.h;
1308 select = '#include[ \t]+\"';
1309 c_fix = format;
1310 c_fix_arg = "%1<%2.h>";
1312 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1314 test_text = '#include <architecture/ppc/math.h>';
1318 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1319 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1321 fix = {
1322 hackname = darwin_externc;
1323 mach = "*-*-darwin*";
1324 files = mach-o/swap.h;
1325 files = mach/mach_time.h;
1326 files = mach/mach_traps.h;
1327 files = mach/message.h;
1328 files = mach/mig.h;
1329 files = mach/semaphore.h;
1330 bypass = "extern \"C\"";
1331 bypass = "__BEGIN_DECLS";
1332 c_fix = wrap;
1333 c_fix_arg = "#ifdef __cplusplus\n"
1334 "extern \"C\" {\n"
1335 "#endif\n";
1336 c_fix_arg = "#ifdef __cplusplus\n"
1337 "}\n"
1338 "#endif\n";
1339 test_text = "extern void swap_fat_header();\n";
1343 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1344 * bad __GNUC__ tests.
1346 fix = {
1347 hackname = darwin_gcc4_breakage;
1348 mach = "*-*-darwin*";
1349 files = AvailabilityMacros.h;
1350 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1351 c_fix = format;
1352 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1353 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1354 "(__GNUC_MINOR__ >= 1)\n";
1358 * math.h hides the long long functions that are available on the system for
1359 * 10.5 and 10.6 SDKs, we expect to use them in G++ without specifying a value
1360 * for __STDC_VERSION__, or switching __STRICT_ANSI__ off.
1362 fix = {
1363 hackname = darwin_ll_funcs_avail;
1364 mach = "*-*-darwin*";
1365 files = architecture/ppc/math.h, architecture/i386/math.h;
1366 select = "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
1367 "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
1368 sed = "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
1369 "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
1370 test_text = "#if\ !(__DARWIN_NO_LONG_LONG)";
1374 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1376 fix = {
1377 hackname = darwin_longjmp_noreturn;
1378 mach = "*-*-darwin*";
1379 files = "i386/setjmp.h";
1380 bypass = "__dead2";
1381 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1382 c_fix = format;
1383 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1385 test_text = "void siglongjmp(sigjmp_buf, int);";
1389 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1391 fix = {
1392 hackname = darwin_os_trace_1;
1393 mach = "*-*-darwin*";
1394 files = os/trace.h;
1395 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1396 c_fix = format;
1397 c_fix_arg = "%1";
1398 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1402 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1403 * extension without guard.
1405 fix = {
1406 hackname = darwin_os_trace_2;
1407 mach = "*-*-darwin*";
1408 files = os/trace.h;
1409 select = "typedef.*\\^os_trace_payload_t.*";
1410 c_fix = format;
1411 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1412 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1416 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1417 * os_trace_payload_t typedef, too.
1419 fix = {
1420 hackname = darwin_os_trace_3;
1421 mach = "*-*-darwin*";
1422 files = os/trace.h;
1423 select = <<- _EOSelect_
1424 __(API|OSX)_.*
1425 OS_EXPORT.*
1427 _os_trace.*os_trace_payload_t payload);
1428 _EOSelect_;
1429 c_fix = format;
1430 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1431 test_text = <<- _EOText_
1432 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1433 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1434 void
1435 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1437 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1438 OS_EXPORT OS_NOTHROW
1439 void
1440 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1441 _EOText_;
1445 * In macOS 10.10 <os/base.h>, doesn't have __has_extension guarded.
1447 fix = {
1448 hackname = darwin_os_base_1;
1449 mach = "*-*-darwin*";
1450 files = os/base.h;
1451 select = <<- OS_BASE_1_SEL
1452 #define __has_attribute.*
1453 #endif
1454 OS_BASE_1_SEL;
1455 c_fix = format;
1456 c_fix_arg = <<- OS_BASE_1_FIX
1458 #ifndef __has_extension
1459 #define __has_extension(x) 0
1460 #endif
1461 OS_BASE_1_FIX;
1462 test_text = <<- OS_BASE_1_TEST
1463 #define __has_attribute(x) 0
1464 #endif
1466 #if __GNUC__
1467 OS_BASE_1_TEST;
1471 * In macOS 10.10 <dispatch/object.h>, has unguarded block syntax.
1473 fix = {
1474 hackname = darwin_dispatch_object_1;
1475 mach = "*-*-darwin*";
1476 files = dispatch/object.h;
1477 select = "typedef void.*\\^dispatch_block_t.*";
1478 c_fix = format;
1479 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1480 test_text = <<- DISPATCH_OBJECT_1_TEST
1481 typedef void (^dispatch_block_t)(void);
1483 __BEGIN_DECLS
1484 DISPATCH_OBJECT_1_TEST;
1488 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1489 * why would you ever put it in a system header file?
1491 fix = {
1492 hackname = darwin_private_extern;
1493 mach = "*-*-darwin*";
1494 files = mach-o/dyld.h;
1495 select = "__private_extern__ [a-z_]+ _dyld_";
1496 c_fix = format;
1497 c_fix_arg = "extern";
1498 c_fix_arg = "__private_extern__";
1499 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1500 "const char *dyld_func_name,\n"
1501 "unsigned long *address);\n";
1505 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1506 * unsigned constants.
1508 fix = {
1509 hackname = darwin_stdint_1;
1510 mach = "*-*-darwin*";
1511 files = stdint-darwin.h, stdint.h;
1512 c_fix = format;
1513 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1514 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1515 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1516 test_text = "#define UINT8_C(v) (v ## U)\n"
1517 "#define UINT16_C(v) (v ## U)";
1521 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1522 * with wrong types.
1524 fix = {
1525 hackname = darwin_stdint_2;
1526 mach = "*-*-darwin*";
1527 files = stdint-darwin.h, stdint.h;
1528 c_fix = format;
1529 c_fix_arg = "#if __WORDSIZE == 64\n"
1530 "#define INTPTR_MAX 9223372036854775807L\n"
1531 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1532 "#else\n"
1533 "#define INTPTR_MAX 2147483647L\n"
1534 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1535 "#endif";
1536 select = "#if __WORDSIZE == 64\n"
1537 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1538 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1539 "#else\n"
1540 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1541 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1542 "#endif";
1543 test_text = "#if __WORDSIZE == 64\n"
1544 "#define INTPTR_MIN INT64_MIN\n"
1545 "#define INTPTR_MAX INT64_MAX\n"
1546 "#else\n"
1547 "#define INTPTR_MIN INT32_MIN\n"
1548 "#define INTPTR_MAX INT32_MAX\n"
1549 "#endif";
1553 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1555 fix = {
1556 hackname = darwin_stdint_3;
1557 mach = "*-*-darwin*";
1558 files = stdint-darwin.h, stdint.h;
1559 c_fix = format;
1560 c_fix_arg = "#if __WORDSIZE == 64\n"
1561 "#define UINTPTR_MAX 18446744073709551615UL\n"
1562 "#else\n"
1563 "#define UINTPTR_MAX 4294967295UL\n"
1564 "#endif";
1565 select = "#if __WORDSIZE == 64\n"
1566 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1567 "#else\n"
1568 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1569 "#endif";
1570 test_text = "#if __WORDSIZE == 64\n"
1571 "#define UINTPTR_MAX UINT64_MAX\n"
1572 "#else\n"
1573 "#define UINTPTR_MAX UINT32_MAX\n"
1574 "#endif";
1578 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1580 fix = {
1581 hackname = darwin_stdint_4;
1582 mach = "*-*-darwin*";
1583 files = stdint-darwin.h, stdint.h;
1584 c_fix = format;
1585 c_fix_arg = "#if __WORDSIZE == 64\n"
1586 "#define SIZE_MAX 18446744073709551615UL\n"
1587 "#else\n"
1588 "#define SIZE_MAX 4294967295UL\n"
1589 "#endif";
1590 select = "#if __WORDSIZE == 64\n"
1591 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1592 "#else\n"
1593 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1594 "#endif";
1595 test_text = "#if __WORDSIZE == 64\n"
1596 "#define SIZE_MAX UINT64_MAX\n"
1597 "#else\n"
1598 "#define SIZE_MAX UINT32_MAX\n"
1599 "#endif";
1603 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1604 * with a wrong type.
1606 fix = {
1607 hackname = darwin_stdint_5;
1608 mach = "*-*-darwin*";
1609 files = stdint-darwin.h, stdint.h;
1610 c_fix = format;
1611 c_fix_arg = "#if __WORDSIZE == 64\n"
1612 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1613 "#define INTMAX_MAX 9223372036854775807L\n"
1614 "#define UINTMAX_MAX 18446744073709551615UL\n"
1615 "#else\n"
1616 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1617 "#define INTMAX_MAX 9223372036854775807LL\n"
1618 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1619 "#endif";
1620 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1621 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1622 "\n"
1623 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1624 test_text = "#define INTMAX_MIN INT64_MIN\n"
1625 "#define INTMAX_MAX INT64_MAX\n"
1626 "\n"
1627 "#define UINTMAX_MAX UINT64_MAX";
1631 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1632 * with a wrong type.
1634 fix = {
1635 hackname = darwin_stdint_6;
1636 mach = "*-*-darwin*";
1637 files = stdint-darwin.h, stdint.h;
1638 c_fix = format;
1639 c_fix_arg = "#if __WORDSIZE == 64\n"
1640 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1641 "#define PTRDIFF_MAX 9223372036854775807L\n"
1642 "#else\n"
1643 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1644 "#define PTRDIFF_MAX 2147483647\n"
1645 "#endif";
1646 select = "#if __WORDSIZE == 64\n"
1647 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1648 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1649 "#else\n"
1650 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1651 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1652 "#endif";
1653 test_text = "#if __WORDSIZE == 64\n"
1654 "#define PTRDIFF_MIN INT64_MIN\n"
1655 "#define PTRDIFF_MAX INT64_MAX\n"
1656 "#else\n"
1657 "#define PTRDIFF_MIN INT32_MIN\n"
1658 "#define PTRDIFF_MAX INT32_MAX\n"
1659 "#endif";
1663 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1664 * with a wrong type.
1666 fix = {
1667 hackname = darwin_stdint_7;
1668 mach = "*-*-darwin*";
1669 files = stdint-darwin.h, stdint.h;
1670 c_fix = format;
1671 c_fix_arg = "#if __WORDSIZE == 64\n"
1672 "#define INTMAX_C(v) (v ## L)\n"
1673 "#define UINTMAX_C(v) (v ## UL)\n"
1674 "#else\n"
1675 "#define INTMAX_C(v) (v ## LL)\n"
1676 "#define UINTMAX_C(v) (v ## ULL)\n"
1677 "#endif";
1678 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1679 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1680 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1681 "#define UINTMAX_C(v) (v ## ULL)";
1684 /* The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
1685 C11 _Atomic keyword (exposing it to C++ code). The work-around here follows
1686 the header in declaring the entity volatile when _Atomic is not available.
1688 fix = {
1689 hackname = darwin_ucred__Atomic;
1690 mach = "*-*-darwin*";
1691 files = sys/ucred.h;
1692 select = "_Atomic";
1693 c_fix = wrap;
1694 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1695 "# define _Atomic volatile\n"
1696 "#endif\n";
1697 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1698 "# undef _Atomic\n"
1699 "#endif\n";
1700 test_text = ""; /* Don't provide this for wrap fixes. */
1704 * Fix <c_asm.h> on Digital UNIX V4.0:
1705 * It contains a prototype for a DEC C internal asm() function,
1706 * clashing with gcc's asm keyword. So protect this with __DECC.
1708 fix = {
1709 hackname = dec_intern_asm;
1710 files = c_asm.h;
1711 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1712 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1713 "#endif\n";
1714 test_text =
1715 "float fasm {\n"
1716 " ... asm stuff ...\n"
1717 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1721 * Fix typo in <wchar.h> on DJGPP 2.03.
1723 fix = {
1724 hackname = djgpp_wchar_h;
1725 file = wchar.h;
1726 select = "__DJ_wint_t";
1727 bypass = "sys/djtypes.h";
1728 c_fix = format;
1729 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1730 c_fix_arg = "#include <stddef.h>";
1731 test_text = "#include <stddef.h>\n"
1732 "extern __DJ_wint_t x;\n";
1736 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1738 fix = {
1739 hackname = ecd_cursor;
1740 files = "sunwindow/win_lock.h";
1741 files = "sunwindow/win_cursor.h";
1742 select = 'ecd\.cursor';
1743 c_fix = format;
1744 c_fix_arg = 'ecd_cursor';
1746 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1750 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1751 * that fails when compiling for SSE-less 32-bit x86.
1753 fix = {
1754 hackname = feraiseexcept_nosse_divbyzero;
1755 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1756 files = bits/fenv.h, '*/bits/fenv.h';
1757 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1758 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1759 bypass = "\"fdivp .*; fwait\"";
1761 c_fix = format;
1762 c_fix_arg = <<- _EOText_
1763 # ifdef __SSE_MATH__
1765 # else
1766 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1767 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1768 # endif
1769 _EOText_;
1771 test_text = <<- _EOText_
1772 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1773 _EOText_;
1777 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1778 * that fails when compiling for SSE-less 32-bit x86.
1780 fix = {
1781 hackname = feraiseexcept_nosse_invalid;
1782 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1783 files = bits/fenv.h, '*/bits/fenv.h';
1784 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1785 ": \"x\" \\(__f\\)\\);$";
1786 bypass = "\"fdiv .*; fwait\"";
1788 c_fix = format;
1789 c_fix_arg = <<- _EOText_
1790 # ifdef __SSE_MATH__
1792 # else
1793 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1794 %1 : "=t" (__f) : "0" (__f));
1795 # endif
1796 _EOText_;
1798 test_text = <<- _EOText_
1799 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1800 _EOText_;
1804 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1805 * neither the existence of GCC 3 nor its exact feature set yet break
1806 * (by design?) when __GNUC__ is set beyond 2.
1808 fix = {
1809 hackname = freebsd_gcc3_breakage;
1810 mach = "*-*-freebsd*";
1811 files = sys/cdefs.h;
1812 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1813 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1814 c_fix = format;
1815 c_fix_arg = '%0 || __GNUC__ >= 3';
1816 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1820 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1821 * neither the existence of GCC 4 nor its exact feature set yet break
1822 * (by design?) when __GNUC__ is set beyond 3.
1824 fix = {
1825 hackname = freebsd_gcc4_breakage;
1826 mach = "*-*-freebsd*";
1827 files = sys/cdefs.h;
1828 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1829 c_fix = format;
1830 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1831 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1835 * Some versions of glibc don't expect the C99 inline semantics.
1837 fix = {
1838 hackname = glibc_c99_inline_1;
1839 files = features.h, '*/features.h';
1840 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1841 c_fix = format;
1842 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1843 test_text = <<-EOT
1844 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1845 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1846 # define __USE_EXTERN_INLINES 1
1847 #endif
1848 EOT;
1852 * Similar, but a version that didn't have __NO_INLINE__
1854 fix = {
1855 hackname = glibc_c99_inline_1a;
1856 files = features.h, '*/features.h';
1857 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1858 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1859 c_fix = format;
1860 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1861 test_text = <<-EOT
1862 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1863 # define __USE_EXTERN_INLINES 1
1864 #endif
1865 EOT;
1869 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1870 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1871 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1873 fix = {
1874 hackname = glibc_c99_inline_2;
1875 files = sys/stat.h, '*/sys/stat.h';
1876 select = "extern __inline__ int";
1877 sed = "s/extern int \\(stat\\)/"
1878 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1879 "__inline__ int \\1/";
1880 sed = "s/extern int \\([lf]stat\\)/"
1881 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1882 "__inline__ int \\1/";
1883 sed = "s/extern int \\(mknod\\)/"
1884 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1885 "__inline__ int \\1/";
1886 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1887 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1888 "__inline__ int __REDIRECT\\1 (\\2/";
1889 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1890 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1891 "__inline__ int __REDIRECT\\1 (\\2/";
1892 sed = "s/^extern __inline__ int/"
1893 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1894 "__inline__ int/";
1895 test_text = <<-EOT
1896 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1897 extern __inline__ int
1898 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1900 EOT;
1904 * glibc_c99_inline_3
1906 fix = {
1907 hackname = glibc_c99_inline_3;
1908 files = bits/string2.h, '*/bits/string2.h';
1909 select = "extern __inline";
1910 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1911 c_fix = format;
1912 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1913 c_fix_arg = "^# ifdef __cplusplus$";
1914 test_text = <<-EOT
1915 # ifdef __cplusplus
1916 # define __STRING_INLINE inline
1917 # else
1918 # define __STRING_INLINE extern __inline
1919 # endif
1920 EOT;
1924 * glibc_c99_inline_4
1926 fix = {
1927 hackname = glibc_c99_inline_4;
1928 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1929 pthread.h, '*/pthread.h';
1930 bypass = "__extern_inline|__gnu_inline__";
1931 select = "(^| )extern __inline";
1932 c_fix = format;
1933 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1934 test_text = <<-EOT
1935 __extension__ extern __inline unsigned int
1936 extern __inline unsigned int
1937 EOT;
1940 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1941 * so we replace them with versions that correspond to the
1942 * definition.
1944 fix = {
1945 hackname = glibc_mutex_init;
1946 files = pthread.h;
1947 select = '\{ *\{ *0, *\} *\}';
1948 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1949 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1950 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1951 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1952 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1953 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1954 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1955 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1956 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1957 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1958 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1959 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1960 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1961 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1962 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1963 "N;s/^[ \t]*#[ \t]*"
1964 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1965 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1966 "# \\1\\\n"
1967 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1968 "# else\\\n"
1969 "# \\1\\\n"
1970 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1971 "# endif/";
1972 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1973 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1974 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1975 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1977 test_text = <<- _EOText_
1978 #define PTHREAD_MUTEX_INITIALIZER \\
1979 { { 0, } }
1980 #ifdef __USE_GNU
1981 # if __WORDSIZE == 64
1982 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1983 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1984 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1985 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1986 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1987 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1988 # else
1989 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1990 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1991 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1992 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1993 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1994 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1995 # endif
1996 #endif
1997 # define PTHREAD_RWLOCK_INITIALIZER \\
1998 { { 0, } }
1999 # ifdef __USE_GNU
2000 # if __WORDSIZE == 64
2001 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2002 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
2003 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2004 # else
2005 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2006 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2007 # endif
2008 # endif
2009 #define PTHREAD_COND_INITIALIZER { { 0, } }
2010 _EOText_;
2013 /* glibc versions before 2.5 have a version of stdint.h that defines
2014 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2015 versions with stdint.h based on those glibc versions. */
2016 fix = {
2017 hackname = glibc_stdint;
2018 files = stdint.h;
2019 select = "GNU C Library";
2020 c_fix = format;
2021 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2022 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2023 test_text = "/* This file is part of the GNU C Library. */\n"
2024 "# define UINT8_C(c)\tc ## U\n"
2025 "# define UINT16_C(c)\tc ## U";
2028 /* Some versions of glibc have a version of bits/string2.h that
2029 produces "value computed is not used" warnings from strncpy; fix
2030 this definition by using __builtin_strncpy instead as in newer
2031 versions. */
2032 fix = {
2033 hackname = glibc_strncpy;
2034 files = bits/string2.h, '*/bits/string2.h';
2035 bypass = "__builtin_strncpy";
2036 c_fix = format;
2037 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2038 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
2039 test_text = <<-EOT
2040 # define strncpy(dest, src, n) \
2041 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
2042 ? (strlen (src) + 1 >= ((size_t) (n)) \\
2043 ? (char *) memcpy (dest, src, n) \\
2044 : strncpy (dest, src, n)) \\
2045 : strncpy (dest, src, n)))
2046 EOT;
2050 /* glibc's tgmath.h relies on an expression that is not an integer
2051 constant expression being treated as it was by GCC 4.4 and
2052 earlier. */
2053 fix = {
2054 hackname = glibc_tgmath;
2055 files = tgmath.h;
2056 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2057 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2058 c_fix = format;
2059 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
2060 "(__builtin_classify_type ((type) 0) == 9 && "
2061 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2062 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2066 * Fix these files to use the types we think they should for
2067 * ptrdiff_t, size_t, and wchar_t.
2069 * This defines the types in terms of macros predefined by our 'cpp'.
2070 * This is supposedly necessary for glibc's handling of these types.
2071 * It's probably not necessary for anyone else, but it doesn't hurt.
2073 fix = {
2074 hackname = gnu_types;
2075 files = "sys/types.h";
2076 files = "stdlib.h";
2077 files = "sys/stdtypes.h";
2078 files = "stddef.h";
2079 files = "memory.h";
2080 files = "unistd.h";
2081 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2082 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2083 c_fix = gnu_type;
2084 /* The Solaris 10 headers already define these types correctly. */
2085 mach = '*-*-solaris2.1[0-9]*';
2086 not_machine = true;
2088 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2089 "typedef uint_t size_t; /* uint_t */\n"
2090 "typedef ushort_t wchar_t; /* ushort_t */";
2094 * Fix HP & Sony's use of "../machine/xxx.h"
2095 * to refer to: <machine/xxx.h>
2097 fix = {
2098 hackname = hp_inline;
2099 files = sys/spinlock.h;
2100 files = machine/machparam.h;
2101 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2103 c_fix = format;
2104 c_fix_arg = "%1<machine/%2.h>";
2106 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2107 '([a-z]+)\.h"';
2109 test_text = ' # include "../machine/mumble.h"';
2113 * Check for (...) in C++ code in HP/UX sys/file.h.
2115 fix = {
2116 hackname = hp_sysfile;
2117 files = sys/file.h;
2118 select = "HPUX_SOURCE";
2120 c_fix = format;
2121 c_fix_arg = "(struct file *, ...)";
2122 c_fix_arg = '\(\.\.\.\)';
2124 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2128 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2129 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2131 fix = {
2132 hackname = hppa_hpux_fp_macros;
2133 mach = "hppa*-hp-hpux11*";
2134 files = math.h;
2135 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2136 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2137 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2138 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2139 "#[ \t]*define[ \t]*FP_NAN.*\n";
2140 c_fix = format;
2141 c_fix_arg = <<- _EOFix_
2142 #endif /* _INCLUDE_HPUX_SOURCE */
2144 #if defined(_INCLUDE_HPUX_SOURCE) || \
2145 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2146 %0#endif
2148 #ifdef _INCLUDE_HPUX_SOURCE
2150 _EOFix_;
2152 test_text =
2153 "# define FP_NORMAL 0\n"
2154 "# define FP_ZERO 1\n"
2155 "# define FP_INFINITE 2\n"
2156 "# define FP_SUBNORMAL 3\n"
2157 "# define FP_NAN 4\n";
2161 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2162 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2164 fix = {
2165 hackname = hpux10_cpp_pow_inline;
2166 files = fixinc-test-limits.h, math.h;
2167 select = <<- END_POW_INLINE
2168 ^# +ifdef +__cplusplus
2170 +inline +double +pow\(double +__d,int +__expon\) +\{
2171 [ ]+return +pow\(__d,\(double\)__expon\);
2173 +extern +"C" +\{
2174 #else
2175 # +endif
2176 END_POW_INLINE;
2178 c_fix = format;
2179 c_fix_arg = "";
2181 test_text =
2182 "# ifdef __cplusplus\n"
2183 " }\n"
2184 " inline double pow(double __d,int __expon) {\n"
2185 "\t return pow(__d,(double)__expon);\n"
2186 " }\n"
2187 ' extern "C"' " {\n"
2188 "#else\n"
2189 "# endif";
2192 fix = {
2193 hackname = hpux11_cpp_pow_inline;
2194 files = math.h;
2195 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2196 " +return pow\\(d, \\(double\\)expon\\);\n"
2197 " +\\}\n";
2198 c_fix = format;
2199 c_fix_arg = "";
2201 test_text =
2202 " inline double pow(double d,int expon) {\n"
2203 " return pow(d, (double)expon);\n"
2204 " }\n";
2208 * Fix hpux 10.X missing ctype declarations 1
2210 fix = {
2211 hackname = hpux10_ctype_declarations1;
2212 files = ctype.h;
2213 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2214 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2215 c_fix = format;
2216 c_fix_arg = "#ifdef _PROTOTYPES\n"
2217 "extern int __tolower(int);\n"
2218 "extern int __toupper(int);\n"
2219 "#else /* NOT _PROTOTYPES */\n"
2220 "extern int __tolower();\n"
2221 "extern int __toupper();\n"
2222 "#endif /* _PROTOTYPES */\n\n"
2223 "%0\n";
2225 test_text = "# define _toupper(__c) __toupper(__c)\n";
2229 * Fix hpux 10.X missing ctype declarations 2
2231 fix = {
2232 hackname = hpux10_ctype_declarations2;
2233 files = ctype.h;
2234 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2235 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2236 c_fix = format;
2237 c_fix_arg = "%0\n\n"
2238 "#ifdef _PROTOTYPES\n"
2239 " extern int _isalnum(int);\n"
2240 " extern int _isalpha(int);\n"
2241 " extern int _iscntrl(int);\n"
2242 " extern int _isdigit(int);\n"
2243 " extern int _isgraph(int);\n"
2244 " extern int _islower(int);\n"
2245 " extern int _isprint(int);\n"
2246 " extern int _ispunct(int);\n"
2247 " extern int _isspace(int);\n"
2248 " extern int _isupper(int);\n"
2249 " extern int _isxdigit(int);\n"
2250 "# else /* not _PROTOTYPES */\n"
2251 " extern int _isalnum();\n"
2252 " extern int _isalpha();\n"
2253 " extern int _iscntrl();\n"
2254 " extern int _isdigit();\n"
2255 " extern int _isgraph();\n"
2256 " extern int _islower();\n"
2257 " extern int _isprint();\n"
2258 " extern int _ispunct();\n"
2259 " extern int _isspace();\n"
2260 " extern int _isupper();\n"
2261 " extern int _isxdigit();\n"
2262 "#endif /* _PROTOTYPES */\n";
2264 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2265 " extern unsigned int *__SB_masks;\n";
2269 * Fix hpux 10.X missing stdio declarations
2271 fix = {
2272 hackname = hpux10_stdio_declarations;
2273 files = stdio.h;
2274 select = "^#[ \t]*define _iob[ \t]*__iob";
2275 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2276 c_fix = format;
2277 c_fix_arg = "%0\n\n"
2278 "# if defined(__STDC__) || defined(__cplusplus)\n"
2279 " extern int snprintf(char *, size_t, const char *, ...);\n"
2280 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2281 "# else /* not __STDC__) || __cplusplus */\n"
2282 " extern int snprintf();\n"
2283 " extern int vsnprintf();\n"
2284 "# endif /* __STDC__) || __cplusplus */\n";
2286 test_text = "# define _iob __iob\n";
2290 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2291 * As a result, we need to include sys/stdsyms.h in alloca.h.
2293 fix = {
2294 hackname = hppa_hpux11_alloca;
2295 mach = "hppa*-*-hpux11*";
2296 files = alloca.h;
2297 select = "#ifndef _STDDEF_INCLUDED";
2298 c_fix = format;
2299 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2300 "# include <sys/stdsyms.h>\n"
2301 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2302 "%0";
2304 test_text = "#ifndef _STDDEF_INCLUDED";
2308 * Make sure hpux defines abs in header.
2310 fix = {
2311 hackname = hpux11_abs;
2312 mach = "*-hp-hpux11*";
2313 files = stdlib.h;
2314 select = "ifndef _MATH_INCLUDED";
2315 c_fix = format;
2316 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2317 test_text = "#ifndef _MATH_INCLUDED";
2321 * Fix hpux11 __LWP_RWLOCK_VALID define
2323 fix = {
2324 hackname = hpux11_lwp_rwlock_valid;
2325 mach = "*-hp-hpux11*";
2326 files = sys/pthread.h;
2327 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2328 c_fix = format;
2329 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2330 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2334 * hpux sendfile()
2336 fix = {
2337 hackname = hpux11_extern_sendfile;
2338 mach = "*-hp-hpux11.[12]*";
2339 files = sys/socket.h;
2340 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2341 c_fix = format;
2342 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2343 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2344 " const struct iovec *, int));\n";
2348 * hpux sendpath()
2350 fix = {
2351 hackname = hpux11_extern_sendpath;
2352 mach = "*-hp-hpux11.[12]*";
2353 files = sys/socket.h;
2354 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2355 c_fix = format;
2356 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2357 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2358 " const struct iovec *, int));\n";
2362 * Keep HP-UX 11 from stomping on C++ math namespace
2363 * with defines for fabsf.
2365 fix = {
2366 hackname = hpux11_fabsf;
2367 mach = "*-hp-hpux11*";
2368 files = math.h;
2369 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2371 c_fix = format;
2372 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2374 test_text =
2375 "#ifdef _PA_RISC\n"
2376 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2377 "#endif";
2381 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2382 * in pthread.h need to be constant expressions to be standard complient.
2383 * As a result, we need to remove the void * casts in the initializers
2384 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2385 * to use the long type.
2387 fix = {
2388 hackname = hpux11_pthread_pointer;
2389 mach = "*-hp-hpux11.[0-3]*";
2390 files = sys/pthread.h;
2391 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2393 c_fix = format;
2394 c_fix_arg = "long\t%2%3";
2395 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2399 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2401 fix = {
2402 hackname = hpux11_pthread_const;
2403 mach = "*-hp-hpux11.[0-3]*";
2404 files = sys/pthread.h;
2405 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2407 c_fix = format;
2408 c_fix_arg = "%11";
2409 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2413 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2414 * being defined by having it define _hpux_size_t instead.
2416 fix = {
2417 hackname = hpux11_size_t;
2418 mach = "*-hp-hpux11*";
2419 select = "__size_t";
2421 c_fix = format;
2422 c_fix_arg = "_hpux_size_t";
2424 test_text =
2425 "#define __size_t size_t\n"
2426 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2430 * Fix hpux 11.00 broken snprintf declaration
2431 * (third argument is char *, needs to be const char * to prevent
2432 * spurious warnings with -Wwrite-strings or in C++).
2434 fix = {
2435 hackname = hpux11_snprintf;
2436 files = stdio.h;
2437 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2438 ' *(char *\*, *\.\.\.\);)';
2439 c_fix = format;
2440 c_fix_arg = '%1 const %3';
2442 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2443 "extern int snprintf(char *, __size_t, char *, ...);\n"
2444 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2448 * Fix hpux 11.00 broken vsnprintf declaration
2450 fix = {
2451 hackname = hpux11_vsnprintf;
2452 files = stdio.h;
2453 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2454 'const char \*,) __va__list\);';
2455 c_fix = format;
2456 c_fix_arg = "%1 __va_list);";
2458 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2459 ' __va__list);';
2463 * Fix missing const in hpux vsscanf declaration
2465 fix = {
2466 hackname = hpux_vsscanf;
2467 mach = "*-*-hpux*";
2468 files = stdio.h;
2469 select = '(extern int vsscanf\()char';
2470 c_fix = format;
2471 c_fix_arg = "%1const char";
2473 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2477 * get rid of bogus inline definitions in HP-UX 8.0
2479 fix = {
2480 hackname = hpux8_bogus_inlines;
2481 files = math.h;
2482 select = inline;
2483 bypass = "__GNUG__";
2484 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2485 "@extern \"C\" int abs(int);@";
2486 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2487 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2488 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2489 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2490 "inline double sqr(double v) { return v**0.5; }";
2494 * hpux intptr
2496 fix = {
2497 hackname = hpux_c99_intptr;
2498 mach = "*-hp-hpux11.3*";
2499 files = stdint-hpux11.h, stdint.h;
2500 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2501 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2502 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2503 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2504 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2505 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2506 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2507 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2508 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2509 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2510 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2511 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2512 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2513 "#define PTRDIFF_MIN INT32_MIN\n"
2514 "#define INTPTR_MAX INT32_MAX\n"
2515 "#define INTPTR_MIN INT32_MIN\n"
2516 "#define UINTPTR_MAX UINT32_MAX\n"
2517 "#define SIZE_MAX UINT32_MAX\n";
2521 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2523 fix = {
2524 hackname = hpux_c99_inttypes;
2525 mach = "*-hp-hpux11.[23]*";
2526 files = inttypes.h;
2527 files = stdint-hpux11.h, stdint.h;
2528 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2529 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2530 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2531 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2532 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2533 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2534 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2535 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2536 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2537 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2538 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2539 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2543 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2545 fix = {
2546 hackname = hpux_c99_inttypes2;
2547 mach = "*-hp-hpux11.2*";
2548 files = stdint-hpux11.h, stdint.h;
2549 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2550 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2551 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2552 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2553 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2554 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2555 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2556 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2557 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2558 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2559 "# define INT16_C(__c) ((short)(__c))\n"
2560 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2564 * Fix hpux broken ctype macros
2566 fix = {
2567 hackname = hpux_ctype_macros;
2568 files = ctype.h;
2569 select = '((: |\()__SB_masks \? )'
2570 '(__SB_masks\[__(alnum|c)\] & _IS)';
2571 c_fix = format;
2572 c_fix_arg = "%1(int)%3";
2574 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2575 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2579 * hpux errno()
2581 fix = {
2582 hackname = hpux_extern_errno;
2583 mach = "*-hp-hpux10.*";
2584 mach = "*-hp-hpux11.[0-2]*";
2585 files = errno.h;
2586 select = "^[ \t]*extern int errno;$";
2587 c_fix = format;
2588 c_fix_arg = "#ifdef __cplusplus\n"
2589 "extern \"C\" {\n"
2590 "#endif\n"
2591 "%0\n"
2592 "#ifdef __cplusplus\n"
2593 "}\n"
2594 "#endif";
2595 test_text = " extern int errno;\n";
2599 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2601 fix = {
2602 hackname = hpux_htonl;
2603 files = netinet/in.h;
2604 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2605 "(/\\*\n"
2606 " \\* Macros for number representation conversion\\.\n"
2607 " \\*/\n"
2608 "#ifndef ntohl)";
2609 c_fix = format;
2610 c_fix_arg = "#if 1\n%1";
2612 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2613 "/*\n"
2614 " * Macros for number representation conversion.\n"
2615 " */\n"
2616 "#ifndef ntohl\n"
2617 "#define ntohl(x) (x)\n"
2618 "#define ntohs(x) (x)\n"
2619 "#define htonl(x) (x)\n"
2620 "#define htons(x) (x)\n"
2621 "#endif\n"
2622 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2626 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2628 fix = {
2629 hackname = hpux_imaginary_i;
2630 mach = "ia64-hp-hpux11.*";
2631 files = complex.h;
2632 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2633 c_fix = format;
2634 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2635 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2639 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2641 fix = {
2642 hackname = hpux_inttype_int8_t;
2643 mach = "*-hp-hpux1[01].*";
2644 files = sys/_inttypes.h;
2645 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2646 c_fix = format;
2647 c_fix_arg = "typedef signed char int%18_t;";
2648 test_text = "typedef char int_least8_t;\n"
2649 "typedef char int8_t;\n";
2653 * HP-UX long_double
2655 fix = {
2656 hackname = hpux_long_double;
2657 mach = "*-*-hpux10*";
2658 mach = "*-*-hpux11.[012]*";
2659 files = stdlib.h;
2660 select = "extern[ \t]long_double[ \t]strtold";
2661 bypass = "long_double_t";
2662 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2663 sed = "s/long_double/long double/g";
2665 test_text = "# ifndef _LONG_DOUBLE\n"
2666 "# define _LONG_DOUBLE\n"
2667 " typedef struct {\n"
2668 " unsigned int word1, word2, word3, word4;\n"
2669 " } long_double;\n"
2670 "# endif /* _LONG_DOUBLE */\n"
2671 "extern long_double strtold(const char *, char **);\n";
2675 * We cannot use the above rule on 11.31 because it removes the strtold
2676 * definition. ia64 is OK with no hack, PA needs some help.
2678 fix = {
2679 hackname = hpux_long_double_2;
2680 mach = "hppa*-*-hpux11.3*";
2681 files = stdlib.h;
2682 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2683 "defined\\(_PROTOTYPES\\) \\|\\| "
2684 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2685 c_fix = format;
2686 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2688 test_text = "# if !defined(__ia64) || "
2689 "!defined(_PROTOTYPES) || "
2690 "defined(_LONG_DOUBLE_STRUCT)\n";
2694 * Add missing braces to pthread initializer defines.
2696 fix = {
2697 hackname = hpux_pthread_initializers;
2698 mach = "*-hp-hpux11.[0-3]*";
2699 files = sys/pthread.h;
2700 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2701 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2702 sed = "s@^[ \t]*1,[ \t]*\\\\"
2703 "@\t{ 1, 0 }@";
2704 sed = "/^[ \t]*0$/d";
2705 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2706 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2707 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2708 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2709 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2710 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2711 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2712 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2713 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2714 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2715 sed = "s@__PTHREAD_COND_VALID, 0"
2716 "@{ __PTHREAD_COND_VALID, 0 }@";
2717 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2718 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2719 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2720 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2721 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2722 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2723 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2724 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2725 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2726 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2727 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2728 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2729 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2730 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2731 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2732 "}\n";
2736 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2737 * type and mpinfou is only defined when _KERNEL is set.
2739 fix = {
2740 hackname = hpux_spu_info;
2741 mach = "*-hp-hpux*";
2743 * It is tempting to omit the first "files" entry. Do not.
2744 * The testing machinery will take the first "files" entry as the name
2745 * of a test file to play with. It would be a nuisance to have a directory
2746 * with the name "*".
2748 files = "ia64/sys/getppdp.h";
2749 files = "*/sys/getppdp.h";
2750 select = "^.*extern.*spu_info.*";
2752 c_fix = format;
2753 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2755 test_text = "extern union mpinfou spu_info[];";
2759 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2761 fix = {
2762 hackname = hpux_stdint_least_fast;
2763 mach = "*-hp-hpux11.2*";
2764 files = stdint-hpux11.h, stdint.h;
2765 select =
2766 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2767 c_fix = format;
2768 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2769 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2770 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2774 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2776 fix = {
2777 hackname = hpux_longjmp;
2778 mach = "*-hp-hpux*";
2779 files = setjmp.h;
2780 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2782 c_fix = format;
2783 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2785 test_text = 'extern void longjmp __((jmp_buf, int));';
2789 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2791 fix = {
2792 hackname = hpux_systime;
2793 files = sys/time.h;
2794 select = "^extern struct sigevent;";
2796 c_fix = format;
2797 c_fix_arg = "struct sigevent;";
2799 test_text = 'extern struct sigevent;';
2803 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2805 fix = {
2806 hackname = huge_val_hex;
2807 files = bits/huge_val.h, '*/bits/huge_val.h';
2808 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2809 bypass = "__builtin_huge_val";
2811 c_fix = format;
2812 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2814 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2818 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2820 fix = {
2821 hackname = huge_valf_hex;
2822 files = bits/huge_val.h, '*/bits/huge_val.h';
2823 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2824 bypass = "__builtin_huge_valf";
2826 c_fix = format;
2827 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2829 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2833 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2835 fix = {
2836 hackname = huge_vall_hex;
2837 files = bits/huge_val.h, '*/bits/huge_val.h';
2838 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2839 bypass = "__builtin_huge_vall";
2841 c_fix = format;
2842 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2844 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2848 * Fix return type of abort and free
2850 fix = {
2851 hackname = int_abort_free_and_exit;
2852 files = stdlib.h;
2853 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2854 bypass = "_CLASSIC_ANSI_TYPES";
2856 c_fix = format;
2857 c_fix_arg = "void\t%1(";
2859 test_text = "extern int abort(int);\n"
2860 "extern int free(void*);\n"
2861 "extern int exit(void*);";
2865 * Fix various macros used to define ioctl numbers.
2866 * The traditional syntax was:
2868 * #define _IO(n, x) (('n'<<8)+x)
2869 * #define TIOCFOO _IO(T, 1)
2871 * but this does not work with the C standard, which disallows macro
2872 * expansion inside strings. We have to rewrite it thus:
2874 * #define _IO(n, x) ((n<<8)+x)
2875 * #define TIOCFOO _IO('T', 1)
2877 * The select expressions match too much, but the c_fix code is cautious.
2879 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2881 fix = {
2882 hackname = io_quotes_def;
2883 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2884 c_fix = char_macro_def;
2885 c_fix_arg = "IO";
2886 test_text =
2887 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2888 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2889 "#define _IO(x,y) ('x'<<8|y)";
2890 test_text =
2891 "#define XX_IO(x) ('x'<<8|256)";
2895 * Fix the usage of the ioctl macro numbers.
2897 fix = {
2898 hackname = io_quotes_use;
2899 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2900 "\\( *[^,']";
2901 c_fix = char_macro_use;
2902 c_fix_arg = "IO";
2903 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2904 "#define TIOCFOO \\\\\n"
2905 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2909 * Check for missing ';' in struct
2911 fix = {
2912 hackname = ip_missing_semi;
2913 files = netinet/ip.h;
2914 select = "}$";
2915 sed = "/^struct/,/^};/s/}$/};/";
2916 test_text=
2917 "struct mumble {\n"
2918 " union {\n"
2919 " int x;\n"
2920 " }\n"
2921 "}; /* mumbled struct */\n";
2925 * Non-traditional "const" declaration in Irix's limits.h.
2927 fix = {
2928 hackname = irix_limits_const;
2929 files = fixinc-test-limits.h, limits.h;
2930 select = "^extern const ";
2931 c_fix = format;
2932 c_fix_arg = "extern __const ";
2933 test_text = "extern const char limit; /* test limits */";
2937 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2938 * taking char *. However, GCC uses void * for va_list, so
2939 * calling vfprintf with a va_list fails in C++. */
2940 fix = {
2941 hackname = irix_stdio_va_list;
2942 files = stdio.h;
2944 select = '/\* va_list \*/ char \*';
2945 c_fix = format;
2946 c_fix_arg = "__gnuc_va_list";
2947 test_text =
2948 "extern int printf( const char *, /* va_list */ char * );";
2952 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2953 * use / * * / to concatenate tokens.
2955 fix = {
2956 hackname = kandr_concat;
2957 files = "sparc/asm_linkage.h";
2958 files = "sun*/asm_linkage.h";
2959 files = "arm/as_support.h";
2960 files = "arm/mc_type.h";
2961 files = "arm/xcb.h";
2962 files = "dev/chardefmac.h";
2963 files = "dev/ps_irq.h";
2964 files = "dev/screen.h";
2965 files = "dev/scsi.h";
2966 files = "sys/tty.h";
2967 files = "Xm.acorn/XmP.h";
2968 files = bsd43/bsd43_.h;
2969 select = '/\*\*/';
2970 c_fix = format;
2971 c_fix_arg = '##';
2972 test_text = "#define __CONCAT__(a,b) a/**/b";
2976 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2977 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2978 * constant on recent versions of g++.
2980 fix = {
2981 hackname = linux_ia64_ucontext;
2982 files = "sys/ucontext.h";
2983 mach = "ia64-*-linux*";
2984 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2985 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2986 c_fix = format;
2987 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2988 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2989 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2993 * Remove header file warning from sys/time.h. Autoconf's
2994 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2995 * which causes warning on LynxOS. Remove the warning.
2997 fix = {
2998 hackname = lynxos_no_warning_in_sys_time_h;
2999 files = sys/time.h;
3000 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
3001 c_fix = format;
3002 c_fix_arg = "";
3003 test_text = "#warning Using <time.h> instead of <sys/time.h>";
3007 * Add missing declaration for putenv.
3009 fix = {
3010 hackname = lynxos_missing_putenv;
3011 mach = '*-*-lynxos*';
3012 files = stdlib.h;
3013 bypass = 'putenv[ \t]*\\(';
3014 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3015 c_fix = format;
3016 c_fix_arg = "%0\n"
3017 "extern int putenv _AP((char *));";
3018 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3019 test_text = "extern char *getenv _AP((const char *));";
3023 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3025 * On NetBSD, machine is a symbolic link to an architecture specific
3026 * directory name, so we can't match a specific file name here.
3028 fix = {
3029 hackname = machine_ansi_h_va_list;
3030 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
3031 bypass = '__builtin_va_list';
3033 c_fix = format;
3034 c_fix_arg = "%1__builtin_va_list";
3035 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3037 test_text = " # define _BSD_VA_LIST_\tchar**";
3041 * Fix non-ansi machine name defines
3043 fix = {
3044 hackname = machine_name;
3045 c_test = machine_name;
3046 c_fix = machine_name;
3048 test_text = "/* MACH_DIFF: */\n"
3049 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
3050 "\n/* no uniform test, so be careful :-) */";
3054 * Some math.h files define struct exception (it's in the System V
3055 * Interface Definition), which conflicts with the class exception defined
3056 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
3057 * This is not a great fix, but I haven't been able to think of anything
3058 * better.
3060 fix = {
3061 hackname = math_exception;
3062 files = math.h;
3063 select = "struct exception";
3065 * This should be bypassed on __cplusplus, but some supposedly C++
3066 * aware headers, such as Solaris 8 and 9, don't wrap their struct
3067 * exception either. So currently we bypass only for glibc, based on a
3068 * comment in the fixed glibc header. Ick.
3070 bypass = 'We have a problem when using C\+\+|for C\+\+, '
3071 '_[a-z0-9A-Z_]+_exception; for C, exception';
3072 /* The Solaris 10 headers already get this right. */
3073 mach = '*-*-solaris2.1[0-9]*';
3074 not_machine = true;
3075 c_fix = wrap;
3077 c_fix_arg = "#ifdef __cplusplus\n"
3078 "#define exception __math_exception\n"
3079 "#endif\n";
3081 c_fix_arg = "#ifdef __cplusplus\n"
3082 "#undef exception\n"
3083 "#endif\n";
3085 test_text = "typedef struct exception t_math_exception;";
3089 * This looks pretty broken to me. ``dbl_max_def'' will contain
3090 * "define DBL_MAX " at the start, when what we really want is just
3091 * the value portion. Can't figure out how to write a test case
3092 * for this either :-(
3094 fix = {
3095 hackname = math_huge_val_from_dbl_max;
3096 files = math.h;
3099 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3100 * in math.h, this fix applies.
3102 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3103 bypass = "define[ \t]+DBL_MAX";
3105 shell =
3107 * See if we have a definition for DBL_MAX in float.h.
3108 * If we do, we will replace the one in math.h with that one.
3111 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3112 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3114 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3115 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3116 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3117 "\telse cat\n"
3118 "\tfi";
3120 test_text =
3121 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3122 "#define HUGE_VAL DBL_MAX";
3126 * nested comment
3128 fix = {
3129 hackname = nested_auth_des;
3130 files = rpc/rpc.h;
3131 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3132 c_fix = format;
3133 c_fix_arg = "%1*/ /*";
3134 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3138 * Some versions of NetBSD don't expect the C99 inline semantics.
3140 fix = {
3141 hackname = netbsd_c99_inline_1;
3142 mach = "*-*-netbsd*";
3143 files = signal.h;
3144 select = "extern __inline int";
3146 c_fix = format;
3147 c_fix_arg = "extern\n"
3148 "#ifdef __GNUC_STDC_INLINE__\n"
3149 "__attribute__((__gnu_inline__))\n"
3150 "#endif\n"
3151 "__inline int";
3153 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3157 * netbsd_c99_inline_2
3159 fix = {
3160 hackname = netbsd_c99_inline_2;
3161 mach = "*-*-netbsd*";
3162 files = signal.h;
3163 select = "#define _SIGINLINE extern __inline";
3165 c_fix = format;
3166 c_fix_arg = <<- _EOArg_
3167 #ifdef __GNUC_STDC_INLINE__
3168 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3169 #else
3171 #endif
3172 _EOArg_;
3174 test_text = "#define _SIGINLINE extern __inline";
3178 * NetBSD has a semicolon after the ending '}' for some extern "C".
3180 fix = {
3181 hackname = netbsd_extra_semicolon;
3182 mach = "*-*-netbsd*";
3183 files = sys/cdefs.h;
3184 select = "#define[ \t]*__END_DECLS[ \t]*};";
3186 c_fix = format;
3187 c_fix_arg = "#define __END_DECLS }";
3189 test_text = "#define __END_DECLS };";
3193 * newlib's stdint.h has several failures to conform to C99. The fix
3194 * for these removed a comment that can be matched to identify unfixed
3195 * versions.
3197 fix = {
3198 hackname = newlib_stdint_1;
3199 files = stdint-newlib.h, stdint.h;
3200 select = "@todo - Add support for wint_t types";
3201 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3202 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3203 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3204 sed = "s@#define INT_LEAST32_MIN.*@"
3205 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3206 sed = "s@#define INT_LEAST32_MAX.*@"
3207 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3208 sed = "s@#define UINT_LEAST32_MAX.*@"
3209 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3210 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3211 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3212 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3213 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3214 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3215 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3216 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3217 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3218 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3219 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3220 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3221 test_text = "/* @todo - Add support for wint_t types. */\n"
3222 "#define INT32_MIN (-2147483647-1)\n"
3223 "#define INT32_MAX 2147483647\n"
3224 "#define UINT32_MAX 4294967295U\n"
3225 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3226 "#define INT_LEAST32_MAX 2147483647\n"
3227 "#define UINT_LEAST32_MAX 4294967295U\n"
3228 "#define INT_FAST8_MIN INT8_MIN\n"
3229 "#define INT_FAST8_MAX INT8_MAX\n"
3230 "#define UINT_FAST8_MAX UINT8_MAX\n"
3231 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3232 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3233 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3234 "#define UINT8_C(x) x##U\n"
3235 "#define UINT16_C(x) x##U";
3239 * newlib_stdint_2
3241 fix = {
3242 hackname = newlib_stdint_2;
3243 files = stdint-newlib.h, stdint.h;
3244 select = "@todo - Add support for wint_t types";
3245 c_fix = format;
3246 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3247 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3248 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3249 "#define WCHAR_MAX __WCHAR_MAX__\n"
3250 "#define WCHAR_MIN __WCHAR_MIN__\n"
3251 "#define WINT_MAX __WINT_MAX__\n"
3252 "#define WINT_MIN __WINT_MIN__\n\n"
3253 "%0";
3254 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3255 test_text = "/* @todo - Add support for wint_t types. */\n"
3256 "/** Macros for minimum-width integer constant expressions */";
3260 * NeXT 3.2 adds const prefix to some math functions.
3261 * These conflict with the built-in functions.
3263 fix = {
3264 hackname = next_math_prefix;
3265 files = ansi/math.h;
3266 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3268 c_fix = format;
3269 c_fix_arg = "extern double %1(";
3270 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3272 test_text = "extern\tdouble\t__const__\tmumble();";
3276 * NeXT 3.2 uses the word "template" as a parameter for some
3277 * functions. GCC reports an invalid use of a reserved key word
3278 * with the built-in functions.
3280 fix = {
3281 hackname = next_template;
3282 files = bsd/libc.h;
3283 select = "[ \t]template\\)";
3285 c_fix = format;
3286 c_fix_arg = "(%1)";
3287 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3288 test_text = "extern mumble( char * template); /* fix */";
3292 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3293 * function prototypes. That conflicts with the built-in functions.
3295 fix = {
3296 hackname = next_volitile;
3297 files = ansi/stdlib.h;
3298 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3300 c_fix = format;
3301 c_fix_arg = "extern void %1(";
3302 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3304 test_text = "extern\tvolatile\tvoid\tabort();";
3308 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3309 * Note that version 3 of the NeXT system has wait.h in a different directory,
3310 * so that this code won't do anything. But wait.h in version 3 has a
3311 * conditional, so it doesn't need this fix. So everything is okay.
3313 fix = {
3314 hackname = next_wait_union;
3315 files = sys/wait.h;
3317 select = 'wait\(union wait';
3318 c_fix = format;
3319 c_fix_arg = "wait(void";
3320 test_text = "extern pid_d wait(union wait*);";
3324 * a missing semi-colon at the end of the nodeent structure definition.
3326 fix = {
3327 hackname = nodeent_syntax;
3328 files = netdnet/dnetdb.h;
3329 select = "char[ \t]*\\*na_addr[ \t]*$";
3330 c_fix = format;
3331 c_fix_arg = "%0;";
3332 test_text = "char *na_addr\t";
3336 * Fix OpenBSD's NULL definition.
3338 fix = {
3339 hackname = openbsd_null_definition;
3340 mach = "*-*-openbsd*";
3341 files = locale.h, stddef.h, stdio.h, string.h,
3342 time.h, unistd.h, wchar.h, sys/param.h;
3343 select = "__GNUG__";
3344 c_fix = format;
3345 c_fix_arg = "#ifndef NULL\n"
3346 "#ifdef __cplusplus\n"
3347 "#ifdef __GNUG__\n"
3348 "#define NULL\t__null\n"
3349 "#else\t /* ! __GNUG__ */\n"
3350 "#define NULL\t0L\n"
3351 "#endif\t /* __GNUG__ */\n"
3352 "#else\t /* ! __cplusplus */\n"
3353 "#define NULL\t((void *)0)\n"
3354 "#endif\t /* __cplusplus */\n"
3355 "#endif\t /* !NULL */";
3357 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3358 "^#ifdef[ \t]*__GNUG__\n"
3359 "^#define[ \t]*NULL[ \t]*__null\n"
3360 "^#else\n"
3361 "^#define[ \t]*NULL[ \t]*0L\n"
3362 "^#endif\n"
3363 "^#endif";
3364 test_text =
3365 "#ifndef NULL\n"
3366 "#ifdef __GNUG__\n"
3367 "#define NULL __null\n"
3368 "#else\n"
3369 "#define NULL 0L\n"
3370 "#endif\n"
3371 "#endif\n";
3375 * obstack.h used casts as lvalues.
3377 * We need to change postincrements of casted pointers (which are
3378 * then dereferenced and assigned into) of the form
3380 * *((TYPE*)PTRVAR)++ = (VALUE)
3382 * into expressions like
3384 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3386 * which is correct for the cases used in obstack.h since PTRVAR is
3387 * of type char * and the value of the expression is not used.
3389 fix = {
3390 hackname = obstack_lvalue_cast;
3391 files = obstack.h;
3392 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3393 c_fix = format;
3394 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3395 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3399 * Fix OpenBSD's va_start define.
3401 fix = {
3402 hackname = openbsd_va_start;
3403 mach = "*-*-openbsd*";
3404 files = stdarg.h;
3405 select = '__builtin_stdarg_start';
3406 c_fix = format;
3407 c_fix_arg = __builtin_va_start;
3409 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3413 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3414 * defining regex.h related types. This causes libg++ build and usage
3415 * failures. Fixing this correctly requires checking and modifying 3 files.
3417 fix = {
3418 hackname = osf_namespace_a;
3419 files = reg_types.h;
3420 files = sys/lc_core.h;
3421 test = " -r reg_types.h";
3422 test = " -r sys/lc_core.h";
3423 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3424 test = " -z \"`grep __regex_t regex.h`\"";
3426 c_fix = format;
3427 c_fix_arg = "__%0";
3428 c_fix_arg = "reg(ex|off|match)_t";
3430 test_text = "`touch sys/lc_core.h`"
3431 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3432 "extern regex_t re;\n"
3433 "extern regoff_t ro;\n"
3434 "extern regmatch_t rm;\n";
3437 fix = {
3438 hackname = osf_namespace_c;
3439 files = regex.h;
3440 test = " -r reg_types.h";
3441 test = " -r sys/lc_core.h";
3442 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3443 test = " -z \"`grep __regex_t regex.h`\"";
3445 select = "#include <reg_types\.h>.*";
3446 c_fix = format;
3447 c_fix_arg = "%0\n"
3448 "typedef __regex_t\tregex_t;\n"
3449 "typedef __regoff_t\tregoff_t;\n"
3450 "typedef __regmatch_t\tregmatch_t;";
3452 test_text = "#include <reg_types.h>";
3456 * On broken glibc-2.3.3 systems an array of incomplete structures is
3457 * passed to __sigsetjmp. Fix that to take a pointer instead.
3459 fix = {
3460 hackname = pthread_incomplete_struct_argument;
3461 files = pthread.h;
3462 select = "struct __jmp_buf_tag";
3463 c_fix = format;
3464 c_fix_arg = "%1 *%2%3";
3465 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3466 "(__env)\\[1\\](.*)$";
3467 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3468 "int __savemask);";
3472 * Fix return type of fread and fwrite on sysV68
3474 fix = {
3475 hackname = read_ret_type;
3476 files = stdio.h;
3477 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3478 c_fix = format;
3479 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3480 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3482 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3486 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3488 fix = {
3489 hackname = rpc_xdr_lvalue_cast_a;
3490 files = rpc/xdr.h;
3491 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3492 c_fix = format;
3493 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3494 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3495 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3499 * rpc_xdr_lvalue_cast_b
3501 fix = {
3502 hackname = rpc_xdr_lvalue_cast_b;
3503 files = rpc/xdr.h;
3504 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3505 c_fix = format;
3506 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3507 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3508 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3512 * function class(double x) conflicts with C++ keyword on rs/6000
3514 fix = {
3515 hackname = rs6000_double;
3516 files = math.h;
3517 select = '[^a-zA-Z_]class\(';
3519 c_fix = format;
3520 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3521 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3523 test_text = "extern int class();";
3527 * Wrong fchmod prototype on RS/6000.
3529 fix = {
3530 hackname = rs6000_fchmod;
3531 files = sys/stat.h;
3532 select = 'fchmod\(char \*';
3533 c_fix = format;
3534 c_fix_arg = "fchmod(int";
3535 test_text = "extern int fchmod(char *, mode_t);";
3539 * parameters conflict with C++ new on rs/6000
3541 fix = {
3542 hackname = rs6000_param;
3543 files = "stdio.h";
3544 files = "unistd.h";
3546 select = 'rename\(const char \*old, const char \*new\)';
3547 c_fix = format;
3548 c_fix_arg = 'rename(const char *_old, const char *_new)';
3550 test_text = 'extern int rename(const char *old, const char *new);';
3554 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3555 * for C99. This is wrong for C++, which needs many C99 features, but
3556 * only supports __restrict.
3558 fix = {
3559 hackname = solaris___restrict;
3560 files = sys/feature_tests.h;
3561 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3562 mach = "*-*-solaris2*";
3563 c_fix = format;
3564 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3565 "#else\n%0\n#endif";
3566 test_text = "#define _RESTRICT_KYWD restrict";
3570 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3571 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3572 * and imaginary definitions which are not supported by GCC.
3574 fix = {
3575 hackname = solaris_complex;
3576 mach = "*-*-solaris2.*";
3577 files = complex.h;
3578 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3579 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3580 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3581 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3582 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3583 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3584 test_text = "#define _Complex_I _Complex_I\n"
3585 "#define complex _Complex\n"
3586 "#define _Imaginary_I _Imaginary_I\n"
3587 "#define imaginary _Imaginary\n"
3588 "#undef I\n"
3589 "#define I _Imaginary_I";
3593 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3594 * extern "C" instead so libstdc++ can use it.
3596 fix = {
3597 hackname = solaris_complex_cxx;
3598 mach = "*-*-solaris2.*";
3599 files = complex.h;
3600 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3601 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3602 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3603 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3604 test_text = "#if !defined(__cplusplus)\n"
3605 "#endif /* !defined(__cplusplus) */";
3609 * g++ rejects functions declared with both C and C++ linkage.
3611 fix = {
3612 hackname = solaris_cxx_linkage;
3613 mach = '*-*-solaris2*';
3614 files = "iso/stdlib_iso.h";
3615 select = "(#if __cplusplus >= 199711L)\n"
3616 "(extern \"C\\+\\+\" \\{\n)"
3617 "(.*(bsearch|qsort).*)";
3618 c_fix = format;
3619 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3621 test_text =
3622 "#if __cplusplus >= 199711L\n"
3623 "extern \"C++\" {\n"
3624 " void *bsearch(const void *, const void *, size_t, size_t,";
3628 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3629 * _STRICT_STDC, but uses it.
3631 fix = {
3632 hackname = solaris_getc_strict_stdc;
3633 mach = "*-*-solaris2*";
3634 files = "iso/stdio_iso.h";
3635 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3636 c_fix = format;
3637 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3639 test_text =
3640 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3644 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3646 fix = {
3647 hackname = solaris_gets_c11;
3648 mach = "*-*-solaris2*";
3649 files = "iso/stdio_iso.h";
3650 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3652 c_fix = format;
3653 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3654 "%1 __attribute__((__deprecated__));\n"
3655 "#endif";
3657 test_text = "extern char *gets(char *);";
3661 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3663 fix = {
3664 hackname = solaris_gets_cxx14;
3665 mach = "*-*-solaris2*";
3666 files = "iso/stdio_iso.h";
3667 select = <<- _EOSelect_
3668 (#if __STDC_VERSION__ < 201112L)
3669 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3670 _EOSelect_;
3671 c_fix = format;
3672 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3674 test_text = <<- _EOText_
3675 #if __STDC_VERSION__ < 201112L
3676 extern char *gets(char *) __ATTR_DEPRECATED;
3677 _EOText_;
3681 * Sun Solaris 2 has a version of sys/int_const.h that defines
3682 * UINT8_C and UINT16_C to unsigned constants.
3684 fix = {
3685 hackname = solaris_int_const;
3686 files = sys/int_const.h;
3687 mach = '*-*-solaris2*';
3688 c_fix = format;
3689 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3690 "%1\n"
3691 "#define\tUINT16_C(c)\t(c)";
3692 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3693 "(/\*.*\*/)\n"
3694 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3695 test_text =
3696 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3697 "/* CSTYLED */\n"
3698 "#define UINT16_C(c) __CONCAT__(c,u)";
3702 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3703 * UINT8_MAX and UINT16_MAX to unsigned constants.
3705 fix = {
3706 hackname = solaris_int_limits_1;
3707 files = sys/int_limits.h;
3708 mach = '*-*-solaris2*';
3709 c_fix = format;
3710 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3711 "#define\tUINT16_MAX\t(65535)";
3712 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3713 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3714 test_text =
3715 "#define UINT8_MAX (255U)\n"
3716 "#define UINT16_MAX (65535U)";
3720 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3721 * INT_FAST16 limits to wrong values for sys/int_types.h.
3723 fix = {
3724 hackname = solaris_int_limits_2;
3725 files = sys/int_limits.h;
3726 mach = '*-*-solaris2*';
3727 c_fix = format;
3728 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3729 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3730 test_text =
3731 "#define INT_FAST16_MAX INT16_MAX\n"
3732 "#define UINT_FAST16_MAX UINT16_MAX\n"
3733 "#define INT_FAST16_MIN INT16_MIN";
3737 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3738 * SIZE_MAX as unsigned long.
3740 fix = {
3741 hackname = solaris_int_limits_3;
3742 files = sys/int_limits.h;
3743 mach = '*-*-solaris2*';
3744 c_fix = format;
3745 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3746 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3747 test_text =
3748 "#define SIZE_MAX 4294967295UL";
3752 * Sun Solaris 10 defines several C99 math macros in terms of
3753 * builtins specific to the Studio compiler, in particular not
3754 * compatible with the GNU compiler.
3756 fix = {
3757 hackname = solaris_math_1;
3758 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3759 bypass = "__GNUC__";
3760 files = iso/math_c99.h;
3761 c_fix = format;
3762 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3763 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3764 test_text =
3765 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3766 "#undef HUGE_VAL\n"
3767 "#define HUGE_VAL __builtin_huge_val\n"
3768 "#undef HUGE_VALF\n"
3769 "#define HUGE_VALF __builtin_huge_valf\n"
3770 "#undef HUGE_VALL\n"
3771 "#define HUGE_VALL __builtin_huge_vall";
3775 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3776 * exception. Provide an alternative using GCC's builtin.
3778 fix = {
3779 hackname = solaris_math_10;
3780 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3781 files = iso/math_c99.h;
3782 c_fix = format;
3783 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3784 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3785 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3786 "[ \t]*\\\\\n"
3787 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3788 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3789 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3790 "\\(-INFINITY\\);[ \t]*\\}\\)";
3791 test_text =
3792 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3793 "#undef isinf\n"
3794 "#define isinf(x) __extension__( \\\\\n"
3795 " { __typeof(x) __x_i = (x); \\\\\n"
3796 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3797 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3801 * Solaris math INFINITY
3803 fix = {
3804 hackname = solaris_math_2;
3805 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3806 bypass = "__GNUC__";
3807 files = iso/math_c99.h;
3808 c_fix = format;
3809 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3810 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3811 test_text =
3812 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3813 "#undef INFINITY\n"
3814 "#define INFINITY __builtin_infinity";
3818 * Solaris math NAN
3820 fix = {
3821 hackname = solaris_math_3;
3822 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3823 bypass = "__GNUC__";
3824 files = iso/math_c99.h;
3825 c_fix = format;
3826 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3827 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3828 test_text =
3829 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3830 "#undef NAN\n"
3831 "#define NAN __builtin_nan";
3835 * Solaris math fpclassify
3837 fix = {
3838 hackname = solaris_math_4;
3839 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3840 bypass = "__GNUC__";
3841 files = iso/math_c99.h;
3842 c_fix = format;
3843 c_fix_arg = "#define\tfpclassify(x) \\\n"
3844 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3845 "FP_SUBNORMAL, FP_ZERO, (x))";
3846 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3847 test_text =
3848 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3849 "#undef fpclassify\n"
3850 "#define fpclassify(x) __builtin_fpclassify(x)";
3854 * Solaris math signbit
3856 fix = {
3857 hackname = solaris_math_8;
3858 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3859 bypass = "__GNUC__";
3860 files = iso/math_c99.h;
3861 c_fix = format;
3862 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3863 "\t\t\t ? __builtin_signbitf(x) \\\n"
3864 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3865 "\t\t\t ? __builtin_signbitl(x) \\\n"
3866 "\t\t\t : __builtin_signbit(x))";
3867 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3868 test_text = <<- _EOText_
3869 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3870 #undef signbit
3871 #define signbit(x) __builtin_signbit(x)
3872 _EOText_;
3876 * Solaris math comparison macros
3878 fix = {
3879 hackname = solaris_math_9;
3880 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3881 bypass = "__GNUC__";
3882 files = iso/math_c99.h;
3883 c_fix = format;
3884 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3885 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3886 "__builtin_[a-z]+\\(y\\)\\)";
3887 test_text =
3888 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3889 "#undef isgreater\n"
3890 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3891 "#undef isgreaterequal\n"
3892 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3893 "#undef isless\n"
3894 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3895 "#undef islessequal\n"
3896 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3897 "#undef islessgreater\n"
3898 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3899 "#undef isunordered\n"
3900 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3904 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3905 * warnings.
3907 fix = {
3908 hackname = solaris_math_11;
3909 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3910 files = iso/math_c99.h;
3911 c_fix = format;
3912 c_fix_arg = << _EOArg_
3913 #undef signbit
3914 #define signbit(x) (sizeof(x) == sizeof(float) \
3915 ? __builtin_signbitf(x) \
3916 : sizeof(x) == sizeof(long double) \
3917 ? __builtin_signbitl(x) \
3918 : __builtin_signbit(x))
3919 _EOArg_;
3920 c_fix_arg = << _EOArg_
3921 ^#undef[ ]+signbit
3922 #if defined\(__sparc\)
3923 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3924 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3925 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3926 #elif defined\(__i386\) \|\| defined\(__amd64\)
3927 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3928 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3929 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3930 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3931 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3932 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3933 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3934 #endif
3935 _EOArg_;
3936 test_text = << _EOText_
3937 /* @(#)math_c99.h 1.14 13/03/27 */
3938 #undef signbit
3939 #if defined(__sparc)
3940 #define signbit(x) __extension__( \\
3941 { __typeof(x) __x_s = (x); \\
3942 (int) (*(unsigned *) &__x_s >> 31); })
3943 #elif defined(__i386) || defined(__amd64)
3944 #define signbit(x) __extension__( \\
3945 { __typeof(x) __x_s = (x); \\
3946 (sizeof (__x_s) == sizeof (float) ? \\
3947 (int) (*(unsigned *) &__x_s >> 31) : \\
3948 sizeof (__x_s) == sizeof (double) ? \\
3949 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3950 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3951 #endif
3952 _EOText_;
3956 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3958 fix = {
3959 hackname = solaris_math_12;
3960 files = math.h;
3961 mach = '*-*-solaris2*';
3962 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3963 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3964 test_text = << _EOText_
3965 #if __cplusplus >= 201103L
3966 #undef _GLIBCXX_USE_C99_MATH
3967 #undef _GLIBCXX_USE_C99_MATH_TR1
3968 #endif
3969 _EOText_;
3973 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3974 * structure. As such, it need two levels of brackets, but only
3975 * contains one. Wrap the macro definition in an extra layer.
3977 fix = {
3978 hackname = solaris_once_init_1;
3979 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3980 files = pthread.h;
3981 mach = '*-*-solaris*';
3982 c_fix = format;
3983 c_fix_arg = "%1{%2}%3";
3984 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3985 test_text =
3986 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3987 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3991 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3992 * posix_spawn declarations, which doesn't work with C++.
3994 fix = {
3995 hackname = solaris_posix_spawn_restrict;
3996 files = spawn.h;
3997 mach = '*-*-solaris2*';
3998 c_fix = format;
3999 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
4000 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
4001 test_text =
4002 "char *const argv[_RESTRICT_KYWD],\n"
4003 "char *const envp[_RESTRICT_KYWD]);";
4007 * The pow overloads with int were removed in C++ 2011 DR 550.
4009 fix = {
4010 hackname = solaris_pow_int_overload;
4011 mach = '*-*-solaris2*';
4012 files = "iso/math_iso.h";
4013 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4014 " *\\{[^{}]*\n[^{}]*\\}";
4015 c_fix = format;
4016 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4018 test_text =
4019 " inline long double pow(long double __X, int __Y) { return\n"
4020 " __powl(__X, (long double) (__Y)); }";
4024 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4025 * fields of the pthread_rwlock_t structure, which are of type
4026 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
4027 * defined (e.g. by -ansi) it is a union. So change the initializer
4028 * to "{0}" instead.
4030 fix = {
4031 hackname = solaris_rwlock_init_1;
4032 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4033 files = pthread.h;
4034 mach = '*-*-solaris*';
4035 c_fix = format;
4036 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4037 "%0\n"
4038 "#else\n"
4039 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4040 "#endif";
4041 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4042 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4044 test_text =
4045 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
4046 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4050 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
4051 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
4053 fix = {
4054 hackname = solaris_std___filbuf;
4055 files = stdio.h;
4056 mach = '*-*-solaris2*';
4057 bypass = "using std::__filbuf";
4058 select = "(using std::perror;\n)(#endif)";
4059 c_fix = format;
4060 c_fix_arg = "%1#ifndef _LP64\n"
4061 "using std::__filbuf;\n"
4062 "using std::__flsbuf;\n"
4063 "#endif\n%2";
4065 test_text = "using std::perror;\n"
4066 "#endif";
4070 * Solaris <stdio.h> shouldn't use std::gets for C++14.
4072 fix = {
4073 hackname = solaris_std_gets_cxx14;
4074 mach = "*-*-solaris2*";
4075 files = "stdio.h";
4076 select = "using std::gets;";
4078 c_fix = format;
4079 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4081 test_text = "using std::gets;";
4085 * Sun Solaris 8 has what appears to be some gross workaround for
4086 * some old version of their c++ compiler. G++ doesn't want it
4087 * either, but doesn't want to be tied to SunPRO version numbers.
4089 fix = {
4090 hackname = solaris_stdio_tag;
4091 files = stdio_tag.h;
4093 select = '__cplusplus < 54321L';
4094 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4095 "!defined(__GNUC__)" so we no longer need to fix it. */
4096 bypass = '__GNUC__';
4097 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4099 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4103 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4105 fix = {
4106 hackname = solaris_stdlib_noreturn;
4107 mach = "*-*-solaris2*";
4108 files = "iso/stdlib_c99.h";
4109 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4111 c_fix = format;
4112 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4114 test_text = "extern _Noreturn void quick_exit(int);";
4118 * a missing semi-colon at the end of the statsswtch structure definition.
4120 fix = {
4121 hackname = statsswtch;
4122 files = rpcsvc/rstat.h;
4123 select = "boottime$";
4124 c_fix = format;
4125 c_fix_arg = "boottime;";
4126 test_text = "struct statswtch {\n int boottime\n};";
4130 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4131 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4132 * OK too.
4134 fix = {
4135 hackname = stdio_stdarg_h;
4136 files = stdio.h;
4137 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4139 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4140 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4142 mach = '*-*-solaris2.1[0-9]*';
4143 not_machine = true;
4145 c_fix = wrap;
4147 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4149 test_text = "";
4153 * Don't use or define the name va_list in stdio.h. This is for
4154 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4155 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4156 * indicate that the header knows what it's doing -- under SUSv2,
4157 * stdio.h is required to define va_list, and we shouldn't break
4158 * that.
4160 fix = {
4161 hackname = stdio_va_list;
4162 files = stdio.h;
4163 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4165 * On Solaris 10, the definition in
4166 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4167 * there is therefore no need for this fix there.
4169 mach = '*-*-solaris2.1[0-9]*';
4170 not_machine = true;
4173 * Use __gnuc_va_list in arg types in place of va_list.
4174 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4175 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4176 * trailing parentheses and semicolon save all other systems from this.
4177 * Define __not_va_list__ (something harmless and unused)
4178 * instead of va_list.
4179 * Don't claim to have defined va_list.
4181 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4182 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4183 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4184 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4185 "s@ va_list@ __not_va_list__@\n"
4186 "s@\\*va_list@*__not_va_list__@\n"
4187 "s@ __va_list)@ __gnuc_va_list)@\n"
4188 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4189 "@typedef \\1 __not_va_list__;@\n"
4190 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4191 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4192 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4193 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4194 "s@VA_LIST@DUMMY_VA_LIST@\n"
4195 "s@_Va_LIST@_VA_LIST@";
4196 test_text = "extern void mumble( va_list);";
4200 * Fix headers that use va_list from stdio.h to use the updated
4201 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4202 * dealt with elsewhere. The presence of __gnuc_va_list,
4203 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4204 * knows what it's doing.
4206 fix = {
4207 hackname = stdio_va_list_clients;
4208 files = com_err.h;
4209 files = cps.h;
4210 files = curses.h;
4211 files = krb5.h;
4212 files = lc_core.h;
4213 files = pfmt.h;
4214 files = wchar.h;
4215 files = curses_colr/curses.h;
4216 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4217 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4218 otherwise protected. */
4219 bypass = 'include <stdarg\.h>|#ifdef va_start';
4222 * Use __gnuc_va_list in arg types in place of va_list.
4223 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4224 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4225 * trailing parentheses and semicolon save all other systems from this.
4226 * Define __not_va_list__ (something harmless and unused)
4227 * instead of va_list.
4228 * Don't claim to have defined va_list.
4230 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4231 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4232 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4233 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4234 "s@ va_list@ __not_va_list__@\n"
4235 "s@\\*va_list@*__not_va_list__@\n"
4236 "s@ __va_list)@ __gnuc_va_list)@\n"
4237 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4238 "@typedef \\1 __not_va_list__;@\n"
4239 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4240 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4241 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4242 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4243 "s@VA_LIST@DUMMY_VA_LIST@\n"
4244 "s@_Va_LIST@_VA_LIST@";
4245 test_text = "extern void mumble( va_list);";
4249 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4250 * is "!defined( __STRICT_ANSI__ )"
4252 fix = {
4253 hackname = strict_ansi_not;
4254 select = "^([ \t]*#[ \t]*if.*)"
4255 "(!__STDC__"
4256 "|__STDC__[ \t]*==[ \t]*0"
4257 "|__STDC__[ \t]*!=[ \t]*1"
4258 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4259 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4260 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4261 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4262 is not defined by GCC, so it is safe. */
4263 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4264 c_test = stdc_0_in_system_headers;
4266 c_fix = format;
4267 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4269 test_text = "#if !__STDC__ \n"
4270 "#if __STDC__ == 0\n"
4271 "#if __STDC__ != 1\n"
4272 "#if __STDC__ - 0 == 0"
4273 "/* not std C */\nint foo;\n"
4274 "\n#end-end-end-end-if :-)";
4278 * "__STDC__-0==0"
4279 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4281 fix = {
4282 hackname = strict_ansi_not_ctd;
4283 files = math.h, limits.h, stdio.h, signal.h,
4284 stdlib.h, sys/signal.h, time.h;
4286 * Starting at the beginning of a line, skip white space and
4287 * a leading "(" or "&&" or "||". One of those must be found.
4288 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4289 * expression. If these are nested, then they must accumulate
4290 * because we won't match any closing parentheses. Finally,
4291 * after skipping over all that, we must then match our suspect
4292 * phrase: "__STDC__-0==0" with or without white space.
4294 select = "^([ \t]*" '(\(|&&|\|\|)'
4295 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4296 "[ \t(]*)"
4297 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4298 c_test = stdc_0_in_system_headers;
4300 c_fix = format;
4301 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4303 test_text = "#if 1 && \\\\\n"
4304 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4305 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4306 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4307 "int foo;\n#endif";
4311 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4312 * is "defined( __STRICT_ANSI__ )"
4314 fix = {
4315 hackname = strict_ansi_only;
4316 select = "^([ \t]*#[ \t]*if.*)"
4317 "(__STDC__[ \t]*!=[ \t]*0"
4318 "|__STDC__[ \t]*==[ \t]*1"
4319 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4320 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4321 c_test = stdc_0_in_system_headers;
4323 c_fix = format;
4324 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4326 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4330 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4331 * in prototype without previous definition.
4333 fix = {
4334 hackname = struct_file;
4335 files = rpc/xdr.h;
4336 select = '^.*xdrstdio_create.*struct __file_s';
4337 c_fix = format;
4338 c_fix_arg = "struct __file_s;\n%0";
4339 test_text = "extern void xdrstdio_create( struct __file_s* );";
4343 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4344 * in prototype without previous definition.
4346 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4347 * function, and does define it.
4349 fix = {
4350 hackname = struct_sockaddr;
4351 files = rpc/auth.h;
4352 select = "^.*authdes_create.*struct sockaddr[^_]";
4353 bypass = "<sys/socket\.h>";
4354 bypass = "struct sockaddr;\n";
4355 c_fix = format;
4356 c_fix_arg = "struct sockaddr;\n%0";
4357 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4361 * Apply fix this to all OSs since this problem seems to effect
4362 * more than just SunOS.
4364 fix = {
4365 hackname = sun_auth_proto;
4366 files = rpc/auth.h;
4367 files = rpc/clnt.h;
4368 files = rpc/svc.h;
4369 files = rpc/xdr.h;
4370 bypass = "__cplusplus";
4372 * Select those files containing '(*name)()'.
4374 select = '\(\*[a-z][a-z_]*\)\(\)';
4376 c_fix = format;
4377 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4378 "#else\n%1();%2\n#endif";
4379 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4381 test_text =
4382 "struct auth_t {\n"
4383 " int (*name)(); /* C++ bad */\n"
4384 "};";
4388 * Fix bogus #ifdef on SunOS 4.1.
4390 fix = {
4391 hackname = sun_bogus_ifdef;
4392 files = "hsfs/hsfs_spec.h";
4393 files = "hsfs/iso_spec.h";
4394 select = '#ifdef(.*\|\|.*)';
4395 c_fix = format;
4396 c_fix_arg = "#if%1";
4398 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4402 * Fix the CAT macro in SunOS memvar.h.
4404 fix = {
4405 hackname = sun_catmacro;
4406 files = pixrect/memvar.h;
4407 select = "^#define[ \t]+CAT\\(a,b\\).*";
4408 c_fix = format;
4410 c_fix_arg =
4411 "#ifdef __STDC__\n"
4412 "# define CAT(a,b) a##b\n"
4413 "#else\n%0\n#endif";
4415 test_text =
4416 "#define CAT(a,b)\ta/**/b";
4420 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4421 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4423 fix = {
4424 hackname = sun_malloc;
4425 files = malloc.h;
4426 bypass = "_CLASSIC_ANSI_TYPES";
4428 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4429 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4430 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4431 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4432 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4434 test_text =
4435 "typedef char *\tmalloc_t;\n"
4436 "int \tfree();\n"
4437 "char*\tmalloc();\n"
4438 "char*\tcalloc();\n"
4439 "char*\trealloc();";
4443 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4445 fix = {
4446 hackname = sun_rusers_semi;
4447 files = rpcsvc/rusers.h;
4448 select = "_cnt$";
4449 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4450 test_text = "struct mumble\n int _cnt\n};";
4454 * signal.h on SunOS defines signal using (),
4455 * which causes trouble when compiling with g++ -pedantic.
4457 fix = {
4458 hackname = sun_signal;
4459 files = sys/signal.h;
4460 files = signal.h;
4461 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4463 c_fix = format;
4464 c_fix_arg =
4465 "#ifdef __cplusplus\n"
4466 "void\t(*signal(...))(...);\n"
4467 "#else\n%0\n#endif";
4469 test_text = "void\t(*signal())();";
4473 * Correct the return type for strlen in strings.h in SunOS 4.
4475 fix = {
4476 hackname = sunos_strlen;
4477 files = strings.h;
4478 select = "int[ \t]*strlen\\(\\);(.*)";
4479 c_fix = format;
4480 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4481 test_text = " int\tstrlen(); /* string length */";
4485 * Linux kernel's vt.h breaks C++
4487 fix = {
4488 hackname = suse_linux_vt_cxx;
4489 files = linux/vt.h;
4491 select = "^[ \t]*unsigned int new;";
4492 c_fix = format;
4493 c_fix_arg = "unsigned int newev;";
4495 test_text = " unsigned int new; /* New console (if changing) */";
4499 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4500 * that is visible to any ANSI compiler using this include. Simply
4501 * delete the lines that #define some string functions to internal forms.
4503 fix = {
4504 hackname = svr4_disable_opt;
4505 files = string.h;
4506 select = '#define.*__std_hdr_';
4507 sed = '/#define.*__std_hdr_/d';
4508 test_text = "#define strlen __std_hdr_strlen\n";
4512 * Fix broken decl of getcwd present on some svr4 systems.
4514 fix = {
4515 hackname = svr4_getcwd;
4516 files = stdlib.h;
4517 files = unistd.h;
4518 files = prototypes.h;
4519 select = 'getcwd\(char \*, int\)';
4521 c_fix = format;
4522 c_fix_arg = "getcwd(char *, size_t)";
4524 test_text = "extern char* getcwd(char *, int);";
4528 * Fix broken decl of profil present on some svr4 systems.
4530 fix = {
4531 hackname = svr4_profil;
4532 files = stdlib.h;
4533 files = unistd.h;
4535 select =
4536 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4537 c_fix = format;
4538 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4540 test_text =
4541 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4545 * Correct types for signal handler constants like SIG_DFL; they might be
4546 * void (*) (), and should be void (*) (int). C++ doesn't like the
4547 * old style.
4549 fix = {
4550 hackname = svr4_sighandler_type;
4551 files = sys/signal.h;
4552 select = 'void *\(\*\)\(\)';
4553 c_fix = format;
4554 c_fix_arg = "void (*)(int)";
4555 test_text = "#define SIG_DFL (void(*)())0\n"
4556 "#define SIG_IGN (void (*)())0\n";
4560 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4561 * function 'getrnge' in <regexp.h> before they declare it. For these
4562 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4563 * early on.
4565 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4566 * so put the declaration right after the declaration of 'size'.
4568 * Don't do this if there is already a `static void getrnge' declaration
4569 * present, since this would cause a redeclaration error. Solaris 2.x has
4570 * such a declaration.
4572 fix = {
4573 hackname = svr4_undeclared_getrnge;
4574 files = regexp.h;
4575 select = "getrnge";
4576 bypass = "static void getrnge";
4577 c_fix = format;
4578 c_fix_arg = "%0\n"
4579 "static int getrnge ();";
4580 c_fix_arg = "^static int[ \t]+size;";
4581 test_text = "static int size;\n"
4582 "/* stuff which calls getrnge() */\n"
4583 "static getrnge()\n"
4584 "{}";
4588 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4589 * in string.h on sysV68
4590 * Correct the return type for strlen in string.h on Lynx.
4591 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4592 * Add missing const for strdup on OSF/1 V3.0.
4593 * On sysV88 layout is slightly different.
4595 fix = {
4596 hackname = sysv68_string;
4597 files = testing.h;
4598 files = string.h;
4599 bypass = "_CLASSIC_ANSI_TYPES";
4601 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4602 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4603 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4605 sed = "/^extern char$/N";
4606 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4608 sed = "/^extern int$/N";
4609 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4611 sed = "/^\tstrncmp(),$/N";
4612 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4613 '\1;' "\\\nextern unsigned int\\\n\\2/";
4615 test_text =
4616 "extern int strlen();\n"
4618 "extern int ffs(long);\n"
4620 "extern char\n"
4621 "\t*memccpy(),\n"
4622 "\tmemcpy();\n"
4624 "extern int\n"
4625 "\tstrcmp(),\n"
4626 "\tstrncmp(),\n"
4627 "\tstrlen(),\n"
4628 "\tstrspn();\n"
4630 "extern int\n"
4631 "\tstrlen(), strspn();";
4635 * Fix return type of calloc, malloc, realloc, bsearch and exit
4637 fix = {
4638 hackname = sysz_stdlib_for_sun;
4639 files = stdlib.h;
4640 bypass = "_CLASSIC_ANSI_TYPES";
4642 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4643 c_fix = format;
4644 c_fix_arg = "void *\t%1(";
4646 test_text =
4647 "extern char*\tcalloc(size_t);\n"
4648 "extern char*\tmalloc(size_t);\n"
4649 "extern char*\trealloc(void*,size_t);\n"
4650 "extern char*\tbsearch(void*,size_t,size_t);\n";
4654 * __thread is now a keyword.
4656 fix = {
4657 hackname = thread_keyword;
4658 files = "pthread.h";
4659 files = bits/sigthread.h, '*/bits/sigthread.h';
4660 select = "([* ])__thread([,)])";
4661 c_fix = format;
4662 c_fix_arg = "%1__thr%2";
4664 test_text =
4665 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4666 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4667 "extern int pthread_cancel (pthread_t __thread);";
4671 * if the #if says _cplusplus, not the double underscore __cplusplus
4672 * that it should be
4674 fix = {
4675 hackname = tinfo_cplusplus;
4676 files = tinfo.h;
4677 select = "[ \t]_cplusplus";
4679 c_fix = format;
4680 c_fix_arg = " __cplusplus";
4681 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4685 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4687 fix = {
4688 hackname = ultrix_const;
4689 files = stdio.h;
4690 select = 'perror\( char \*';
4692 c_fix = format;
4693 c_fix_arg = "%1 const %3 *__";
4694 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4695 "[ \t]+(char|void) \\*__";
4697 test_text =
4698 "extern void perror( char *__s );\n"
4699 "extern int fputs( char *__s, FILE *);\n"
4700 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4701 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4702 "extern int scanf( char *__format, ...);\n";
4706 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4708 fix = {
4709 hackname = ultrix_const2;
4710 files = stdio.h;
4712 select = '\*fopen\( char \*';
4713 c_fix = format;
4714 c_fix_arg = "%1( const char *%3, const char *";
4715 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4716 "[ \t]*char[ \t]*\\*([^,]*),"
4717 "[ \t]*char[ \t]*\\*[ \t]*";
4719 test_text =
4720 "extern FILE *fopen( char *__filename, char *__type );\n"
4721 "extern int sscanf( char *__s, char *__format, ...);\n"
4722 "extern FILE *popen(char *, char *);\n"
4723 "extern char *tempnam(char*,char*);\n";
4727 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4729 fix = {
4730 hackname = va_i960_macro;
4731 files = arch/i960/archI960.h;
4732 select = "__(vsiz|vali|vpad|alignof__)";
4734 c_fix = format;
4735 c_fix_arg = "__vx%1";
4737 test_text =
4738 "extern int __vsiz vsiz;\n"
4739 "extern int __vali vali;\n"
4740 "extern int __vpad vpad;\n"
4741 "#define __alignof__(x) ...";
4745 * On VMS, add missing braces around sigset_t constants.
4747 fix = {
4748 hackname = vms_add_missing_braces;
4749 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4750 mach = "*-*-*vms*";
4751 files = "rtldef/signal.h";
4752 c_fix = format;
4754 c_fix_arg = '%1 {%2} ';
4756 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4757 "{0x00000000, 0x00000000},\n"
4758 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4762 * On VMS, some DEC-C builtins are directly used.
4764 fix = {
4765 hackname = vms_decc_builtin;
4766 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4767 mach = "*-*-*vms*";
4768 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4769 rtldef/socket.h;
4770 sed = "s@__MEMSET@memset@";
4771 sed = "s@__MEMMOVE@memmove@";
4772 sed = "s@__MEMCPY@memcpy@";
4773 sed = "s@__STRLEN@strlen@";
4774 sed = "s@__STRCPY@strcpy@";
4776 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4780 * Define __CAN_USE_EXTERN_PREFIX on vms.
4782 fix = {
4783 hackname = vms_define_can_use_extern_prefix;
4784 files = "rtldef/decc$types.h";
4785 select = "#[ \t]*else\n"
4786 "#[ \t]*if defined\\(__DECCXX\\)\n"
4787 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4788 mach = "*-*-*vms*";
4789 c_fix = format;
4791 c_fix_arg = "%0"
4792 "# elif defined (__GNUC__)\n"
4793 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4795 test_text = "# else\n"
4796 "# if defined(__DECCXX)\n"
4797 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4798 "# endif\n"
4799 "# endif\n";
4803 * On VMS, disable the use of dec-c string builtins
4805 fix = {
4806 hackname = vms_disable_decc_string_builtins;
4807 select = "#if !defined\\(__VAX\\)\n";
4808 mach = "*-*-*vms*";
4809 files = "rtldef/string.h";
4810 c_fix = format;
4812 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4814 test_text = "#if !defined(__VAX)\n";
4818 * On VMS, fix incompatible redeclaration of hostalias.
4820 fix = {
4821 hackname = vms_do_not_redeclare_hostalias;
4822 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4823 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4824 mach = "*-*-*vms*";
4825 files = "rtldef/resolv.h";
4826 c_fix = format;
4828 c_fix_arg = "%1\n"
4829 "/* %2 */";
4831 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4832 "__char_ptr32 hostalias (const char *);\n";
4836 * On VMS, forward declare structure before referencing them in prototypes.
4838 fix = {
4839 hackname = vms_forward_declare_struct;
4840 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4841 "#ifdef __cplusplus\n";
4842 mach = "*-*-*vms*";
4843 files = rtldef/if.h;
4844 c_fix = format;
4846 c_fix_arg = "%1"
4847 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4849 test_text = "/* forward decls for C++ */\n"
4850 "#ifdef __cplusplus\n"
4851 "struct foo;\n"
4852 "#endif\n";
4856 * On VMS, do not declare getopt and al if pointers are 64 bit.
4858 fix = {
4859 hackname = vms_no_64bit_getopt;
4860 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4861 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4862 mach = "*-*-*vms*";
4863 files = rtldef/stdio.h, rtldef/unistd.h;
4864 c_fix = format;
4866 c_fix_arg = <<- _EOArg_
4867 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4868 %0#endif
4870 _EOArg_;
4872 test_text = "int getopt (int, char * const [], const char *);";
4876 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4877 * which is not yet fully supported by gcc.
4879 fix = {
4880 hackname = vms_use_fast_setjmp;
4881 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4882 mach = "*-*-*vms*";
4883 files = rtldef/setjmp.h;
4884 c_fix = format;
4886 c_fix_arg = "%0 defined (__GNUC__) ||";
4888 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4892 * On VMS, use pragma extern_model instead of VAX-C keywords.
4894 fix = {
4895 hackname = vms_use_pragma_extern_model;
4896 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4897 "# pragma extern_model __save\n";
4898 mach = "*-*-*vms*";
4899 c_fix = format;
4901 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4902 "# pragma extern_model __save\n";
4904 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4905 "# pragma extern_model __save\n"
4906 "# pragma extern_model strict_refdef\n"
4907 " extern struct x zz$yy;\n"
4908 "# pragma extern_model __restore\n"
4909 "#endif\n";
4913 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4914 * conflict while building gcc. Likewise for <builtins.h>
4916 fix = {
4917 hackname = vms_use_quoted_include;
4918 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4919 mach = "*-*-*vms*";
4920 files = rtldef/wait.h, starlet_c/pthread.h;
4921 c_fix = format;
4923 c_fix_arg = '%1<sys/%2.h>';
4925 test_text = "# include <resource.h>";
4929 * AIX and Interix headers define NULL to be cast to a void pointer,
4930 * which is illegal in ANSI C++.
4932 fix = {
4933 hackname = void_null;
4934 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4935 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4936 /* avoid changing C++ friendly NULL */
4937 bypass = __cplusplus;
4938 bypass = __null;
4939 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4940 c_fix = format;
4941 c_fix_arg = <<- _EOFix_
4942 #ifndef NULL
4943 #ifdef __cplusplus
4944 #ifdef __GNUG__
4945 #define NULL __null
4946 #else /* ! __GNUG__ */
4947 #define NULL 0L
4948 #endif /* __GNUG__ */
4949 #else /* ! __cplusplus */
4950 #define NULL ((void *)0)
4951 #endif /* __cplusplus */
4952 #endif /* !NULL */
4953 _EOFix_;
4954 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4958 * Make VxWorks header which is almost gcc ready fully gcc ready.
4960 fix = {
4961 hackname = vxworks_gcc_problem;
4962 files = types/vxTypesBase.h;
4963 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4965 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4966 "#if 1/";
4968 sed = "/[ \t]size_t/i\\\n"
4969 "#ifndef _GCC_SIZE_T\\\n"
4970 "#define _GCC_SIZE_T\n";
4972 sed = "/[ \t]size_t/a\\\n"
4973 "#endif\n";
4975 sed = "/[ \t]ptrdiff_t/i\\\n"
4976 "#ifndef _GCC_PTRDIFF_T\\\n"
4977 "#define _GCC_PTRDIFF_T\n";
4979 sed = "/[ \t]ptrdiff_t/a\\\n"
4980 "#endif\n";
4982 sed = "/[ \t]wchar_t/i\\\n"
4983 "#ifndef _GCC_WCHAR_T\\\n"
4984 "#define _GCC_WCHAR_T\n";
4986 sed = "/[ \t]wchar_t/a\\\n"
4987 "#endif\n";
4989 test_text =
4990 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4991 "typedef unsigned int size_t;\n"
4992 "typedef long ptrdiff_t;\n"
4993 "typedef unsigned short wchar_t;\n"
4994 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4998 * Wrap VxWorks ioctl to keep everything pretty
5000 fix = {
5001 hackname = vxworks_ioctl_macro;
5002 files = ioLib.h;
5003 mach = "*-*-vxworks*";
5005 c_fix = format;
5006 c_fix_arg = "%0\n"
5007 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
5008 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
5010 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5014 * Wrap VxWorks mkdir to be posix compliant
5016 fix = {
5017 hackname = vxworks_mkdir_macro;
5018 files = sys/stat.h;
5019 mach = "*-*-vxworks*";
5021 c_fix = format;
5022 c_fix_arg = "%0\n"
5023 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5024 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5025 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5026 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5027 "\\)[\t ]*;";
5029 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
5033 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
5035 fix = {
5036 hackname = vxworks_needs_vxtypes;
5037 files = time.h;
5038 select = "uint_t([ \t]+_clocks_per_sec)";
5039 c_fix = format;
5040 c_fix_arg = "unsigned int%1";
5041 test_text = "uint_t\t_clocks_per_sec;";
5045 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5047 fix = {
5048 hackname = vxworks_needs_vxworks;
5049 files = sys/stat.h;
5050 test = " -r types/vxTypesOld.h";
5051 test = " -n \"`egrep '#include' $file`\"";
5052 test = " -n \"`egrep ULONG $file`\"";
5053 select = "#[ \t]define[ \t]+__INCstath";
5055 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5056 "#include <types/vxTypesOld.h>\n";
5058 test_text = "`touch types/vxTypesOld.h`"
5059 "#include </dev/null> /* ULONG */\n"
5060 "# define\t__INCstath <sys/stat.h>";
5064 * Make it so VxWorks does not include gcc/regs.h accidentally
5066 fix = {
5067 hackname = vxworks_regs;
5068 mach = "*-*-vxworks*";
5070 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5071 c_fix = format;
5072 c_fix_arg = "#include <arch/../regs.h>";
5074 test_text = "#include <regs.h>\n";
5078 * Another bad dependency in VxWorks 5.2 <time.h>.
5080 fix = {
5081 hackname = vxworks_time;
5082 files = time.h;
5083 test = " -r vxWorks.h";
5085 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5086 c_fix = format;
5088 c_fix_arg =
5089 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5090 "#ifdef __cplusplus\n"
5091 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5092 "#else\n"
5093 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5094 "#endif\n"
5095 "#define __gcc_VOIDFUNCPTR_defined\n"
5096 "#endif\n"
5097 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5099 test_text = "`touch vxWorks.h`"
5100 "#define VOIDFUNCPTR (void(*)())";
5104 * This hack makes write const-correct on VxWorks
5106 fix = {
5107 hackname = vxworks_write_const;
5108 files = ioLib.h;
5109 mach = "*-*-vxworks*";
5111 c_fix = format;
5112 c_fix_arg = "extern int write (int, const char*, size_t);";
5113 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5114 "[\t ]*int[\t ]*,"
5115 "[\t ]*char[\t ]*\\*[\t ]*,"
5116 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5118 test_text = "extern int write ( int , char * , size_t ) ;";
5122 * This hack ensures the include_next in the fixed unistd.h actually
5123 * finds the system's unistd.h and not the fixed unistd.h again.
5125 fix = {
5126 hackname = vxworks_iolib_include_unistd;
5127 files = ioLib.h;
5128 mach = "*-*-vxworks*";
5129 select = "#include \"unistd.h\"";
5131 c_fix = format;
5132 c_fix_arg = "#include <unistd.h>";
5134 test_text = "#include \"unistd.h\"";
5138 * There are several name conflicts with C++ reserved words in X11 header
5139 * files. These are fixed in some versions, so don't do the fixes if
5140 * we find __cplusplus in the file. These were found on the RS/6000.
5142 fix = {
5143 hackname = x11_class;
5144 files = X11/ShellP.h;
5145 bypass = __cplusplus;
5146 select = "^([ \t]*char \\*)class;(.*)";
5147 c_fix = format;
5148 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5149 "#else\n%1class;%2\n#endif";
5150 test_text =
5151 "struct {\n"
5152 " char *class;\n"
5153 "} mumble;\n";
5157 * class in Xm/BaseClassI.h
5159 fix = {
5160 hackname = x11_class_usage;
5161 files = Xm/BaseClassI.h;
5162 bypass = "__cplusplus";
5164 select = " class\\)";
5165 c_fix = format;
5166 c_fix_arg = " c_class)";
5168 test_text = "extern mumble (int class);\n";
5172 * new in Xm/Traversal.h
5174 fix = {
5175 hackname = x11_new;
5176 files = Xm/Traversal.h;
5177 bypass = __cplusplus;
5179 sed = "/Widget\told, new;/i\\\n"
5180 "#ifdef __cplusplus\\\n"
5181 "\\\tWidget\told, c_new;\\\n"
5182 "#else\n";
5184 sed = "/Widget\told, new;/a\\\n"
5185 "#endif\n";
5187 sed = "s/Widget new,/Widget c_new,/g";
5188 test_text =
5189 "struct wedge {\n"
5190 " Widget\told, new;\n"
5191 "};\nextern Wedged( Widget new, Widget old );";
5195 * Incorrect sprintf declaration in X11/Xmu.h
5197 fix = {
5198 hackname = x11_sprintf;
5199 files = X11/Xmu.h;
5200 files = X11/Xmu/Xmu.h;
5201 select = "^extern char \\*\tsprintf\\(\\);$";
5203 c_fix = format;
5204 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5206 test_text = "extern char *\tsprintf();";
5208 /*EOF*/