Fix libgfortran build on hppa*-hp-hpux[01]*
[official-gcc.git] / fixincludes / inclhack.def
blob46e3b8c993a3e214056aee8bdbd3ab28eeec6d46
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 * SDKs for 10.13 and 10.14 omit the definitions for API_AVAILABLE where
199 * __attribute__((availability)) is not supported.
201 fix = {
202 hackname = darwin_api_availability;
203 mach = "*-*-darwin*";
204 files = os/availability.h;
205 bypass = "__IPHONE_OS_VERSION_MIN_REQUIRED";
206 select =
207 " *#define __API_AVAILABLE.*\n"
208 " *#define __API_DEPRECATED.*\n"
209 " *#define __API_DEPRECATED_WITH_REPLACEMENT.*\n"
210 " *#define __API_UNAVAILABLE.*\n";
211 c_fix = format;
212 c_fix_arg =
213 " #define API_AVAILABLE(...)\n"
214 " #define API_DEPRECATED(...)\n"
215 " #define API_DEPRECATED_WITH_REPLACEMENT(...)\n"
216 " #define API_UNAVAILABLE(...)\n";
217 test_text =
218 "#define __API_AVAILABLE(...)\n"
219 "#define __API_DEPRECATED(...)\n"
220 "#define __API_DEPRECATED_WITH_REPLACEMENT(...)\n"
221 "#define __API_UNAVAILABLE(...)\n";
225 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
227 fix = {
228 hackname = AAB_fd_zero_asm_posix_types_h;
229 files = asm/posix_types.h;
230 mach = 'i[34567]86-*-linux*';
231 bypass = '} while';
232 bypass = 'x86_64';
233 bypass = 'posix_types_64';
236 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
237 * the start, so that if #include_next gets another instance of
238 * the wrapper, this will follow the #include_next chain until
239 * we arrive at the real <asm/posix_types.h>.
241 replace = <<- _EndOfHeader_
242 /* This file fixes a bug in the __FD_ZERO macro
243 for older versions of the Linux kernel. */
244 #ifndef _POSIX_TYPES_H_WRAPPER
245 #include <features.h>
246 #include_next <asm/posix_types.h>
248 #if defined(__FD_ZERO) && !defined(__GLIBC__)
249 #undef __FD_ZERO
250 #define __FD_ZERO(fdsetp) \
251 do { \
252 int __d0, __d1; \
253 __asm__ __volatile__("cld ; rep ; stosl" \
254 : "=&c" (__d0), "=&D" (__d1) \
255 : "a" (0), "0" (__FDSET_LONGS), \
256 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
257 } while (0)
258 #endif
260 #define _POSIX_TYPES_H_WRAPPER
261 #endif /* _POSIX_TYPES_H_WRAPPER */
262 _EndOfHeader_;
266 * This fixes __FD_ZERO bug for glibc-1.x
268 fix = {
269 hackname = AAB_fd_zero_gnu_types_h;
270 files = gnu/types.h;
271 mach = 'i[34567]86-*-linux*';
274 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
275 * the start, so that if #include_next gets another instance of
276 * the wrapper, this will follow the #include_next chain until
277 * we arrive at the real <gnu/types.h>.
279 replace = <<- _EndOfHeader_
280 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
281 #ifndef _TYPES_H_WRAPPER
282 #include <features.h>
283 #include_next <gnu/types.h>
285 #if defined(__FD_ZERO) && !defined(__GLIBC__)
286 #undef __FD_ZERO
287 # define __FD_ZERO(fdsetp) \
288 do { \
289 int __d0, __d1; \
290 __asm__ __volatile__("cld ; rep ; stosl" \
291 : "=&c" (__d0), "=&D" (__d1) \
292 : "a" (0), "0" (__FDSET_LONGS), \
293 "1" ((__fd_set *) (fdsetp)) :"memory"); \
294 } while (0)
295 #endif
297 #define _TYPES_H_WRAPPER
298 #endif /* _TYPES_H_WRAPPER */
299 _EndOfHeader_;
303 * This fixes __FD_ZERO bug for glibc-2.0.x
305 fix = {
306 hackname = AAB_fd_zero_selectbits_h;
307 files = selectbits.h;
308 mach = 'i[34567]86-*-linux*';
311 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
312 * the start, so that if #include_next gets another instance of
313 * the wrapper, this will follow the #include_next chain until
314 * we arrive at the real <selectbits.h>.
316 replace = <<- _EndOfHeader_
317 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
318 #ifndef _SELECTBITS_H_WRAPPER
319 #include <features.h>
320 #include_next <selectbits.h>
322 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
323 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
324 && __GLIBC_MINOR__ == 0
325 #undef __FD_ZERO
326 #define __FD_ZERO(fdsetp) \\
327 do { \\
328 int __d0, __d1; \\
329 __asm__ __volatile__ ("cld; rep; stosl" \\
330 : "=&c" (__d0), "=&D" (__d1) \\
331 : "a" (0), "0" (sizeof (__fd_set) \\
332 / sizeof (__fd_mask)), \\
333 "1" ((__fd_mask *) (fdsetp)) \\
334 : "memory"); \\
335 } while (0)
336 #endif
338 #define _SELECTBITS_H_WRAPPER
339 #endif /* _SELECTBITS_H_WRAPPER */
340 _EndOfHeader_;
344 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
345 * the same interface as <stdarg.h>. No idea why they couldn't have just
346 * used the standard header.
348 fix = {
349 hackname = AAB_solaris_sys_varargs_h;
350 files = "sys/varargs.h";
351 mach = '*-*-solaris*';
352 replace = <<- _EndOfHeader_
353 #ifdef __STDC__
354 #include <stdarg.h>
355 #else
356 #include <varargs.h>
357 #endif
358 _EndOfHeader_;
362 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
363 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
364 * many other systems have similar text but correct versions of the file.
365 * To ensure only Sun's is fixed, we grep for a likely unique string.
366 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
368 fix = {
369 hackname = AAB_sun_memcpy;
370 files = memory.h;
371 select = "/\\*\t@\\(#\\)"
372 "(head/memory.h\t50.1\t "
373 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
375 replace = <<- _EndOfHeader_
376 /* This file was generated by fixincludes */
377 #ifndef __memory_h__
378 #define __memory_h__
380 #ifdef __STDC__
381 extern void *memccpy();
382 extern void *memchr();
383 extern void *memcpy();
384 extern void *memset();
385 #else
386 extern char *memccpy();
387 extern char *memchr();
388 extern char *memcpy();
389 extern char *memset();
390 #endif /* __STDC__ */
392 extern int memcmp();
394 #endif /* __memory_h__ */
395 _EndOfHeader_;
399 * Fix assert.h on VxWorks:
401 fix = {
402 hackname = AAB_vxworks_assert;
403 files = assert.h;
404 mach = "*-*-vxworks*";
406 replace = <<- _EndOfHeader_
407 #ifdef _ASSERT_H
408 #undef _ASSERT_H
409 #undef assert
410 #endif
412 #define _ASSERT_H
414 #ifdef __cplusplus
415 extern "C" {
416 #endif
418 #if defined(__STDC__) || defined(__cplusplus)
419 extern void __assert (const char*);
420 #else
421 extern void __assert ();
422 #endif
424 #ifdef NDEBUG
425 #define assert(ign) ((void)0)
426 #else
428 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
429 #define ASSERT_STRINGIFY_HELPER(str) #str
431 #define assert(test) ((void) \
432 ((test) ? ((void)0) : \
433 __assert("Assertion failed: " #test ", file " \
434 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
436 #endif
438 #ifdef __cplusplus
440 #endif
441 _EndOfHeader_;
445 * Add needed include to regs.h (NOT the gcc header) on VxWorks
448 fix = {
449 hackname = AAB_vxworks_regs_vxtypes;
450 files = regs.h;
451 mach = "*-*-vxworks*";
453 replace = <<- _EndOfHeader_
454 #ifndef _REGS_H
455 #define _REGS_H
456 /* regs.h depends on CPU_FAMILY being properly defined, which
457 is done by vxCpu.h. */
458 #include <types/vxCpu.h>
459 /* regs.h includes a CPU_FAMILY-specific header that requires
460 vxTypesOld.h to already have been included. Those headers
461 contain proper _ASMLANGUAGE guards around their typedefs,
462 but vxTypesOld.h itself does not. So we avoid including
463 vxTypesOld.h from assembly. */
464 #ifndef _ASMLANGUAGE
465 #include <types/vxTypesOld.h>
466 #endif
467 #include_next <arch/../regs.h>
468 #endif
469 _EndOfHeader_;
473 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
475 fix = {
476 hackname = AAB_vxworks_unistd;
477 files = unistd.h;
478 mach = "*-*-vxworks*";
480 replace = <<- _EndOfHeader_
481 #ifndef _UNISTD_H
482 #define _UNISTD_H
483 #include_next <unistd.h>
484 #include <ioLib.h>
485 #ifndef STDIN_FILENO
486 #define STDIN_FILENO 0
487 #endif
488 #ifndef STDOUT_FILENO
489 #define STDOUT_FILENO 1
490 #endif
491 #ifndef STDERR_FILENO
492 #define STDERR_FILENO 2
493 #endif
494 #endif /* _UNISTD_H */
495 _EndOfHeader_;
499 * assert.h on AIX 7 redefines static_assert as _Static_assert without
500 * protecting C++.
502 fix = {
503 hackname = aix_assert;
504 mach = "*-*-aix*";
505 files = assert.h;
506 select = "#define[ \t]static_assert[ \t]_Static_assert";
507 c_fix = format;
508 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
509 test_text = "#define static_assert _Static_assert";
513 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
514 * which only is provided by AIX xlc C99.
516 fix = {
517 hackname = aix_complex;
518 mach = "*-*-aix*";
519 files = complex.h;
520 select = "#define[ \t]_Complex_I[ \t]__I";
521 c_fix = format;
522 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
523 test_text = "#define _Complex_I __I\n";
527 * On AIX some headers are not properly guarded by 'extern "C"'.
529 fix = {
530 hackname = aix_externc;
531 mach = "*-*-aix*";
532 files = ctype.h;
533 files = fcntl.h;
534 files = langinfo.h;
535 files = ldfcn.h;
536 files = sys/localedef.h;
537 files = sys/times.h;
538 bypass = "extern \"C\"";
539 c_fix = wrap;
540 c_fix_arg = "#ifdef __cplusplus\n"
541 "extern \"C\" {\n"
542 "#endif\n";
543 c_fix_arg = "#ifdef __cplusplus\n"
544 "}\n"
545 "#endif\n";
546 test_text = "extern int __n_pthreads;\n";
550 * On AIX sys/socket.h assumes C++.
552 fix = {
553 hackname = aix_externcpp1;
554 mach = "*-*-aix*";
555 files = "sys/socket.h";
556 select = "#ifndef _KERNEL\n"
557 "#ifdef __cplusplus\n"
558 "extern \"C\" int naccept\\(int, struct sockaddr \\*, socklen_t \\*\\);";
559 c_fix = format;
560 c_fix_arg = "#ifndef _KERNEL\n"
561 "#ifdef __cplusplus\n"
562 "extern \"C++\" {\n"
563 "extern \"C\" int naccept(int, struct sockaddr *, socklen_t *);";
564 test_text = "#ifndef _KERNEL\n"
565 "#ifdef __cplusplus\n"
566 "extern \"C\" int naccept(int, struct sockaddr *, socklen_t *);";
569 fix = {
570 hackname = aix_externcpp2;
571 mach = "*-*-aix*";
572 files = "sys/socket.h";
573 select = "#endif /\\* COMPAT_43 \\*/\n"
574 "#else /\\* __cplusplus \\*/";
575 c_fix = format;
576 c_fix_arg = "#endif /* COMPAT_43 */\n"
577 "} /* extern \"C++\" */\n"
578 "#else /* __cplusplus */";
579 test_text = "#endif /* COMPAT_43 */\n"
580 "#else /* __cplusplus */";
584 * inttypes.h STDC_FORMAT_MACROS
586 fix = {
587 hackname = aix_inttypes;
588 mach = "*-*-aix*";
589 files = "sys/inttypes.h";
590 select = "#if !defined\\(__cplusplus\\) \\|\\| defined\\(__STDC_FORMAT_MACROS\\)";
591 c_fix = format;
592 c_fix_arg = "#if 1";
593 test_text = "#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)";
597 * malloc.h on AIX6 uses XLC++ specific builtin syntax
599 fix = {
600 hackname = aix_malloc;
601 mach = "*-*-aix*";
602 files = "malloc.h";
603 select = "#ifdef __cplusplus\n"
604 "extern \"C\" \\{\n"
605 "[ \t]extern \"builtin\" char \\*__alloca \\(size_t\\);";
606 c_fix = format;
607 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
608 "extern \"C\" {\n"
609 "\textern \"builtin\" char *__alloca (size_t);";
610 test_text = "#ifdef __cplusplus\n"
611 "extern \"C\" {\n"
612 "\textern \"builtin\" char *__alloca (size_t);";
616 * net/if_arp.h defines a variable fc_softc instead of adding a
617 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
619 fix = {
620 hackname = aix_net_if_arp;
621 mach = "*-*-aix*";
622 files = "net/if_arp.h";
623 select = "^struct fc_softc \\{";
624 c_fix = format;
625 c_fix_arg = "typedef struct _fc_softc {";
626 test_text = "struct fc_softc {\n int a;\n};";
630 * Fix AIX definition of NULL for G++.
632 fix = {
633 hackname = aix_null;
634 mach = "*-*-aix*";
635 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
636 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
637 bypass = __null;
638 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
639 c_fix = format;
640 c_fix_arg = <<- _EOFix_
641 #ifndef NULL
642 #ifdef __cplusplus
643 #ifdef __GNUG__
644 #define NULL __null
645 #else /* ! __GNUG__ */
646 #define NULL 0L
647 #endif /* __GNUG__ */
648 #else /* ! __cplusplus */
649 #define NULL ((void *)0)
650 #endif /* __cplusplus */
651 #endif /* !NULL */
652 _EOFix_;
653 test_text = "# define\tNULL \t(0L) /* typed NULL */";
657 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
658 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
659 * braces.
661 fix = {
662 hackname = aix_once_init_1;
663 mach = "*-*-aix*";
664 files = "pthread.h";
665 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
666 "\\{ \\\\\n";
667 c_fix = format;
668 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
669 "{{ \\\n";
670 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
671 "{ \\\\\n";
674 fix = {
675 hackname = aix_once_init_2;
676 mach = "*-*-aix*";
677 files = "pthread.h";
678 select = "[ \t]0 \\\\\n"
679 "\\}\n";
680 c_fix = format;
681 c_fix_arg = " 0 \\\n"
682 "}}\n";
683 test_text = " 0 \\\\\n"
684 "}\n";
687 fix = {
688 hackname = aix_mutex_initializer_1;
689 mach = "*-*-aix*";
690 files = "pthread.h";
691 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
692 "\\{ \\\\\n";
693 c_fix = format;
694 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
695 "{{ \\\n";
696 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
697 "{ \\\\\n";
700 fix = {
701 hackname = aix_cond_initializer_1;
702 mach = "*-*-aix*";
703 files = "pthread.h";
704 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
705 "\\{ \\\\\n";
706 c_fix = format;
707 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
708 "{{ \\\n";
709 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
710 "{ \\\\\n";
713 fix = {
714 hackname = aix_rwlock_initializer_1;
715 mach = "*-*-aix*";
716 files = "pthread.h";
717 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
718 "\\{ \\\\\n";
719 c_fix = format;
720 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
721 "{{ \\\n";
722 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
723 "{ \\\\\n";
727 /* On AIX 'typedef struct {<stuff>} * physadr_t;' needs to give the struct a
728 name for linkage purposes. Fortunately it is on exactly one
729 line. */
730 fix = {
731 hackname = aix_physadr_t;
732 mach = "*-*-aix*";
733 files = sys/types.h;
734 select = "typedef[ \t]*struct[ \t]*([{][^}]*[}][ \t]*\\*[ \t]*physadr_t;)";
735 c_fix = format;
736 c_fix_arg = "typedef struct __physadr_s %1";
737 test_text = "typedef struct { random stuff } * physadr_t;";
741 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
742 * which violates a requirement of ISO C.
744 fix = {
745 hackname = aix_pthread;
746 files = "pthread.h";
747 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
748 c_fix = format;
749 c_fix_arg = "%1 %2";
750 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
751 "{...init stuff...}";
755 * AIX stdint.h fixes.
757 fix = {
758 hackname = aix_stdint_1;
759 mach = "*-*-aix*";
760 files = stdint-aix.h, stdint.h;
761 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
762 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
763 c_fix = format;
764 c_fix_arg = "#define UINT8_MAX (255)\n"
765 "#define UINT16_MAX (65535)";
766 test_text = "#define UINT8_MAX (255U)\n"
767 "#define UINT16_MAX (65535U)";
771 * aix_stdint_2
773 fix = {
774 hackname = aix_stdint_2;
775 mach = "*-*-aix*";
776 files = stdint-aix.h, stdint.h;
777 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
778 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
779 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
780 "#else\n"
781 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
782 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
783 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
784 c_fix = format;
785 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
786 "#define INTPTR_MAX 9223372036854775807L\n"
787 "#define UINTPTR_MAX 18446744073709551615UL\n"
788 "#else\n"
789 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
790 "#define INTPTR_MAX 2147483647L\n"
791 "#define UINTPTR_MAX 4294967295UL";
792 test_text = "#define INTPTR_MIN INT64_MIN\n"
793 "#define INTPTR_MAX INT64_MAX\n"
794 "#define UINTPTR_MAX UINT64_MAX\n"
795 "#else\n"
796 "#define INTPTR_MIN INT32_MIN\n"
797 "#define INTPTR_MAX INT32_MAX\n"
798 "#define UINTPTR_MAX UINT32_MAX";
802 * aix_stdint_3
804 fix = {
805 hackname = aix_stdint_3;
806 mach = "*-*-aix*";
807 files = stdint-aix.h, stdint.h;
808 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
809 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
810 "#else\n"
811 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
812 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
813 c_fix = format;
814 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
815 "#define PTRDIFF_MAX 9223372036854775807L\n"
816 "#else\n"
817 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
818 "#define PTRDIFF_MAX 2147483647L";
819 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
820 "#define PTRDIFF_MAX INT64_MAX\n"
821 "#else\n"
822 "#define PTRDIFF_MIN INT32_MIN\n"
823 "#define PTRDIFF_MAX INT32_MAX";
827 * aix_stdint_4
829 fix = {
830 hackname = aix_stdint_4;
831 mach = "*-*-aix*";
832 files = stdint-aix.h, stdint.h;
833 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
834 "#else\n"
835 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
836 c_fix = format;
837 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
838 "#else\n"
839 "#define SIZE_MAX 4294967295UL";
840 test_text = "#define SIZE_MAX UINT64_MAX\n"
841 "#else\n"
842 "#define SIZE_MAX UINT32_MAX";
846 * aix_stdint_5
848 fix = {
849 hackname = aix_stdint_5;
850 mach = "*-*-aix*";
851 files = stdint-aix.h, stdint.h;
852 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
853 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
854 c_fix = format;
855 c_fix_arg = "#define UINT8_C(c) c\n"
856 "#define UINT16_C(c) c";
857 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
858 "#define UINT16_C(c) __CONCAT__(c,U)";
862 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
863 produces wrong code with G++.
865 fix = {
866 hackname = aix_stdio_inline;
867 mach = "*-*-aix*";
868 files = stdio.h;
869 select = "#ifdef __cplusplus\\\n"
870 "}\\\n\\\n"
871 "#ifdef ferror\\\n";
872 c_fix = format;
873 c_fix_arg = "#ifdef __cplusplus\n"
874 "}\n"
875 "#endif\n\n"
876 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
877 "#ifdef ferror\n";
878 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
882 * stdlib.h on AIX uses #define on malloc and friends.
884 fix = {
885 hackname = aix_stdlib_malloc;
886 mach = "*-*-aix*";
887 files = stdlib.h;
888 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
889 c_fix = format;
890 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
891 test_text = "#define malloc __linux_malloc";
894 fix = {
895 hackname = aix_stdlib_realloc;
896 mach = "*-*-aix*";
897 files = stdlib.h;
898 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
899 c_fix = format;
900 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
901 test_text = "#define realloc __linux_realloc";
904 fix = {
905 hackname = aix_stdlib_calloc;
906 mach = "*-*-aix*";
907 files = stdlib.h;
908 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
909 c_fix = format;
910 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
911 test_text = "#define calloc __linux_calloc";
914 fix = {
915 hackname = aix_stdlib_valloc;
916 mach = "*-*-aix*";
917 files = stdlib.h;
918 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
919 c_fix = format;
920 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
921 test_text = "#define valloc __linux_valloc";
924 fix = {
925 hackname = aix_stdlib_vec_malloc;
926 mach = "*-*-aix*";
927 files = stdlib.h;
928 select = "#define[ \t]+malloc[ \t]+vec_malloc";
929 c_fix = format;
930 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
931 test_text = "#define malloc vec_malloc";
934 fix = {
935 hackname = aix_stdlib_vec_calloc;
936 mach = "*-*-aix*";
937 files = stdlib.h;
938 select = "#define[ \t]+calloc[ \t]+vec_calloc";
939 c_fix = format;
940 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
941 test_text = "#define calloc vec_calloc";
945 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
947 fix = {
948 hackname = aix_strtof_const;
949 mach = "*-*-aix*";
950 files = stdlib.h;
951 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
952 c_fix = format;
953 c_fix_arg = "%1(const char *, char **);";
954 test_text = "extern float strtof(char *, char **);";
958 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
959 * in an otherwise harmless (and #ifed out) macro definition
961 fix = {
962 hackname = aix_sysmachine;
963 mach = "*-*-aix*";
964 files = sys/machine.h;
965 select = "\\\\ +\n";
966 c_fix = format;
967 c_fix_arg = "\\\n";
968 test_text = "#define FOO \\\n"
969 " bar \\ \n baz \\ \n bat";
973 * sys/wait.h on AIX 5.2 defines macros that have both signed and
974 * unsigned types in conditional expressions.
976 fix = {
977 hackname = aix_syswait_2;
978 mach = "*-*-aix*";
979 files = sys/wait.h;
980 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
981 c_fix = format;
982 c_fix_arg = "? (int)%1";
983 test_text = "#define WSTOPSIG(__x) "
984 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
988 * sys/signal.h on some versions of AIX uses volatile in the typedef of
989 * sig_atomic_t, which causes gcc to generate a warning about duplicate
990 * volatile when a sig_atomic_t variable is declared volatile, as
991 * required by ANSI C.
993 fix = {
994 hackname = aix_volatile;
995 mach = "*-*-aix*";
996 files = sys/signal.h;
997 select = "typedef volatile int sig_atomic_t";
998 c_fix = format;
999 c_fix_arg = "typedef int sig_atomic_t";
1000 test_text = "typedef volatile int sig_atomic_t;";
1004 * AIX unistd.h defines a static function with an empty parameter list.
1006 fix = {
1007 hackname = aix_unistd;
1008 mach = "*-*-aix*";
1009 files = unistd.h;
1011 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
1012 c_fix = format;
1013 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
1014 test_text = " static int getdtablesize()";
1018 * Fix __assert declaration in assert.h on Alpha OSF/1.
1020 fix = {
1021 hackname = alpha___assert;
1022 files = "assert.h";
1023 select = '__assert\(char \*, char \*, int\)';
1024 c_fix = format;
1025 c_fix_arg = "__assert(const char *, const char *, int)";
1026 test_text = 'extern void __assert(char *, char *, int);';
1030 * Fix assert macro in assert.h on Alpha OSF/1.
1031 * The superfluous int cast breaks C++.
1033 fix = {
1034 hackname = alpha_assert;
1035 files = "assert.h";
1036 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
1037 c_fix = format;
1038 c_fix_arg = "%1(EX)";
1039 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
1040 ': __assert(#EX, __FILE__, __LINE__))';
1044 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1046 fix = {
1047 hackname = alpha_getopt;
1048 files = "stdio.h";
1049 files = "stdlib.h";
1050 select = 'getopt\(int, char \*\[\], *char \*\)';
1051 c_fix = format;
1052 c_fix_arg = "getopt(int, char *const[], const char *)";
1053 test_text = 'extern int getopt(int, char *[], char *);';
1057 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
1059 fix = {
1060 hackname = alpha_if_semicolon;
1061 files = net/if.h;
1062 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
1063 c_fix = format;
1064 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
1065 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1069 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1071 fix = {
1072 hackname = alpha_parens;
1073 files = sym.h;
1074 select = '#ifndef\(__mips64\)';
1075 c_fix = format;
1076 c_fix_arg = "#ifndef __mips64";
1077 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1081 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1082 * And OpenBSD.
1084 fix = {
1085 hackname = alpha_sbrk;
1086 files = unistd.h;
1087 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1088 c_fix = format;
1089 c_fix_arg = "void *sbrk(";
1090 test_text = "extern char* sbrk(ptrdiff_t increment);";
1094 * For C++, avoid any typedef or macro definition of bool,
1095 * and use the built in type instead.
1096 * HP/UX 10.20 also has it in curses_colr/curses.h.
1098 fix = {
1099 hackname = avoid_bool_define;
1100 files = curses.h;
1101 files = curses_colr/curses.h;
1102 files = term.h;
1103 files = tinfo.h;
1105 select = "#[ \t]*define[ \t]+bool[ \t]";
1106 bypass = "__cplusplus";
1108 c_fix = format;
1109 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1110 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1112 test_text = "# define bool\t char \n";
1116 * avoid_bool_type
1118 fix = {
1119 hackname = avoid_bool_type;
1120 files = curses.h;
1121 files = curses_colr/curses.h;
1122 files = term.h;
1123 files = tinfo.h;
1125 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1126 bypass = "__cplusplus";
1128 c_fix = format;
1129 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1131 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1135 * For C++, avoid any typedef definition of wchar_t,
1136 * and use the built in type instead.
1137 * Don't do this for headers that are smart enough to do the right
1138 * thing (recent [n]curses.h and Xlib.h).
1139 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1140 * and will be broken by the edit.
1143 fix = {
1144 hackname = avoid_wchar_t_type;
1146 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1147 bypass = "__cplusplus";
1148 bypass = "_LINUX_NLS_H";
1149 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1151 c_fix = format;
1152 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1154 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1158 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1160 fix = {
1161 hackname = bad_struct_term;
1162 files = curses.h;
1163 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1164 c_fix = format;
1165 c_fix_arg = "struct term;";
1167 test_text = 'typedef struct term;';
1171 * Fix one other error in this file:
1172 * a mismatched quote not inside a C comment.
1174 fix = {
1175 hackname = badquote;
1176 files = sundev/vuid_event.h;
1177 select = "doesn't";
1178 c_fix = format;
1179 c_fix_arg = "does not";
1181 test_text = "/* doesn't have matched single quotes */";
1185 * check for broken assert.h that needs stdio.h
1187 fix = {
1188 hackname = broken_assert_stdio;
1189 files = assert.h;
1190 select = stderr;
1191 bypass = "include.*stdio\\.h";
1192 c_fix = wrap;
1193 c_fix_arg = "#include <stdio.h>\n";
1194 test_text = "extern FILE* stderr;";
1198 * check for broken assert.h that needs stdlib.h
1200 fix = {
1201 hackname = broken_assert_stdlib;
1202 files = assert.h;
1203 select = 'exit *\(|abort *\(';
1204 bypass = "include.*stdlib\\.h";
1205 c_fix = wrap;
1206 c_fix_arg = "#ifdef __cplusplus\n"
1207 "#include <stdlib.h>\n"
1208 "#endif\n";
1209 test_text = "extern void exit ( int );";
1213 * Remove `extern double cabs' declarations from math.h.
1214 * This conflicts with C99. Discovered on AIX.
1215 * Darwin hides its broken cabs in architecture-specific subdirs.
1217 fix = {
1218 hackname = broken_cabs;
1219 files = math.h, "architecture/*/math.h";
1220 select = "^extern[ \t]+double[ \t]+cabs";
1222 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1223 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1225 test_text = "#ifdef __STDC__\n"
1226 "extern double cabs(struct dbl_hypot);\n"
1227 "#else\n"
1228 "extern double cabs();\n"
1229 "#endif\n"
1230 "extern double cabs ( _Complex z );";
1234 * Fixup Darwin's broken check for __builtin_nanf.
1236 fix = {
1237 hackname = broken_nan;
1239 * It is tempting to omit the first "files" entry. Do not.
1240 * The testing machinery will take the first "files" entry as the name
1241 * of a test file to play with. It would be a nuisance to have a directory
1242 * with the name "*".
1244 files = "architecture/ppc/math.h";
1245 files = "architecture/*/math.h";
1246 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1247 bypass = "powl";
1248 c_fix = format;
1249 c_fix_arg = "#if 1";
1250 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1254 * Various systems derived from BSD4.4 contain a macro definition
1255 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1256 * Known to be fixed in FreeBSD 5 system headers.
1258 fix = {
1259 hackname = bsd_stdio_attrs_conflict;
1260 mach = "*-*-*bsd*";
1261 mach = "*-*-*darwin*";
1262 files = stdio.h;
1263 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1264 c_fix = format;
1265 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1266 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1267 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1268 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1269 test_text = '#define vfscanf __svfscanf';
1273 * Fix various macros used to define ioctl numbers.
1274 * The traditional syntax was:
1276 * #define _CTRL(n, x) (('n'<<8)+x)
1277 * #define TCTRLCFOO _CTRL(T, 1)
1279 * but this does not work with the C standard, which disallows macro
1280 * expansion inside strings. We have to rewrite it thus:
1282 * #define _CTRL(n, x) ((n<<8)+x)
1283 * #define TCTRLCFOO _CTRL('T', 1)
1285 * The select expressions match too much, but the c_fix code is cautious.
1287 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1289 fix = {
1290 hackname = ctrl_quotes_def;
1291 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1292 c_fix = char_macro_def;
1293 c_fix_arg = "CTRL";
1296 * This is two tests in order to ensure that the "CTRL(c)" can
1297 * be selected in isolation from the multi-arg format
1299 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1300 test_text = "#define _CTRL(c) ('c'&037)";
1304 * Fix various macros used to define ioctl numbers.
1306 fix = {
1307 hackname = ctrl_quotes_use;
1308 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1309 c_fix = char_macro_use;
1310 c_fix_arg = "CTRL";
1311 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1315 * sys/mman.h on HP/UX is not C++ ready,
1316 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1318 * rpc/types.h on OSF1/2.0 is not C++ ready,
1319 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1321 * The problem is the declaration of malloc.
1323 fix = {
1324 hackname = cxx_unready;
1325 files = sys/mman.h;
1326 files = rpc/types.h;
1327 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1328 not within a macro. */
1329 bypass = '"C"|__BEGIN_DECLS';
1331 c_fix = wrap;
1332 c_fix_arg = "#ifdef __cplusplus\n"
1333 "extern \"C\" {\n"
1334 "#endif\n";
1335 c_fix_arg = "#ifdef __cplusplus\n"
1336 "}\n"
1337 "#endif\n";
1338 test_text = "extern void* malloc( size_t );";
1342 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1343 * unconditionally.
1345 fix = {
1346 hackname = darwin_availabilityinternal;
1347 mach = "*-*-darwin*";
1348 files = AvailabilityInternal.h;
1349 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1350 c_fix = format;
1351 c_fix_arg = <<- _EOFix_
1352 #if defined(__has_attribute)
1353 #if __has_attribute(availability)
1355 #else
1356 #define %1
1357 #endif
1358 #else
1359 #define %1
1360 #endif
1361 _EOFix_;
1363 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1364 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1368 * For the AAB_darwin7_9_long_double_funcs fix (and later fixes for long long)
1369 * to be useful, the main math.h must use <> and not "" includes.
1371 fix = {
1372 hackname = darwin_9_long_double_funcs_2;
1373 mach = "*-*-darwin*";
1374 files = math.h;
1375 select = '#include[ \t]+\"';
1376 c_fix = format;
1377 c_fix_arg = "%1<%2.h>";
1379 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1381 test_text = '#include <architecture/ppc/math.h>';
1385 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1386 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1388 fix = {
1389 hackname = darwin_externc;
1390 mach = "*-*-darwin*";
1391 files = mach-o/swap.h;
1392 files = mach/mach_time.h;
1393 files = mach/mach_traps.h;
1394 files = mach/message.h;
1395 files = mach/mig.h;
1396 files = mach/semaphore.h;
1397 bypass = "extern \"C\"";
1398 bypass = "__BEGIN_DECLS";
1399 c_fix = wrap;
1400 c_fix_arg = "#ifdef __cplusplus\n"
1401 "extern \"C\" {\n"
1402 "#endif\n";
1403 c_fix_arg = "#ifdef __cplusplus\n"
1404 "}\n"
1405 "#endif\n";
1406 test_text = "extern void swap_fat_header();\n";
1410 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1411 * bad __GNUC__ tests.
1413 fix = {
1414 hackname = darwin_gcc4_breakage;
1415 mach = "*-*-darwin*";
1416 files = AvailabilityMacros.h;
1417 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1418 c_fix = format;
1419 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1420 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1421 "(__GNUC_MINOR__ >= 1)\n";
1425 * math.h hides the long long functions that are available on the system for
1426 * 10.5 and 10.6 SDKs, we expect to use them in G++ without specifying a value
1427 * for __STDC_VERSION__, or switching __STRICT_ANSI__ off.
1429 fix = {
1430 hackname = darwin_ll_funcs_avail;
1431 mach = "*-*-darwin*";
1432 files = architecture/ppc/math.h, architecture/i386/math.h;
1433 select = "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
1434 "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
1435 sed = "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
1436 "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
1437 test_text = "#if\ !(__DARWIN_NO_LONG_LONG)";
1441 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1443 fix = {
1444 hackname = darwin_longjmp_noreturn;
1445 mach = "*-*-darwin*";
1446 files = "i386/setjmp.h";
1447 bypass = "__dead2";
1448 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1449 c_fix = format;
1450 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1452 test_text = "void siglongjmp(sigjmp_buf, int);";
1456 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1458 fix = {
1459 hackname = darwin_os_trace_1;
1460 mach = "*-*-darwin*";
1461 files = os/trace.h;
1462 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1463 c_fix = format;
1464 c_fix_arg = "%1";
1465 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1469 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1470 * extension without guard.
1472 fix = {
1473 hackname = darwin_os_trace_2;
1474 mach = "*-*-darwin*";
1475 files = os/trace.h;
1476 select = "typedef.*\\^os_trace_payload_t.*";
1477 c_fix = format;
1478 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1479 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1483 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1484 * os_trace_payload_t typedef, too.
1486 fix = {
1487 hackname = darwin_os_trace_3;
1488 mach = "*-*-darwin*";
1489 files = os/trace.h;
1490 select = <<- _EOSelect_
1491 __(API|OSX)_.*
1492 OS_EXPORT.*
1494 _os_trace.*os_trace_payload_t payload);
1495 _EOSelect_;
1496 c_fix = format;
1497 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1498 test_text = <<- _EOText_
1499 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1500 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1501 void
1502 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1504 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1505 OS_EXPORT OS_NOTHROW
1506 void
1507 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1508 _EOText_;
1512 * In macOS 10.10 <os/base.h>, doesn't have __has_extension guarded.
1514 fix = {
1515 hackname = darwin_os_base_1;
1516 mach = "*-*-darwin*";
1517 files = os/base.h;
1518 select = <<- OS_BASE_1_SEL
1519 #define __has_attribute.*
1520 #endif
1521 OS_BASE_1_SEL;
1522 c_fix = format;
1523 c_fix_arg = <<- OS_BASE_1_FIX
1525 #ifndef __has_extension
1526 #define __has_extension(x) 0
1527 #endif
1528 OS_BASE_1_FIX;
1529 test_text = <<- OS_BASE_1_TEST
1530 #define __has_attribute(x) 0
1531 #endif
1533 #if __GNUC__
1534 OS_BASE_1_TEST;
1538 * In macOS 10.10 <dispatch/object.h>, has unguarded block syntax.
1540 fix = {
1541 hackname = darwin_dispatch_object_1;
1542 mach = "*-*-darwin*";
1543 files = dispatch/object.h;
1544 select = "typedef void.*\\^dispatch_block_t.*";
1545 c_fix = format;
1546 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1547 test_text = <<- DISPATCH_OBJECT_1_TEST
1548 typedef void (^dispatch_block_t)(void);
1550 __BEGIN_DECLS
1551 DISPATCH_OBJECT_1_TEST;
1555 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1556 * why would you ever put it in a system header file?
1558 fix = {
1559 hackname = darwin_private_extern;
1560 mach = "*-*-darwin*";
1561 files = mach-o/dyld.h;
1562 select = "__private_extern__ [a-z_]+ _dyld_";
1563 c_fix = format;
1564 c_fix_arg = "extern";
1565 c_fix_arg = "__private_extern__";
1566 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1567 "const char *dyld_func_name,\n"
1568 "unsigned long *address);\n";
1572 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1573 * unsigned constants.
1575 fix = {
1576 hackname = darwin_stdint_1;
1577 mach = "*-*-darwin*";
1578 files = stdint-darwin.h, stdint.h;
1579 c_fix = format;
1580 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1581 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1582 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1583 test_text = "#define UINT8_C(v) (v ## U)\n"
1584 "#define UINT16_C(v) (v ## U)";
1588 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1589 * with wrong types.
1591 fix = {
1592 hackname = darwin_stdint_2;
1593 mach = "*-*-darwin*";
1594 files = stdint-darwin.h, stdint.h;
1595 c_fix = format;
1596 c_fix_arg = "#if __WORDSIZE == 64\n"
1597 "#define INTPTR_MAX 9223372036854775807L\n"
1598 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1599 "#else\n"
1600 "#define INTPTR_MAX 2147483647L\n"
1601 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1602 "#endif";
1603 select = "#if __WORDSIZE == 64\n"
1604 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1605 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1606 "#else\n"
1607 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1608 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1609 "#endif";
1610 test_text = "#if __WORDSIZE == 64\n"
1611 "#define INTPTR_MIN INT64_MIN\n"
1612 "#define INTPTR_MAX INT64_MAX\n"
1613 "#else\n"
1614 "#define INTPTR_MIN INT32_MIN\n"
1615 "#define INTPTR_MAX INT32_MAX\n"
1616 "#endif";
1620 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1622 fix = {
1623 hackname = darwin_stdint_3;
1624 mach = "*-*-darwin*";
1625 files = stdint-darwin.h, stdint.h;
1626 c_fix = format;
1627 c_fix_arg = "#if __WORDSIZE == 64\n"
1628 "#define UINTPTR_MAX 18446744073709551615UL\n"
1629 "#else\n"
1630 "#define UINTPTR_MAX 4294967295UL\n"
1631 "#endif";
1632 select = "#if __WORDSIZE == 64\n"
1633 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1634 "#else\n"
1635 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1636 "#endif";
1637 test_text = "#if __WORDSIZE == 64\n"
1638 "#define UINTPTR_MAX UINT64_MAX\n"
1639 "#else\n"
1640 "#define UINTPTR_MAX UINT32_MAX\n"
1641 "#endif";
1645 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1647 fix = {
1648 hackname = darwin_stdint_4;
1649 mach = "*-*-darwin*";
1650 files = stdint-darwin.h, stdint.h;
1651 c_fix = format;
1652 c_fix_arg = "#if __WORDSIZE == 64\n"
1653 "#define SIZE_MAX 18446744073709551615UL\n"
1654 "#else\n"
1655 "#define SIZE_MAX 4294967295UL\n"
1656 "#endif";
1657 select = "#if __WORDSIZE == 64\n"
1658 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1659 "#else\n"
1660 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1661 "#endif";
1662 test_text = "#if __WORDSIZE == 64\n"
1663 "#define SIZE_MAX UINT64_MAX\n"
1664 "#else\n"
1665 "#define SIZE_MAX UINT32_MAX\n"
1666 "#endif";
1670 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1671 * with a wrong type.
1673 fix = {
1674 hackname = darwin_stdint_5;
1675 mach = "*-*-darwin*";
1676 files = stdint-darwin.h, stdint.h;
1677 c_fix = format;
1678 c_fix_arg = "#if __WORDSIZE == 64\n"
1679 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1680 "#define INTMAX_MAX 9223372036854775807L\n"
1681 "#define UINTMAX_MAX 18446744073709551615UL\n"
1682 "#else\n"
1683 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1684 "#define INTMAX_MAX 9223372036854775807LL\n"
1685 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1686 "#endif";
1687 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1688 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1689 "\n"
1690 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1691 test_text = "#define INTMAX_MIN INT64_MIN\n"
1692 "#define INTMAX_MAX INT64_MAX\n"
1693 "\n"
1694 "#define UINTMAX_MAX UINT64_MAX";
1698 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1699 * with a wrong type.
1701 fix = {
1702 hackname = darwin_stdint_6;
1703 mach = "*-*-darwin*";
1704 files = stdint-darwin.h, stdint.h;
1705 c_fix = format;
1706 c_fix_arg = "#if __WORDSIZE == 64\n"
1707 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1708 "#define PTRDIFF_MAX 9223372036854775807L\n"
1709 "#else\n"
1710 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1711 "#define PTRDIFF_MAX 2147483647\n"
1712 "#endif";
1713 select = "#if __WORDSIZE == 64\n"
1714 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1715 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1716 "#else\n"
1717 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1718 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1719 "#endif";
1720 test_text = "#if __WORDSIZE == 64\n"
1721 "#define PTRDIFF_MIN INT64_MIN\n"
1722 "#define PTRDIFF_MAX INT64_MAX\n"
1723 "#else\n"
1724 "#define PTRDIFF_MIN INT32_MIN\n"
1725 "#define PTRDIFF_MAX INT32_MAX\n"
1726 "#endif";
1730 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1731 * with a wrong type.
1733 fix = {
1734 hackname = darwin_stdint_7;
1735 mach = "*-*-darwin*";
1736 files = stdint-darwin.h, stdint.h;
1737 c_fix = format;
1738 c_fix_arg = "#if __WORDSIZE == 64\n"
1739 "#define INTMAX_C(v) (v ## L)\n"
1740 "#define UINTMAX_C(v) (v ## UL)\n"
1741 "#else\n"
1742 "#define INTMAX_C(v) (v ## LL)\n"
1743 "#define UINTMAX_C(v) (v ## ULL)\n"
1744 "#endif";
1745 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1746 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1747 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1748 "#define UINTMAX_C(v) (v ## ULL)";
1751 /* The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
1752 C11 _Atomic keyword (exposing it to C++ code). The work-around here follows
1753 the header in declaring the entity volatile when _Atomic is not available.
1755 fix = {
1756 hackname = darwin_ucred__Atomic;
1757 mach = "*-*-darwin*";
1758 files = sys/ucred.h;
1759 select = "_Atomic";
1760 c_fix = wrap;
1761 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1762 "# define _Atomic volatile\n"
1763 "#endif\n";
1764 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1765 "# undef _Atomic\n"
1766 "#endif\n";
1767 test_text = ""; /* Don't provide this for wrap fixes. */
1771 * Fix <c_asm.h> on Digital UNIX V4.0:
1772 * It contains a prototype for a DEC C internal asm() function,
1773 * clashing with gcc's asm keyword. So protect this with __DECC.
1775 fix = {
1776 hackname = dec_intern_asm;
1777 files = c_asm.h;
1778 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1779 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1780 "#endif\n";
1781 test_text =
1782 "float fasm {\n"
1783 " ... asm stuff ...\n"
1784 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1788 * Fix typo in <wchar.h> on DJGPP 2.03.
1790 fix = {
1791 hackname = djgpp_wchar_h;
1792 file = wchar.h;
1793 select = "__DJ_wint_t";
1794 bypass = "sys/djtypes.h";
1795 c_fix = format;
1796 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1797 c_fix_arg = "#include <stddef.h>";
1798 test_text = "#include <stddef.h>\n"
1799 "extern __DJ_wint_t x;\n";
1803 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1805 fix = {
1806 hackname = ecd_cursor;
1807 files = "sunwindow/win_lock.h";
1808 files = "sunwindow/win_cursor.h";
1809 select = 'ecd\.cursor';
1810 c_fix = format;
1811 c_fix_arg = 'ecd_cursor';
1813 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1817 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1818 * that fails when compiling for SSE-less 32-bit x86.
1820 fix = {
1821 hackname = feraiseexcept_nosse_divbyzero;
1822 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1823 files = bits/fenv.h, '*/bits/fenv.h';
1824 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1825 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1826 bypass = "\"fdivp .*; fwait\"";
1828 c_fix = format;
1829 c_fix_arg = <<- _EOText_
1830 # ifdef __SSE_MATH__
1832 # else
1833 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1834 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1835 # endif
1836 _EOText_;
1838 test_text = <<- _EOText_
1839 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1840 _EOText_;
1844 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1845 * that fails when compiling for SSE-less 32-bit x86.
1847 fix = {
1848 hackname = feraiseexcept_nosse_invalid;
1849 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1850 files = bits/fenv.h, '*/bits/fenv.h';
1851 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1852 ": \"x\" \\(__f\\)\\);$";
1853 bypass = "\"fdiv .*; fwait\"";
1855 c_fix = format;
1856 c_fix_arg = <<- _EOText_
1857 # ifdef __SSE_MATH__
1859 # else
1860 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1861 %1 : "=t" (__f) : "0" (__f));
1862 # endif
1863 _EOText_;
1865 test_text = <<- _EOText_
1866 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1867 _EOText_;
1871 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1872 * neither the existence of GCC 3 nor its exact feature set yet break
1873 * (by design?) when __GNUC__ is set beyond 2.
1875 fix = {
1876 hackname = freebsd_gcc3_breakage;
1877 mach = "*-*-freebsd*";
1878 files = sys/cdefs.h;
1879 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1880 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1881 c_fix = format;
1882 c_fix_arg = '%0 || __GNUC__ >= 3';
1883 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1887 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1888 * neither the existence of GCC 4 nor its exact feature set yet break
1889 * (by design?) when __GNUC__ is set beyond 3.
1891 fix = {
1892 hackname = freebsd_gcc4_breakage;
1893 mach = "*-*-freebsd*";
1894 files = sys/cdefs.h;
1895 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1896 c_fix = format;
1897 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1898 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1902 * Some versions of glibc don't expect the C99 inline semantics.
1904 fix = {
1905 hackname = glibc_c99_inline_1;
1906 files = features.h, '*/features.h';
1907 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1908 c_fix = format;
1909 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1910 test_text = <<-EOT
1911 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1912 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1913 # define __USE_EXTERN_INLINES 1
1914 #endif
1915 EOT;
1919 * Similar, but a version that didn't have __NO_INLINE__
1921 fix = {
1922 hackname = glibc_c99_inline_1a;
1923 files = features.h, '*/features.h';
1924 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1925 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1926 c_fix = format;
1927 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1928 test_text = <<-EOT
1929 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1930 # define __USE_EXTERN_INLINES 1
1931 #endif
1932 EOT;
1936 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1937 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1938 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1940 fix = {
1941 hackname = glibc_c99_inline_2;
1942 files = sys/stat.h, '*/sys/stat.h';
1943 select = "extern __inline__ int";
1944 sed = "s/extern int \\(stat\\)/"
1945 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1946 "__inline__ int \\1/";
1947 sed = "s/extern int \\([lf]stat\\)/"
1948 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1949 "__inline__ int \\1/";
1950 sed = "s/extern int \\(mknod\\)/"
1951 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1952 "__inline__ int \\1/";
1953 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1954 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1955 "__inline__ int __REDIRECT\\1 (\\2/";
1956 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1957 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1958 "__inline__ int __REDIRECT\\1 (\\2/";
1959 sed = "s/^extern __inline__ int/"
1960 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1961 "__inline__ int/";
1962 test_text = <<-EOT
1963 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1964 extern __inline__ int
1965 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1967 EOT;
1971 * glibc_c99_inline_3
1973 fix = {
1974 hackname = glibc_c99_inline_3;
1975 files = bits/string2.h, '*/bits/string2.h';
1976 select = "extern __inline";
1977 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1978 c_fix = format;
1979 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1980 c_fix_arg = "^# ifdef __cplusplus$";
1981 test_text = <<-EOT
1982 # ifdef __cplusplus
1983 # define __STRING_INLINE inline
1984 # else
1985 # define __STRING_INLINE extern __inline
1986 # endif
1987 EOT;
1991 * glibc_c99_inline_4
1993 fix = {
1994 hackname = glibc_c99_inline_4;
1995 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1996 pthread.h, '*/pthread.h';
1997 bypass = "__extern_inline|__gnu_inline__";
1998 select = "(^| )extern __inline";
1999 c_fix = format;
2000 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
2001 test_text = <<-EOT
2002 __extension__ extern __inline unsigned int
2003 extern __inline unsigned int
2004 EOT;
2007 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
2008 * so we replace them with versions that correspond to the
2009 * definition.
2011 fix = {
2012 hackname = glibc_mutex_init;
2013 files = pthread.h;
2014 select = '\{ *\{ *0, *\} *\}';
2015 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
2016 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
2017 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2018 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
2019 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2020 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
2021 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2022 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
2023 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2024 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
2025 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2026 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
2027 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2028 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
2029 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
2030 "N;s/^[ \t]*#[ \t]*"
2031 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
2032 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
2033 "# \\1\\\n"
2034 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
2035 "# else\\\n"
2036 "# \\1\\\n"
2037 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
2038 "# endif/";
2039 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
2040 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
2041 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
2042 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
2044 test_text = <<- _EOText_
2045 #define PTHREAD_MUTEX_INITIALIZER \\
2046 { { 0, } }
2047 #ifdef __USE_GNU
2048 # if __WORDSIZE == 64
2049 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2050 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2051 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2052 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2053 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2054 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2055 # else
2056 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2057 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2058 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2059 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2060 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2061 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2062 # endif
2063 #endif
2064 # define PTHREAD_RWLOCK_INITIALIZER \\
2065 { { 0, } }
2066 # ifdef __USE_GNU
2067 # if __WORDSIZE == 64
2068 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2069 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
2070 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2071 # else
2072 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2073 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2074 # endif
2075 # endif
2076 #define PTHREAD_COND_INITIALIZER { { 0, } }
2077 _EOText_;
2080 /* glibc versions before 2.5 have a version of stdint.h that defines
2081 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2082 versions with stdint.h based on those glibc versions. */
2083 fix = {
2084 hackname = glibc_stdint;
2085 files = stdint.h;
2086 select = "GNU C Library";
2087 c_fix = format;
2088 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2089 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2090 test_text = "/* This file is part of the GNU C Library. */\n"
2091 "# define UINT8_C(c)\tc ## U\n"
2092 "# define UINT16_C(c)\tc ## U";
2095 /* Some versions of glibc have a version of bits/string2.h that
2096 produces "value computed is not used" warnings from strncpy; fix
2097 this definition by using __builtin_strncpy instead as in newer
2098 versions. */
2099 fix = {
2100 hackname = glibc_strncpy;
2101 files = bits/string2.h, '*/bits/string2.h';
2102 bypass = "__builtin_strncpy";
2103 c_fix = format;
2104 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2105 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
2106 test_text = <<-EOT
2107 # define strncpy(dest, src, n) \
2108 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
2109 ? (strlen (src) + 1 >= ((size_t) (n)) \\
2110 ? (char *) memcpy (dest, src, n) \\
2111 : strncpy (dest, src, n)) \\
2112 : strncpy (dest, src, n)))
2113 EOT;
2117 /* glibc's tgmath.h relies on an expression that is not an integer
2118 constant expression being treated as it was by GCC 4.4 and
2119 earlier. */
2120 fix = {
2121 hackname = glibc_tgmath;
2122 files = tgmath.h;
2123 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2124 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2125 c_fix = format;
2126 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
2127 "(__builtin_classify_type ((type) 0) == 9 && "
2128 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2129 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2133 * Fix these files to use the types we think they should for
2134 * ptrdiff_t, size_t, and wchar_t.
2136 * This defines the types in terms of macros predefined by our 'cpp'.
2137 * This is supposedly necessary for glibc's handling of these types.
2138 * It's probably not necessary for anyone else, but it doesn't hurt.
2140 fix = {
2141 hackname = gnu_types;
2142 files = "sys/types.h";
2143 files = "stdlib.h";
2144 files = "sys/stdtypes.h";
2145 files = "stddef.h";
2146 files = "memory.h";
2147 files = "unistd.h";
2148 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2149 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2150 c_fix = gnu_type;
2151 /* The Solaris 10 headers already define these types correctly. */
2152 mach = '*-*-solaris2.1[0-9]*';
2153 not_machine = true;
2155 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2156 "typedef uint_t size_t; /* uint_t */\n"
2157 "typedef ushort_t wchar_t; /* ushort_t */";
2161 * Fix HP & Sony's use of "../machine/xxx.h"
2162 * to refer to: <machine/xxx.h>
2164 fix = {
2165 hackname = hp_inline;
2166 files = sys/spinlock.h;
2167 files = machine/machparam.h;
2168 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2170 c_fix = format;
2171 c_fix_arg = "%1<machine/%2.h>";
2173 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2174 '([a-z]+)\.h"';
2176 test_text = ' # include "../machine/mumble.h"';
2180 * Check for (...) in C++ code in HP/UX sys/file.h.
2182 fix = {
2183 hackname = hp_sysfile;
2184 files = sys/file.h;
2185 select = "HPUX_SOURCE";
2187 c_fix = format;
2188 c_fix_arg = "(struct file *, ...)";
2189 c_fix_arg = '\(\.\.\.\)';
2191 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2195 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2196 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2198 fix = {
2199 hackname = hppa_hpux_fp_macros;
2200 mach = "hppa*-hp-hpux11*";
2201 files = math.h;
2202 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2203 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2204 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2205 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2206 "#[ \t]*define[ \t]*FP_NAN.*\n";
2207 c_fix = format;
2208 c_fix_arg = <<- _EOFix_
2209 #endif /* _INCLUDE_HPUX_SOURCE */
2211 #if defined(_INCLUDE_HPUX_SOURCE) || \
2212 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2213 %0#endif
2215 #ifdef _INCLUDE_HPUX_SOURCE
2217 _EOFix_;
2219 test_text =
2220 "# define FP_NORMAL 0\n"
2221 "# define FP_ZERO 1\n"
2222 "# define FP_INFINITE 2\n"
2223 "# define FP_SUBNORMAL 3\n"
2224 "# define FP_NAN 4\n";
2228 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2229 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2231 fix = {
2232 hackname = hpux10_cpp_pow_inline;
2233 files = fixinc-test-limits.h, math.h;
2234 select = <<- END_POW_INLINE
2235 ^# +ifdef +__cplusplus
2237 +inline +double +pow\(double +__d,int +__expon\) +\{
2238 [ ]+return +pow\(__d,\(double\)__expon\);
2240 +extern +"C" +\{
2241 #else
2242 # +endif
2243 END_POW_INLINE;
2245 c_fix = format;
2246 c_fix_arg = "";
2248 test_text =
2249 "# ifdef __cplusplus\n"
2250 " }\n"
2251 " inline double pow(double __d,int __expon) {\n"
2252 "\t return pow(__d,(double)__expon);\n"
2253 " }\n"
2254 ' extern "C"' " {\n"
2255 "#else\n"
2256 "# endif";
2259 fix = {
2260 hackname = hpux11_cpp_pow_inline;
2261 files = math.h;
2262 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2263 " +return pow\\(d, \\(double\\)expon\\);\n"
2264 " +\\}\n";
2265 c_fix = format;
2266 c_fix_arg = "";
2268 test_text =
2269 " inline double pow(double d,int expon) {\n"
2270 " return pow(d, (double)expon);\n"
2271 " }\n";
2275 * Fix hpux 10.X missing ctype declarations 1
2277 fix = {
2278 hackname = hpux10_ctype_declarations1;
2279 files = ctype.h;
2280 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2281 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2282 c_fix = format;
2283 c_fix_arg = "#ifdef _PROTOTYPES\n"
2284 "extern int __tolower(int);\n"
2285 "extern int __toupper(int);\n"
2286 "#else /* NOT _PROTOTYPES */\n"
2287 "extern int __tolower();\n"
2288 "extern int __toupper();\n"
2289 "#endif /* _PROTOTYPES */\n\n"
2290 "%0\n";
2292 test_text = "# define _toupper(__c) __toupper(__c)\n";
2296 * Fix hpux 10.X missing ctype declarations 2
2298 fix = {
2299 hackname = hpux10_ctype_declarations2;
2300 files = ctype.h;
2301 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2302 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2303 c_fix = format;
2304 c_fix_arg = "%0\n\n"
2305 "#ifdef _PROTOTYPES\n"
2306 " extern int _isalnum(int);\n"
2307 " extern int _isalpha(int);\n"
2308 " extern int _iscntrl(int);\n"
2309 " extern int _isdigit(int);\n"
2310 " extern int _isgraph(int);\n"
2311 " extern int _islower(int);\n"
2312 " extern int _isprint(int);\n"
2313 " extern int _ispunct(int);\n"
2314 " extern int _isspace(int);\n"
2315 " extern int _isupper(int);\n"
2316 " extern int _isxdigit(int);\n"
2317 "# else /* not _PROTOTYPES */\n"
2318 " extern int _isalnum();\n"
2319 " extern int _isalpha();\n"
2320 " extern int _iscntrl();\n"
2321 " extern int _isdigit();\n"
2322 " extern int _isgraph();\n"
2323 " extern int _islower();\n"
2324 " extern int _isprint();\n"
2325 " extern int _ispunct();\n"
2326 " extern int _isspace();\n"
2327 " extern int _isupper();\n"
2328 " extern int _isxdigit();\n"
2329 "#endif /* _PROTOTYPES */\n";
2331 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2332 " extern unsigned int *__SB_masks;\n";
2336 * Fix hpux 10.X missing stdio declarations
2338 fix = {
2339 hackname = hpux10_stdio_declarations;
2340 files = stdio.h;
2341 select = "^#[ \t]*define _iob[ \t]*__iob";
2342 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2343 c_fix = format;
2344 c_fix_arg = "%0\n\n"
2345 "# if defined(__STDC__) || defined(__cplusplus)\n"
2346 " extern int snprintf(char *, size_t, const char *, ...);\n"
2347 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2348 "# else /* not __STDC__) || __cplusplus */\n"
2349 " extern int snprintf();\n"
2350 " extern int vsnprintf();\n"
2351 "# endif /* __STDC__) || __cplusplus */\n";
2353 test_text = "# define _iob __iob\n";
2357 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2358 * As a result, we need to include sys/stdsyms.h in alloca.h.
2360 fix = {
2361 hackname = hppa_hpux11_alloca;
2362 mach = "hppa*-*-hpux11*";
2363 files = alloca.h;
2364 select = "#ifndef _STDDEF_INCLUDED";
2365 c_fix = format;
2366 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2367 "# include <sys/stdsyms.h>\n"
2368 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2369 "%0";
2371 test_text = "#ifndef _STDDEF_INCLUDED";
2375 * Make sure hpux defines abs in header.
2377 fix = {
2378 hackname = hpux11_abs;
2379 mach = "*-hp-hpux11*";
2380 files = stdlib.h;
2381 select = "ifndef _MATH_INCLUDED";
2382 c_fix = format;
2383 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2384 test_text = "#ifndef _MATH_INCLUDED";
2388 * Fix hpux11 __LWP_RWLOCK_VALID define
2390 fix = {
2391 hackname = hpux11_lwp_rwlock_valid;
2392 mach = "*-hp-hpux11*";
2393 files = sys/pthread.h;
2394 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2395 c_fix = format;
2396 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2397 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2401 * hpux sendfile()
2403 fix = {
2404 hackname = hpux11_extern_sendfile;
2405 mach = "*-hp-hpux11.[12]*";
2406 files = sys/socket.h;
2407 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2408 c_fix = format;
2409 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2410 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2411 " const struct iovec *, int));\n";
2415 * hpux sendpath()
2417 fix = {
2418 hackname = hpux11_extern_sendpath;
2419 mach = "*-hp-hpux11.[12]*";
2420 files = sys/socket.h;
2421 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2422 c_fix = format;
2423 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2424 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2425 " const struct iovec *, int));\n";
2429 * Keep HP-UX 11 from stomping on C++ math namespace
2430 * with defines for fabsf.
2432 fix = {
2433 hackname = hpux11_fabsf;
2434 mach = "*-hp-hpux11*";
2435 files = math.h;
2436 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2438 c_fix = format;
2439 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2441 test_text =
2442 "#ifdef _PA_RISC\n"
2443 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2444 "#endif";
2448 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2449 * in pthread.h need to be constant expressions to be standard complient.
2450 * As a result, we need to remove the void * casts in the initializers
2451 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2452 * to use the long type.
2454 fix = {
2455 hackname = hpux11_pthread_pointer;
2456 mach = "*-hp-hpux11.[0-3]*";
2457 files = sys/pthread.h;
2458 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2460 c_fix = format;
2461 c_fix_arg = "long\t%2%3";
2462 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2466 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2468 fix = {
2469 hackname = hpux11_pthread_const;
2470 mach = "*-hp-hpux11.[0-3]*";
2471 files = sys/pthread.h;
2472 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2474 c_fix = format;
2475 c_fix_arg = "%11";
2476 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2480 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2481 * being defined by having it define _hpux_size_t instead.
2483 fix = {
2484 hackname = hpux11_size_t;
2485 mach = "*-hp-hpux11*";
2486 select = "__size_t";
2488 c_fix = format;
2489 c_fix_arg = "_hpux_size_t";
2491 test_text =
2492 "#define __size_t size_t\n"
2493 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2497 * Fix hpux 11.00 broken snprintf declaration
2498 * (third argument is char *, needs to be const char * to prevent
2499 * spurious warnings with -Wwrite-strings or in C++).
2501 fix = {
2502 hackname = hpux11_snprintf;
2503 files = stdio.h;
2504 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2505 ' *(char *\*, *\.\.\.\);)';
2506 c_fix = format;
2507 c_fix_arg = '%1 const %3';
2509 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2510 "extern int snprintf(char *, __size_t, char *, ...);\n"
2511 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2515 * Fix hpux 11.00 broken vsnprintf declaration
2517 fix = {
2518 hackname = hpux11_vsnprintf;
2519 files = stdio.h;
2520 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2521 'const char \*,) __va__list\);';
2522 c_fix = format;
2523 c_fix_arg = "%1 __va_list);";
2525 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2526 ' __va__list);';
2530 * Fix missing const in hpux vsscanf declaration
2532 fix = {
2533 hackname = hpux_vsscanf;
2534 mach = "*-*-hpux*";
2535 files = stdio.h;
2536 select = '(extern int vsscanf\()char';
2537 c_fix = format;
2538 c_fix_arg = "%1const char";
2540 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2544 * get rid of bogus inline definitions in HP-UX 8.0
2546 fix = {
2547 hackname = hpux8_bogus_inlines;
2548 files = math.h;
2549 select = inline;
2550 bypass = "__GNUG__";
2551 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2552 "@extern \"C\" int abs(int);@";
2553 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2554 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2555 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2556 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2557 "inline double sqr(double v) { return v**0.5; }";
2561 * hpux intptr
2563 fix = {
2564 hackname = hpux_c99_intptr;
2565 mach = "*-hp-hpux11.3*";
2566 files = stdint-hpux11.h, stdint.h;
2567 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2568 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2569 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2570 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2571 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2572 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2573 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2574 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2575 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2576 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2577 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2578 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2579 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2580 "#define PTRDIFF_MIN INT32_MIN\n"
2581 "#define INTPTR_MAX INT32_MAX\n"
2582 "#define INTPTR_MIN INT32_MIN\n"
2583 "#define UINTPTR_MAX UINT32_MAX\n"
2584 "#define SIZE_MAX UINT32_MAX\n";
2588 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2590 fix = {
2591 hackname = hpux_c99_inttypes;
2592 mach = "*-hp-hpux11.[23]*";
2593 files = inttypes.h;
2594 files = stdint-hpux11.h, stdint.h;
2595 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2596 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2597 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2598 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2599 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2600 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2601 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2602 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2603 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2604 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2605 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2606 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2610 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2612 fix = {
2613 hackname = hpux_c99_inttypes2;
2614 mach = "*-hp-hpux11.2*";
2615 files = stdint-hpux11.h, stdint.h;
2616 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2617 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2618 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2619 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2620 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2621 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2622 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2623 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2624 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2625 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2626 "# define INT16_C(__c) ((short)(__c))\n"
2627 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2631 * Fix broken and missing defines in inttypes.h
2633 fix = {
2634 hackname = hpux_c99_inttypes3;
2635 mach = "hppa*-hp-hpux11*";
2636 files = inttypes.h;
2637 select = "#define[ \t]INTPTR_MAX[ \t]*\n"
2638 "#define[ \t]UINTPTR_MAX[ \t]*\n";
2639 c_fix = format;
2640 c_fix_arg = "#undef SIZE_MAX\n"
2641 "#define SIZE_MAX __SIZE_MAX__\n"
2642 "#ifdef __INTPTR_MAX__\n"
2643 "# undef INTPTR_MAX\n"
2644 "# define INTPTR_MAX __INTPTR_MAX__\n"
2645 "# undef INTPTR_MIN\n"
2646 "# define INTPTR_MIN (-INTPTR_MAX - 1)\n"
2647 "#endif\n"
2648 "#ifdef __UINTPTR_MAX__\n"
2649 "# undef UINTPTR_MAX\n"
2650 "# define UINTPTR_MAX __UINTPTR_MAX__\n"
2651 "#endif\n";
2652 test_text = "#define INTPTR_MAX\n"
2653 "#define UINTPTR_MAX\n";
2657 * Fix missing SCNuMAX defines in inttypes.h
2659 fix = {
2660 hackname = hpux_c99_inttypes4;
2661 mach = "hppa*-hp-hpux11.[01]*";
2662 files = inttypes.h;
2663 sed = "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx64/a\\\n"
2664 "#define SCNuMAX \t SCNu64\n";
2665 sed = "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx32/a\\\n"
2666 "#define SCNuMAX \t SCNu32\n";
2667 test_text = "#define SCNxMAX SCNx64\n"
2668 "#define SCNxMAX SCNx32\n";
2672 * Fix missing PRIdPTR defines in inttypes.h
2674 fix = {
2675 hackname = hpux_c99_inttypes5;
2676 mach = "hppa*-hp-hpux11.[01]*";
2677 files = inttypes.h;
2678 select = "#ifndef[ \t]_KERNEL[ \t]*\n";
2679 c_fix = format;
2680 c_fix_arg = "#ifndef __LP64__\n"
2681 "#define PRIdPTR\t\tPRId32\n"
2682 "#define PRIiPTR\t\tPRIi32\n"
2683 "#define PRIoPTR\t\tPRIo32\n"
2684 "#define PRIuPTR\t\tPRIu32\n"
2685 "#define PRIxPTR\t\tPRIx32\n"
2686 "#define PRIXPTR\t\tPRIX32\n"
2687 "#else\n"
2688 "#define PRIdPTR\t\tPRId64\n"
2689 "#define PRIiPTR\t\tPRIi64\n"
2690 "#define PRIoPTR\t\tPRIo64\n"
2691 "#define PRIuPTR\t\tPRIu64\n"
2692 "#define PRIxPTR\t\tPRIx64\n"
2693 "#define PRIXPTR\t\tPRIX64\n"
2694 "#endif\n\n"
2695 "#ifndef _KERNEL\n";
2696 test_text = "#ifndef _KERNEL\n";
2700 * Fix hpux broken ctype macros
2702 fix = {
2703 hackname = hpux_ctype_macros;
2704 files = ctype.h;
2705 select = '((: |\()__SB_masks \? )'
2706 '(__SB_masks\[__(alnum|c)\] & _IS)';
2707 c_fix = format;
2708 c_fix_arg = "%1(int)%3";
2710 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2711 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2715 * hpux errno()
2717 fix = {
2718 hackname = hpux_extern_errno;
2719 mach = "*-hp-hpux10.*";
2720 mach = "*-hp-hpux11.[0-2]*";
2721 files = errno.h;
2722 select = "^[ \t]*extern int errno;$";
2723 c_fix = format;
2724 c_fix_arg = "#ifdef __cplusplus\n"
2725 "extern \"C\" {\n"
2726 "#endif\n"
2727 "%0\n"
2728 "#ifdef __cplusplus\n"
2729 "}\n"
2730 "#endif";
2731 test_text = " extern int errno;\n";
2735 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2737 fix = {
2738 hackname = hpux_htonl;
2739 files = netinet/in.h;
2740 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2741 "(/\\*\n"
2742 " \\* Macros for number representation conversion\\.\n"
2743 " \\*/\n"
2744 "#ifndef ntohl)";
2745 c_fix = format;
2746 c_fix_arg = "#if 1\n%1";
2748 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2749 "/*\n"
2750 " * Macros for number representation conversion.\n"
2751 " */\n"
2752 "#ifndef ntohl\n"
2753 "#define ntohl(x) (x)\n"
2754 "#define ntohs(x) (x)\n"
2755 "#define htonl(x) (x)\n"
2756 "#define htons(x) (x)\n"
2757 "#endif\n"
2758 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2762 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2764 fix = {
2765 hackname = hpux_imaginary_i;
2766 mach = "ia64-hp-hpux11.*";
2767 files = complex.h;
2768 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2769 c_fix = format;
2770 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2771 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2775 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2777 fix = {
2778 hackname = hpux_inttype_int8_t;
2779 mach = "*-hp-hpux1[01].*";
2780 files = sys/_inttypes.h;
2781 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2782 c_fix = format;
2783 c_fix_arg = "typedef signed char int%18_t;";
2784 test_text = "typedef char int_least8_t;\n"
2785 "typedef char int8_t;\n";
2789 * HP-UX long_double
2791 fix = {
2792 hackname = hpux_long_double;
2793 mach = "*-*-hpux10*";
2794 mach = "*-*-hpux11.[012]*";
2795 files = stdlib.h;
2796 select = "extern[ \t]long_double[ \t]strtold";
2797 bypass = "long_double_t";
2798 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2799 sed = "s/long_double/long double/g";
2801 test_text = "# ifndef _LONG_DOUBLE\n"
2802 "# define _LONG_DOUBLE\n"
2803 " typedef struct {\n"
2804 " unsigned int word1, word2, word3, word4;\n"
2805 " } long_double;\n"
2806 "# endif /* _LONG_DOUBLE */\n"
2807 "extern long_double strtold(const char *, char **);\n";
2811 * We cannot use the above rule on 11.31 because it removes the strtold
2812 * definition. ia64 is OK with no hack, PA needs some help.
2814 fix = {
2815 hackname = hpux_long_double_2;
2816 mach = "hppa*-*-hpux11.3*";
2817 files = stdlib.h;
2818 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2819 "defined\\(_PROTOTYPES\\) \\|\\| "
2820 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2821 c_fix = format;
2822 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2824 test_text = "# if !defined(__ia64) || "
2825 "!defined(_PROTOTYPES) || "
2826 "defined(_LONG_DOUBLE_STRUCT)\n";
2830 * Add missing braces to pthread initializer defines.
2832 fix = {
2833 hackname = hpux_pthread_initializers;
2834 mach = "*-hp-hpux11.[0-3]*";
2835 files = sys/pthread.h;
2836 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2837 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2838 sed = "s@^[ \t]*1,[ \t]*\\\\"
2839 "@\t{ 1, 0 }@";
2840 sed = "/^[ \t]*0$/d";
2841 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2842 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2843 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2844 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2845 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2846 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2847 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2848 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2849 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2850 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2851 sed = "s@__PTHREAD_COND_VALID, 0"
2852 "@{ __PTHREAD_COND_VALID, 0 }@";
2853 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2854 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2855 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2856 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2857 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2858 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2859 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2860 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2861 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2862 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2863 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2864 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2865 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2866 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2867 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2868 "}\n";
2872 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2873 * type and mpinfou is only defined when _KERNEL is set.
2875 fix = {
2876 hackname = hpux_spu_info;
2877 mach = "*-hp-hpux*";
2879 * It is tempting to omit the first "files" entry. Do not.
2880 * The testing machinery will take the first "files" entry as the name
2881 * of a test file to play with. It would be a nuisance to have a directory
2882 * with the name "*".
2884 files = "ia64/sys/getppdp.h";
2885 files = "*/sys/getppdp.h";
2886 select = "^.*extern.*spu_info.*";
2888 c_fix = format;
2889 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2891 test_text = "extern union mpinfou spu_info[];";
2895 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2897 fix = {
2898 hackname = hpux_stdint_least_fast;
2899 mach = "*-hp-hpux11.2*";
2900 files = stdint-hpux11.h, stdint.h;
2901 select =
2902 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2903 c_fix = format;
2904 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2905 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2906 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2910 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2912 fix = {
2913 hackname = hpux_longjmp;
2914 mach = "*-hp-hpux*";
2915 files = setjmp.h;
2916 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2918 c_fix = format;
2919 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2921 test_text = 'extern void longjmp __((jmp_buf, int));';
2925 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2927 fix = {
2928 hackname = hpux_systime;
2929 files = sys/time.h;
2930 select = "^extern struct sigevent;";
2932 c_fix = format;
2933 c_fix_arg = "struct sigevent;";
2935 test_text = 'extern struct sigevent;';
2939 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2941 fix = {
2942 hackname = huge_val_hex;
2943 files = bits/huge_val.h, '*/bits/huge_val.h';
2944 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2945 bypass = "__builtin_huge_val";
2947 c_fix = format;
2948 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2950 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2954 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2956 fix = {
2957 hackname = huge_valf_hex;
2958 files = bits/huge_val.h, '*/bits/huge_val.h';
2959 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2960 bypass = "__builtin_huge_valf";
2962 c_fix = format;
2963 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2965 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2969 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2971 fix = {
2972 hackname = huge_vall_hex;
2973 files = bits/huge_val.h, '*/bits/huge_val.h';
2974 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2975 bypass = "__builtin_huge_vall";
2977 c_fix = format;
2978 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2980 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2984 * Fix return type of abort and free
2986 fix = {
2987 hackname = int_abort_free_and_exit;
2988 files = stdlib.h;
2989 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2990 bypass = "_CLASSIC_ANSI_TYPES";
2992 c_fix = format;
2993 c_fix_arg = "void\t%1(";
2995 test_text = "extern int abort(int);\n"
2996 "extern int free(void*);\n"
2997 "extern int exit(void*);";
3001 * Fix various macros used to define ioctl numbers.
3002 * The traditional syntax was:
3004 * #define _IO(n, x) (('n'<<8)+x)
3005 * #define TIOCFOO _IO(T, 1)
3007 * but this does not work with the C standard, which disallows macro
3008 * expansion inside strings. We have to rewrite it thus:
3010 * #define _IO(n, x) ((n<<8)+x)
3011 * #define TIOCFOO _IO('T', 1)
3013 * The select expressions match too much, but the c_fix code is cautious.
3015 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
3017 fix = {
3018 hackname = io_quotes_def;
3019 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
3020 c_fix = char_macro_def;
3021 c_fix_arg = "IO";
3022 test_text =
3023 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
3024 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
3025 "#define _IO(x,y) ('x'<<8|y)";
3026 test_text =
3027 "#define XX_IO(x) ('x'<<8|256)";
3031 * Fix the usage of the ioctl macro numbers.
3033 fix = {
3034 hackname = io_quotes_use;
3035 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
3036 "\\( *[^,']";
3037 c_fix = char_macro_use;
3038 c_fix_arg = "IO";
3039 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
3040 "#define TIOCFOO \\\\\n"
3041 "BSD43__IOWR(T, 1) /* Some are multi-line */";
3045 * Check for missing ';' in struct
3047 fix = {
3048 hackname = ip_missing_semi;
3049 files = netinet/ip.h;
3050 select = "}$";
3051 sed = "/^struct/,/^};/s/}$/};/";
3052 test_text=
3053 "struct mumble {\n"
3054 " union {\n"
3055 " int x;\n"
3056 " }\n"
3057 "}; /* mumbled struct */\n";
3061 * Non-traditional "const" declaration in Irix's limits.h.
3063 fix = {
3064 hackname = irix_limits_const;
3065 files = fixinc-test-limits.h, limits.h;
3066 select = "^extern const ";
3067 c_fix = format;
3068 c_fix_arg = "extern __const ";
3069 test_text = "extern const char limit; /* test limits */";
3073 * IRIX 5.x's stdio.h declares some functions that take a va_list as
3074 * taking char *. However, GCC uses void * for va_list, so
3075 * calling vfprintf with a va_list fails in C++. */
3076 fix = {
3077 hackname = irix_stdio_va_list;
3078 files = stdio.h;
3080 select = '/\* va_list \*/ char \*';
3081 c_fix = format;
3082 c_fix_arg = "__gnuc_va_list";
3083 test_text =
3084 "extern int printf( const char *, /* va_list */ char * );";
3088 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
3089 * use / * * / to concatenate tokens.
3091 fix = {
3092 hackname = kandr_concat;
3093 files = "sparc/asm_linkage.h";
3094 files = "sun*/asm_linkage.h";
3095 files = "arm/as_support.h";
3096 files = "arm/mc_type.h";
3097 files = "arm/xcb.h";
3098 files = "dev/chardefmac.h";
3099 files = "dev/ps_irq.h";
3100 files = "dev/screen.h";
3101 files = "dev/scsi.h";
3102 files = "sys/tty.h";
3103 files = "Xm.acorn/XmP.h";
3104 files = bsd43/bsd43_.h;
3105 select = '/\*\*/';
3106 c_fix = format;
3107 c_fix_arg = '##';
3108 test_text = "#define __CONCAT__(a,b) a/**/b";
3112 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
3113 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
3114 * constant on recent versions of g++.
3116 fix = {
3117 hackname = linux_ia64_ucontext;
3118 files = "sys/ucontext.h";
3119 mach = "ia64-*-linux*";
3120 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
3121 '->sc_gr\[0\]\) - \(char \*\) 0\)';
3122 c_fix = format;
3123 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
3124 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
3125 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
3129 * Remove header file warning from sys/time.h. Autoconf's
3130 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
3131 * which causes warning on LynxOS. Remove the warning.
3133 fix = {
3134 hackname = lynxos_no_warning_in_sys_time_h;
3135 files = sys/time.h;
3136 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
3137 c_fix = format;
3138 c_fix_arg = "";
3139 test_text = "#warning Using <time.h> instead of <sys/time.h>";
3143 * Add missing declaration for putenv.
3145 fix = {
3146 hackname = lynxos_missing_putenv;
3147 mach = '*-*-lynxos*';
3148 files = stdlib.h;
3149 bypass = 'putenv[ \t]*\\(';
3150 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3151 c_fix = format;
3152 c_fix_arg = "%0\n"
3153 "extern int putenv _AP((char *));";
3154 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3155 test_text = "extern char *getenv _AP((const char *));";
3159 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3161 * On NetBSD, machine is a symbolic link to an architecture specific
3162 * directory name, so we can't match a specific file name here.
3164 fix = {
3165 hackname = machine_ansi_h_va_list;
3166 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
3167 bypass = '__builtin_va_list';
3169 c_fix = format;
3170 c_fix_arg = "%1__builtin_va_list";
3171 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3173 test_text = " # define _BSD_VA_LIST_\tchar**";
3177 * Fix non-ansi machine name defines
3179 fix = {
3180 hackname = machine_name;
3181 c_test = machine_name;
3182 c_fix = machine_name;
3184 test_text = "/* MACH_DIFF: */\n"
3185 "#if defined( i386 ) || defined( sparc ) || defined( vax ) || "
3186 "defined( linux ) || __has_include ( <linux.h> )"
3187 "\n/* no uniform test, so be careful :-) */";
3191 * Some math.h files define struct exception (it's in the System V
3192 * Interface Definition), which conflicts with the class exception defined
3193 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
3194 * This is not a great fix, but I haven't been able to think of anything
3195 * better.
3197 fix = {
3198 hackname = math_exception;
3199 files = math.h;
3200 select = "struct exception";
3202 * This should be bypassed on __cplusplus, but some supposedly C++
3203 * aware headers, such as Solaris 8 and 9, don't wrap their struct
3204 * exception either. So currently we bypass only for glibc, based on a
3205 * comment in the fixed glibc header. Ick.
3207 bypass = 'We have a problem when using C\+\+|for C\+\+, '
3208 '_[a-z0-9A-Z_]+_exception; for C, exception';
3209 /* The Solaris 10 headers already get this right. */
3210 mach = '*-*-solaris2.1[0-9]*';
3211 not_machine = true;
3212 c_fix = wrap;
3214 c_fix_arg = "#ifdef __cplusplus\n"
3215 "#define exception __math_exception\n"
3216 "#endif\n";
3218 c_fix_arg = "#ifdef __cplusplus\n"
3219 "#undef exception\n"
3220 "#endif\n";
3222 test_text = "typedef struct exception t_math_exception;";
3226 * This looks pretty broken to me. ``dbl_max_def'' will contain
3227 * "define DBL_MAX " at the start, when what we really want is just
3228 * the value portion. Can't figure out how to write a test case
3229 * for this either :-(
3231 fix = {
3232 hackname = math_huge_val_from_dbl_max;
3233 files = math.h;
3236 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3237 * in math.h, this fix applies.
3239 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3240 bypass = "define[ \t]+DBL_MAX";
3242 shell =
3244 * See if we have a definition for DBL_MAX in float.h.
3245 * If we do, we will replace the one in math.h with that one.
3248 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3249 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3251 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3252 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3253 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3254 "\telse cat\n"
3255 "\tfi";
3257 test_text =
3258 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3259 "#define HUGE_VAL DBL_MAX";
3263 * nested comment
3265 fix = {
3266 hackname = nested_auth_des;
3267 files = rpc/rpc.h;
3268 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3269 c_fix = format;
3270 c_fix_arg = "%1*/ /*";
3271 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3275 * Some versions of NetBSD don't expect the C99 inline semantics.
3277 fix = {
3278 hackname = netbsd_c99_inline_1;
3279 mach = "*-*-netbsd*";
3280 files = signal.h;
3281 select = "extern __inline int";
3283 c_fix = format;
3284 c_fix_arg = "extern\n"
3285 "#ifdef __GNUC_STDC_INLINE__\n"
3286 "__attribute__((__gnu_inline__))\n"
3287 "#endif\n"
3288 "__inline int";
3290 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3294 * netbsd_c99_inline_2
3296 fix = {
3297 hackname = netbsd_c99_inline_2;
3298 mach = "*-*-netbsd*";
3299 files = signal.h;
3300 select = "#define _SIGINLINE extern __inline";
3302 c_fix = format;
3303 c_fix_arg = <<- _EOArg_
3304 #ifdef __GNUC_STDC_INLINE__
3305 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3306 #else
3308 #endif
3309 _EOArg_;
3311 test_text = "#define _SIGINLINE extern __inline";
3315 * NetBSD has a semicolon after the ending '}' for some extern "C".
3317 fix = {
3318 hackname = netbsd_extra_semicolon;
3319 mach = "*-*-netbsd*";
3320 files = sys/cdefs.h;
3321 select = "#define[ \t]*__END_DECLS[ \t]*};";
3323 c_fix = format;
3324 c_fix_arg = "#define __END_DECLS }";
3326 test_text = "#define __END_DECLS };";
3330 * newlib's stdint.h has several failures to conform to C99. The fix
3331 * for these removed a comment that can be matched to identify unfixed
3332 * versions.
3334 fix = {
3335 hackname = newlib_stdint_1;
3336 files = stdint-newlib.h, stdint.h;
3337 select = "@todo - Add support for wint_t types";
3338 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3339 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3340 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3341 sed = "s@#define INT_LEAST32_MIN.*@"
3342 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3343 sed = "s@#define INT_LEAST32_MAX.*@"
3344 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3345 sed = "s@#define UINT_LEAST32_MAX.*@"
3346 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3347 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3348 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3349 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3350 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3351 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3352 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3353 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3354 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3355 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3356 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3357 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3358 test_text = "/* @todo - Add support for wint_t types. */\n"
3359 "#define INT32_MIN (-2147483647-1)\n"
3360 "#define INT32_MAX 2147483647\n"
3361 "#define UINT32_MAX 4294967295U\n"
3362 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3363 "#define INT_LEAST32_MAX 2147483647\n"
3364 "#define UINT_LEAST32_MAX 4294967295U\n"
3365 "#define INT_FAST8_MIN INT8_MIN\n"
3366 "#define INT_FAST8_MAX INT8_MAX\n"
3367 "#define UINT_FAST8_MAX UINT8_MAX\n"
3368 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3369 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3370 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3371 "#define UINT8_C(x) x##U\n"
3372 "#define UINT16_C(x) x##U";
3376 * newlib_stdint_2
3378 fix = {
3379 hackname = newlib_stdint_2;
3380 files = stdint-newlib.h, stdint.h;
3381 select = "@todo - Add support for wint_t types";
3382 c_fix = format;
3383 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3384 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3385 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3386 "#define WCHAR_MAX __WCHAR_MAX__\n"
3387 "#define WCHAR_MIN __WCHAR_MIN__\n"
3388 "#define WINT_MAX __WINT_MAX__\n"
3389 "#define WINT_MIN __WINT_MIN__\n\n"
3390 "%0";
3391 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3392 test_text = "/* @todo - Add support for wint_t types. */\n"
3393 "/** Macros for minimum-width integer constant expressions */";
3397 * NeXT 3.2 adds const prefix to some math functions.
3398 * These conflict with the built-in functions.
3400 fix = {
3401 hackname = next_math_prefix;
3402 files = ansi/math.h;
3403 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3405 c_fix = format;
3406 c_fix_arg = "extern double %1(";
3407 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3409 test_text = "extern\tdouble\t__const__\tmumble();";
3413 * NeXT 3.2 uses the word "template" as a parameter for some
3414 * functions. GCC reports an invalid use of a reserved key word
3415 * with the built-in functions.
3417 fix = {
3418 hackname = next_template;
3419 files = bsd/libc.h;
3420 select = "[ \t]template\\)";
3422 c_fix = format;
3423 c_fix_arg = "(%1)";
3424 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3425 test_text = "extern mumble( char * template); /* fix */";
3429 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3430 * function prototypes. That conflicts with the built-in functions.
3432 fix = {
3433 hackname = next_volitile;
3434 files = ansi/stdlib.h;
3435 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3437 c_fix = format;
3438 c_fix_arg = "extern void %1(";
3439 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3441 test_text = "extern\tvolatile\tvoid\tabort();";
3445 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3446 * Note that version 3 of the NeXT system has wait.h in a different directory,
3447 * so that this code won't do anything. But wait.h in version 3 has a
3448 * conditional, so it doesn't need this fix. So everything is okay.
3450 fix = {
3451 hackname = next_wait_union;
3452 files = sys/wait.h;
3454 select = 'wait\(union wait';
3455 c_fix = format;
3456 c_fix_arg = "wait(void";
3457 test_text = "extern pid_d wait(union wait*);";
3461 * a missing semi-colon at the end of the nodeent structure definition.
3463 fix = {
3464 hackname = nodeent_syntax;
3465 files = netdnet/dnetdb.h;
3466 select = "char[ \t]*\\*na_addr[ \t]*$";
3467 c_fix = format;
3468 c_fix_arg = "%0;";
3469 test_text = "char *na_addr\t";
3473 * Fix OpenBSD's NULL definition.
3475 fix = {
3476 hackname = openbsd_null_definition;
3477 mach = "*-*-openbsd*";
3478 files = locale.h, stddef.h, stdio.h, string.h,
3479 time.h, unistd.h, wchar.h, sys/param.h;
3480 select = "__GNUG__";
3481 c_fix = format;
3482 c_fix_arg = "#ifndef NULL\n"
3483 "#ifdef __cplusplus\n"
3484 "#ifdef __GNUG__\n"
3485 "#define NULL\t__null\n"
3486 "#else\t /* ! __GNUG__ */\n"
3487 "#define NULL\t0L\n"
3488 "#endif\t /* __GNUG__ */\n"
3489 "#else\t /* ! __cplusplus */\n"
3490 "#define NULL\t((void *)0)\n"
3491 "#endif\t /* __cplusplus */\n"
3492 "#endif\t /* !NULL */";
3494 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3495 "^#ifdef[ \t]*__GNUG__\n"
3496 "^#define[ \t]*NULL[ \t]*__null\n"
3497 "^#else\n"
3498 "^#define[ \t]*NULL[ \t]*0L\n"
3499 "^#endif\n"
3500 "^#endif";
3501 test_text =
3502 "#ifndef NULL\n"
3503 "#ifdef __GNUG__\n"
3504 "#define NULL __null\n"
3505 "#else\n"
3506 "#define NULL 0L\n"
3507 "#endif\n"
3508 "#endif\n";
3512 * obstack.h used casts as lvalues.
3514 * We need to change postincrements of casted pointers (which are
3515 * then dereferenced and assigned into) of the form
3517 * *((TYPE*)PTRVAR)++ = (VALUE)
3519 * into expressions like
3521 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3523 * which is correct for the cases used in obstack.h since PTRVAR is
3524 * of type char * and the value of the expression is not used.
3526 fix = {
3527 hackname = obstack_lvalue_cast;
3528 files = obstack.h;
3529 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3530 c_fix = format;
3531 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3532 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3536 * Fix OpenBSD's va_start define.
3538 fix = {
3539 hackname = openbsd_va_start;
3540 mach = "*-*-openbsd*";
3541 files = stdarg.h;
3542 select = '__builtin_stdarg_start';
3543 c_fix = format;
3544 c_fix_arg = __builtin_va_start;
3546 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3550 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3551 * defining regex.h related types. This causes libg++ build and usage
3552 * failures. Fixing this correctly requires checking and modifying 3 files.
3554 fix = {
3555 hackname = osf_namespace_a;
3556 files = reg_types.h;
3557 files = sys/lc_core.h;
3558 test = " -r reg_types.h";
3559 test = " -r sys/lc_core.h";
3560 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3561 test = " -z \"`grep __regex_t regex.h`\"";
3563 c_fix = format;
3564 c_fix_arg = "__%0";
3565 c_fix_arg = "reg(ex|off|match)_t";
3567 test_text = "`touch sys/lc_core.h`"
3568 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3569 "extern regex_t re;\n"
3570 "extern regoff_t ro;\n"
3571 "extern regmatch_t rm;\n";
3574 fix = {
3575 hackname = osf_namespace_c;
3576 files = regex.h;
3577 test = " -r reg_types.h";
3578 test = " -r sys/lc_core.h";
3579 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3580 test = " -z \"`grep __regex_t regex.h`\"";
3582 select = "#include <reg_types\.h>.*";
3583 c_fix = format;
3584 c_fix_arg = "%0\n"
3585 "typedef __regex_t\tregex_t;\n"
3586 "typedef __regoff_t\tregoff_t;\n"
3587 "typedef __regmatch_t\tregmatch_t;";
3589 test_text = "#include <reg_types.h>";
3593 * On broken glibc-2.3.3 systems an array of incomplete structures is
3594 * passed to __sigsetjmp. Fix that to take a pointer instead.
3596 fix = {
3597 hackname = pthread_incomplete_struct_argument;
3598 files = pthread.h;
3599 select = "struct __jmp_buf_tag";
3600 c_fix = format;
3601 c_fix_arg = "%1 *%2%3";
3602 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3603 "(__env)\\[1\\](.*)$";
3604 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3605 "int __savemask);";
3609 * Fix return type of fread and fwrite on sysV68
3611 fix = {
3612 hackname = read_ret_type;
3613 files = stdio.h;
3614 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3615 c_fix = format;
3616 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3617 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3619 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3623 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3625 fix = {
3626 hackname = rpc_xdr_lvalue_cast_a;
3627 files = rpc/xdr.h;
3628 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3629 c_fix = format;
3630 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3631 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3632 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3636 * rpc_xdr_lvalue_cast_b
3638 fix = {
3639 hackname = rpc_xdr_lvalue_cast_b;
3640 files = rpc/xdr.h;
3641 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3642 c_fix = format;
3643 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3644 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3645 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3649 * function class(double x) conflicts with C++ keyword on rs/6000
3651 fix = {
3652 hackname = rs6000_double;
3653 files = math.h;
3654 select = '[^a-zA-Z_]class\(';
3656 c_fix = format;
3657 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3658 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3660 test_text = "extern int class();";
3664 * Wrong fchmod prototype on RS/6000.
3666 fix = {
3667 hackname = rs6000_fchmod;
3668 files = sys/stat.h;
3669 select = 'fchmod\(char \*';
3670 c_fix = format;
3671 c_fix_arg = "fchmod(int";
3672 test_text = "extern int fchmod(char *, mode_t);";
3676 * parameters conflict with C++ new on rs/6000
3678 fix = {
3679 hackname = rs6000_param;
3680 files = "stdio.h";
3681 files = "unistd.h";
3683 select = 'rename\(const char \*old, const char \*new\)';
3684 c_fix = format;
3685 c_fix_arg = 'rename(const char *_old, const char *_new)';
3687 test_text = 'extern int rename(const char *old, const char *new);';
3691 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3692 * for C99. This is wrong for C++, which needs many C99 features, but
3693 * only supports __restrict.
3695 fix = {
3696 hackname = solaris___restrict;
3697 files = sys/feature_tests.h;
3698 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3699 mach = "*-*-solaris2*";
3700 c_fix = format;
3701 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3702 "#else\n%0\n#endif";
3703 test_text = "#define _RESTRICT_KYWD restrict";
3707 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3708 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3709 * and imaginary definitions which are not supported by GCC.
3711 fix = {
3712 hackname = solaris_complex;
3713 mach = "*-*-solaris2.*";
3714 files = complex.h;
3715 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3716 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3717 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3718 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3719 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3720 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3721 test_text = "#define _Complex_I _Complex_I\n"
3722 "#define complex _Complex\n"
3723 "#define _Imaginary_I _Imaginary_I\n"
3724 "#define imaginary _Imaginary\n"
3725 "#undef I\n"
3726 "#define I _Imaginary_I";
3730 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3731 * extern "C" instead so libstdc++ can use it.
3733 fix = {
3734 hackname = solaris_complex_cxx;
3735 mach = "*-*-solaris2.*";
3736 files = complex.h;
3737 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3738 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3739 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3740 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3741 test_text = "#if !defined(__cplusplus)\n"
3742 "#endif /* !defined(__cplusplus) */";
3746 * g++ rejects functions declared with both C and C++ linkage.
3748 fix = {
3749 hackname = solaris_cxx_linkage;
3750 mach = '*-*-solaris2*';
3751 files = "iso/stdlib_iso.h";
3752 select = "(#if __cplusplus >= 199711L)\n"
3753 "(extern \"C\\+\\+\" \\{\n)"
3754 "(.*(bsearch|qsort).*)";
3755 c_fix = format;
3756 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3758 test_text =
3759 "#if __cplusplus >= 199711L\n"
3760 "extern \"C++\" {\n"
3761 " void *bsearch(const void *, const void *, size_t, size_t,";
3765 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3766 * _STRICT_STDC, but uses it.
3768 fix = {
3769 hackname = solaris_getc_strict_stdc;
3770 mach = "*-*-solaris2*";
3771 files = "iso/stdio_iso.h";
3772 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3773 c_fix = format;
3774 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3776 test_text =
3777 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3781 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3783 fix = {
3784 hackname = solaris_gets_c11;
3785 mach = "*-*-solaris2*";
3786 files = "iso/stdio_iso.h";
3787 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3789 c_fix = format;
3790 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3791 "%1 __attribute__((__deprecated__));\n"
3792 "#endif";
3794 test_text = "extern char *gets(char *);";
3798 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3800 fix = {
3801 hackname = solaris_gets_cxx14;
3802 mach = "*-*-solaris2*";
3803 files = "iso/stdio_iso.h";
3804 select = <<- _EOSelect_
3805 (#if __STDC_VERSION__ < 201112L)
3806 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3807 _EOSelect_;
3808 c_fix = format;
3809 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3811 test_text = <<- _EOText_
3812 #if __STDC_VERSION__ < 201112L
3813 extern char *gets(char *) __ATTR_DEPRECATED;
3814 _EOText_;
3818 * Sun Solaris 2 has a version of sys/int_const.h that defines
3819 * UINT8_C and UINT16_C to unsigned constants.
3821 fix = {
3822 hackname = solaris_int_const;
3823 files = sys/int_const.h;
3824 mach = '*-*-solaris2*';
3825 c_fix = format;
3826 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3827 "%1\n"
3828 "#define\tUINT16_C(c)\t(c)";
3829 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3830 "(/\*.*\*/)\n"
3831 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3832 test_text =
3833 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3834 "/* CSTYLED */\n"
3835 "#define UINT16_C(c) __CONCAT__(c,u)";
3839 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3840 * UINT8_MAX and UINT16_MAX to unsigned constants.
3842 fix = {
3843 hackname = solaris_int_limits_1;
3844 files = sys/int_limits.h;
3845 mach = '*-*-solaris2*';
3846 c_fix = format;
3847 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3848 "#define\tUINT16_MAX\t(65535)";
3849 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3850 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3851 test_text =
3852 "#define UINT8_MAX (255U)\n"
3853 "#define UINT16_MAX (65535U)";
3857 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3858 * INT_FAST16 limits to wrong values for sys/int_types.h.
3860 fix = {
3861 hackname = solaris_int_limits_2;
3862 files = sys/int_limits.h;
3863 mach = '*-*-solaris2*';
3864 c_fix = format;
3865 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3866 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3867 test_text =
3868 "#define INT_FAST16_MAX INT16_MAX\n"
3869 "#define UINT_FAST16_MAX UINT16_MAX\n"
3870 "#define INT_FAST16_MIN INT16_MIN";
3874 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3875 * SIZE_MAX as unsigned long.
3877 fix = {
3878 hackname = solaris_int_limits_3;
3879 files = sys/int_limits.h;
3880 mach = '*-*-solaris2*';
3881 c_fix = format;
3882 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3883 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3884 test_text =
3885 "#define SIZE_MAX 4294967295UL";
3889 * Sun Solaris 10 defines several C99 math macros in terms of
3890 * builtins specific to the Studio compiler, in particular not
3891 * compatible with the GNU compiler.
3893 fix = {
3894 hackname = solaris_math_1;
3895 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3896 bypass = "__GNUC__";
3897 files = iso/math_c99.h;
3898 c_fix = format;
3899 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3900 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3901 test_text =
3902 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3903 "#undef HUGE_VAL\n"
3904 "#define HUGE_VAL __builtin_huge_val\n"
3905 "#undef HUGE_VALF\n"
3906 "#define HUGE_VALF __builtin_huge_valf\n"
3907 "#undef HUGE_VALL\n"
3908 "#define HUGE_VALL __builtin_huge_vall";
3912 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3913 * exception. Provide an alternative using GCC's builtin.
3915 fix = {
3916 hackname = solaris_math_10;
3917 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3918 files = iso/math_c99.h;
3919 c_fix = format;
3920 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3921 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3922 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3923 "[ \t]*\\\\\n"
3924 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3925 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3926 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3927 "\\(-INFINITY\\);[ \t]*\\}\\)";
3928 test_text =
3929 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3930 "#undef isinf\n"
3931 "#define isinf(x) __extension__( \\\\\n"
3932 " { __typeof(x) __x_i = (x); \\\\\n"
3933 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3934 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3938 * Solaris math INFINITY
3940 fix = {
3941 hackname = solaris_math_2;
3942 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3943 bypass = "__GNUC__";
3944 files = iso/math_c99.h;
3945 c_fix = format;
3946 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3947 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3948 test_text =
3949 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3950 "#undef INFINITY\n"
3951 "#define INFINITY __builtin_infinity";
3955 * Solaris math NAN
3957 fix = {
3958 hackname = solaris_math_3;
3959 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3960 bypass = "__GNUC__";
3961 files = iso/math_c99.h;
3962 c_fix = format;
3963 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3964 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3965 test_text =
3966 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3967 "#undef NAN\n"
3968 "#define NAN __builtin_nan";
3972 * Solaris math fpclassify
3974 fix = {
3975 hackname = solaris_math_4;
3976 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3977 bypass = "__GNUC__";
3978 files = iso/math_c99.h;
3979 c_fix = format;
3980 c_fix_arg = "#define\tfpclassify(x) \\\n"
3981 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3982 "FP_SUBNORMAL, FP_ZERO, (x))";
3983 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3984 test_text =
3985 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3986 "#undef fpclassify\n"
3987 "#define fpclassify(x) __builtin_fpclassify(x)";
3991 * Solaris math signbit
3993 fix = {
3994 hackname = solaris_math_8;
3995 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3996 bypass = "__GNUC__";
3997 files = iso/math_c99.h;
3998 c_fix = format;
3999 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
4000 "\t\t\t ? __builtin_signbitf(x) \\\n"
4001 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
4002 "\t\t\t ? __builtin_signbitl(x) \\\n"
4003 "\t\t\t : __builtin_signbit(x))";
4004 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
4005 test_text = <<- _EOText_
4006 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
4007 #undef signbit
4008 #define signbit(x) __builtin_signbit(x)
4009 _EOText_;
4013 * Solaris math comparison macros
4015 fix = {
4016 hackname = solaris_math_9;
4017 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4018 bypass = "__GNUC__";
4019 files = iso/math_c99.h;
4020 c_fix = format;
4021 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
4022 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
4023 "__builtin_[a-z]+\\(y\\)\\)";
4024 test_text =
4025 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
4026 "#undef isgreater\n"
4027 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
4028 "#undef isgreaterequal\n"
4029 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
4030 "#undef isless\n"
4031 "#define isless(x, y) ((x) __builtin_isless(y))\n"
4032 "#undef islessequal\n"
4033 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
4034 "#undef islessgreater\n"
4035 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
4036 "#undef isunordered\n"
4037 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
4041 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
4042 * warnings.
4044 fix = {
4045 hackname = solaris_math_11;
4046 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
4047 files = iso/math_c99.h;
4048 c_fix = format;
4049 c_fix_arg = << _EOArg_
4050 #undef signbit
4051 #define signbit(x) (sizeof(x) == sizeof(float) \
4052 ? __builtin_signbitf(x) \
4053 : sizeof(x) == sizeof(long double) \
4054 ? __builtin_signbitl(x) \
4055 : __builtin_signbit(x))
4056 _EOArg_;
4057 c_fix_arg = << _EOArg_
4058 ^#undef[ ]+signbit
4059 #if defined\(__sparc\)
4060 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
4061 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
4062 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
4063 #elif defined\(__i386\) \|\| defined\(__amd64\)
4064 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
4065 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
4066 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
4067 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
4068 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
4069 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
4070 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
4071 #endif
4072 _EOArg_;
4073 test_text = << _EOText_
4074 /* @(#)math_c99.h 1.14 13/03/27 */
4075 #undef signbit
4076 #if defined(__sparc)
4077 #define signbit(x) __extension__( \\
4078 { __typeof(x) __x_s = (x); \\
4079 (int) (*(unsigned *) &__x_s >> 31); })
4080 #elif defined(__i386) || defined(__amd64)
4081 #define signbit(x) __extension__( \\
4082 { __typeof(x) __x_s = (x); \\
4083 (sizeof (__x_s) == sizeof (float) ? \\
4084 (int) (*(unsigned *) &__x_s >> 31) : \\
4085 sizeof (__x_s) == sizeof (double) ? \\
4086 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
4087 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
4088 #endif
4089 _EOText_;
4093 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
4095 fix = {
4096 hackname = solaris_math_12;
4097 files = math.h;
4098 mach = '*-*-solaris2*';
4099 select = '#undef.*_GLIBCXX_USE_C99_MATH';
4100 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
4101 test_text = << _EOText_
4102 #if __cplusplus >= 201103L
4103 #undef _GLIBCXX_USE_C99_MATH
4104 #undef _GLIBCXX_USE_C99_MATH_TR1
4105 #endif
4106 _EOText_;
4110 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
4111 * structure. As such, it need two levels of brackets, but only
4112 * contains one. Wrap the macro definition in an extra layer.
4114 fix = {
4115 hackname = solaris_once_init_1;
4116 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4117 files = pthread.h;
4118 mach = '*-*-solaris*';
4119 c_fix = format;
4120 c_fix_arg = "%1{%2}%3";
4121 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
4122 test_text =
4123 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
4124 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
4128 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
4129 * posix_spawn declarations, which doesn't work with C++.
4131 fix = {
4132 hackname = solaris_posix_spawn_restrict;
4133 files = spawn.h;
4134 mach = '*-*-solaris2*';
4135 c_fix = format;
4136 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
4137 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
4138 test_text =
4139 "char *const argv[_RESTRICT_KYWD],\n"
4140 "char *const envp[_RESTRICT_KYWD]);";
4144 * The pow overloads with int were removed in C++ 2011 DR 550.
4146 fix = {
4147 hackname = solaris_pow_int_overload;
4148 mach = '*-*-solaris2*';
4149 files = "iso/math_iso.h";
4150 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4151 " *\\{[^{}]*\n[^{}]*\\}";
4152 c_fix = format;
4153 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4155 test_text =
4156 " inline long double pow(long double __X, int __Y) { return\n"
4157 " __powl(__X, (long double) (__Y)); }";
4161 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4162 * fields of the pthread_rwlock_t structure, which are of type
4163 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
4164 * defined (e.g. by -ansi) it is a union. So change the initializer
4165 * to "{0}" instead.
4167 fix = {
4168 hackname = solaris_rwlock_init_1;
4169 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4170 files = pthread.h;
4171 mach = '*-*-solaris*';
4172 c_fix = format;
4173 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4174 "%0\n"
4175 "#else\n"
4176 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4177 "#endif";
4178 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4179 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4181 test_text =
4182 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
4183 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4187 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
4188 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
4190 fix = {
4191 hackname = solaris_std___filbuf;
4192 files = stdio.h;
4193 mach = '*-*-solaris2*';
4194 bypass = "using std::__filbuf";
4195 select = "(using std::perror;\n)(#endif)";
4196 c_fix = format;
4197 c_fix_arg = "%1#ifndef _LP64\n"
4198 "using std::__filbuf;\n"
4199 "using std::__flsbuf;\n"
4200 "#endif\n%2";
4202 test_text = "using std::perror;\n"
4203 "#endif";
4207 * Solaris <stdio.h> shouldn't use std::gets for C++14.
4209 fix = {
4210 hackname = solaris_std_gets_cxx14;
4211 mach = "*-*-solaris2*";
4212 files = "stdio.h";
4213 select = "using std::gets;";
4215 c_fix = format;
4216 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4218 test_text = "using std::gets;";
4222 * Sun Solaris 8 has what appears to be some gross workaround for
4223 * some old version of their c++ compiler. G++ doesn't want it
4224 * either, but doesn't want to be tied to SunPRO version numbers.
4226 fix = {
4227 hackname = solaris_stdio_tag;
4228 files = stdio_tag.h;
4230 select = '__cplusplus < 54321L';
4231 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4232 "!defined(__GNUC__)" so we no longer need to fix it. */
4233 bypass = '__GNUC__';
4234 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4236 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4240 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4242 fix = {
4243 hackname = solaris_stdlib_noreturn;
4244 mach = "*-*-solaris2*";
4245 files = "iso/stdlib_c99.h";
4246 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4248 c_fix = format;
4249 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4251 test_text = "extern _Noreturn void quick_exit(int);";
4255 * a missing semi-colon at the end of the statsswtch structure definition.
4257 fix = {
4258 hackname = statsswtch;
4259 files = rpcsvc/rstat.h;
4260 select = "boottime$";
4261 c_fix = format;
4262 c_fix_arg = "boottime;";
4263 test_text = "struct statswtch {\n int boottime\n};";
4267 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4268 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4269 * OK too.
4271 fix = {
4272 hackname = stdio_stdarg_h;
4273 files = stdio.h;
4274 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4276 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4277 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4279 mach = '*-*-solaris2.1[0-9]*';
4280 not_machine = true;
4282 c_fix = wrap;
4284 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4286 test_text = "";
4290 * Don't use or define the name va_list in stdio.h. This is for
4291 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4292 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4293 * indicate that the header knows what it's doing -- under SUSv2,
4294 * stdio.h is required to define va_list, and we shouldn't break
4295 * that.
4297 fix = {
4298 hackname = stdio_va_list;
4299 files = stdio.h;
4300 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4302 * On Solaris 10, the definition in
4303 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4304 * there is therefore no need for this fix there.
4306 mach = '*-*-solaris2.1[0-9]*';
4307 not_machine = true;
4310 * Use __gnuc_va_list in arg types in place of va_list.
4311 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4312 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4313 * trailing parentheses and semicolon save all other systems from this.
4314 * Define __not_va_list__ (something harmless and unused)
4315 * instead of va_list.
4316 * Don't claim to have defined va_list.
4318 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4319 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4320 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4321 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4322 "s@ va_list@ __not_va_list__@\n"
4323 "s@\\*va_list@*__not_va_list__@\n"
4324 "s@ __va_list)@ __gnuc_va_list)@\n"
4325 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4326 "@typedef \\1 __not_va_list__;@\n"
4327 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4328 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4329 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4330 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4331 "s@VA_LIST@DUMMY_VA_LIST@\n"
4332 "s@_Va_LIST@_VA_LIST@";
4333 test_text = "extern void mumble( va_list);";
4337 * Fix headers that use va_list from stdio.h to use the updated
4338 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4339 * dealt with elsewhere. The presence of __gnuc_va_list,
4340 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4341 * knows what it's doing.
4343 fix = {
4344 hackname = stdio_va_list_clients;
4345 files = com_err.h;
4346 files = cps.h;
4347 files = curses.h;
4348 files = krb5.h;
4349 files = lc_core.h;
4350 files = pfmt.h;
4351 files = wchar.h;
4352 files = curses_colr/curses.h;
4353 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4354 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4355 otherwise protected. */
4356 bypass = 'include <stdarg\.h>|#ifdef va_start';
4359 * Use __gnuc_va_list in arg types in place of va_list.
4360 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4361 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4362 * trailing parentheses and semicolon save all other systems from this.
4363 * Define __not_va_list__ (something harmless and unused)
4364 * instead of va_list.
4365 * Don't claim to have defined va_list.
4367 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4368 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4369 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4370 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4371 "s@ va_list@ __not_va_list__@\n"
4372 "s@\\*va_list@*__not_va_list__@\n"
4373 "s@ __va_list)@ __gnuc_va_list)@\n"
4374 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4375 "@typedef \\1 __not_va_list__;@\n"
4376 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4377 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4378 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4379 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4380 "s@VA_LIST@DUMMY_VA_LIST@\n"
4381 "s@_Va_LIST@_VA_LIST@";
4382 test_text = "extern void mumble( va_list);";
4386 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4387 * is "!defined( __STRICT_ANSI__ )"
4389 fix = {
4390 hackname = strict_ansi_not;
4391 select = "^([ \t]*#[ \t]*if.*)"
4392 "(!__STDC__"
4393 "|__STDC__[ \t]*==[ \t]*0"
4394 "|__STDC__[ \t]*!=[ \t]*1"
4395 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4396 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4397 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4398 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4399 is not defined by GCC, so it is safe. */
4400 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4401 c_test = stdc_0_in_system_headers;
4403 c_fix = format;
4404 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4406 test_text = "#if !__STDC__ \n"
4407 "#if __STDC__ == 0\n"
4408 "#if __STDC__ != 1\n"
4409 "#if __STDC__ - 0 == 0"
4410 "/* not std C */\nint foo;\n"
4411 "\n#end-end-end-end-if :-)";
4415 * "__STDC__-0==0"
4416 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4418 fix = {
4419 hackname = strict_ansi_not_ctd;
4420 files = math.h, limits.h, stdio.h, signal.h,
4421 stdlib.h, sys/signal.h, time.h;
4423 * Starting at the beginning of a line, skip white space and
4424 * a leading "(" or "&&" or "||". One of those must be found.
4425 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4426 * expression. If these are nested, then they must accumulate
4427 * because we won't match any closing parentheses. Finally,
4428 * after skipping over all that, we must then match our suspect
4429 * phrase: "__STDC__-0==0" with or without white space.
4431 select = "^([ \t]*" '(\(|&&|\|\|)'
4432 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4433 "[ \t(]*)"
4434 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4435 c_test = stdc_0_in_system_headers;
4437 c_fix = format;
4438 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4440 test_text = "#if 1 && \\\\\n"
4441 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4442 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4443 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4444 "int foo;\n#endif";
4448 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4449 * is "defined( __STRICT_ANSI__ )"
4451 fix = {
4452 hackname = strict_ansi_only;
4453 select = "^([ \t]*#[ \t]*if.*)"
4454 "(__STDC__[ \t]*!=[ \t]*0"
4455 "|__STDC__[ \t]*==[ \t]*1"
4456 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4457 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4458 c_test = stdc_0_in_system_headers;
4460 c_fix = format;
4461 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4463 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4467 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4468 * in prototype without previous definition.
4470 fix = {
4471 hackname = struct_file;
4472 files = rpc/xdr.h;
4473 select = '^.*xdrstdio_create.*struct __file_s';
4474 c_fix = format;
4475 c_fix_arg = "struct __file_s;\n%0";
4476 test_text = "extern void xdrstdio_create( struct __file_s* );";
4480 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4481 * in prototype without previous definition.
4483 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4484 * function, and does define it.
4486 fix = {
4487 hackname = struct_sockaddr;
4488 files = rpc/auth.h;
4489 select = "^.*authdes_create.*struct sockaddr[^_]";
4490 bypass = "<sys/socket\.h>";
4491 bypass = "struct sockaddr;\n";
4492 c_fix = format;
4493 c_fix_arg = "struct sockaddr;\n%0";
4494 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4498 * Apply fix this to all OSs since this problem seems to effect
4499 * more than just SunOS.
4501 fix = {
4502 hackname = sun_auth_proto;
4503 files = rpc/auth.h;
4504 files = rpc/clnt.h;
4505 files = rpc/svc.h;
4506 files = rpc/xdr.h;
4507 bypass = "__cplusplus";
4509 * Select those files containing '(*name)()'.
4511 select = '\(\*[a-z][a-z_]*\)\(\)';
4513 c_fix = format;
4514 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4515 "#else\n%1();%2\n#endif";
4516 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4518 test_text =
4519 "struct auth_t {\n"
4520 " int (*name)(); /* C++ bad */\n"
4521 "};";
4525 * Fix bogus #ifdef on SunOS 4.1.
4527 fix = {
4528 hackname = sun_bogus_ifdef;
4529 files = "hsfs/hsfs_spec.h";
4530 files = "hsfs/iso_spec.h";
4531 select = '#ifdef(.*\|\|.*)';
4532 c_fix = format;
4533 c_fix_arg = "#if%1";
4535 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4539 * Fix the CAT macro in SunOS memvar.h.
4541 fix = {
4542 hackname = sun_catmacro;
4543 files = pixrect/memvar.h;
4544 select = "^#define[ \t]+CAT\\(a,b\\).*";
4545 c_fix = format;
4547 c_fix_arg =
4548 "#ifdef __STDC__\n"
4549 "# define CAT(a,b) a##b\n"
4550 "#else\n%0\n#endif";
4552 test_text =
4553 "#define CAT(a,b)\ta/**/b";
4557 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4558 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4560 fix = {
4561 hackname = sun_malloc;
4562 files = malloc.h;
4563 bypass = "_CLASSIC_ANSI_TYPES";
4565 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4566 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4567 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4568 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4569 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4571 test_text =
4572 "typedef char *\tmalloc_t;\n"
4573 "int \tfree();\n"
4574 "char*\tmalloc();\n"
4575 "char*\tcalloc();\n"
4576 "char*\trealloc();";
4580 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4582 fix = {
4583 hackname = sun_rusers_semi;
4584 files = rpcsvc/rusers.h;
4585 select = "_cnt$";
4586 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4587 test_text = "struct mumble\n int _cnt\n};";
4591 * signal.h on SunOS defines signal using (),
4592 * which causes trouble when compiling with g++ -pedantic.
4594 fix = {
4595 hackname = sun_signal;
4596 files = sys/signal.h;
4597 files = signal.h;
4598 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4600 c_fix = format;
4601 c_fix_arg =
4602 "#ifdef __cplusplus\n"
4603 "void\t(*signal(...))(...);\n"
4604 "#else\n%0\n#endif";
4606 test_text = "void\t(*signal())();";
4610 * Correct the return type for strlen in strings.h in SunOS 4.
4612 fix = {
4613 hackname = sunos_strlen;
4614 files = strings.h;
4615 select = "int[ \t]*strlen\\(\\);(.*)";
4616 c_fix = format;
4617 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4618 test_text = " int\tstrlen(); /* string length */";
4622 * Linux kernel's vt.h breaks C++
4624 fix = {
4625 hackname = suse_linux_vt_cxx;
4626 files = linux/vt.h;
4628 select = "^[ \t]*unsigned int new;";
4629 c_fix = format;
4630 c_fix_arg = "unsigned int newev;";
4632 test_text = " unsigned int new; /* New console (if changing) */";
4636 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4637 * that is visible to any ANSI compiler using this include. Simply
4638 * delete the lines that #define some string functions to internal forms.
4640 fix = {
4641 hackname = svr4_disable_opt;
4642 files = string.h;
4643 select = '#define.*__std_hdr_';
4644 sed = '/#define.*__std_hdr_/d';
4645 test_text = "#define strlen __std_hdr_strlen\n";
4649 * Fix broken decl of getcwd present on some svr4 systems.
4651 fix = {
4652 hackname = svr4_getcwd;
4653 files = stdlib.h;
4654 files = unistd.h;
4655 files = prototypes.h;
4656 select = 'getcwd\(char \*, int\)';
4658 c_fix = format;
4659 c_fix_arg = "getcwd(char *, size_t)";
4661 test_text = "extern char* getcwd(char *, int);";
4665 * Fix broken decl of profil present on some svr4 systems.
4667 fix = {
4668 hackname = svr4_profil;
4669 files = stdlib.h;
4670 files = unistd.h;
4672 select =
4673 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4674 c_fix = format;
4675 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4677 test_text =
4678 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4682 * Correct types for signal handler constants like SIG_DFL; they might be
4683 * void (*) (), and should be void (*) (int). C++ doesn't like the
4684 * old style.
4686 fix = {
4687 hackname = svr4_sighandler_type;
4688 files = sys/signal.h;
4689 select = 'void *\(\*\)\(\)';
4690 c_fix = format;
4691 c_fix_arg = "void (*)(int)";
4692 test_text = "#define SIG_DFL (void(*)())0\n"
4693 "#define SIG_IGN (void (*)())0\n";
4697 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4698 * function 'getrnge' in <regexp.h> before they declare it. For these
4699 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4700 * early on.
4702 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4703 * so put the declaration right after the declaration of 'size'.
4705 * Don't do this if there is already a `static void getrnge' declaration
4706 * present, since this would cause a redeclaration error. Solaris 2.x has
4707 * such a declaration.
4709 fix = {
4710 hackname = svr4_undeclared_getrnge;
4711 files = regexp.h;
4712 select = "getrnge";
4713 bypass = "static void getrnge";
4714 c_fix = format;
4715 c_fix_arg = "%0\n"
4716 "static int getrnge ();";
4717 c_fix_arg = "^static int[ \t]+size;";
4718 test_text = "static int size;\n"
4719 "/* stuff which calls getrnge() */\n"
4720 "static getrnge()\n"
4721 "{}";
4725 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4726 * in string.h on sysV68
4727 * Correct the return type for strlen in string.h on Lynx.
4728 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4729 * Add missing const for strdup on OSF/1 V3.0.
4730 * On sysV88 layout is slightly different.
4732 fix = {
4733 hackname = sysv68_string;
4734 files = testing.h;
4735 files = string.h;
4736 bypass = "_CLASSIC_ANSI_TYPES";
4738 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4739 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4740 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4742 sed = "/^extern char$/N";
4743 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4745 sed = "/^extern int$/N";
4746 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4748 sed = "/^\tstrncmp(),$/N";
4749 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4750 '\1;' "\\\nextern unsigned int\\\n\\2/";
4752 test_text =
4753 "extern int strlen();\n"
4755 "extern int ffs(long);\n"
4757 "extern char\n"
4758 "\t*memccpy(),\n"
4759 "\tmemcpy();\n"
4761 "extern int\n"
4762 "\tstrcmp(),\n"
4763 "\tstrncmp(),\n"
4764 "\tstrlen(),\n"
4765 "\tstrspn();\n"
4767 "extern int\n"
4768 "\tstrlen(), strspn();";
4772 * Fix return type of calloc, malloc, realloc, bsearch and exit
4774 fix = {
4775 hackname = sysz_stdlib_for_sun;
4776 files = stdlib.h;
4777 bypass = "_CLASSIC_ANSI_TYPES";
4779 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4780 c_fix = format;
4781 c_fix_arg = "void *\t%1(";
4783 test_text =
4784 "extern char*\tcalloc(size_t);\n"
4785 "extern char*\tmalloc(size_t);\n"
4786 "extern char*\trealloc(void*,size_t);\n"
4787 "extern char*\tbsearch(void*,size_t,size_t);\n";
4791 * __thread is now a keyword.
4793 fix = {
4794 hackname = thread_keyword;
4795 files = "pthread.h";
4796 files = bits/sigthread.h, '*/bits/sigthread.h';
4797 select = "([* ])__thread([,)])";
4798 c_fix = format;
4799 c_fix_arg = "%1__thr%2";
4801 test_text =
4802 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4803 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4804 "extern int pthread_cancel (pthread_t __thread);";
4808 * if the #if says _cplusplus, not the double underscore __cplusplus
4809 * that it should be
4811 fix = {
4812 hackname = tinfo_cplusplus;
4813 files = tinfo.h;
4814 select = "[ \t]_cplusplus";
4816 c_fix = format;
4817 c_fix_arg = " __cplusplus";
4818 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4822 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4824 fix = {
4825 hackname = ultrix_const;
4826 files = stdio.h;
4827 select = 'perror\( char \*';
4829 c_fix = format;
4830 c_fix_arg = "%1 const %3 *__";
4831 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4832 "[ \t]+(char|void) \\*__";
4834 test_text =
4835 "extern void perror( char *__s );\n"
4836 "extern int fputs( char *__s, FILE *);\n"
4837 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4838 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4839 "extern int scanf( char *__format, ...);\n";
4843 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4845 fix = {
4846 hackname = ultrix_const2;
4847 files = stdio.h;
4849 select = '\*fopen\( char \*';
4850 c_fix = format;
4851 c_fix_arg = "%1( const char *%3, const char *";
4852 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4853 "[ \t]*char[ \t]*\\*([^,]*),"
4854 "[ \t]*char[ \t]*\\*[ \t]*";
4856 test_text =
4857 "extern FILE *fopen( char *__filename, char *__type );\n"
4858 "extern int sscanf( char *__s, char *__format, ...);\n"
4859 "extern FILE *popen(char *, char *);\n"
4860 "extern char *tempnam(char*,char*);\n";
4864 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4866 fix = {
4867 hackname = va_i960_macro;
4868 files = arch/i960/archI960.h;
4869 select = "__(vsiz|vali|vpad|alignof__)";
4871 c_fix = format;
4872 c_fix_arg = "__vx%1";
4874 test_text =
4875 "extern int __vsiz vsiz;\n"
4876 "extern int __vali vali;\n"
4877 "extern int __vpad vpad;\n"
4878 "#define __alignof__(x) ...";
4882 * On VMS, add missing braces around sigset_t constants.
4884 fix = {
4885 hackname = vms_add_missing_braces;
4886 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4887 mach = "*-*-*vms*";
4888 files = "rtldef/signal.h";
4889 c_fix = format;
4891 c_fix_arg = '%1 {%2} ';
4893 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4894 "{0x00000000, 0x00000000},\n"
4895 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4899 * On VMS, some DEC-C builtins are directly used.
4901 fix = {
4902 hackname = vms_decc_builtin;
4903 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4904 mach = "*-*-*vms*";
4905 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4906 rtldef/socket.h;
4907 sed = "s@__MEMSET@memset@";
4908 sed = "s@__MEMMOVE@memmove@";
4909 sed = "s@__MEMCPY@memcpy@";
4910 sed = "s@__STRLEN@strlen@";
4911 sed = "s@__STRCPY@strcpy@";
4913 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4917 * Define __CAN_USE_EXTERN_PREFIX on vms.
4919 fix = {
4920 hackname = vms_define_can_use_extern_prefix;
4921 files = "rtldef/decc$types.h";
4922 select = "#[ \t]*else\n"
4923 "#[ \t]*if defined\\(__DECCXX\\)\n"
4924 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4925 mach = "*-*-*vms*";
4926 c_fix = format;
4928 c_fix_arg = "%0"
4929 "# elif defined (__GNUC__)\n"
4930 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4932 test_text = "# else\n"
4933 "# if defined(__DECCXX)\n"
4934 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4935 "# endif\n"
4936 "# endif\n";
4940 * On VMS, disable the use of dec-c string builtins
4942 fix = {
4943 hackname = vms_disable_decc_string_builtins;
4944 select = "#if !defined\\(__VAX\\)\n";
4945 mach = "*-*-*vms*";
4946 files = "rtldef/string.h";
4947 c_fix = format;
4949 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4951 test_text = "#if !defined(__VAX)\n";
4955 * On VMS, fix incompatible redeclaration of hostalias.
4957 fix = {
4958 hackname = vms_do_not_redeclare_hostalias;
4959 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4960 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4961 mach = "*-*-*vms*";
4962 files = "rtldef/resolv.h";
4963 c_fix = format;
4965 c_fix_arg = "%1\n"
4966 "/* %2 */";
4968 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4969 "__char_ptr32 hostalias (const char *);\n";
4973 * On VMS, forward declare structure before referencing them in prototypes.
4975 fix = {
4976 hackname = vms_forward_declare_struct;
4977 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4978 "#ifdef __cplusplus\n";
4979 mach = "*-*-*vms*";
4980 files = rtldef/if.h;
4981 c_fix = format;
4983 c_fix_arg = "%1"
4984 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4986 test_text = "/* forward decls for C++ */\n"
4987 "#ifdef __cplusplus\n"
4988 "struct foo;\n"
4989 "#endif\n";
4993 * On VMS, do not declare getopt and al if pointers are 64 bit.
4995 fix = {
4996 hackname = vms_no_64bit_getopt;
4997 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4998 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4999 mach = "*-*-*vms*";
5000 files = rtldef/stdio.h, rtldef/unistd.h;
5001 c_fix = format;
5003 c_fix_arg = <<- _EOArg_
5004 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
5005 %0#endif
5007 _EOArg_;
5009 test_text = "int getopt (int, char * const [], const char *);";
5013 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
5014 * which is not yet fully supported by gcc.
5016 fix = {
5017 hackname = vms_use_fast_setjmp;
5018 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
5019 mach = "*-*-*vms*";
5020 files = rtldef/setjmp.h;
5021 c_fix = format;
5023 c_fix_arg = "%0 defined (__GNUC__) ||";
5025 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
5029 * On VMS, use pragma extern_model instead of VAX-C keywords.
5031 fix = {
5032 hackname = vms_use_pragma_extern_model;
5033 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
5034 "# pragma extern_model __save\n";
5035 mach = "*-*-*vms*";
5036 c_fix = format;
5038 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
5039 "# pragma extern_model __save\n";
5041 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
5042 "# pragma extern_model __save\n"
5043 "# pragma extern_model strict_refdef\n"
5044 " extern struct x zz$yy;\n"
5045 "# pragma extern_model __restore\n"
5046 "#endif\n";
5050 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
5051 * conflict while building gcc. Likewise for <builtins.h>
5053 fix = {
5054 hackname = vms_use_quoted_include;
5055 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
5056 mach = "*-*-*vms*";
5057 files = rtldef/wait.h, starlet_c/pthread.h;
5058 c_fix = format;
5060 c_fix_arg = '%1<sys/%2.h>';
5062 test_text = "# include <resource.h>";
5066 * AIX and Interix headers define NULL to be cast to a void pointer,
5067 * which is illegal in ANSI C++.
5069 fix = {
5070 hackname = void_null;
5071 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
5072 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
5073 /* avoid changing C++ friendly NULL */
5074 bypass = __cplusplus;
5075 bypass = __null;
5076 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
5077 c_fix = format;
5078 c_fix_arg = <<- _EOFix_
5079 #ifndef NULL
5080 #ifdef __cplusplus
5081 #ifdef __GNUG__
5082 #define NULL __null
5083 #else /* ! __GNUG__ */
5084 #define NULL 0L
5085 #endif /* __GNUG__ */
5086 #else /* ! __cplusplus */
5087 #define NULL ((void *)0)
5088 #endif /* __cplusplus */
5089 #endif /* !NULL */
5090 _EOFix_;
5091 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
5095 * Make VxWorks header which is almost gcc ready fully gcc ready.
5097 fix = {
5098 hackname = vxworks_gcc_problem;
5099 files = types/vxTypesBase.h;
5100 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
5102 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
5103 "#if 1/";
5105 sed = "/[ \t]size_t/i\\\n"
5106 "#ifndef _GCC_SIZE_T\\\n"
5107 "#define _GCC_SIZE_T\n";
5109 sed = "/[ \t]size_t/a\\\n"
5110 "#endif\n";
5112 sed = "/[ \t]ptrdiff_t/i\\\n"
5113 "#ifndef _GCC_PTRDIFF_T\\\n"
5114 "#define _GCC_PTRDIFF_T\n";
5116 sed = "/[ \t]ptrdiff_t/a\\\n"
5117 "#endif\n";
5119 sed = "/[ \t]wchar_t/i\\\n"
5120 "#ifndef _GCC_WCHAR_T\\\n"
5121 "#define _GCC_WCHAR_T\n";
5123 sed = "/[ \t]wchar_t/a\\\n"
5124 "#endif\n";
5126 test_text =
5127 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
5128 "typedef unsigned int size_t;\n"
5129 "typedef long ptrdiff_t;\n"
5130 "typedef unsigned short wchar_t;\n"
5131 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
5135 * Wrap VxWorks ioctl to keep everything pretty
5137 fix = {
5138 hackname = vxworks_ioctl_macro;
5139 files = ioLib.h;
5140 mach = "*-*-vxworks*";
5142 c_fix = format;
5143 c_fix_arg = "%0\n"
5144 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
5145 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
5147 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5151 * Wrap VxWorks mkdir to be posix compliant
5153 fix = {
5154 hackname = vxworks_mkdir_macro;
5155 files = sys/stat.h;
5156 mach = "*-*-vxworks*";
5158 c_fix = format;
5159 c_fix_arg = "%0\n"
5160 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5161 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5162 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5163 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5164 "\\)[\t ]*;";
5166 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
5170 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
5172 fix = {
5173 hackname = vxworks_needs_vxtypes;
5174 files = time.h;
5175 select = "uint_t([ \t]+_clocks_per_sec)";
5176 c_fix = format;
5177 c_fix_arg = "unsigned int%1";
5178 test_text = "uint_t\t_clocks_per_sec;";
5182 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5184 fix = {
5185 hackname = vxworks_needs_vxworks;
5186 files = sys/stat.h;
5187 test = " -r types/vxTypesOld.h";
5188 test = " -n \"`egrep '#include' $file`\"";
5189 test = " -n \"`egrep ULONG $file`\"";
5190 select = "#[ \t]define[ \t]+__INCstath";
5192 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5193 "#include <types/vxTypesOld.h>\n";
5195 test_text = "`touch types/vxTypesOld.h`"
5196 "#include </dev/null> /* ULONG */\n"
5197 "# define\t__INCstath <sys/stat.h>";
5201 * Make it so VxWorks does not include gcc/regs.h accidentally
5203 fix = {
5204 hackname = vxworks_regs;
5205 mach = "*-*-vxworks*";
5207 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5208 c_fix = format;
5209 c_fix_arg = "#include <arch/../regs.h>";
5211 test_text = "#include <regs.h>\n";
5215 * Another bad dependency in VxWorks 5.2 <time.h>.
5217 fix = {
5218 hackname = vxworks_time;
5219 files = time.h;
5220 test = " -r vxWorks.h";
5222 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5223 c_fix = format;
5225 c_fix_arg =
5226 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5227 "#ifdef __cplusplus\n"
5228 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5229 "#else\n"
5230 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5231 "#endif\n"
5232 "#define __gcc_VOIDFUNCPTR_defined\n"
5233 "#endif\n"
5234 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5236 test_text = "`touch vxWorks.h`"
5237 "#define VOIDFUNCPTR (void(*)())";
5241 * This hack makes write const-correct on VxWorks
5243 fix = {
5244 hackname = vxworks_write_const;
5245 files = ioLib.h;
5246 mach = "*-*-vxworks*";
5248 c_fix = format;
5249 c_fix_arg = "extern int write (int, const char*, size_t);";
5250 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5251 "[\t ]*int[\t ]*,"
5252 "[\t ]*char[\t ]*\\*[\t ]*,"
5253 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5255 test_text = "extern int write ( int , char * , size_t ) ;";
5259 * This hack ensures the include_next in the fixed unistd.h actually
5260 * finds the system's unistd.h and not the fixed unistd.h again.
5262 fix = {
5263 hackname = vxworks_iolib_include_unistd;
5264 files = ioLib.h;
5265 mach = "*-*-vxworks*";
5266 select = "#include \"unistd.h\"";
5268 c_fix = format;
5269 c_fix_arg = "#include <unistd.h>";
5271 test_text = "#include \"unistd.h\"";
5275 * There are several name conflicts with C++ reserved words in X11 header
5276 * files. These are fixed in some versions, so don't do the fixes if
5277 * we find __cplusplus in the file. These were found on the RS/6000.
5279 fix = {
5280 hackname = x11_class;
5281 files = X11/ShellP.h;
5282 bypass = __cplusplus;
5283 select = "^([ \t]*char \\*)class;(.*)";
5284 c_fix = format;
5285 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5286 "#else\n%1class;%2\n#endif";
5287 test_text =
5288 "struct {\n"
5289 " char *class;\n"
5290 "} mumble;\n";
5294 * class in Xm/BaseClassI.h
5296 fix = {
5297 hackname = x11_class_usage;
5298 files = Xm/BaseClassI.h;
5299 bypass = "__cplusplus";
5301 select = " class\\)";
5302 c_fix = format;
5303 c_fix_arg = " c_class)";
5305 test_text = "extern mumble (int class);\n";
5309 * new in Xm/Traversal.h
5311 fix = {
5312 hackname = x11_new;
5313 files = Xm/Traversal.h;
5314 bypass = __cplusplus;
5316 sed = "/Widget\told, new;/i\\\n"
5317 "#ifdef __cplusplus\\\n"
5318 "\\\tWidget\told, c_new;\\\n"
5319 "#else\n";
5321 sed = "/Widget\told, new;/a\\\n"
5322 "#endif\n";
5324 sed = "s/Widget new,/Widget c_new,/g";
5325 test_text =
5326 "struct wedge {\n"
5327 " Widget\told, new;\n"
5328 "};\nextern Wedged( Widget new, Widget old );";
5332 * Incorrect sprintf declaration in X11/Xmu.h
5334 fix = {
5335 hackname = x11_sprintf;
5336 files = X11/Xmu.h;
5337 files = X11/Xmu/Xmu.h;
5338 select = "^extern char \\*\tsprintf\\(\\);$";
5340 c_fix = format;
5341 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5343 test_text = "extern char *\tsprintf();";
5345 /*EOF*/