aix: apply socket.h extern "C++" more narrowly.
[gcc.git] / fixincludes / inclhack.def
1 /* -*- Mode: C -*- */
2
3 autogen definitions fixincl;
4
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.
7
8 This is the sort command:
9
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key=$'hackname[ \t]*=[ \t]*(.*);'
15
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
18
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
22
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
29 */
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 */
36
37 c_fix = wrap;
38
39 c_fix_arg = "";
40
41 c_fix_arg = <<- _EOArg_
42
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");
60 }
61 #endif
62 #endif
63
64 _EOArg_;
65 };
66
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
71 */
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 */
78
79 c_fix = wrap;
80
81 c_fix_arg = "";
82
83 c_fix_arg = <<- _EOArg_
84
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
98 }
99 #endif
100 #endif
101
102 _EOArg_;
103 };
104
105 /*
106 * On Mac OS 10.3.9, the 'long double' functions are available in
107 * libSystem, but are not prototyped in math.h.
108 */
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
191 }
192 # endif
193 #endif /* __MATH__ */
194 _EndOfHeader_;
195 };
196
197 /*
198 * SDKs for 10.13 and 10.14 omit the definitions for API_AVAILABLE where
199 * __attribute__((availability)) is not supported.
200 */
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";
222 };
223
224 /*
225 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
226 */
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';
234
235 /*
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>.
240 */
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>
247
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
259
260 #define _POSIX_TYPES_H_WRAPPER
261 #endif /* _POSIX_TYPES_H_WRAPPER */
262 _EndOfHeader_;
263 };
264
265 /*
266 * This fixes __FD_ZERO bug for glibc-1.x
267 */
268 fix = {
269 hackname = AAB_fd_zero_gnu_types_h;
270 files = gnu/types.h;
271 mach = 'i[34567]86-*-linux*';
272
273 /*
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>.
278 */
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>
284
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
296
297 #define _TYPES_H_WRAPPER
298 #endif /* _TYPES_H_WRAPPER */
299 _EndOfHeader_;
300 };
301
302 /*
303 * This fixes __FD_ZERO bug for glibc-2.0.x
304 */
305 fix = {
306 hackname = AAB_fd_zero_selectbits_h;
307 files = selectbits.h;
308 mach = 'i[34567]86-*-linux*';
309
310 /*
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>.
315 */
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>
321
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
337
338 #define _SELECTBITS_H_WRAPPER
339 #endif /* _SELECTBITS_H_WRAPPER */
340 _EndOfHeader_;
341 };
342
343 /*
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.
347 */
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_;
359 };
360
361 /*
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 )
367 */
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)\\*/";
374
375 replace = <<- _EndOfHeader_
376 /* This file was generated by fixincludes */
377 #ifndef __memory_h__
378 #define __memory_h__
379
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__ */
391
392 extern int memcmp();
393
394 #endif /* __memory_h__ */
395 _EndOfHeader_;
396 };
397
398 /*
399 * Fix assert.h on VxWorks:
400 */
401 fix = {
402 hackname = AAB_vxworks_assert;
403 files = assert.h;
404 mach = "*-*-vxworks*";
405
406 replace = <<- _EndOfHeader_
407 #ifdef _ASSERT_H
408 #undef _ASSERT_H
409 #undef assert
410 #endif
411
412 #define _ASSERT_H
413
414 #ifdef __cplusplus
415 extern "C" {
416 #endif
417
418 #if defined(__STDC__) || defined(__cplusplus)
419 extern void __assert (const char*);
420 #else
421 extern void __assert ();
422 #endif
423
424 #ifdef NDEBUG
425 #define assert(ign) ((void)0)
426 #else
427
428 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
429 #define ASSERT_STRINGIFY_HELPER(str) #str
430
431 #define assert(test) ((void) \
432 ((test) ? ((void)0) : \
433 __assert("Assertion failed: " #test ", file " \
434 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
435
436 #endif
437
438 #ifdef __cplusplus
439 }
440 #endif
441 _EndOfHeader_;
442 };
443
444 /*
445 * Add needed include to regs.h (NOT the gcc header) on VxWorks
446 */
447
448 fix = {
449 hackname = AAB_vxworks_regs_vxtypes;
450 files = regs.h;
451 mach = "*-*-vxworks*";
452
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_;
470 };
471
472 /*
473 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
474 */
475 fix = {
476 hackname = AAB_vxworks_unistd;
477 files = unistd.h;
478 mach = "*-*-vxworks*";
479
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_;
496 };
497
498 /*
499 * assert.h on AIX 7 redefines static_assert as _Static_assert without
500 * protecting C++.
501 */
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";
510 };
511
512 /*
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.
515 */
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";
524 };
525
526 /*
527 * On AIX some headers are not properly guarded by 'extern "C"'.
528 */
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";
547 };
548
549 /*
550 * On AIX sys/socket.h assumes C++.
551 */
552 fix = {
553 hackname = aix_externcpp1;
554 mach = "*-*-aix*";
555 files = "sys/socket.h";
556 select = "#ifndef _KERNEL\n"
557 "#ifdef __cplusplus";
558 c_fix = format;
559 c_fix_arg = "#ifndef _KERNEL\n"
560 "#ifdef __cplusplus\n"
561 "extern \"C++\" {";
562 test_text = "#ifndef _KERNEL\n"
563 "#ifdef __cplusplus";
564 };
565
566 fix = {
567 hackname = aix_externcpp2;
568 mach = "*-*-aix*";
569 files = "sys/socket.h";
570 select = "#endif /\\* COMPAT_43 \\*/\n"
571 "#else /\\* __cplusplus \\*/";
572 c_fix = format;
573 c_fix_arg = "#endif /* COMPAT_43 */\n"
574 "} /* extern \"C++\" */\n"
575 "#else /* __cplusplus */";
576 test_text = "#endif /* COMPAT_43 */\n"
577 "#else /* __cplusplus */";
578 };
579
580 /*
581 * malloc.h on AIX6 uses XLC++ specific builtin syntax
582 */
583 fix = {
584 hackname = aix_malloc;
585 mach = "*-*-aix*";
586 files = "malloc.h";
587 select = "#ifdef __cplusplus";
588 c_fix = format;
589 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
590 test_text = "#ifdef __cplusplus";
591 };
592
593 /*
594 * net/if_arp.h defines a variable fc_softc instead of adding a
595 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
596 */
597 fix = {
598 hackname = aix_net_if_arp;
599 mach = "*-*-aix*";
600 files = "net/if_arp.h";
601 select = "^struct fc_softc \\{";
602 c_fix = format;
603 c_fix_arg = "typedef struct _fc_softc {";
604 test_text = "struct fc_softc {\n int a;\n};";
605 };
606
607 /*
608 * Fix AIX definition of NULL for G++.
609 */
610 fix = {
611 hackname = aix_null;
612 mach = "*-*-aix*";
613 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
614 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
615 bypass = __null;
616 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
617 c_fix = format;
618 c_fix_arg = <<- _EOFix_
619 #ifndef NULL
620 #ifdef __cplusplus
621 #ifdef __GNUG__
622 #define NULL __null
623 #else /* ! __GNUG__ */
624 #define NULL 0L
625 #endif /* __GNUG__ */
626 #else /* ! __cplusplus */
627 #define NULL ((void *)0)
628 #endif /* __cplusplus */
629 #endif /* !NULL */
630 _EOFix_;
631 test_text = "# define\tNULL \t(0L) /* typed NULL */";
632 };
633
634 /*
635 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
636 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
637 * braces.
638 */
639 fix = {
640 hackname = aix_once_init_1;
641 mach = "*-*-aix*";
642 files = "pthread.h";
643 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
644 "\\{ \\\\\n";
645 c_fix = format;
646 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
647 "{{ \\\n";
648 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
649 "{ \\\\\n";
650 };
651
652 fix = {
653 hackname = aix_once_init_2;
654 mach = "*-*-aix*";
655 files = "pthread.h";
656 select = "[ \t]0 \\\\\n"
657 "\\}\n";
658 c_fix = format;
659 c_fix_arg = " 0 \\\n"
660 "}}\n";
661 test_text = " 0 \\\\\n"
662 "}\n";
663 };
664
665 fix = {
666 hackname = aix_mutex_initializer_1;
667 mach = "*-*-aix*";
668 files = "pthread.h";
669 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
670 "\\{ \\\\\n";
671 c_fix = format;
672 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
673 "{{ \\\n";
674 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
675 "{ \\\\\n";
676 };
677
678 fix = {
679 hackname = aix_cond_initializer_1;
680 mach = "*-*-aix*";
681 files = "pthread.h";
682 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
683 "\\{ \\\\\n";
684 c_fix = format;
685 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
686 "{{ \\\n";
687 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
688 "{ \\\\\n";
689 };
690
691 fix = {
692 hackname = aix_rwlock_initializer_1;
693 mach = "*-*-aix*";
694 files = "pthread.h";
695 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
696 "\\{ \\\\\n";
697 c_fix = format;
698 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
699 "{{ \\\n";
700 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
701 "{ \\\\\n";
702 };
703
704 /*
705 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
706 * which violates a requirement of ISO C.
707 */
708 fix = {
709 hackname = aix_pthread;
710 files = "pthread.h";
711 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
712 c_fix = format;
713 c_fix_arg = "%1 %2";
714 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
715 "{...init stuff...}";
716 };
717
718 /*
719 * AIX stdint.h fixes.
720 */
721 fix = {
722 hackname = aix_stdint_1;
723 mach = "*-*-aix*";
724 files = stdint-aix.h, stdint.h;
725 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
726 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
727 c_fix = format;
728 c_fix_arg = "#define UINT8_MAX (255)\n"
729 "#define UINT16_MAX (65535)";
730 test_text = "#define UINT8_MAX (255U)\n"
731 "#define UINT16_MAX (65535U)";
732 };
733
734 /*
735 * aix_stdint_2
736 */
737 fix = {
738 hackname = aix_stdint_2;
739 mach = "*-*-aix*";
740 files = stdint-aix.h, stdint.h;
741 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
742 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
743 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
744 "#else\n"
745 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
746 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
747 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
748 c_fix = format;
749 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
750 "#define INTPTR_MAX 9223372036854775807L\n"
751 "#define UINTPTR_MAX 18446744073709551615UL\n"
752 "#else\n"
753 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
754 "#define INTPTR_MAX 2147483647L\n"
755 "#define UINTPTR_MAX 4294967295UL";
756 test_text = "#define INTPTR_MIN INT64_MIN\n"
757 "#define INTPTR_MAX INT64_MAX\n"
758 "#define UINTPTR_MAX UINT64_MAX\n"
759 "#else\n"
760 "#define INTPTR_MIN INT32_MIN\n"
761 "#define INTPTR_MAX INT32_MAX\n"
762 "#define UINTPTR_MAX UINT32_MAX";
763 };
764
765 /*
766 * aix_stdint_3
767 */
768 fix = {
769 hackname = aix_stdint_3;
770 mach = "*-*-aix*";
771 files = stdint-aix.h, stdint.h;
772 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
773 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
774 "#else\n"
775 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
776 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
777 c_fix = format;
778 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
779 "#define PTRDIFF_MAX 9223372036854775807L\n"
780 "#else\n"
781 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
782 "#define PTRDIFF_MAX 2147483647L";
783 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
784 "#define PTRDIFF_MAX INT64_MAX\n"
785 "#else\n"
786 "#define PTRDIFF_MIN INT32_MIN\n"
787 "#define PTRDIFF_MAX INT32_MAX";
788 };
789
790 /*
791 * aix_stdint_4
792 */
793 fix = {
794 hackname = aix_stdint_4;
795 mach = "*-*-aix*";
796 files = stdint-aix.h, stdint.h;
797 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
798 "#else\n"
799 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
800 c_fix = format;
801 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
802 "#else\n"
803 "#define SIZE_MAX 4294967295UL";
804 test_text = "#define SIZE_MAX UINT64_MAX\n"
805 "#else\n"
806 "#define SIZE_MAX UINT32_MAX";
807 };
808
809 /*
810 * aix_stdint_5
811 */
812 fix = {
813 hackname = aix_stdint_5;
814 mach = "*-*-aix*";
815 files = stdint-aix.h, stdint.h;
816 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
817 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
818 c_fix = format;
819 c_fix_arg = "#define UINT8_C(c) c\n"
820 "#define UINT16_C(c) c";
821 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
822 "#define UINT16_C(c) __CONCAT__(c,U)";
823 };
824
825 /*
826 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
827 produces wrong code with G++.
828 */
829 fix = {
830 hackname = aix_stdio_inline;
831 mach = "*-*-aix*";
832 files = stdio.h;
833 select = "#ifdef __cplusplus\\\n"
834 "}\\\n\\\n"
835 "#ifdef ferror\\\n";
836 c_fix = format;
837 c_fix_arg = "#ifdef __cplusplus\n"
838 "}\n"
839 "#endif\n\n"
840 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
841 "#ifdef ferror\n";
842 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
843 };
844
845 /*
846 * stdlib.h on AIX uses #define on malloc and friends.
847 */
848 fix = {
849 hackname = aix_stdlib_malloc;
850 mach = "*-*-aix*";
851 files = stdlib.h;
852 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
853 c_fix = format;
854 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
855 test_text = "#define malloc __linux_malloc";
856 };
857
858 fix = {
859 hackname = aix_stdlib_realloc;
860 mach = "*-*-aix*";
861 files = stdlib.h;
862 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
863 c_fix = format;
864 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
865 test_text = "#define realloc __linux_realloc";
866 };
867
868 fix = {
869 hackname = aix_stdlib_calloc;
870 mach = "*-*-aix*";
871 files = stdlib.h;
872 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
873 c_fix = format;
874 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
875 test_text = "#define calloc __linux_calloc";
876 };
877
878 fix = {
879 hackname = aix_stdlib_valloc;
880 mach = "*-*-aix*";
881 files = stdlib.h;
882 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
883 c_fix = format;
884 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
885 test_text = "#define valloc __linux_valloc";
886 };
887
888 fix = {
889 hackname = aix_stdlib_vec_malloc;
890 mach = "*-*-aix*";
891 files = stdlib.h;
892 select = "#define[ \t]+malloc[ \t]+vec_malloc";
893 c_fix = format;
894 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
895 test_text = "#define malloc vec_malloc";
896 };
897
898 fix = {
899 hackname = aix_stdlib_vec_calloc;
900 mach = "*-*-aix*";
901 files = stdlib.h;
902 select = "#define[ \t]+calloc[ \t]+vec_calloc";
903 c_fix = format;
904 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
905 test_text = "#define calloc vec_calloc";
906 };
907
908 /*
909 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
910 */
911 fix = {
912 hackname = aix_strtof_const;
913 mach = "*-*-aix*";
914 files = stdlib.h;
915 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
916 c_fix = format;
917 c_fix_arg = "%1(const char *, char **);";
918 test_text = "extern float strtof(char *, char **);";
919 };
920
921 /*
922 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
923 * in an otherwise harmless (and #ifed out) macro definition
924 */
925 fix = {
926 hackname = aix_sysmachine;
927 mach = "*-*-aix*";
928 files = sys/machine.h;
929 select = "\\\\ +\n";
930 c_fix = format;
931 c_fix_arg = "\\\n";
932 test_text = "#define FOO \\\n"
933 " bar \\ \n baz \\ \n bat";
934 };
935
936 /*
937 * sys/wait.h on AIX 5.2 defines macros that have both signed and
938 * unsigned types in conditional expressions.
939 */
940 fix = {
941 hackname = aix_syswait_2;
942 mach = "*-*-aix*";
943 files = sys/wait.h;
944 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
945 c_fix = format;
946 c_fix_arg = "? (int)%1";
947 test_text = "#define WSTOPSIG(__x) "
948 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
949 };
950
951 /*
952 * sys/signal.h on some versions of AIX uses volatile in the typedef of
953 * sig_atomic_t, which causes gcc to generate a warning about duplicate
954 * volatile when a sig_atomic_t variable is declared volatile, as
955 * required by ANSI C.
956 */
957 fix = {
958 hackname = aix_volatile;
959 mach = "*-*-aix*";
960 files = sys/signal.h;
961 select = "typedef volatile int sig_atomic_t";
962 c_fix = format;
963 c_fix_arg = "typedef int sig_atomic_t";
964 test_text = "typedef volatile int sig_atomic_t;";
965 };
966
967 /*
968 * AIX unistd.h defines a static function with an empty parameter list.
969 */
970 fix = {
971 hackname = aix_unistd;
972 mach = "*-*-aix*";
973 files = unistd.h;
974
975 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
976 c_fix = format;
977 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
978 test_text = " static int getdtablesize()";
979 };
980
981 /*
982 * Fix __assert declaration in assert.h on Alpha OSF/1.
983 */
984 fix = {
985 hackname = alpha___assert;
986 files = "assert.h";
987 select = '__assert\(char \*, char \*, int\)';
988 c_fix = format;
989 c_fix_arg = "__assert(const char *, const char *, int)";
990 test_text = 'extern void __assert(char *, char *, int);';
991 };
992
993 /*
994 * Fix assert macro in assert.h on Alpha OSF/1.
995 * The superfluous int cast breaks C++.
996 */
997 fix = {
998 hackname = alpha_assert;
999 files = "assert.h";
1000 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
1001 c_fix = format;
1002 c_fix_arg = "%1(EX)";
1003 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
1004 ': __assert(#EX, __FILE__, __LINE__))';
1005 };
1006
1007 /*
1008 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1009 */
1010 fix = {
1011 hackname = alpha_getopt;
1012 files = "stdio.h";
1013 files = "stdlib.h";
1014 select = 'getopt\(int, char \*\[\], *char \*\)';
1015 c_fix = format;
1016 c_fix_arg = "getopt(int, char *const[], const char *)";
1017 test_text = 'extern int getopt(int, char *[], char *);';
1018 };
1019
1020 /*
1021 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
1022 */
1023 fix = {
1024 hackname = alpha_if_semicolon;
1025 files = net/if.h;
1026 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
1027 c_fix = format;
1028 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
1029 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
1030 };
1031
1032 /*
1033 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1034 */
1035 fix = {
1036 hackname = alpha_parens;
1037 files = sym.h;
1038 select = '#ifndef\(__mips64\)';
1039 c_fix = format;
1040 c_fix_arg = "#ifndef __mips64";
1041 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1042 };
1043
1044 /*
1045 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1046 * And OpenBSD.
1047 */
1048 fix = {
1049 hackname = alpha_sbrk;
1050 files = unistd.h;
1051 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1052 c_fix = format;
1053 c_fix_arg = "void *sbrk(";
1054 test_text = "extern char* sbrk(ptrdiff_t increment);";
1055 };
1056
1057 /*
1058 * For C++, avoid any typedef or macro definition of bool,
1059 * and use the built in type instead.
1060 * HP/UX 10.20 also has it in curses_colr/curses.h.
1061 */
1062 fix = {
1063 hackname = avoid_bool_define;
1064 files = curses.h;
1065 files = curses_colr/curses.h;
1066 files = term.h;
1067 files = tinfo.h;
1068
1069 select = "#[ \t]*define[ \t]+bool[ \t]";
1070 bypass = "__cplusplus";
1071
1072 c_fix = format;
1073 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1074 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1075
1076 test_text = "# define bool\t char \n";
1077 };
1078
1079 /*
1080 * avoid_bool_type
1081 */
1082 fix = {
1083 hackname = avoid_bool_type;
1084 files = curses.h;
1085 files = curses_colr/curses.h;
1086 files = term.h;
1087 files = tinfo.h;
1088
1089 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1090 bypass = "__cplusplus";
1091
1092 c_fix = format;
1093 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1094
1095 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1096 };
1097
1098 /*
1099 * For C++, avoid any typedef definition of wchar_t,
1100 * and use the built in type instead.
1101 * Don't do this for headers that are smart enough to do the right
1102 * thing (recent [n]curses.h and Xlib.h).
1103 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
1104 * and will be broken by the edit.
1105 */
1106
1107 fix = {
1108 hackname = avoid_wchar_t_type;
1109
1110 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1111 bypass = "__cplusplus";
1112 bypass = "_LINUX_NLS_H";
1113 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1114
1115 c_fix = format;
1116 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1117
1118 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1119 };
1120
1121 /*
1122 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1123 */
1124 fix = {
1125 hackname = bad_struct_term;
1126 files = curses.h;
1127 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1128 c_fix = format;
1129 c_fix_arg = "struct term;";
1130
1131 test_text = 'typedef struct term;';
1132 };
1133
1134 /*
1135 * Fix one other error in this file:
1136 * a mismatched quote not inside a C comment.
1137 */
1138 fix = {
1139 hackname = badquote;
1140 files = sundev/vuid_event.h;
1141 select = "doesn't";
1142 c_fix = format;
1143 c_fix_arg = "does not";
1144
1145 test_text = "/* doesn't have matched single quotes */";
1146 };
1147
1148 /*
1149 * check for broken assert.h that needs stdio.h
1150 */
1151 fix = {
1152 hackname = broken_assert_stdio;
1153 files = assert.h;
1154 select = stderr;
1155 bypass = "include.*stdio\\.h";
1156 c_fix = wrap;
1157 c_fix_arg = "#include <stdio.h>\n";
1158 test_text = "extern FILE* stderr;";
1159 };
1160
1161 /*
1162 * check for broken assert.h that needs stdlib.h
1163 */
1164 fix = {
1165 hackname = broken_assert_stdlib;
1166 files = assert.h;
1167 select = 'exit *\(|abort *\(';
1168 bypass = "include.*stdlib\\.h";
1169 c_fix = wrap;
1170 c_fix_arg = "#ifdef __cplusplus\n"
1171 "#include <stdlib.h>\n"
1172 "#endif\n";
1173 test_text = "extern void exit ( int );";
1174 };
1175
1176 /*
1177 * Remove `extern double cabs' declarations from math.h.
1178 * This conflicts with C99. Discovered on AIX.
1179 * Darwin hides its broken cabs in architecture-specific subdirs.
1180 */
1181 fix = {
1182 hackname = broken_cabs;
1183 files = math.h, "architecture/*/math.h";
1184 select = "^extern[ \t]+double[ \t]+cabs";
1185
1186 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1187 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1188
1189 test_text = "#ifdef __STDC__\n"
1190 "extern double cabs(struct dbl_hypot);\n"
1191 "#else\n"
1192 "extern double cabs();\n"
1193 "#endif\n"
1194 "extern double cabs ( _Complex z );";
1195 };
1196
1197 /*
1198 * Fixup Darwin's broken check for __builtin_nanf.
1199 */
1200 fix = {
1201 hackname = broken_nan;
1202 /*
1203 * It is tempting to omit the first "files" entry. Do not.
1204 * The testing machinery will take the first "files" entry as the name
1205 * of a test file to play with. It would be a nuisance to have a directory
1206 * with the name "*".
1207 */
1208 files = "architecture/ppc/math.h";
1209 files = "architecture/*/math.h";
1210 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1211 bypass = "powl";
1212 c_fix = format;
1213 c_fix_arg = "#if 1";
1214 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1215 };
1216
1217 /*
1218 * Various systems derived from BSD4.4 contain a macro definition
1219 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1220 * Known to be fixed in FreeBSD 5 system headers.
1221 */
1222 fix = {
1223 hackname = bsd_stdio_attrs_conflict;
1224 mach = "*-*-*bsd*";
1225 mach = "*-*-*darwin*";
1226 files = stdio.h;
1227 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1228 c_fix = format;
1229 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1230 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1231 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1232 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1233 test_text = '#define vfscanf __svfscanf';
1234 };
1235
1236 /*
1237 * Fix various macros used to define ioctl numbers.
1238 * The traditional syntax was:
1239 *
1240 * #define _CTRL(n, x) (('n'<<8)+x)
1241 * #define TCTRLCFOO _CTRL(T, 1)
1242 *
1243 * but this does not work with the C standard, which disallows macro
1244 * expansion inside strings. We have to rewrite it thus:
1245 *
1246 * #define _CTRL(n, x) ((n<<8)+x)
1247 * #define TCTRLCFOO _CTRL('T', 1)
1248 *
1249 * The select expressions match too much, but the c_fix code is cautious.
1250 *
1251 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1252 */
1253 fix = {
1254 hackname = ctrl_quotes_def;
1255 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1256 c_fix = char_macro_def;
1257 c_fix_arg = "CTRL";
1258
1259 /*
1260 * This is two tests in order to ensure that the "CTRL(c)" can
1261 * be selected in isolation from the multi-arg format
1262 */
1263 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1264 test_text = "#define _CTRL(c) ('c'&037)";
1265 };
1266
1267 /*
1268 * Fix various macros used to define ioctl numbers.
1269 */
1270 fix = {
1271 hackname = ctrl_quotes_use;
1272 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1273 c_fix = char_macro_use;
1274 c_fix_arg = "CTRL";
1275 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1276 };
1277
1278 /*
1279 * sys/mman.h on HP/UX is not C++ ready,
1280 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1281 *
1282 * rpc/types.h on OSF1/2.0 is not C++ ready,
1283 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1284 *
1285 * The problem is the declaration of malloc.
1286 */
1287 fix = {
1288 hackname = cxx_unready;
1289 files = sys/mman.h;
1290 files = rpc/types.h;
1291 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1292 not within a macro. */
1293 bypass = '"C"|__BEGIN_DECLS';
1294
1295 c_fix = wrap;
1296 c_fix_arg = "#ifdef __cplusplus\n"
1297 "extern \"C\" {\n"
1298 "#endif\n";
1299 c_fix_arg = "#ifdef __cplusplus\n"
1300 "}\n"
1301 "#endif\n";
1302 test_text = "extern void* malloc( size_t );";
1303 };
1304
1305 /*
1306 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1307 * unconditionally.
1308 */
1309 fix = {
1310 hackname = darwin_availabilityinternal;
1311 mach = "*-*-darwin*";
1312 files = AvailabilityInternal.h;
1313 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1314 c_fix = format;
1315 c_fix_arg = <<- _EOFix_
1316 #if defined(__has_attribute)
1317 #if __has_attribute(availability)
1318 %0
1319 #else
1320 #define %1
1321 #endif
1322 #else
1323 #define %1
1324 #endif
1325 _EOFix_;
1326
1327 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1328 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1329 };
1330
1331 /*
1332 * For the AAB_darwin7_9_long_double_funcs fix (and later fixes for long long)
1333 * to be useful, the main math.h must use <> and not "" includes.
1334 */
1335 fix = {
1336 hackname = darwin_9_long_double_funcs_2;
1337 mach = "*-*-darwin*";
1338 files = math.h;
1339 select = '#include[ \t]+\"';
1340 c_fix = format;
1341 c_fix_arg = "%1<%2.h>";
1342
1343 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1344
1345 test_text = '#include <architecture/ppc/math.h>';
1346 };
1347
1348 /*
1349 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1350 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1351 */
1352 fix = {
1353 hackname = darwin_externc;
1354 mach = "*-*-darwin*";
1355 files = mach-o/swap.h;
1356 files = mach/mach_time.h;
1357 files = mach/mach_traps.h;
1358 files = mach/message.h;
1359 files = mach/mig.h;
1360 files = mach/semaphore.h;
1361 bypass = "extern \"C\"";
1362 bypass = "__BEGIN_DECLS";
1363 c_fix = wrap;
1364 c_fix_arg = "#ifdef __cplusplus\n"
1365 "extern \"C\" {\n"
1366 "#endif\n";
1367 c_fix_arg = "#ifdef __cplusplus\n"
1368 "}\n"
1369 "#endif\n";
1370 test_text = "extern void swap_fat_header();\n";
1371 };
1372
1373 /*
1374 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1375 * bad __GNUC__ tests.
1376 */
1377 fix = {
1378 hackname = darwin_gcc4_breakage;
1379 mach = "*-*-darwin*";
1380 files = AvailabilityMacros.h;
1381 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1382 c_fix = format;
1383 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1384 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1385 "(__GNUC_MINOR__ >= 1)\n";
1386 };
1387
1388 /*
1389 * math.h hides the long long functions that are available on the system for
1390 * 10.5 and 10.6 SDKs, we expect to use them in G++ without specifying a value
1391 * for __STDC_VERSION__, or switching __STRICT_ANSI__ off.
1392 */
1393 fix = {
1394 hackname = darwin_ll_funcs_avail;
1395 mach = "*-*-darwin*";
1396 files = architecture/ppc/math.h, architecture/i386/math.h;
1397 select = "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
1398 "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
1399 sed = "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
1400 "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
1401 test_text = "#if\ !(__DARWIN_NO_LONG_LONG)";
1402 };
1403
1404 /*
1405 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1406 */
1407 fix = {
1408 hackname = darwin_longjmp_noreturn;
1409 mach = "*-*-darwin*";
1410 files = "i386/setjmp.h";
1411 bypass = "__dead2";
1412 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1413 c_fix = format;
1414 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1415
1416 test_text = "void siglongjmp(sigjmp_buf, int);";
1417 };
1418
1419 /*
1420 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1421 */
1422 fix = {
1423 hackname = darwin_os_trace_1;
1424 mach = "*-*-darwin*";
1425 files = os/trace.h;
1426 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1427 c_fix = format;
1428 c_fix_arg = "%1";
1429 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1430 };
1431
1432 /*
1433 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1434 * extension without guard.
1435 */
1436 fix = {
1437 hackname = darwin_os_trace_2;
1438 mach = "*-*-darwin*";
1439 files = os/trace.h;
1440 select = "typedef.*\\^os_trace_payload_t.*";
1441 c_fix = format;
1442 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1443 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1444 };
1445
1446 /*
1447 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1448 * os_trace_payload_t typedef, too.
1449 */
1450 fix = {
1451 hackname = darwin_os_trace_3;
1452 mach = "*-*-darwin*";
1453 files = os/trace.h;
1454 select = <<- _EOSelect_
1455 __(API|OSX)_.*
1456 OS_EXPORT.*
1457 .*
1458 _os_trace.*os_trace_payload_t payload);
1459 _EOSelect_;
1460 c_fix = format;
1461 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1462 test_text = <<- _EOText_
1463 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1464 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1465 void
1466 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1467
1468 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1469 OS_EXPORT OS_NOTHROW
1470 void
1471 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1472 _EOText_;
1473 };
1474
1475 /*
1476 * In macOS 10.10 <os/base.h>, doesn't have __has_extension guarded.
1477 */
1478 fix = {
1479 hackname = darwin_os_base_1;
1480 mach = "*-*-darwin*";
1481 files = os/base.h;
1482 select = <<- OS_BASE_1_SEL
1483 #define __has_attribute.*
1484 #endif
1485 OS_BASE_1_SEL;
1486 c_fix = format;
1487 c_fix_arg = <<- OS_BASE_1_FIX
1488 %0
1489 #ifndef __has_extension
1490 #define __has_extension(x) 0
1491 #endif
1492 OS_BASE_1_FIX;
1493 test_text = <<- OS_BASE_1_TEST
1494 #define __has_attribute(x) 0
1495 #endif
1496
1497 #if __GNUC__
1498 OS_BASE_1_TEST;
1499 };
1500
1501 /*
1502 * In macOS 10.10 <dispatch/object.h>, has unguarded block syntax.
1503 */
1504 fix = {
1505 hackname = darwin_dispatch_object_1;
1506 mach = "*-*-darwin*";
1507 files = dispatch/object.h;
1508 select = "typedef void.*\\^dispatch_block_t.*";
1509 c_fix = format;
1510 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1511 test_text = <<- DISPATCH_OBJECT_1_TEST
1512 typedef void (^dispatch_block_t)(void);
1513
1514 __BEGIN_DECLS
1515 DISPATCH_OBJECT_1_TEST;
1516 };
1517
1518 /*
1519 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1520 * why would you ever put it in a system header file?
1521 */
1522 fix = {
1523 hackname = darwin_private_extern;
1524 mach = "*-*-darwin*";
1525 files = mach-o/dyld.h;
1526 select = "__private_extern__ [a-z_]+ _dyld_";
1527 c_fix = format;
1528 c_fix_arg = "extern";
1529 c_fix_arg = "__private_extern__";
1530 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1531 "const char *dyld_func_name,\n"
1532 "unsigned long *address);\n";
1533 };
1534
1535 /*
1536 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1537 * unsigned constants.
1538 */
1539 fix = {
1540 hackname = darwin_stdint_1;
1541 mach = "*-*-darwin*";
1542 files = stdint-darwin.h, stdint.h;
1543 c_fix = format;
1544 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1545 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1546 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1547 test_text = "#define UINT8_C(v) (v ## U)\n"
1548 "#define UINT16_C(v) (v ## U)";
1549 };
1550
1551 /*
1552 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1553 * with wrong types.
1554 */
1555 fix = {
1556 hackname = darwin_stdint_2;
1557 mach = "*-*-darwin*";
1558 files = stdint-darwin.h, stdint.h;
1559 c_fix = format;
1560 c_fix_arg = "#if __WORDSIZE == 64\n"
1561 "#define INTPTR_MAX 9223372036854775807L\n"
1562 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1563 "#else\n"
1564 "#define INTPTR_MAX 2147483647L\n"
1565 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1566 "#endif";
1567 select = "#if __WORDSIZE == 64\n"
1568 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1569 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1570 "#else\n"
1571 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1572 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1573 "#endif";
1574 test_text = "#if __WORDSIZE == 64\n"
1575 "#define INTPTR_MIN INT64_MIN\n"
1576 "#define INTPTR_MAX INT64_MAX\n"
1577 "#else\n"
1578 "#define INTPTR_MIN INT32_MIN\n"
1579 "#define INTPTR_MAX INT32_MAX\n"
1580 "#endif";
1581 };
1582
1583 /*
1584 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1585 */
1586 fix = {
1587 hackname = darwin_stdint_3;
1588 mach = "*-*-darwin*";
1589 files = stdint-darwin.h, stdint.h;
1590 c_fix = format;
1591 c_fix_arg = "#if __WORDSIZE == 64\n"
1592 "#define UINTPTR_MAX 18446744073709551615UL\n"
1593 "#else\n"
1594 "#define UINTPTR_MAX 4294967295UL\n"
1595 "#endif";
1596 select = "#if __WORDSIZE == 64\n"
1597 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1598 "#else\n"
1599 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1600 "#endif";
1601 test_text = "#if __WORDSIZE == 64\n"
1602 "#define UINTPTR_MAX UINT64_MAX\n"
1603 "#else\n"
1604 "#define UINTPTR_MAX UINT32_MAX\n"
1605 "#endif";
1606 };
1607
1608 /*
1609 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1610 */
1611 fix = {
1612 hackname = darwin_stdint_4;
1613 mach = "*-*-darwin*";
1614 files = stdint-darwin.h, stdint.h;
1615 c_fix = format;
1616 c_fix_arg = "#if __WORDSIZE == 64\n"
1617 "#define SIZE_MAX 18446744073709551615UL\n"
1618 "#else\n"
1619 "#define SIZE_MAX 4294967295UL\n"
1620 "#endif";
1621 select = "#if __WORDSIZE == 64\n"
1622 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1623 "#else\n"
1624 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1625 "#endif";
1626 test_text = "#if __WORDSIZE == 64\n"
1627 "#define SIZE_MAX UINT64_MAX\n"
1628 "#else\n"
1629 "#define SIZE_MAX UINT32_MAX\n"
1630 "#endif";
1631 };
1632
1633 /*
1634 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1635 * with a wrong type.
1636 */
1637 fix = {
1638 hackname = darwin_stdint_5;
1639 mach = "*-*-darwin*";
1640 files = stdint-darwin.h, stdint.h;
1641 c_fix = format;
1642 c_fix_arg = "#if __WORDSIZE == 64\n"
1643 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1644 "#define INTMAX_MAX 9223372036854775807L\n"
1645 "#define UINTMAX_MAX 18446744073709551615UL\n"
1646 "#else\n"
1647 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1648 "#define INTMAX_MAX 9223372036854775807LL\n"
1649 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1650 "#endif";
1651 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1652 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1653 "\n"
1654 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1655 test_text = "#define INTMAX_MIN INT64_MIN\n"
1656 "#define INTMAX_MAX INT64_MAX\n"
1657 "\n"
1658 "#define UINTMAX_MAX UINT64_MAX";
1659 };
1660
1661 /*
1662 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1663 * with a wrong type.
1664 */
1665 fix = {
1666 hackname = darwin_stdint_6;
1667 mach = "*-*-darwin*";
1668 files = stdint-darwin.h, stdint.h;
1669 c_fix = format;
1670 c_fix_arg = "#if __WORDSIZE == 64\n"
1671 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1672 "#define PTRDIFF_MAX 9223372036854775807L\n"
1673 "#else\n"
1674 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1675 "#define PTRDIFF_MAX 2147483647\n"
1676 "#endif";
1677 select = "#if __WORDSIZE == 64\n"
1678 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1679 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1680 "#else\n"
1681 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1682 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1683 "#endif";
1684 test_text = "#if __WORDSIZE == 64\n"
1685 "#define PTRDIFF_MIN INT64_MIN\n"
1686 "#define PTRDIFF_MAX INT64_MAX\n"
1687 "#else\n"
1688 "#define PTRDIFF_MIN INT32_MIN\n"
1689 "#define PTRDIFF_MAX INT32_MAX\n"
1690 "#endif";
1691 };
1692
1693 /*
1694 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1695 * with a wrong type.
1696 */
1697 fix = {
1698 hackname = darwin_stdint_7;
1699 mach = "*-*-darwin*";
1700 files = stdint-darwin.h, stdint.h;
1701 c_fix = format;
1702 c_fix_arg = "#if __WORDSIZE == 64\n"
1703 "#define INTMAX_C(v) (v ## L)\n"
1704 "#define UINTMAX_C(v) (v ## UL)\n"
1705 "#else\n"
1706 "#define INTMAX_C(v) (v ## LL)\n"
1707 "#define UINTMAX_C(v) (v ## ULL)\n"
1708 "#endif";
1709 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1710 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1711 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1712 "#define UINTMAX_C(v) (v ## ULL)";
1713 };
1714
1715 /* The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
1716 C11 _Atomic keyword (exposing it to C++ code). The work-around here follows
1717 the header in declaring the entity volatile when _Atomic is not available.
1718 */
1719 fix = {
1720 hackname = darwin_ucred__Atomic;
1721 mach = "*-*-darwin*";
1722 files = sys/ucred.h;
1723 select = "_Atomic";
1724 c_fix = wrap;
1725 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1726 "# define _Atomic volatile\n"
1727 "#endif\n";
1728 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1729 "# undef _Atomic\n"
1730 "#endif\n";
1731 test_text = ""; /* Don't provide this for wrap fixes. */
1732 };
1733
1734 /*
1735 * Fix <c_asm.h> on Digital UNIX V4.0:
1736 * It contains a prototype for a DEC C internal asm() function,
1737 * clashing with gcc's asm keyword. So protect this with __DECC.
1738 */
1739 fix = {
1740 hackname = dec_intern_asm;
1741 files = c_asm.h;
1742 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1743 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1744 "#endif\n";
1745 test_text =
1746 "float fasm {\n"
1747 " ... asm stuff ...\n"
1748 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1749 };
1750
1751 /*
1752 * Fix typo in <wchar.h> on DJGPP 2.03.
1753 */
1754 fix = {
1755 hackname = djgpp_wchar_h;
1756 file = wchar.h;
1757 select = "__DJ_wint_t";
1758 bypass = "sys/djtypes.h";
1759 c_fix = format;
1760 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1761 c_fix_arg = "#include <stddef.h>";
1762 test_text = "#include <stddef.h>\n"
1763 "extern __DJ_wint_t x;\n";
1764 };
1765
1766 /*
1767 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1768 */
1769 fix = {
1770 hackname = ecd_cursor;
1771 files = "sunwindow/win_lock.h";
1772 files = "sunwindow/win_cursor.h";
1773 select = 'ecd\.cursor';
1774 c_fix = format;
1775 c_fix_arg = 'ecd_cursor';
1776
1777 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1778 };
1779
1780 /*
1781 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1782 * that fails when compiling for SSE-less 32-bit x86.
1783 */
1784 fix = {
1785 hackname = feraiseexcept_nosse_divbyzero;
1786 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1787 files = bits/fenv.h, '*/bits/fenv.h';
1788 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1789 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1790 bypass = "\"fdivp .*; fwait\"";
1791
1792 c_fix = format;
1793 c_fix_arg = <<- _EOText_
1794 # ifdef __SSE_MATH__
1795 %0
1796 # else
1797 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1798 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1799 # endif
1800 _EOText_;
1801
1802 test_text = <<- _EOText_
1803 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1804 _EOText_;
1805 };
1806
1807 /*
1808 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1809 * that fails when compiling for SSE-less 32-bit x86.
1810 */
1811 fix = {
1812 hackname = feraiseexcept_nosse_invalid;
1813 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1814 files = bits/fenv.h, '*/bits/fenv.h';
1815 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1816 ": \"x\" \\(__f\\)\\);$";
1817 bypass = "\"fdiv .*; fwait\"";
1818
1819 c_fix = format;
1820 c_fix_arg = <<- _EOText_
1821 # ifdef __SSE_MATH__
1822 %0
1823 # else
1824 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1825 %1 : "=t" (__f) : "0" (__f));
1826 # endif
1827 _EOText_;
1828
1829 test_text = <<- _EOText_
1830 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1831 _EOText_;
1832 };
1833
1834 /*
1835 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1836 * neither the existence of GCC 3 nor its exact feature set yet break
1837 * (by design?) when __GNUC__ is set beyond 2.
1838 */
1839 fix = {
1840 hackname = freebsd_gcc3_breakage;
1841 mach = "*-*-freebsd*";
1842 files = sys/cdefs.h;
1843 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1844 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1845 c_fix = format;
1846 c_fix_arg = '%0 || __GNUC__ >= 3';
1847 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1848 };
1849
1850 /*
1851 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1852 * neither the existence of GCC 4 nor its exact feature set yet break
1853 * (by design?) when __GNUC__ is set beyond 3.
1854 */
1855 fix = {
1856 hackname = freebsd_gcc4_breakage;
1857 mach = "*-*-freebsd*";
1858 files = sys/cdefs.h;
1859 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1860 c_fix = format;
1861 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1862 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1863 };
1864
1865 /*
1866 * Some versions of glibc don't expect the C99 inline semantics.
1867 */
1868 fix = {
1869 hackname = glibc_c99_inline_1;
1870 files = features.h, '*/features.h';
1871 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1872 c_fix = format;
1873 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1874 test_text = <<-EOT
1875 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1876 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1877 # define __USE_EXTERN_INLINES 1
1878 #endif
1879 EOT;
1880 };
1881
1882 /*
1883 * Similar, but a version that didn't have __NO_INLINE__
1884 */
1885 fix = {
1886 hackname = glibc_c99_inline_1a;
1887 files = features.h, '*/features.h';
1888 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1889 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1890 c_fix = format;
1891 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1892 test_text = <<-EOT
1893 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1894 # define __USE_EXTERN_INLINES 1
1895 #endif
1896 EOT;
1897 };
1898
1899 /*
1900 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1901 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1902 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1903 */
1904 fix = {
1905 hackname = glibc_c99_inline_2;
1906 files = sys/stat.h, '*/sys/stat.h';
1907 select = "extern __inline__ int";
1908 sed = "s/extern int \\(stat\\)/"
1909 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1910 "__inline__ int \\1/";
1911 sed = "s/extern int \\([lf]stat\\)/"
1912 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1913 "__inline__ int \\1/";
1914 sed = "s/extern int \\(mknod\\)/"
1915 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1916 "__inline__ int \\1/";
1917 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1918 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1919 "__inline__ int __REDIRECT\\1 (\\2/";
1920 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1921 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1922 "__inline__ int __REDIRECT\\1 (\\2/";
1923 sed = "s/^extern __inline__ int/"
1924 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1925 "__inline__ int/";
1926 test_text = <<-EOT
1927 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1928 extern __inline__ int
1929 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1930 {}
1931 EOT;
1932 };
1933
1934 /*
1935 * glibc_c99_inline_3
1936 */
1937 fix = {
1938 hackname = glibc_c99_inline_3;
1939 files = bits/string2.h, '*/bits/string2.h';
1940 select = "extern __inline";
1941 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1942 c_fix = format;
1943 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1944 c_fix_arg = "^# ifdef __cplusplus$";
1945 test_text = <<-EOT
1946 # ifdef __cplusplus
1947 # define __STRING_INLINE inline
1948 # else
1949 # define __STRING_INLINE extern __inline
1950 # endif
1951 EOT;
1952 };
1953
1954 /*
1955 * glibc_c99_inline_4
1956 */
1957 fix = {
1958 hackname = glibc_c99_inline_4;
1959 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1960 pthread.h, '*/pthread.h';
1961 bypass = "__extern_inline|__gnu_inline__";
1962 select = "(^| )extern __inline";
1963 c_fix = format;
1964 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1965 test_text = <<-EOT
1966 __extension__ extern __inline unsigned int
1967 extern __inline unsigned int
1968 EOT;
1969 };
1970
1971 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1972 * so we replace them with versions that correspond to the
1973 * definition.
1974 */
1975 fix = {
1976 hackname = glibc_mutex_init;
1977 files = pthread.h;
1978 select = '\{ *\{ *0, *\} *\}';
1979 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1980 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1981 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1982 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1983 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1984 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1985 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1986 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1987 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1988 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1989 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1990 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1991 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1992 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1993 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1994 "N;s/^[ \t]*#[ \t]*"
1995 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1996 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1997 "# \\1\\\n"
1998 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1999 "# else\\\n"
2000 "# \\1\\\n"
2001 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
2002 "# endif/";
2003 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
2004 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
2005 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
2006 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
2007
2008 test_text = <<- _EOText_
2009 #define PTHREAD_MUTEX_INITIALIZER \\
2010 { { 0, } }
2011 #ifdef __USE_GNU
2012 # if __WORDSIZE == 64
2013 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2014 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2015 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2016 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2017 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2018 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2019 # else
2020 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2021 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2022 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2023 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2024 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2025 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2026 # endif
2027 #endif
2028 # define PTHREAD_RWLOCK_INITIALIZER \\
2029 { { 0, } }
2030 # ifdef __USE_GNU
2031 # if __WORDSIZE == 64
2032 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2033 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
2034 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2035 # else
2036 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2037 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2038 # endif
2039 # endif
2040 #define PTHREAD_COND_INITIALIZER { { 0, } }
2041 _EOText_;
2042 };
2043
2044 /* glibc versions before 2.5 have a version of stdint.h that defines
2045 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2046 versions with stdint.h based on those glibc versions. */
2047 fix = {
2048 hackname = glibc_stdint;
2049 files = stdint.h;
2050 select = "GNU C Library";
2051 c_fix = format;
2052 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2053 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2054 test_text = "/* This file is part of the GNU C Library. */\n"
2055 "# define UINT8_C(c)\tc ## U\n"
2056 "# define UINT16_C(c)\tc ## U";
2057 };
2058
2059 /* Some versions of glibc have a version of bits/string2.h that
2060 produces "value computed is not used" warnings from strncpy; fix
2061 this definition by using __builtin_strncpy instead as in newer
2062 versions. */
2063 fix = {
2064 hackname = glibc_strncpy;
2065 files = bits/string2.h, '*/bits/string2.h';
2066 bypass = "__builtin_strncpy";
2067 c_fix = format;
2068 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2069 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
2070 test_text = <<-EOT
2071 # define strncpy(dest, src, n) \
2072 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
2073 ? (strlen (src) + 1 >= ((size_t) (n)) \\
2074 ? (char *) memcpy (dest, src, n) \\
2075 : strncpy (dest, src, n)) \\
2076 : strncpy (dest, src, n)))
2077 EOT;
2078
2079 };
2080
2081 /* glibc's tgmath.h relies on an expression that is not an integer
2082 constant expression being treated as it was by GCC 4.4 and
2083 earlier. */
2084 fix = {
2085 hackname = glibc_tgmath;
2086 files = tgmath.h;
2087 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2088 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2089 c_fix = format;
2090 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
2091 "(__builtin_classify_type ((type) 0) == 9 && "
2092 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2093 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2094 };
2095
2096 /*
2097 * Fix these files to use the types we think they should for
2098 * ptrdiff_t, size_t, and wchar_t.
2099 *
2100 * This defines the types in terms of macros predefined by our 'cpp'.
2101 * This is supposedly necessary for glibc's handling of these types.
2102 * It's probably not necessary for anyone else, but it doesn't hurt.
2103 */
2104 fix = {
2105 hackname = gnu_types;
2106 files = "sys/types.h";
2107 files = "stdlib.h";
2108 files = "sys/stdtypes.h";
2109 files = "stddef.h";
2110 files = "memory.h";
2111 files = "unistd.h";
2112 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
2113 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2114 c_fix = gnu_type;
2115 /* The Solaris 10 headers already define these types correctly. */
2116 mach = '*-*-solaris2.1[0-9]*';
2117 not_machine = true;
2118
2119 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2120 "typedef uint_t size_t; /* uint_t */\n"
2121 "typedef ushort_t wchar_t; /* ushort_t */";
2122 };
2123
2124 /*
2125 * Fix HP & Sony's use of "../machine/xxx.h"
2126 * to refer to: <machine/xxx.h>
2127 */
2128 fix = {
2129 hackname = hp_inline;
2130 files = sys/spinlock.h;
2131 files = machine/machparam.h;
2132 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2133
2134 c_fix = format;
2135 c_fix_arg = "%1<machine/%2.h>";
2136
2137 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2138 '([a-z]+)\.h"';
2139
2140 test_text = ' # include "../machine/mumble.h"';
2141 };
2142
2143 /*
2144 * Check for (...) in C++ code in HP/UX sys/file.h.
2145 */
2146 fix = {
2147 hackname = hp_sysfile;
2148 files = sys/file.h;
2149 select = "HPUX_SOURCE";
2150
2151 c_fix = format;
2152 c_fix_arg = "(struct file *, ...)";
2153 c_fix_arg = '\(\.\.\.\)';
2154
2155 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2156 };
2157
2158 /*
2159 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2160 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2161 */
2162 fix = {
2163 hackname = hppa_hpux_fp_macros;
2164 mach = "hppa*-hp-hpux11*";
2165 files = math.h;
2166 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2167 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2168 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2169 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2170 "#[ \t]*define[ \t]*FP_NAN.*\n";
2171 c_fix = format;
2172 c_fix_arg = <<- _EOFix_
2173 #endif /* _INCLUDE_HPUX_SOURCE */
2174
2175 #if defined(_INCLUDE_HPUX_SOURCE) || \
2176 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2177 %0#endif
2178
2179 #ifdef _INCLUDE_HPUX_SOURCE
2180
2181 _EOFix_;
2182
2183 test_text =
2184 "# define FP_NORMAL 0\n"
2185 "# define FP_ZERO 1\n"
2186 "# define FP_INFINITE 2\n"
2187 "# define FP_SUBNORMAL 3\n"
2188 "# define FP_NAN 4\n";
2189 };
2190
2191 /*
2192 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2193 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2194 */
2195 fix = {
2196 hackname = hpux10_cpp_pow_inline;
2197 files = fixinc-test-limits.h, math.h;
2198 select = <<- END_POW_INLINE
2199 ^# +ifdef +__cplusplus
2200 +\}
2201 +inline +double +pow\(double +__d,int +__expon\) +\{
2202 [ ]+return +pow\(__d,\(double\)__expon\);
2203 +\}
2204 +extern +"C" +\{
2205 #else
2206 # +endif
2207 END_POW_INLINE;
2208
2209 c_fix = format;
2210 c_fix_arg = "";
2211
2212 test_text =
2213 "# ifdef __cplusplus\n"
2214 " }\n"
2215 " inline double pow(double __d,int __expon) {\n"
2216 "\t return pow(__d,(double)__expon);\n"
2217 " }\n"
2218 ' extern "C"' " {\n"
2219 "#else\n"
2220 "# endif";
2221 };
2222
2223 fix = {
2224 hackname = hpux11_cpp_pow_inline;
2225 files = math.h;
2226 select = " +inline double pow\\(double d,int expon\\) \\{\n"
2227 " +return pow\\(d, \\(double\\)expon\\);\n"
2228 " +\\}\n";
2229 c_fix = format;
2230 c_fix_arg = "";
2231
2232 test_text =
2233 " inline double pow(double d,int expon) {\n"
2234 " return pow(d, (double)expon);\n"
2235 " }\n";
2236 };
2237
2238 /*
2239 * Fix hpux 10.X missing ctype declarations 1
2240 */
2241 fix = {
2242 hackname = hpux10_ctype_declarations1;
2243 files = ctype.h;
2244 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2245 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2246 c_fix = format;
2247 c_fix_arg = "#ifdef _PROTOTYPES\n"
2248 "extern int __tolower(int);\n"
2249 "extern int __toupper(int);\n"
2250 "#else /* NOT _PROTOTYPES */\n"
2251 "extern int __tolower();\n"
2252 "extern int __toupper();\n"
2253 "#endif /* _PROTOTYPES */\n\n"
2254 "%0\n";
2255
2256 test_text = "# define _toupper(__c) __toupper(__c)\n";
2257 };
2258
2259 /*
2260 * Fix hpux 10.X missing ctype declarations 2
2261 */
2262 fix = {
2263 hackname = hpux10_ctype_declarations2;
2264 files = ctype.h;
2265 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2266 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2267 c_fix = format;
2268 c_fix_arg = "%0\n\n"
2269 "#ifdef _PROTOTYPES\n"
2270 " extern int _isalnum(int);\n"
2271 " extern int _isalpha(int);\n"
2272 " extern int _iscntrl(int);\n"
2273 " extern int _isdigit(int);\n"
2274 " extern int _isgraph(int);\n"
2275 " extern int _islower(int);\n"
2276 " extern int _isprint(int);\n"
2277 " extern int _ispunct(int);\n"
2278 " extern int _isspace(int);\n"
2279 " extern int _isupper(int);\n"
2280 " extern int _isxdigit(int);\n"
2281 "# else /* not _PROTOTYPES */\n"
2282 " extern int _isalnum();\n"
2283 " extern int _isalpha();\n"
2284 " extern int _iscntrl();\n"
2285 " extern int _isdigit();\n"
2286 " extern int _isgraph();\n"
2287 " extern int _islower();\n"
2288 " extern int _isprint();\n"
2289 " extern int _ispunct();\n"
2290 " extern int _isspace();\n"
2291 " extern int _isupper();\n"
2292 " extern int _isxdigit();\n"
2293 "#endif /* _PROTOTYPES */\n";
2294
2295 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2296 " extern unsigned int *__SB_masks;\n";
2297 };
2298
2299 /*
2300 * Fix hpux 10.X missing stdio declarations
2301 */
2302 fix = {
2303 hackname = hpux10_stdio_declarations;
2304 files = stdio.h;
2305 select = "^#[ \t]*define _iob[ \t]*__iob";
2306 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2307 c_fix = format;
2308 c_fix_arg = "%0\n\n"
2309 "# if defined(__STDC__) || defined(__cplusplus)\n"
2310 " extern int snprintf(char *, size_t, const char *, ...);\n"
2311 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2312 "# else /* not __STDC__) || __cplusplus */\n"
2313 " extern int snprintf();\n"
2314 " extern int vsnprintf();\n"
2315 "# endif /* __STDC__) || __cplusplus */\n";
2316
2317 test_text = "# define _iob __iob\n";
2318 };
2319
2320 /*
2321 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2322 * As a result, we need to include sys/stdsyms.h in alloca.h.
2323 */
2324 fix = {
2325 hackname = hppa_hpux11_alloca;
2326 mach = "hppa*-*-hpux11*";
2327 files = alloca.h;
2328 select = "#ifndef _STDDEF_INCLUDED";
2329 c_fix = format;
2330 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2331 "# include <sys/stdsyms.h>\n"
2332 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2333 "%0";
2334
2335 test_text = "#ifndef _STDDEF_INCLUDED";
2336 };
2337
2338 /*
2339 * Make sure hpux defines abs in header.
2340 */
2341 fix = {
2342 hackname = hpux11_abs;
2343 mach = "*-hp-hpux11*";
2344 files = stdlib.h;
2345 select = "ifndef _MATH_INCLUDED";
2346 c_fix = format;
2347 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2348 test_text = "#ifndef _MATH_INCLUDED";
2349 };
2350
2351 /*
2352 * Fix hpux11 __LWP_RWLOCK_VALID define
2353 */
2354 fix = {
2355 hackname = hpux11_lwp_rwlock_valid;
2356 mach = "*-hp-hpux11*";
2357 files = sys/pthread.h;
2358 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2359 c_fix = format;
2360 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2361 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2362 };
2363
2364 /*
2365 * hpux sendfile()
2366 */
2367 fix = {
2368 hackname = hpux11_extern_sendfile;
2369 mach = "*-hp-hpux11.[12]*";
2370 files = sys/socket.h;
2371 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2372 c_fix = format;
2373 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2374 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2375 " const struct iovec *, int));\n";
2376 };
2377
2378 /*
2379 * hpux sendpath()
2380 */
2381 fix = {
2382 hackname = hpux11_extern_sendpath;
2383 mach = "*-hp-hpux11.[12]*";
2384 files = sys/socket.h;
2385 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2386 c_fix = format;
2387 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2388 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2389 " const struct iovec *, int));\n";
2390 };
2391
2392 /*
2393 * Keep HP-UX 11 from stomping on C++ math namespace
2394 * with defines for fabsf.
2395 */
2396 fix = {
2397 hackname = hpux11_fabsf;
2398 mach = "*-hp-hpux11*";
2399 files = math.h;
2400 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2401
2402 c_fix = format;
2403 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2404
2405 test_text =
2406 "#ifdef _PA_RISC\n"
2407 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2408 "#endif";
2409 };
2410
2411 /*
2412 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2413 * in pthread.h need to be constant expressions to be standard complient.
2414 * As a result, we need to remove the void * casts in the initializers
2415 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2416 * to use the long type.
2417 */
2418 fix = {
2419 hackname = hpux11_pthread_pointer;
2420 mach = "*-hp-hpux11.[0-3]*";
2421 files = sys/pthread.h;
2422 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2423
2424 c_fix = format;
2425 c_fix_arg = "long\t%2%3";
2426 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2427 };
2428
2429 /*
2430 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2431 */
2432 fix = {
2433 hackname = hpux11_pthread_const;
2434 mach = "*-hp-hpux11.[0-3]*";
2435 files = sys/pthread.h;
2436 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2437
2438 c_fix = format;
2439 c_fix_arg = "%11";
2440 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2441 };
2442
2443 /*
2444 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2445 * being defined by having it define _hpux_size_t instead.
2446 */
2447 fix = {
2448 hackname = hpux11_size_t;
2449 mach = "*-hp-hpux11*";
2450 select = "__size_t";
2451
2452 c_fix = format;
2453 c_fix_arg = "_hpux_size_t";
2454
2455 test_text =
2456 "#define __size_t size_t\n"
2457 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2458 };
2459
2460 /*
2461 * Fix hpux 11.00 broken snprintf declaration
2462 * (third argument is char *, needs to be const char * to prevent
2463 * spurious warnings with -Wwrite-strings or in C++).
2464 */
2465 fix = {
2466 hackname = hpux11_snprintf;
2467 files = stdio.h;
2468 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2469 ' *(char *\*, *\.\.\.\);)';
2470 c_fix = format;
2471 c_fix_arg = '%1 const %3';
2472
2473 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2474 "extern int snprintf(char *, __size_t, char *, ...);\n"
2475 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2476 };
2477
2478 /*
2479 * Fix hpux 11.00 broken vsnprintf declaration
2480 */
2481 fix = {
2482 hackname = hpux11_vsnprintf;
2483 files = stdio.h;
2484 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2485 'const char \*,) __va__list\);';
2486 c_fix = format;
2487 c_fix_arg = "%1 __va_list);";
2488
2489 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2490 ' __va__list);';
2491 };
2492
2493 /*
2494 * Fix missing const in hpux vsscanf declaration
2495 */
2496 fix = {
2497 hackname = hpux_vsscanf;
2498 mach = "*-*-hpux*";
2499 files = stdio.h;
2500 select = '(extern int vsscanf\()char';
2501 c_fix = format;
2502 c_fix_arg = "%1const char";
2503
2504 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2505 };
2506
2507 /*
2508 * get rid of bogus inline definitions in HP-UX 8.0
2509 */
2510 fix = {
2511 hackname = hpux8_bogus_inlines;
2512 files = math.h;
2513 select = inline;
2514 bypass = "__GNUG__";
2515 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2516 "@extern \"C\" int abs(int);@";
2517 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2518 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2519 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2520 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2521 "inline double sqr(double v) { return v**0.5; }";
2522 };
2523
2524 /*
2525 * hpux intptr
2526 */
2527 fix = {
2528 hackname = hpux_c99_intptr;
2529 mach = "*-hp-hpux11.3*";
2530 files = stdint-hpux11.h, stdint.h;
2531 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2532 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2533 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2534 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2535 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2536 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2537 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2538 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2539 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2540 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2541 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2542 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2543 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2544 "#define PTRDIFF_MIN INT32_MIN\n"
2545 "#define INTPTR_MAX INT32_MAX\n"
2546 "#define INTPTR_MIN INT32_MIN\n"
2547 "#define UINTPTR_MAX UINT32_MAX\n"
2548 "#define SIZE_MAX UINT32_MAX\n";
2549 };
2550
2551 /*
2552 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2553 */
2554 fix = {
2555 hackname = hpux_c99_inttypes;
2556 mach = "*-hp-hpux11.[23]*";
2557 files = inttypes.h;
2558 files = stdint-hpux11.h, stdint.h;
2559 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2560 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2561 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2562 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2563 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2564 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2565 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2566 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2567 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2568 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2569 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2570 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2571 };
2572
2573 /*
2574 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2575 */
2576 fix = {
2577 hackname = hpux_c99_inttypes2;
2578 mach = "*-hp-hpux11.2*";
2579 files = stdint-hpux11.h, stdint.h;
2580 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2581 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2582 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2583 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2584 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2585 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2586 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2587 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2588 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2589 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2590 "# define INT16_C(__c) ((short)(__c))\n"
2591 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2592 };
2593
2594 /*
2595 * Fix broken and missing defines in inttypes.h
2596 */
2597 fix = {
2598 hackname = hpux_c99_inttypes3;
2599 mach = "hppa*-hp-hpux11*";
2600 files = inttypes.h;
2601 select = "#define[ \t]INTPTR_MAX[ \t]*\n"
2602 "#define[ \t]UINTPTR_MAX[ \t]*\n";
2603 c_fix = format;
2604 c_fix_arg = "#undef SIZE_MAX\n"
2605 "#define SIZE_MAX __SIZE_MAX__\n"
2606 "#ifdef __INTPTR_MAX__\n"
2607 "# undef INTPTR_MAX\n"
2608 "# define INTPTR_MAX __INTPTR_MAX__\n"
2609 "# undef INTPTR_MIN\n"
2610 "# define INTPTR_MIN (-INTPTR_MAX - 1)\n"
2611 "#endif\n"
2612 "#ifdef __UINTPTR_MAX__\n"
2613 "# undef UINTPTR_MAX\n"
2614 "# define UINTPTR_MAX __UINTPTR_MAX__\n"
2615 "#endif\n";
2616 test_text = "#define INTPTR_MAX\n"
2617 "#define UINTPTR_MAX\n";
2618 };
2619
2620 /*
2621 * Fix missing SCNuMAX defines in inttypes.h
2622 */
2623 fix = {
2624 hackname = hpux_c99_inttypes4;
2625 mach = "hppa*-hp-hpux11.[01]*";
2626 files = inttypes.h;
2627 sed = "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx64/a\\\n"
2628 "#define SCNuMAX \t SCNu64\n";
2629 sed = "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx32/a\\\n"
2630 "#define SCNuMAX \t SCNu32\n";
2631 test_text = "#define SCNxMAX SCNx64\n"
2632 "#define SCNxMAX SCNx32\n";
2633 };
2634
2635 /*
2636 * Fix hpux broken ctype macros
2637 */
2638 fix = {
2639 hackname = hpux_ctype_macros;
2640 files = ctype.h;
2641 select = '((: |\()__SB_masks \? )'
2642 '(__SB_masks\[__(alnum|c)\] & _IS)';
2643 c_fix = format;
2644 c_fix_arg = "%1(int)%3";
2645
2646 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2647 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2648 };
2649
2650 /*
2651 * hpux errno()
2652 */
2653 fix = {
2654 hackname = hpux_extern_errno;
2655 mach = "*-hp-hpux10.*";
2656 mach = "*-hp-hpux11.[0-2]*";
2657 files = errno.h;
2658 select = "^[ \t]*extern int errno;$";
2659 c_fix = format;
2660 c_fix_arg = "#ifdef __cplusplus\n"
2661 "extern \"C\" {\n"
2662 "#endif\n"
2663 "%0\n"
2664 "#ifdef __cplusplus\n"
2665 "}\n"
2666 "#endif";
2667 test_text = " extern int errno;\n";
2668 };
2669
2670 /*
2671 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2672 */
2673 fix = {
2674 hackname = hpux_htonl;
2675 files = netinet/in.h;
2676 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2677 "(/\\*\n"
2678 " \\* Macros for number representation conversion\\.\n"
2679 " \\*/\n"
2680 "#ifndef ntohl)";
2681 c_fix = format;
2682 c_fix_arg = "#if 1\n%1";
2683
2684 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2685 "/*\n"
2686 " * Macros for number representation conversion.\n"
2687 " */\n"
2688 "#ifndef ntohl\n"
2689 "#define ntohl(x) (x)\n"
2690 "#define ntohs(x) (x)\n"
2691 "#define htonl(x) (x)\n"
2692 "#define htons(x) (x)\n"
2693 "#endif\n"
2694 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2695 };
2696
2697 /*
2698 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2699 */
2700 fix = {
2701 hackname = hpux_imaginary_i;
2702 mach = "ia64-hp-hpux11.*";
2703 files = complex.h;
2704 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2705 c_fix = format;
2706 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2707 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2708 };
2709
2710 /*
2711 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2712 */
2713 fix = {
2714 hackname = hpux_inttype_int8_t;
2715 mach = "*-hp-hpux1[01].*";
2716 files = sys/_inttypes.h;
2717 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2718 c_fix = format;
2719 c_fix_arg = "typedef signed char int%18_t;";
2720 test_text = "typedef char int_least8_t;\n"
2721 "typedef char int8_t;\n";
2722 };
2723
2724 /*
2725 * HP-UX long_double
2726 */
2727 fix = {
2728 hackname = hpux_long_double;
2729 mach = "*-*-hpux10*";
2730 mach = "*-*-hpux11.[012]*";
2731 files = stdlib.h;
2732 select = "extern[ \t]long_double[ \t]strtold";
2733 bypass = "long_double_t";
2734 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2735 sed = "s/long_double/long double/g";
2736
2737 test_text = "# ifndef _LONG_DOUBLE\n"
2738 "# define _LONG_DOUBLE\n"
2739 " typedef struct {\n"
2740 " unsigned int word1, word2, word3, word4;\n"
2741 " } long_double;\n"
2742 "# endif /* _LONG_DOUBLE */\n"
2743 "extern long_double strtold(const char *, char **);\n";
2744 };
2745
2746 /*
2747 * We cannot use the above rule on 11.31 because it removes the strtold
2748 * definition. ia64 is OK with no hack, PA needs some help.
2749 */
2750 fix = {
2751 hackname = hpux_long_double_2;
2752 mach = "hppa*-*-hpux11.3*";
2753 files = stdlib.h;
2754 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2755 "defined\\(_PROTOTYPES\\) \\|\\| "
2756 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2757 c_fix = format;
2758 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2759
2760 test_text = "# if !defined(__ia64) || "
2761 "!defined(_PROTOTYPES) || "
2762 "defined(_LONG_DOUBLE_STRUCT)\n";
2763 };
2764
2765 /*
2766 * Add missing braces to pthread initializer defines.
2767 */
2768 fix = {
2769 hackname = hpux_pthread_initializers;
2770 mach = "*-hp-hpux11.[0-3]*";
2771 files = sys/pthread.h;
2772 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2773 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2774 sed = "s@^[ \t]*1,[ \t]*\\\\"
2775 "@\t{ 1, 0 }@";
2776 sed = "/^[ \t]*0$/d";
2777 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2778 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2779 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2780 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2781 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2782 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2783 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2784 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2785 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2786 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2787 sed = "s@__PTHREAD_COND_VALID, 0"
2788 "@{ __PTHREAD_COND_VALID, 0 }@";
2789 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2790 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2791 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2792 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2793 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2794 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2795 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2796 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2797 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2798 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2799 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2800 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2801 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2802 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2803 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2804 "}\n";
2805 };
2806
2807 /*
2808 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2809 * type and mpinfou is only defined when _KERNEL is set.
2810 */
2811 fix = {
2812 hackname = hpux_spu_info;
2813 mach = "*-hp-hpux*";
2814 /*
2815 * It is tempting to omit the first "files" entry. Do not.
2816 * The testing machinery will take the first "files" entry as the name
2817 * of a test file to play with. It would be a nuisance to have a directory
2818 * with the name "*".
2819 */
2820 files = "ia64/sys/getppdp.h";
2821 files = "*/sys/getppdp.h";
2822 select = "^.*extern.*spu_info.*";
2823
2824 c_fix = format;
2825 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2826
2827 test_text = "extern union mpinfou spu_info[];";
2828 };
2829
2830 /*
2831 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2832 */
2833 fix = {
2834 hackname = hpux_stdint_least_fast;
2835 mach = "*-hp-hpux11.2*";
2836 files = stdint-hpux11.h, stdint.h;
2837 select =
2838 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2839 c_fix = format;
2840 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2841 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2842 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2843 };
2844
2845 /*
2846 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2847 */
2848 fix = {
2849 hackname = hpux_longjmp;
2850 mach = "*-hp-hpux*";
2851 files = setjmp.h;
2852 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2853
2854 c_fix = format;
2855 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2856
2857 test_text = 'extern void longjmp __((jmp_buf, int));';
2858 };
2859
2860 /*
2861 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2862 */
2863 fix = {
2864 hackname = hpux_systime;
2865 files = sys/time.h;
2866 select = "^extern struct sigevent;";
2867
2868 c_fix = format;
2869 c_fix_arg = "struct sigevent;";
2870
2871 test_text = 'extern struct sigevent;';
2872 };
2873
2874 /*
2875 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2876 */
2877 fix = {
2878 hackname = huge_val_hex;
2879 files = bits/huge_val.h, '*/bits/huge_val.h';
2880 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2881 bypass = "__builtin_huge_val";
2882
2883 c_fix = format;
2884 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2885
2886 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2887 };
2888
2889 /*
2890 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2891 */
2892 fix = {
2893 hackname = huge_valf_hex;
2894 files = bits/huge_val.h, '*/bits/huge_val.h';
2895 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2896 bypass = "__builtin_huge_valf";
2897
2898 c_fix = format;
2899 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2900
2901 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2902 };
2903
2904 /*
2905 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2906 */
2907 fix = {
2908 hackname = huge_vall_hex;
2909 files = bits/huge_val.h, '*/bits/huge_val.h';
2910 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2911 bypass = "__builtin_huge_vall";
2912
2913 c_fix = format;
2914 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2915
2916 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2917 };
2918
2919 /*
2920 * Fix return type of abort and free
2921 */
2922 fix = {
2923 hackname = int_abort_free_and_exit;
2924 files = stdlib.h;
2925 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2926 bypass = "_CLASSIC_ANSI_TYPES";
2927
2928 c_fix = format;
2929 c_fix_arg = "void\t%1(";
2930
2931 test_text = "extern int abort(int);\n"
2932 "extern int free(void*);\n"
2933 "extern int exit(void*);";
2934 };
2935
2936 /*
2937 * Fix various macros used to define ioctl numbers.
2938 * The traditional syntax was:
2939 *
2940 * #define _IO(n, x) (('n'<<8)+x)
2941 * #define TIOCFOO _IO(T, 1)
2942 *
2943 * but this does not work with the C standard, which disallows macro
2944 * expansion inside strings. We have to rewrite it thus:
2945 *
2946 * #define _IO(n, x) ((n<<8)+x)
2947 * #define TIOCFOO _IO('T', 1)
2948 *
2949 * The select expressions match too much, but the c_fix code is cautious.
2950 *
2951 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2952 */
2953 fix = {
2954 hackname = io_quotes_def;
2955 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2956 c_fix = char_macro_def;
2957 c_fix_arg = "IO";
2958 test_text =
2959 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2960 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2961 "#define _IO(x,y) ('x'<<8|y)";
2962 test_text =
2963 "#define XX_IO(x) ('x'<<8|256)";
2964 };
2965
2966 /*
2967 * Fix the usage of the ioctl macro numbers.
2968 */
2969 fix = {
2970 hackname = io_quotes_use;
2971 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2972 "\\( *[^,']";
2973 c_fix = char_macro_use;
2974 c_fix_arg = "IO";
2975 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2976 "#define TIOCFOO \\\\\n"
2977 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2978 };
2979
2980 /*
2981 * Check for missing ';' in struct
2982 */
2983 fix = {
2984 hackname = ip_missing_semi;
2985 files = netinet/ip.h;
2986 select = "}$";
2987 sed = "/^struct/,/^};/s/}$/};/";
2988 test_text=
2989 "struct mumble {\n"
2990 " union {\n"
2991 " int x;\n"
2992 " }\n"
2993 "}; /* mumbled struct */\n";
2994 };
2995
2996 /*
2997 * Non-traditional "const" declaration in Irix's limits.h.
2998 */
2999 fix = {
3000 hackname = irix_limits_const;
3001 files = fixinc-test-limits.h, limits.h;
3002 select = "^extern const ";
3003 c_fix = format;
3004 c_fix_arg = "extern __const ";
3005 test_text = "extern const char limit; /* test limits */";
3006 };
3007
3008 /*
3009 * IRIX 5.x's stdio.h declares some functions that take a va_list as
3010 * taking char *. However, GCC uses void * for va_list, so
3011 * calling vfprintf with a va_list fails in C++. */
3012 fix = {
3013 hackname = irix_stdio_va_list;
3014 files = stdio.h;
3015
3016 select = '/\* va_list \*/ char \*';
3017 c_fix = format;
3018 c_fix_arg = "__gnuc_va_list";
3019 test_text =
3020 "extern int printf( const char *, /* va_list */ char * );";
3021 };
3022
3023 /*
3024 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
3025 * use / * * / to concatenate tokens.
3026 */
3027 fix = {
3028 hackname = kandr_concat;
3029 files = "sparc/asm_linkage.h";
3030 files = "sun*/asm_linkage.h";
3031 files = "arm/as_support.h";
3032 files = "arm/mc_type.h";
3033 files = "arm/xcb.h";
3034 files = "dev/chardefmac.h";
3035 files = "dev/ps_irq.h";
3036 files = "dev/screen.h";
3037 files = "dev/scsi.h";
3038 files = "sys/tty.h";
3039 files = "Xm.acorn/XmP.h";
3040 files = bsd43/bsd43_.h;
3041 select = '/\*\*/';
3042 c_fix = format;
3043 c_fix_arg = '##';
3044 test_text = "#define __CONCAT__(a,b) a/**/b";
3045 };
3046
3047 /*
3048 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
3049 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
3050 * constant on recent versions of g++.
3051 */
3052 fix = {
3053 hackname = linux_ia64_ucontext;
3054 files = "sys/ucontext.h";
3055 mach = "ia64-*-linux*";
3056 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
3057 '->sc_gr\[0\]\) - \(char \*\) 0\)';
3058 c_fix = format;
3059 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
3060 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
3061 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
3062 };
3063
3064 /*
3065 * Remove header file warning from sys/time.h. Autoconf's
3066 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
3067 * which causes warning on LynxOS. Remove the warning.
3068 */
3069 fix = {
3070 hackname = lynxos_no_warning_in_sys_time_h;
3071 files = sys/time.h;
3072 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
3073 c_fix = format;
3074 c_fix_arg = "";
3075 test_text = "#warning Using <time.h> instead of <sys/time.h>";
3076 };
3077
3078 /*
3079 * Add missing declaration for putenv.
3080 */
3081 fix = {
3082 hackname = lynxos_missing_putenv;
3083 mach = '*-*-lynxos*';
3084 files = stdlib.h;
3085 bypass = 'putenv[ \t]*\\(';
3086 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3087 c_fix = format;
3088 c_fix_arg = "%0\n"
3089 "extern int putenv _AP((char *));";
3090 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3091 test_text = "extern char *getenv _AP((const char *));";
3092 };
3093
3094 /*
3095 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3096 *
3097 * On NetBSD, machine is a symbolic link to an architecture specific
3098 * directory name, so we can't match a specific file name here.
3099 */
3100 fix = {
3101 hackname = machine_ansi_h_va_list;
3102 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
3103 bypass = '__builtin_va_list';
3104
3105 c_fix = format;
3106 c_fix_arg = "%1__builtin_va_list";
3107 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3108
3109 test_text = " # define _BSD_VA_LIST_\tchar**";
3110 };
3111
3112 /*
3113 * Fix non-ansi machine name defines
3114 */
3115 fix = {
3116 hackname = machine_name;
3117 c_test = machine_name;
3118 c_fix = machine_name;
3119
3120 test_text = "/* MACH_DIFF: */\n"
3121 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
3122 "\n/* no uniform test, so be careful :-) */";
3123 };
3124
3125 /*
3126 * Some math.h files define struct exception (it's in the System V
3127 * Interface Definition), which conflicts with the class exception defined
3128 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
3129 * This is not a great fix, but I haven't been able to think of anything
3130 * better.
3131 */
3132 fix = {
3133 hackname = math_exception;
3134 files = math.h;
3135 select = "struct exception";
3136 /*
3137 * This should be bypassed on __cplusplus, but some supposedly C++
3138 * aware headers, such as Solaris 8 and 9, don't wrap their struct
3139 * exception either. So currently we bypass only for glibc, based on a
3140 * comment in the fixed glibc header. Ick.
3141 */
3142 bypass = 'We have a problem when using C\+\+|for C\+\+, '
3143 '_[a-z0-9A-Z_]+_exception; for C, exception';
3144 /* The Solaris 10 headers already get this right. */
3145 mach = '*-*-solaris2.1[0-9]*';
3146 not_machine = true;
3147 c_fix = wrap;
3148
3149 c_fix_arg = "#ifdef __cplusplus\n"
3150 "#define exception __math_exception\n"
3151 "#endif\n";
3152
3153 c_fix_arg = "#ifdef __cplusplus\n"
3154 "#undef exception\n"
3155 "#endif\n";
3156
3157 test_text = "typedef struct exception t_math_exception;";
3158 };
3159
3160 /*
3161 * This looks pretty broken to me. ``dbl_max_def'' will contain
3162 * "define DBL_MAX " at the start, when what we really want is just
3163 * the value portion. Can't figure out how to write a test case
3164 * for this either :-(
3165 */
3166 fix = {
3167 hackname = math_huge_val_from_dbl_max;
3168 files = math.h;
3169
3170 /*
3171 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3172 * in math.h, this fix applies.
3173 */
3174 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3175 bypass = "define[ \t]+DBL_MAX";
3176
3177 shell =
3178 /*
3179 * See if we have a definition for DBL_MAX in float.h.
3180 * If we do, we will replace the one in math.h with that one.
3181 */
3182
3183 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
3184 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
3185
3186 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3187 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
3188 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
3189 "\telse cat\n"
3190 "\tfi";
3191
3192 test_text =
3193 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
3194 "#define HUGE_VAL DBL_MAX";
3195 };
3196
3197 /*
3198 * nested comment
3199 */
3200 fix = {
3201 hackname = nested_auth_des;
3202 files = rpc/rpc.h;
3203 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
3204 c_fix = format;
3205 c_fix_arg = "%1*/ /*";
3206 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3207 };
3208
3209 /*
3210 * Some versions of NetBSD don't expect the C99 inline semantics.
3211 */
3212 fix = {
3213 hackname = netbsd_c99_inline_1;
3214 mach = "*-*-netbsd*";
3215 files = signal.h;
3216 select = "extern __inline int";
3217
3218 c_fix = format;
3219 c_fix_arg = "extern\n"
3220 "#ifdef __GNUC_STDC_INLINE__\n"
3221 "__attribute__((__gnu_inline__))\n"
3222 "#endif\n"
3223 "__inline int";
3224
3225 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3226 };
3227
3228 /*
3229 * netbsd_c99_inline_2
3230 */
3231 fix = {
3232 hackname = netbsd_c99_inline_2;
3233 mach = "*-*-netbsd*";
3234 files = signal.h;
3235 select = "#define _SIGINLINE extern __inline";
3236
3237 c_fix = format;
3238 c_fix_arg = <<- _EOArg_
3239 #ifdef __GNUC_STDC_INLINE__
3240 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3241 #else
3242 %0
3243 #endif
3244 _EOArg_;
3245
3246 test_text = "#define _SIGINLINE extern __inline";
3247 };
3248
3249 /*
3250 * NetBSD has a semicolon after the ending '}' for some extern "C".
3251 */
3252 fix = {
3253 hackname = netbsd_extra_semicolon;
3254 mach = "*-*-netbsd*";
3255 files = sys/cdefs.h;
3256 select = "#define[ \t]*__END_DECLS[ \t]*};";
3257
3258 c_fix = format;
3259 c_fix_arg = "#define __END_DECLS }";
3260
3261 test_text = "#define __END_DECLS };";
3262 };
3263
3264 /*
3265 * newlib's stdint.h has several failures to conform to C99. The fix
3266 * for these removed a comment that can be matched to identify unfixed
3267 * versions.
3268 */
3269 fix = {
3270 hackname = newlib_stdint_1;
3271 files = stdint-newlib.h, stdint.h;
3272 select = "@todo - Add support for wint_t types";
3273 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3274 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3275 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3276 sed = "s@#define INT_LEAST32_MIN.*@"
3277 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3278 sed = "s@#define INT_LEAST32_MAX.*@"
3279 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3280 sed = "s@#define UINT_LEAST32_MAX.*@"
3281 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3282 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3283 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3284 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3285 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3286 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3287 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3288 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3289 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3290 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3291 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3292 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3293 test_text = "/* @todo - Add support for wint_t types. */\n"
3294 "#define INT32_MIN (-2147483647-1)\n"
3295 "#define INT32_MAX 2147483647\n"
3296 "#define UINT32_MAX 4294967295U\n"
3297 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3298 "#define INT_LEAST32_MAX 2147483647\n"
3299 "#define UINT_LEAST32_MAX 4294967295U\n"
3300 "#define INT_FAST8_MIN INT8_MIN\n"
3301 "#define INT_FAST8_MAX INT8_MAX\n"
3302 "#define UINT_FAST8_MAX UINT8_MAX\n"
3303 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3304 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3305 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3306 "#define UINT8_C(x) x##U\n"
3307 "#define UINT16_C(x) x##U";
3308 };
3309
3310 /*
3311 * newlib_stdint_2
3312 */
3313 fix = {
3314 hackname = newlib_stdint_2;
3315 files = stdint-newlib.h, stdint.h;
3316 select = "@todo - Add support for wint_t types";
3317 c_fix = format;
3318 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3319 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3320 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3321 "#define WCHAR_MAX __WCHAR_MAX__\n"
3322 "#define WCHAR_MIN __WCHAR_MIN__\n"
3323 "#define WINT_MAX __WINT_MAX__\n"
3324 "#define WINT_MIN __WINT_MIN__\n\n"
3325 "%0";
3326 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
3327 test_text = "/* @todo - Add support for wint_t types. */\n"
3328 "/** Macros for minimum-width integer constant expressions */";
3329 };
3330
3331 /*
3332 * NeXT 3.2 adds const prefix to some math functions.
3333 * These conflict with the built-in functions.
3334 */
3335 fix = {
3336 hackname = next_math_prefix;
3337 files = ansi/math.h;
3338 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3339
3340 c_fix = format;
3341 c_fix_arg = "extern double %1(";
3342 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3343
3344 test_text = "extern\tdouble\t__const__\tmumble();";
3345 };
3346
3347 /*
3348 * NeXT 3.2 uses the word "template" as a parameter for some
3349 * functions. GCC reports an invalid use of a reserved key word
3350 * with the built-in functions.
3351 */
3352 fix = {
3353 hackname = next_template;
3354 files = bsd/libc.h;
3355 select = "[ \t]template\\)";
3356
3357 c_fix = format;
3358 c_fix_arg = "(%1)";
3359 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3360 test_text = "extern mumble( char * template); /* fix */";
3361 };
3362
3363 /*
3364 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3365 * function prototypes. That conflicts with the built-in functions.
3366 */
3367 fix = {
3368 hackname = next_volitile;
3369 files = ansi/stdlib.h;
3370 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3371
3372 c_fix = format;
3373 c_fix_arg = "extern void %1(";
3374 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3375
3376 test_text = "extern\tvolatile\tvoid\tabort();";
3377 };
3378
3379 /*
3380 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3381 * Note that version 3 of the NeXT system has wait.h in a different directory,
3382 * so that this code won't do anything. But wait.h in version 3 has a
3383 * conditional, so it doesn't need this fix. So everything is okay.
3384 */
3385 fix = {
3386 hackname = next_wait_union;
3387 files = sys/wait.h;
3388
3389 select = 'wait\(union wait';
3390 c_fix = format;
3391 c_fix_arg = "wait(void";
3392 test_text = "extern pid_d wait(union wait*);";
3393 };
3394
3395 /*
3396 * a missing semi-colon at the end of the nodeent structure definition.
3397 */
3398 fix = {
3399 hackname = nodeent_syntax;
3400 files = netdnet/dnetdb.h;
3401 select = "char[ \t]*\\*na_addr[ \t]*$";
3402 c_fix = format;
3403 c_fix_arg = "%0;";
3404 test_text = "char *na_addr\t";
3405 };
3406
3407 /*
3408 * Fix OpenBSD's NULL definition.
3409 */
3410 fix = {
3411 hackname = openbsd_null_definition;
3412 mach = "*-*-openbsd*";
3413 files = locale.h, stddef.h, stdio.h, string.h,
3414 time.h, unistd.h, wchar.h, sys/param.h;
3415 select = "__GNUG__";
3416 c_fix = format;
3417 c_fix_arg = "#ifndef NULL\n"
3418 "#ifdef __cplusplus\n"
3419 "#ifdef __GNUG__\n"
3420 "#define NULL\t__null\n"
3421 "#else\t /* ! __GNUG__ */\n"
3422 "#define NULL\t0L\n"
3423 "#endif\t /* __GNUG__ */\n"
3424 "#else\t /* ! __cplusplus */\n"
3425 "#define NULL\t((void *)0)\n"
3426 "#endif\t /* __cplusplus */\n"
3427 "#endif\t /* !NULL */";
3428
3429 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3430 "^#ifdef[ \t]*__GNUG__\n"
3431 "^#define[ \t]*NULL[ \t]*__null\n"
3432 "^#else\n"
3433 "^#define[ \t]*NULL[ \t]*0L\n"
3434 "^#endif\n"
3435 "^#endif";
3436 test_text =
3437 "#ifndef NULL\n"
3438 "#ifdef __GNUG__\n"
3439 "#define NULL __null\n"
3440 "#else\n"
3441 "#define NULL 0L\n"
3442 "#endif\n"
3443 "#endif\n";
3444 };
3445
3446 /*
3447 * obstack.h used casts as lvalues.
3448 *
3449 * We need to change postincrements of casted pointers (which are
3450 * then dereferenced and assigned into) of the form
3451 *
3452 * *((TYPE*)PTRVAR)++ = (VALUE)
3453 *
3454 * into expressions like
3455 *
3456 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3457 *
3458 * which is correct for the cases used in obstack.h since PTRVAR is
3459 * of type char * and the value of the expression is not used.
3460 */
3461 fix = {
3462 hackname = obstack_lvalue_cast;
3463 files = obstack.h;
3464 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3465 c_fix = format;
3466 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3467 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3468 };
3469
3470 /*
3471 * Fix OpenBSD's va_start define.
3472 */
3473 fix = {
3474 hackname = openbsd_va_start;
3475 mach = "*-*-openbsd*";
3476 files = stdarg.h;
3477 select = '__builtin_stdarg_start';
3478 c_fix = format;
3479 c_fix_arg = __builtin_va_start;
3480
3481 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3482 };
3483
3484 /*
3485 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3486 * defining regex.h related types. This causes libg++ build and usage
3487 * failures. Fixing this correctly requires checking and modifying 3 files.
3488 */
3489 fix = {
3490 hackname = osf_namespace_a;
3491 files = reg_types.h;
3492 files = sys/lc_core.h;
3493 test = " -r reg_types.h";
3494 test = " -r sys/lc_core.h";
3495 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3496 test = " -z \"`grep __regex_t regex.h`\"";
3497
3498 c_fix = format;
3499 c_fix_arg = "__%0";
3500 c_fix_arg = "reg(ex|off|match)_t";
3501
3502 test_text = "`touch sys/lc_core.h`"
3503 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3504 "extern regex_t re;\n"
3505 "extern regoff_t ro;\n"
3506 "extern regmatch_t rm;\n";
3507 };
3508
3509 fix = {
3510 hackname = osf_namespace_c;
3511 files = regex.h;
3512 test = " -r reg_types.h";
3513 test = " -r sys/lc_core.h";
3514 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
3515 test = " -z \"`grep __regex_t regex.h`\"";
3516
3517 select = "#include <reg_types\.h>.*";
3518 c_fix = format;
3519 c_fix_arg = "%0\n"
3520 "typedef __regex_t\tregex_t;\n"
3521 "typedef __regoff_t\tregoff_t;\n"
3522 "typedef __regmatch_t\tregmatch_t;";
3523
3524 test_text = "#include <reg_types.h>";
3525 };
3526
3527 /*
3528 * On broken glibc-2.3.3 systems an array of incomplete structures is
3529 * passed to __sigsetjmp. Fix that to take a pointer instead.
3530 */
3531 fix = {
3532 hackname = pthread_incomplete_struct_argument;
3533 files = pthread.h;
3534 select = "struct __jmp_buf_tag";
3535 c_fix = format;
3536 c_fix_arg = "%1 *%2%3";
3537 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3538 "(__env)\\[1\\](.*)$";
3539 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3540 "int __savemask);";
3541 };
3542
3543 /*
3544 * Fix return type of fread and fwrite on sysV68
3545 */
3546 fix = {
3547 hackname = read_ret_type;
3548 files = stdio.h;
3549 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3550 c_fix = format;
3551 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3552 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3553
3554 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3555 };
3556
3557 /*
3558 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3559 */
3560 fix = {
3561 hackname = rpc_xdr_lvalue_cast_a;
3562 files = rpc/xdr.h;
3563 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3564 c_fix = format;
3565 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3566 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3567 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3568 };
3569
3570 /*
3571 * rpc_xdr_lvalue_cast_b
3572 */
3573 fix = {
3574 hackname = rpc_xdr_lvalue_cast_b;
3575 files = rpc/xdr.h;
3576 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3577 c_fix = format;
3578 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3579 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3580 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3581 };
3582
3583 /*
3584 * function class(double x) conflicts with C++ keyword on rs/6000
3585 */
3586 fix = {
3587 hackname = rs6000_double;
3588 files = math.h;
3589 select = '[^a-zA-Z_]class\(';
3590
3591 c_fix = format;
3592 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3593 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3594
3595 test_text = "extern int class();";
3596 };
3597
3598 /*
3599 * Wrong fchmod prototype on RS/6000.
3600 */
3601 fix = {
3602 hackname = rs6000_fchmod;
3603 files = sys/stat.h;
3604 select = 'fchmod\(char \*';
3605 c_fix = format;
3606 c_fix_arg = "fchmod(int";
3607 test_text = "extern int fchmod(char *, mode_t);";
3608 };
3609
3610 /*
3611 * parameters conflict with C++ new on rs/6000
3612 */
3613 fix = {
3614 hackname = rs6000_param;
3615 files = "stdio.h";
3616 files = "unistd.h";
3617
3618 select = 'rename\(const char \*old, const char \*new\)';
3619 c_fix = format;
3620 c_fix_arg = 'rename(const char *_old, const char *_new)';
3621
3622 test_text = 'extern int rename(const char *old, const char *new);';
3623 };
3624
3625 /*
3626 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3627 * for C99. This is wrong for C++, which needs many C99 features, but
3628 * only supports __restrict.
3629 */
3630 fix = {
3631 hackname = solaris___restrict;
3632 files = sys/feature_tests.h;
3633 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3634 mach = "*-*-solaris2*";
3635 c_fix = format;
3636 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3637 "#else\n%0\n#endif";
3638 test_text = "#define _RESTRICT_KYWD restrict";
3639 };
3640
3641 /*
3642 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3643 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3644 * and imaginary definitions which are not supported by GCC.
3645 */
3646 fix = {
3647 hackname = solaris_complex;
3648 mach = "*-*-solaris2.*";
3649 files = complex.h;
3650 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3651 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3652 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3653 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3654 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3655 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3656 test_text = "#define _Complex_I _Complex_I\n"
3657 "#define complex _Complex\n"
3658 "#define _Imaginary_I _Imaginary_I\n"
3659 "#define imaginary _Imaginary\n"
3660 "#undef I\n"
3661 "#define I _Imaginary_I";
3662 };
3663
3664 /*
3665 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3666 * extern "C" instead so libstdc++ can use it.
3667 */
3668 fix = {
3669 hackname = solaris_complex_cxx;
3670 mach = "*-*-solaris2.*";
3671 files = complex.h;
3672 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3673 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3674 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3675 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3676 test_text = "#if !defined(__cplusplus)\n"
3677 "#endif /* !defined(__cplusplus) */";
3678 };
3679
3680 /*
3681 * g++ rejects functions declared with both C and C++ linkage.
3682 */
3683 fix = {
3684 hackname = solaris_cxx_linkage;
3685 mach = '*-*-solaris2*';
3686 files = "iso/stdlib_iso.h";
3687 select = "(#if __cplusplus >= 199711L)\n"
3688 "(extern \"C\\+\\+\" \\{\n)"
3689 "(.*(bsearch|qsort).*)";
3690 c_fix = format;
3691 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3692
3693 test_text =
3694 "#if __cplusplus >= 199711L\n"
3695 "extern \"C++\" {\n"
3696 " void *bsearch(const void *, const void *, size_t, size_t,";
3697 };
3698
3699 /*
3700 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3701 * _STRICT_STDC, but uses it.
3702 */
3703 fix = {
3704 hackname = solaris_getc_strict_stdc;
3705 mach = "*-*-solaris2*";
3706 files = "iso/stdio_iso.h";
3707 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3708 c_fix = format;
3709 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3710
3711 test_text =
3712 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3713 };
3714
3715 /*
3716 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3717 */
3718 fix = {
3719 hackname = solaris_gets_c11;
3720 mach = "*-*-solaris2*";
3721 files = "iso/stdio_iso.h";
3722 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3723
3724 c_fix = format;
3725 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3726 "%1 __attribute__((__deprecated__));\n"
3727 "#endif";
3728
3729 test_text = "extern char *gets(char *);";
3730 };
3731
3732 /*
3733 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3734 */
3735 fix = {
3736 hackname = solaris_gets_cxx14;
3737 mach = "*-*-solaris2*";
3738 files = "iso/stdio_iso.h";
3739 select = <<- _EOSelect_
3740 (#if __STDC_VERSION__ < 201112L)
3741 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3742 _EOSelect_;
3743 c_fix = format;
3744 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3745
3746 test_text = <<- _EOText_
3747 #if __STDC_VERSION__ < 201112L
3748 extern char *gets(char *) __ATTR_DEPRECATED;
3749 _EOText_;
3750 };
3751
3752 /*
3753 * Sun Solaris 2 has a version of sys/int_const.h that defines
3754 * UINT8_C and UINT16_C to unsigned constants.
3755 */
3756 fix = {
3757 hackname = solaris_int_const;
3758 files = sys/int_const.h;
3759 mach = '*-*-solaris2*';
3760 c_fix = format;
3761 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3762 "%1\n"
3763 "#define\tUINT16_C(c)\t(c)";
3764 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3765 "(/\*.*\*/)\n"
3766 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3767 test_text =
3768 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3769 "/* CSTYLED */\n"
3770 "#define UINT16_C(c) __CONCAT__(c,u)";
3771 };
3772
3773 /*
3774 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3775 * UINT8_MAX and UINT16_MAX to unsigned constants.
3776 */
3777 fix = {
3778 hackname = solaris_int_limits_1;
3779 files = sys/int_limits.h;
3780 mach = '*-*-solaris2*';
3781 c_fix = format;
3782 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3783 "#define\tUINT16_MAX\t(65535)";
3784 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3785 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3786 test_text =
3787 "#define UINT8_MAX (255U)\n"
3788 "#define UINT16_MAX (65535U)";
3789 };
3790
3791 /*
3792 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3793 * INT_FAST16 limits to wrong values for sys/int_types.h.
3794 */
3795 fix = {
3796 hackname = solaris_int_limits_2;
3797 files = sys/int_limits.h;
3798 mach = '*-*-solaris2*';
3799 c_fix = format;
3800 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3801 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3802 test_text =
3803 "#define INT_FAST16_MAX INT16_MAX\n"
3804 "#define UINT_FAST16_MAX UINT16_MAX\n"
3805 "#define INT_FAST16_MIN INT16_MIN";
3806 };
3807
3808 /*
3809 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3810 * SIZE_MAX as unsigned long.
3811 */
3812 fix = {
3813 hackname = solaris_int_limits_3;
3814 files = sys/int_limits.h;
3815 mach = '*-*-solaris2*';
3816 c_fix = format;
3817 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3818 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3819 test_text =
3820 "#define SIZE_MAX 4294967295UL";
3821 };
3822
3823 /*
3824 * Sun Solaris 10 defines several C99 math macros in terms of
3825 * builtins specific to the Studio compiler, in particular not
3826 * compatible with the GNU compiler.
3827 */
3828 fix = {
3829 hackname = solaris_math_1;
3830 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3831 bypass = "__GNUC__";
3832 files = iso/math_c99.h;
3833 c_fix = format;
3834 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3835 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3836 test_text =
3837 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3838 "#undef HUGE_VAL\n"
3839 "#define HUGE_VAL __builtin_huge_val\n"
3840 "#undef HUGE_VALF\n"
3841 "#define HUGE_VALF __builtin_huge_valf\n"
3842 "#undef HUGE_VALL\n"
3843 "#define HUGE_VALL __builtin_huge_vall";
3844 };
3845
3846 /*
3847 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3848 * exception. Provide an alternative using GCC's builtin.
3849 */
3850 fix = {
3851 hackname = solaris_math_10;
3852 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3853 files = iso/math_c99.h;
3854 c_fix = format;
3855 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3856 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3857 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3858 "[ \t]*\\\\\n"
3859 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3860 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3861 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3862 "\\(-INFINITY\\);[ \t]*\\}\\)";
3863 test_text =
3864 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3865 "#undef isinf\n"
3866 "#define isinf(x) __extension__( \\\\\n"
3867 " { __typeof(x) __x_i = (x); \\\\\n"
3868 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3869 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3870 };
3871
3872 /*
3873 * Solaris math INFINITY
3874 */
3875 fix = {
3876 hackname = solaris_math_2;
3877 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3878 bypass = "__GNUC__";
3879 files = iso/math_c99.h;
3880 c_fix = format;
3881 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3882 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3883 test_text =
3884 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3885 "#undef INFINITY\n"
3886 "#define INFINITY __builtin_infinity";
3887 };
3888
3889 /*
3890 * Solaris math NAN
3891 */
3892 fix = {
3893 hackname = solaris_math_3;
3894 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3895 bypass = "__GNUC__";
3896 files = iso/math_c99.h;
3897 c_fix = format;
3898 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3899 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3900 test_text =
3901 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3902 "#undef NAN\n"
3903 "#define NAN __builtin_nan";
3904 };
3905
3906 /*
3907 * Solaris math fpclassify
3908 */
3909 fix = {
3910 hackname = solaris_math_4;
3911 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3912 bypass = "__GNUC__";
3913 files = iso/math_c99.h;
3914 c_fix = format;
3915 c_fix_arg = "#define\tfpclassify(x) \\\n"
3916 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3917 "FP_SUBNORMAL, FP_ZERO, (x))";
3918 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3919 test_text =
3920 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3921 "#undef fpclassify\n"
3922 "#define fpclassify(x) __builtin_fpclassify(x)";
3923 };
3924
3925 /*
3926 * Solaris math signbit
3927 */
3928 fix = {
3929 hackname = solaris_math_8;
3930 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3931 bypass = "__GNUC__";
3932 files = iso/math_c99.h;
3933 c_fix = format;
3934 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3935 "\t\t\t ? __builtin_signbitf(x) \\\n"
3936 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3937 "\t\t\t ? __builtin_signbitl(x) \\\n"
3938 "\t\t\t : __builtin_signbit(x))";
3939 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3940 test_text = <<- _EOText_
3941 #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
3942 #undef signbit
3943 #define signbit(x) __builtin_signbit(x)
3944 _EOText_;
3945 };
3946
3947 /*
3948 * Solaris math comparison macros
3949 */
3950 fix = {
3951 hackname = solaris_math_9;
3952 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3953 bypass = "__GNUC__";
3954 files = iso/math_c99.h;
3955 c_fix = format;
3956 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3957 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3958 "__builtin_[a-z]+\\(y\\)\\)";
3959 test_text =
3960 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3961 "#undef isgreater\n"
3962 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3963 "#undef isgreaterequal\n"
3964 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3965 "#undef isless\n"
3966 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3967 "#undef islessequal\n"
3968 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3969 "#undef islessgreater\n"
3970 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3971 "#undef isunordered\n"
3972 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3973 };
3974
3975 /*
3976 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3977 * warnings.
3978 */
3979 fix = {
3980 hackname = solaris_math_11;
3981 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3982 files = iso/math_c99.h;
3983 c_fix = format;
3984 c_fix_arg = << _EOArg_
3985 #undef signbit
3986 #define signbit(x) (sizeof(x) == sizeof(float) \
3987 ? __builtin_signbitf(x) \
3988 : sizeof(x) == sizeof(long double) \
3989 ? __builtin_signbitl(x) \
3990 : __builtin_signbit(x))
3991 _EOArg_;
3992 c_fix_arg = << _EOArg_
3993 ^#undef[ ]+signbit
3994 #if defined\(__sparc\)
3995 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3996 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3997 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3998 #elif defined\(__i386\) \|\| defined\(__amd64\)
3999 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
4000 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
4001 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
4002 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
4003 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
4004 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
4005 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
4006 #endif
4007 _EOArg_;
4008 test_text = << _EOText_
4009 /* @(#)math_c99.h 1.14 13/03/27 */
4010 #undef signbit
4011 #if defined(__sparc)
4012 #define signbit(x) __extension__( \\
4013 { __typeof(x) __x_s = (x); \\
4014 (int) (*(unsigned *) &__x_s >> 31); })
4015 #elif defined(__i386) || defined(__amd64)
4016 #define signbit(x) __extension__( \\
4017 { __typeof(x) __x_s = (x); \\
4018 (sizeof (__x_s) == sizeof (float) ? \\
4019 (int) (*(unsigned *) &__x_s >> 31) : \\
4020 sizeof (__x_s) == sizeof (double) ? \\
4021 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
4022 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
4023 #endif
4024 _EOText_;
4025 };
4026
4027 /*
4028 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
4029 */
4030 fix = {
4031 hackname = solaris_math_12;
4032 files = math.h;
4033 mach = '*-*-solaris2*';
4034 select = '#undef.*_GLIBCXX_USE_C99_MATH';
4035 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
4036 test_text = << _EOText_
4037 #if __cplusplus >= 201103L
4038 #undef _GLIBCXX_USE_C99_MATH
4039 #undef _GLIBCXX_USE_C99_MATH_TR1
4040 #endif
4041 _EOText_;
4042 };
4043
4044 /*
4045 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
4046 * structure. As such, it need two levels of brackets, but only
4047 * contains one. Wrap the macro definition in an extra layer.
4048 */
4049 fix = {
4050 hackname = solaris_once_init_1;
4051 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4052 files = pthread.h;
4053 mach = '*-*-solaris*';
4054 c_fix = format;
4055 c_fix_arg = "%1{%2}%3";
4056 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
4057 test_text =
4058 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
4059 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
4060 };
4061
4062 /*
4063 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
4064 * posix_spawn declarations, which doesn't work with C++.
4065 */
4066 fix = {
4067 hackname = solaris_posix_spawn_restrict;
4068 files = spawn.h;
4069 mach = '*-*-solaris2*';
4070 c_fix = format;
4071 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
4072 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
4073 test_text =
4074 "char *const argv[_RESTRICT_KYWD],\n"
4075 "char *const envp[_RESTRICT_KYWD]);";
4076 };
4077
4078 /*
4079 * The pow overloads with int were removed in C++ 2011 DR 550.
4080 */
4081 fix = {
4082 hackname = solaris_pow_int_overload;
4083 mach = '*-*-solaris2*';
4084 files = "iso/math_iso.h";
4085 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4086 " *\\{[^{}]*\n[^{}]*\\}";
4087 c_fix = format;
4088 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4089
4090 test_text =
4091 " inline long double pow(long double __X, int __Y) { return\n"
4092 " __powl(__X, (long double) (__Y)); }";
4093 };
4094
4095 /*
4096 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4097 * fields of the pthread_rwlock_t structure, which are of type
4098 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
4099 * defined (e.g. by -ansi) it is a union. So change the initializer
4100 * to "{0}" instead.
4101 */
4102 fix = {
4103 hackname = solaris_rwlock_init_1;
4104 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4105 files = pthread.h;
4106 mach = '*-*-solaris*';
4107 c_fix = format;
4108 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4109 "%0\n"
4110 "#else\n"
4111 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4112 "#endif";
4113 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4114 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4115
4116 test_text =
4117 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
4118 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4119 };
4120
4121 /*
4122 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
4123 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
4124 */
4125 fix = {
4126 hackname = solaris_std___filbuf;
4127 files = stdio.h;
4128 mach = '*-*-solaris2*';
4129 bypass = "using std::__filbuf";
4130 select = "(using std::perror;\n)(#endif)";
4131 c_fix = format;
4132 c_fix_arg = "%1#ifndef _LP64\n"
4133 "using std::__filbuf;\n"
4134 "using std::__flsbuf;\n"
4135 "#endif\n%2";
4136
4137 test_text = "using std::perror;\n"
4138 "#endif";
4139 };
4140
4141 /*
4142 * Solaris <stdio.h> shouldn't use std::gets for C++14.
4143 */
4144 fix = {
4145 hackname = solaris_std_gets_cxx14;
4146 mach = "*-*-solaris2*";
4147 files = "stdio.h";
4148 select = "using std::gets;";
4149
4150 c_fix = format;
4151 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4152
4153 test_text = "using std::gets;";
4154 };
4155
4156 /*
4157 * Sun Solaris 8 has what appears to be some gross workaround for
4158 * some old version of their c++ compiler. G++ doesn't want it
4159 * either, but doesn't want to be tied to SunPRO version numbers.
4160 */
4161 fix = {
4162 hackname = solaris_stdio_tag;
4163 files = stdio_tag.h;
4164
4165 select = '__cplusplus < 54321L';
4166 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4167 "!defined(__GNUC__)" so we no longer need to fix it. */
4168 bypass = '__GNUC__';
4169 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
4170
4171 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4172 };
4173
4174 /*
4175 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
4176 */
4177 fix = {
4178 hackname = solaris_stdlib_noreturn;
4179 mach = "*-*-solaris2*";
4180 files = "iso/stdlib_c99.h";
4181 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
4182
4183 c_fix = format;
4184 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
4185
4186 test_text = "extern _Noreturn void quick_exit(int);";
4187 };
4188
4189 /*
4190 * a missing semi-colon at the end of the statsswtch structure definition.
4191 */
4192 fix = {
4193 hackname = statsswtch;
4194 files = rpcsvc/rstat.h;
4195 select = "boottime$";
4196 c_fix = format;
4197 c_fix_arg = "boottime;";
4198 test_text = "struct statswtch {\n int boottime\n};";
4199 };
4200
4201 /*
4202 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4203 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
4204 * OK too.
4205 */
4206 fix = {
4207 hackname = stdio_stdarg_h;
4208 files = stdio.h;
4209 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4210 /*
4211 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4212 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4213 */
4214 mach = '*-*-solaris2.1[0-9]*';
4215 not_machine = true;
4216
4217 c_fix = wrap;
4218
4219 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4220
4221 test_text = "";
4222 };
4223
4224 /*
4225 * Don't use or define the name va_list in stdio.h. This is for
4226 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4227 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
4228 * indicate that the header knows what it's doing -- under SUSv2,
4229 * stdio.h is required to define va_list, and we shouldn't break
4230 * that.
4231 */
4232 fix = {
4233 hackname = stdio_va_list;
4234 files = stdio.h;
4235 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4236 /*
4237 * On Solaris 10, the definition in
4238 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
4239 * there is therefore no need for this fix there.
4240 */
4241 mach = '*-*-solaris2.1[0-9]*';
4242 not_machine = true;
4243
4244 /*
4245 * Use __gnuc_va_list in arg types in place of va_list.
4246 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4247 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4248 * trailing parentheses and semicolon save all other systems from this.
4249 * Define __not_va_list__ (something harmless and unused)
4250 * instead of va_list.
4251 * Don't claim to have defined va_list.
4252 */
4253 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4254 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4255 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4256 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4257 "s@ va_list@ __not_va_list__@\n"
4258 "s@\\*va_list@*__not_va_list__@\n"
4259 "s@ __va_list)@ __gnuc_va_list)@\n"
4260 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4261 "@typedef \\1 __not_va_list__;@\n"
4262 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4263 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4264 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4265 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4266 "s@VA_LIST@DUMMY_VA_LIST@\n"
4267 "s@_Va_LIST@_VA_LIST@";
4268 test_text = "extern void mumble( va_list);";
4269 };
4270
4271 /*
4272 * Fix headers that use va_list from stdio.h to use the updated
4273 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4274 * dealt with elsewhere. The presence of __gnuc_va_list,
4275 * __DJ_va_list, or _G_va_list is taken to indicate that the header
4276 * knows what it's doing.
4277 */
4278 fix = {
4279 hackname = stdio_va_list_clients;
4280 files = com_err.h;
4281 files = cps.h;
4282 files = curses.h;
4283 files = krb5.h;
4284 files = lc_core.h;
4285 files = pfmt.h;
4286 files = wchar.h;
4287 files = curses_colr/curses.h;
4288 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4289 /* Don't fix, if we use va_list from stdarg.h, or if the use is
4290 otherwise protected. */
4291 bypass = 'include <stdarg\.h>|#ifdef va_start';
4292
4293 /*
4294 * Use __gnuc_va_list in arg types in place of va_list.
4295 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4296 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
4297 * trailing parentheses and semicolon save all other systems from this.
4298 * Define __not_va_list__ (something harmless and unused)
4299 * instead of va_list.
4300 * Don't claim to have defined va_list.
4301 */
4302 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4303 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4304 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4305 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4306 "s@ va_list@ __not_va_list__@\n"
4307 "s@\\*va_list@*__not_va_list__@\n"
4308 "s@ __va_list)@ __gnuc_va_list)@\n"
4309 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4310 "@typedef \\1 __not_va_list__;@\n"
4311 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4312 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4313 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4314 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4315 "s@VA_LIST@DUMMY_VA_LIST@\n"
4316 "s@_Va_LIST@_VA_LIST@";
4317 test_text = "extern void mumble( va_list);";
4318 };
4319
4320 /*
4321 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
4322 * is "!defined( __STRICT_ANSI__ )"
4323 */
4324 fix = {
4325 hackname = strict_ansi_not;
4326 select = "^([ \t]*#[ \t]*if.*)"
4327 "(!__STDC__"
4328 "|__STDC__[ \t]*==[ \t]*0"
4329 "|__STDC__[ \t]*!=[ \t]*1"
4330 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4331 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
4332 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
4333 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
4334 is not defined by GCC, so it is safe. */
4335 bypass = '__SCO_VERSION__.*__STDC__ != 1';
4336 c_test = stdc_0_in_system_headers;
4337
4338 c_fix = format;
4339 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4340
4341 test_text = "#if !__STDC__ \n"
4342 "#if __STDC__ == 0\n"
4343 "#if __STDC__ != 1\n"
4344 "#if __STDC__ - 0 == 0"
4345 "/* not std C */\nint foo;\n"
4346 "\n#end-end-end-end-if :-)";
4347 };
4348
4349 /*
4350 * "__STDC__-0==0"
4351 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
4352 */
4353 fix = {
4354 hackname = strict_ansi_not_ctd;
4355 files = math.h, limits.h, stdio.h, signal.h,
4356 stdlib.h, sys/signal.h, time.h;
4357 /*
4358 * Starting at the beginning of a line, skip white space and
4359 * a leading "(" or "&&" or "||". One of those must be found.
4360 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
4361 * expression. If these are nested, then they must accumulate
4362 * because we won't match any closing parentheses. Finally,
4363 * after skipping over all that, we must then match our suspect
4364 * phrase: "__STDC__-0==0" with or without white space.
4365 */
4366 select = "^([ \t]*" '(\(|&&|\|\|)'
4367 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4368 "[ \t(]*)"
4369 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4370 c_test = stdc_0_in_system_headers;
4371
4372 c_fix = format;
4373 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4374
4375 test_text = "#if 1 && \\\\\n"
4376 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4377 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4378 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4379 "int foo;\n#endif";
4380 };
4381
4382 /*
4383 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4384 * is "defined( __STRICT_ANSI__ )"
4385 */
4386 fix = {
4387 hackname = strict_ansi_only;
4388 select = "^([ \t]*#[ \t]*if.*)"
4389 "(__STDC__[ \t]*!=[ \t]*0"
4390 "|__STDC__[ \t]*==[ \t]*1"
4391 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4392 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4393 c_test = stdc_0_in_system_headers;
4394
4395 c_fix = format;
4396 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4397
4398 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4399 };
4400
4401 /*
4402 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4403 * in prototype without previous definition.
4404 */
4405 fix = {
4406 hackname = struct_file;
4407 files = rpc/xdr.h;
4408 select = '^.*xdrstdio_create.*struct __file_s';
4409 c_fix = format;
4410 c_fix_arg = "struct __file_s;\n%0";
4411 test_text = "extern void xdrstdio_create( struct __file_s* );";
4412 };
4413
4414 /*
4415 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4416 * in prototype without previous definition.
4417 *
4418 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
4419 * function, and does define it.
4420 */
4421 fix = {
4422 hackname = struct_sockaddr;
4423 files = rpc/auth.h;
4424 select = "^.*authdes_create.*struct sockaddr[^_]";
4425 bypass = "<sys/socket\.h>";
4426 bypass = "struct sockaddr;\n";
4427 c_fix = format;
4428 c_fix_arg = "struct sockaddr;\n%0";
4429 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
4430 };
4431
4432 /*
4433 * Apply fix this to all OSs since this problem seems to effect
4434 * more than just SunOS.
4435 */
4436 fix = {
4437 hackname = sun_auth_proto;
4438 files = rpc/auth.h;
4439 files = rpc/clnt.h;
4440 files = rpc/svc.h;
4441 files = rpc/xdr.h;
4442 bypass = "__cplusplus";
4443 /*
4444 * Select those files containing '(*name)()'.
4445 */
4446 select = '\(\*[a-z][a-z_]*\)\(\)';
4447
4448 c_fix = format;
4449 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4450 "#else\n%1();%2\n#endif";
4451 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4452
4453 test_text =
4454 "struct auth_t {\n"
4455 " int (*name)(); /* C++ bad */\n"
4456 "};";
4457 };
4458
4459 /*
4460 * Fix bogus #ifdef on SunOS 4.1.
4461 */
4462 fix = {
4463 hackname = sun_bogus_ifdef;
4464 files = "hsfs/hsfs_spec.h";
4465 files = "hsfs/iso_spec.h";
4466 select = '#ifdef(.*\|\|.*)';
4467 c_fix = format;
4468 c_fix_arg = "#if%1";
4469
4470 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4471 };
4472
4473 /*
4474 * Fix the CAT macro in SunOS memvar.h.
4475 */
4476 fix = {
4477 hackname = sun_catmacro;
4478 files = pixrect/memvar.h;
4479 select = "^#define[ \t]+CAT\\(a,b\\).*";
4480 c_fix = format;
4481
4482 c_fix_arg =
4483 "#ifdef __STDC__\n"
4484 "# define CAT(a,b) a##b\n"
4485 "#else\n%0\n#endif";
4486
4487 test_text =
4488 "#define CAT(a,b)\ta/**/b";
4489 };
4490
4491 /*
4492 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4493 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4494 */
4495 fix = {
4496 hackname = sun_malloc;
4497 files = malloc.h;
4498 bypass = "_CLASSIC_ANSI_TYPES";
4499
4500 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4501 sed = "s/int[ \t][ \t]*free/void\tfree/g";
4502 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4503 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4504 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4505
4506 test_text =
4507 "typedef char *\tmalloc_t;\n"
4508 "int \tfree();\n"
4509 "char*\tmalloc();\n"
4510 "char*\tcalloc();\n"
4511 "char*\trealloc();";
4512 };
4513
4514 /*
4515 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4516 */
4517 fix = {
4518 hackname = sun_rusers_semi;
4519 files = rpcsvc/rusers.h;
4520 select = "_cnt$";
4521 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4522 test_text = "struct mumble\n int _cnt\n};";
4523 };
4524
4525 /*
4526 * signal.h on SunOS defines signal using (),
4527 * which causes trouble when compiling with g++ -pedantic.
4528 */
4529 fix = {
4530 hackname = sun_signal;
4531 files = sys/signal.h;
4532 files = signal.h;
4533 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
4534
4535 c_fix = format;
4536 c_fix_arg =
4537 "#ifdef __cplusplus\n"
4538 "void\t(*signal(...))(...);\n"
4539 "#else\n%0\n#endif";
4540
4541 test_text = "void\t(*signal())();";
4542 };
4543
4544 /*
4545 * Correct the return type for strlen in strings.h in SunOS 4.
4546 */
4547 fix = {
4548 hackname = sunos_strlen;
4549 files = strings.h;
4550 select = "int[ \t]*strlen\\(\\);(.*)";
4551 c_fix = format;
4552 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4553 test_text = " int\tstrlen(); /* string length */";
4554 };
4555
4556 /*
4557 * Linux kernel's vt.h breaks C++
4558 */
4559 fix = {
4560 hackname = suse_linux_vt_cxx;
4561 files = linux/vt.h;
4562
4563 select = "^[ \t]*unsigned int new;";
4564 c_fix = format;
4565 c_fix_arg = "unsigned int newev;";
4566
4567 test_text = " unsigned int new; /* New console (if changing) */";
4568 };
4569
4570 /*
4571 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4572 * that is visible to any ANSI compiler using this include. Simply
4573 * delete the lines that #define some string functions to internal forms.
4574 */
4575 fix = {
4576 hackname = svr4_disable_opt;
4577 files = string.h;
4578 select = '#define.*__std_hdr_';
4579 sed = '/#define.*__std_hdr_/d';
4580 test_text = "#define strlen __std_hdr_strlen\n";
4581 };
4582
4583 /*
4584 * Fix broken decl of getcwd present on some svr4 systems.
4585 */
4586 fix = {
4587 hackname = svr4_getcwd;
4588 files = stdlib.h;
4589 files = unistd.h;
4590 files = prototypes.h;
4591 select = 'getcwd\(char \*, int\)';
4592
4593 c_fix = format;
4594 c_fix_arg = "getcwd(char *, size_t)";
4595
4596 test_text = "extern char* getcwd(char *, int);";
4597 };
4598
4599 /*
4600 * Fix broken decl of profil present on some svr4 systems.
4601 */
4602 fix = {
4603 hackname = svr4_profil;
4604 files = stdlib.h;
4605 files = unistd.h;
4606
4607 select =
4608 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4609 c_fix = format;
4610 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4611
4612 test_text =
4613 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4614 };
4615
4616 /*
4617 * Correct types for signal handler constants like SIG_DFL; they might be
4618 * void (*) (), and should be void (*) (int). C++ doesn't like the
4619 * old style.
4620 */
4621 fix = {
4622 hackname = svr4_sighandler_type;
4623 files = sys/signal.h;
4624 select = 'void *\(\*\)\(\)';
4625 c_fix = format;
4626 c_fix_arg = "void (*)(int)";
4627 test_text = "#define SIG_DFL (void(*)())0\n"
4628 "#define SIG_IGN (void (*)())0\n";
4629 };
4630
4631 /*
4632 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4633 * function 'getrnge' in <regexp.h> before they declare it. For these
4634 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4635 * early on.
4636 *
4637 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4638 * so put the declaration right after the declaration of 'size'.
4639 *
4640 * Don't do this if there is already a `static void getrnge' declaration
4641 * present, since this would cause a redeclaration error. Solaris 2.x has
4642 * such a declaration.
4643 */
4644 fix = {
4645 hackname = svr4_undeclared_getrnge;
4646 files = regexp.h;
4647 select = "getrnge";
4648 bypass = "static void getrnge";
4649 c_fix = format;
4650 c_fix_arg = "%0\n"
4651 "static int getrnge ();";
4652 c_fix_arg = "^static int[ \t]+size;";
4653 test_text = "static int size;\n"
4654 "/* stuff which calls getrnge() */\n"
4655 "static getrnge()\n"
4656 "{}";
4657 };
4658
4659 /*
4660 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4661 * in string.h on sysV68
4662 * Correct the return type for strlen in string.h on Lynx.
4663 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4664 * Add missing const for strdup on OSF/1 V3.0.
4665 * On sysV88 layout is slightly different.
4666 */
4667 fix = {
4668 hackname = sysv68_string;
4669 files = testing.h;
4670 files = string.h;
4671 bypass = "_CLASSIC_ANSI_TYPES";
4672
4673 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4674 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4675 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4676
4677 sed = "/^extern char$/N";
4678 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4679
4680 sed = "/^extern int$/N";
4681 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4682
4683 sed = "/^\tstrncmp(),$/N";
4684 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4685 '\1;' "\\\nextern unsigned int\\\n\\2/";
4686
4687 test_text =
4688 "extern int strlen();\n"
4689
4690 "extern int ffs(long);\n"
4691
4692 "extern char\n"
4693 "\t*memccpy(),\n"
4694 "\tmemcpy();\n"
4695
4696 "extern int\n"
4697 "\tstrcmp(),\n"
4698 "\tstrncmp(),\n"
4699 "\tstrlen(),\n"
4700 "\tstrspn();\n"
4701
4702 "extern int\n"
4703 "\tstrlen(), strspn();";
4704 };
4705
4706 /*
4707 * Fix return type of calloc, malloc, realloc, bsearch and exit
4708 */
4709 fix = {
4710 hackname = sysz_stdlib_for_sun;
4711 files = stdlib.h;
4712 bypass = "_CLASSIC_ANSI_TYPES";
4713
4714 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4715 c_fix = format;
4716 c_fix_arg = "void *\t%1(";
4717
4718 test_text =
4719 "extern char*\tcalloc(size_t);\n"
4720 "extern char*\tmalloc(size_t);\n"
4721 "extern char*\trealloc(void*,size_t);\n"
4722 "extern char*\tbsearch(void*,size_t,size_t);\n";
4723 };
4724
4725 /*
4726 * __thread is now a keyword.
4727 */
4728 fix = {
4729 hackname = thread_keyword;
4730 files = "pthread.h";
4731 files = bits/sigthread.h, '*/bits/sigthread.h';
4732 select = "([* ])__thread([,)])";
4733 c_fix = format;
4734 c_fix_arg = "%1__thr%2";
4735
4736 test_text =
4737 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4738 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4739 "extern int pthread_cancel (pthread_t __thread);";
4740 };
4741
4742 /*
4743 * if the #if says _cplusplus, not the double underscore __cplusplus
4744 * that it should be
4745 */
4746 fix = {
4747 hackname = tinfo_cplusplus;
4748 files = tinfo.h;
4749 select = "[ \t]_cplusplus";
4750
4751 c_fix = format;
4752 c_fix_arg = " __cplusplus";
4753 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4754 };
4755
4756 /*
4757 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4758 */
4759 fix = {
4760 hackname = ultrix_const;
4761 files = stdio.h;
4762 select = 'perror\( char \*';
4763
4764 c_fix = format;
4765 c_fix_arg = "%1 const %3 *__";
4766 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4767 "[ \t]+(char|void) \\*__";
4768
4769 test_text =
4770 "extern void perror( char *__s );\n"
4771 "extern int fputs( char *__s, FILE *);\n"
4772 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4773 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4774 "extern int scanf( char *__format, ...);\n";
4775 };
4776
4777 /*
4778 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4779 */
4780 fix = {
4781 hackname = ultrix_const2;
4782 files = stdio.h;
4783
4784 select = '\*fopen\( char \*';
4785 c_fix = format;
4786 c_fix_arg = "%1( const char *%3, const char *";
4787 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4788 "[ \t]*char[ \t]*\\*([^,]*),"
4789 "[ \t]*char[ \t]*\\*[ \t]*";
4790
4791 test_text =
4792 "extern FILE *fopen( char *__filename, char *__type );\n"
4793 "extern int sscanf( char *__s, char *__format, ...);\n"
4794 "extern FILE *popen(char *, char *);\n"
4795 "extern char *tempnam(char*,char*);\n";
4796 };
4797
4798 /*
4799 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4800 */
4801 fix = {
4802 hackname = va_i960_macro;
4803 files = arch/i960/archI960.h;
4804 select = "__(vsiz|vali|vpad|alignof__)";
4805
4806 c_fix = format;
4807 c_fix_arg = "__vx%1";
4808
4809 test_text =
4810 "extern int __vsiz vsiz;\n"
4811 "extern int __vali vali;\n"
4812 "extern int __vpad vpad;\n"
4813 "#define __alignof__(x) ...";
4814 };
4815
4816 /*
4817 * On VMS, add missing braces around sigset_t constants.
4818 */
4819 fix = {
4820 hackname = vms_add_missing_braces;
4821 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4822 mach = "*-*-*vms*";
4823 files = "rtldef/signal.h";
4824 c_fix = format;
4825
4826 c_fix_arg = '%1 {%2} ';
4827
4828 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4829 "{0x00000000, 0x00000000},\n"
4830 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4831 };
4832
4833 /*
4834 * On VMS, some DEC-C builtins are directly used.
4835 */
4836 fix = {
4837 hackname = vms_decc_builtin;
4838 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4839 mach = "*-*-*vms*";
4840 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4841 rtldef/socket.h;
4842 sed = "s@__MEMSET@memset@";
4843 sed = "s@__MEMMOVE@memmove@";
4844 sed = "s@__MEMCPY@memcpy@";
4845 sed = "s@__STRLEN@strlen@";
4846 sed = "s@__STRCPY@strcpy@";
4847
4848 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4849 };
4850
4851 /*
4852 * Define __CAN_USE_EXTERN_PREFIX on vms.
4853 */
4854 fix = {
4855 hackname = vms_define_can_use_extern_prefix;
4856 files = "rtldef/decc$types.h";
4857 select = "#[ \t]*else\n"
4858 "#[ \t]*if defined\\(__DECCXX\\)\n"
4859 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4860 mach = "*-*-*vms*";
4861 c_fix = format;
4862
4863 c_fix_arg = "%0"
4864 "# elif defined (__GNUC__)\n"
4865 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4866
4867 test_text = "# else\n"
4868 "# if defined(__DECCXX)\n"
4869 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4870 "# endif\n"
4871 "# endif\n";
4872 };
4873
4874 /*
4875 * On VMS, disable the use of dec-c string builtins
4876 */
4877 fix = {
4878 hackname = vms_disable_decc_string_builtins;
4879 select = "#if !defined\\(__VAX\\)\n";
4880 mach = "*-*-*vms*";
4881 files = "rtldef/string.h";
4882 c_fix = format;
4883
4884 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4885
4886 test_text = "#if !defined(__VAX)\n";
4887 };
4888
4889 /*
4890 * On VMS, fix incompatible redeclaration of hostalias.
4891 */
4892 fix = {
4893 hackname = vms_do_not_redeclare_hostalias;
4894 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4895 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4896 mach = "*-*-*vms*";
4897 files = "rtldef/resolv.h";
4898 c_fix = format;
4899
4900 c_fix_arg = "%1\n"
4901 "/* %2 */";
4902
4903 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4904 "__char_ptr32 hostalias (const char *);\n";
4905 };
4906
4907 /*
4908 * On VMS, forward declare structure before referencing them in prototypes.
4909 */
4910 fix = {
4911 hackname = vms_forward_declare_struct;
4912 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4913 "#ifdef __cplusplus\n";
4914 mach = "*-*-*vms*";
4915 files = rtldef/if.h;
4916 c_fix = format;
4917
4918 c_fix_arg = "%1"
4919 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4920
4921 test_text = "/* forward decls for C++ */\n"
4922 "#ifdef __cplusplus\n"
4923 "struct foo;\n"
4924 "#endif\n";
4925 };
4926
4927 /*
4928 * On VMS, do not declare getopt and al if pointers are 64 bit.
4929 */
4930 fix = {
4931 hackname = vms_no_64bit_getopt;
4932 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4933 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4934 mach = "*-*-*vms*";
4935 files = rtldef/stdio.h, rtldef/unistd.h;
4936 c_fix = format;
4937
4938 c_fix_arg = <<- _EOArg_
4939 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4940 %0#endif
4941
4942 _EOArg_;
4943
4944 test_text = "int getopt (int, char * const [], const char *);";
4945 };
4946
4947 /*
4948 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4949 * which is not yet fully supported by gcc.
4950 */
4951 fix = {
4952 hackname = vms_use_fast_setjmp;
4953 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4954 mach = "*-*-*vms*";
4955 files = rtldef/setjmp.h;
4956 c_fix = format;
4957
4958 c_fix_arg = "%0 defined (__GNUC__) ||";
4959
4960 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4961 };
4962
4963 /*
4964 * On VMS, use pragma extern_model instead of VAX-C keywords.
4965 */
4966 fix = {
4967 hackname = vms_use_pragma_extern_model;
4968 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4969 "# pragma extern_model __save\n";
4970 mach = "*-*-*vms*";
4971 c_fix = format;
4972
4973 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4974 "# pragma extern_model __save\n";
4975
4976 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4977 "# pragma extern_model __save\n"
4978 "# pragma extern_model strict_refdef\n"
4979 " extern struct x zz$yy;\n"
4980 "# pragma extern_model __restore\n"
4981 "#endif\n";
4982 };
4983
4984 /*
4985 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4986 * conflict while building gcc. Likewise for <builtins.h>
4987 */
4988 fix = {
4989 hackname = vms_use_quoted_include;
4990 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4991 mach = "*-*-*vms*";
4992 files = rtldef/wait.h, starlet_c/pthread.h;
4993 c_fix = format;
4994
4995 c_fix_arg = '%1<sys/%2.h>';
4996
4997 test_text = "# include <resource.h>";
4998 };
4999
5000 /*
5001 * AIX and Interix headers define NULL to be cast to a void pointer,
5002 * which is illegal in ANSI C++.
5003 */
5004 fix = {
5005 hackname = void_null;
5006 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
5007 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
5008 /* avoid changing C++ friendly NULL */
5009 bypass = __cplusplus;
5010 bypass = __null;
5011 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
5012 c_fix = format;
5013 c_fix_arg = <<- _EOFix_
5014 #ifndef NULL
5015 #ifdef __cplusplus
5016 #ifdef __GNUG__
5017 #define NULL __null
5018 #else /* ! __GNUG__ */
5019 #define NULL 0L
5020 #endif /* __GNUG__ */
5021 #else /* ! __cplusplus */
5022 #define NULL ((void *)0)
5023 #endif /* __cplusplus */
5024 #endif /* !NULL */
5025 _EOFix_;
5026 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
5027 };
5028
5029 /*
5030 * Make VxWorks header which is almost gcc ready fully gcc ready.
5031 */
5032 fix = {
5033 hackname = vxworks_gcc_problem;
5034 files = types/vxTypesBase.h;
5035 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
5036
5037 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
5038 "#if 1/";
5039
5040 sed = "/[ \t]size_t/i\\\n"
5041 "#ifndef _GCC_SIZE_T\\\n"
5042 "#define _GCC_SIZE_T\n";
5043
5044 sed = "/[ \t]size_t/a\\\n"
5045 "#endif\n";
5046
5047 sed = "/[ \t]ptrdiff_t/i\\\n"
5048 "#ifndef _GCC_PTRDIFF_T\\\n"
5049 "#define _GCC_PTRDIFF_T\n";
5050
5051 sed = "/[ \t]ptrdiff_t/a\\\n"
5052 "#endif\n";
5053
5054 sed = "/[ \t]wchar_t/i\\\n"
5055 "#ifndef _GCC_WCHAR_T\\\n"
5056 "#define _GCC_WCHAR_T\n";
5057
5058 sed = "/[ \t]wchar_t/a\\\n"
5059 "#endif\n";
5060
5061 test_text =
5062 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
5063 "typedef unsigned int size_t;\n"
5064 "typedef long ptrdiff_t;\n"
5065 "typedef unsigned short wchar_t;\n"
5066 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
5067 };
5068
5069 /*
5070 * Wrap VxWorks ioctl to keep everything pretty
5071 */
5072 fix = {
5073 hackname = vxworks_ioctl_macro;
5074 files = ioLib.h;
5075 mach = "*-*-vxworks*";
5076
5077 c_fix = format;
5078 c_fix_arg = "%0\n"
5079 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
5080 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
5081
5082 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5083 };
5084
5085 /*
5086 * Wrap VxWorks mkdir to be posix compliant
5087 */
5088 fix = {
5089 hackname = vxworks_mkdir_macro;
5090 files = sys/stat.h;
5091 mach = "*-*-vxworks*";
5092
5093 c_fix = format;
5094 c_fix_arg = "%0\n"
5095 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5096 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5097 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5098 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5099 "\\)[\t ]*;";
5100
5101 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
5102 };
5103
5104 /*
5105 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
5106 */
5107 fix = {
5108 hackname = vxworks_needs_vxtypes;
5109 files = time.h;
5110 select = "uint_t([ \t]+_clocks_per_sec)";
5111 c_fix = format;
5112 c_fix_arg = "unsigned int%1";
5113 test_text = "uint_t\t_clocks_per_sec;";
5114 };
5115
5116 /*
5117 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5118 */
5119 fix = {
5120 hackname = vxworks_needs_vxworks;
5121 files = sys/stat.h;
5122 test = " -r types/vxTypesOld.h";
5123 test = " -n \"`egrep '#include' $file`\"";
5124 test = " -n \"`egrep ULONG $file`\"";
5125 select = "#[ \t]define[ \t]+__INCstath";
5126
5127 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5128 "#include <types/vxTypesOld.h>\n";
5129
5130 test_text = "`touch types/vxTypesOld.h`"
5131 "#include </dev/null> /* ULONG */\n"
5132 "# define\t__INCstath <sys/stat.h>";
5133 };
5134
5135 /*
5136 * Make it so VxWorks does not include gcc/regs.h accidentally
5137 */
5138 fix = {
5139 hackname = vxworks_regs;
5140 mach = "*-*-vxworks*";
5141
5142 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5143 c_fix = format;
5144 c_fix_arg = "#include <arch/../regs.h>";
5145
5146 test_text = "#include <regs.h>\n";
5147 };
5148
5149 /*
5150 * Another bad dependency in VxWorks 5.2 <time.h>.
5151 */
5152 fix = {
5153 hackname = vxworks_time;
5154 files = time.h;
5155 test = " -r vxWorks.h";
5156
5157 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5158 c_fix = format;
5159
5160 c_fix_arg =
5161 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5162 "#ifdef __cplusplus\n"
5163 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5164 "#else\n"
5165 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5166 "#endif\n"
5167 "#define __gcc_VOIDFUNCPTR_defined\n"
5168 "#endif\n"
5169 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5170
5171 test_text = "`touch vxWorks.h`"
5172 "#define VOIDFUNCPTR (void(*)())";
5173 };
5174
5175 /*
5176 * This hack makes write const-correct on VxWorks
5177 */
5178 fix = {
5179 hackname = vxworks_write_const;
5180 files = ioLib.h;
5181 mach = "*-*-vxworks*";
5182
5183 c_fix = format;
5184 c_fix_arg = "extern int write (int, const char*, size_t);";
5185 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5186 "[\t ]*int[\t ]*,"
5187 "[\t ]*char[\t ]*\\*[\t ]*,"
5188 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5189
5190 test_text = "extern int write ( int , char * , size_t ) ;";
5191 };
5192
5193 /*
5194 * This hack ensures the include_next in the fixed unistd.h actually
5195 * finds the system's unistd.h and not the fixed unistd.h again.
5196 */
5197 fix = {
5198 hackname = vxworks_iolib_include_unistd;
5199 files = ioLib.h;
5200 mach = "*-*-vxworks*";
5201 select = "#include \"unistd.h\"";
5202
5203 c_fix = format;
5204 c_fix_arg = "#include <unistd.h>";
5205
5206 test_text = "#include \"unistd.h\"";
5207 };
5208
5209 /*
5210 * There are several name conflicts with C++ reserved words in X11 header
5211 * files. These are fixed in some versions, so don't do the fixes if
5212 * we find __cplusplus in the file. These were found on the RS/6000.
5213 */
5214 fix = {
5215 hackname = x11_class;
5216 files = X11/ShellP.h;
5217 bypass = __cplusplus;
5218 select = "^([ \t]*char \\*)class;(.*)";
5219 c_fix = format;
5220 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5221 "#else\n%1class;%2\n#endif";
5222 test_text =
5223 "struct {\n"
5224 " char *class;\n"
5225 "} mumble;\n";
5226 };
5227
5228 /*
5229 * class in Xm/BaseClassI.h
5230 */
5231 fix = {
5232 hackname = x11_class_usage;
5233 files = Xm/BaseClassI.h;
5234 bypass = "__cplusplus";
5235
5236 select = " class\\)";
5237 c_fix = format;
5238 c_fix_arg = " c_class)";
5239
5240 test_text = "extern mumble (int class);\n";
5241 };
5242
5243 /*
5244 * new in Xm/Traversal.h
5245 */
5246 fix = {
5247 hackname = x11_new;
5248 files = Xm/Traversal.h;
5249 bypass = __cplusplus;
5250
5251 sed = "/Widget\told, new;/i\\\n"
5252 "#ifdef __cplusplus\\\n"
5253 "\\\tWidget\told, c_new;\\\n"
5254 "#else\n";
5255
5256 sed = "/Widget\told, new;/a\\\n"
5257 "#endif\n";
5258
5259 sed = "s/Widget new,/Widget c_new,/g";
5260 test_text =
5261 "struct wedge {\n"
5262 " Widget\told, new;\n"
5263 "};\nextern Wedged( Widget new, Widget old );";
5264 };
5265
5266 /*
5267 * Incorrect sprintf declaration in X11/Xmu.h
5268 */
5269 fix = {
5270 hackname = x11_sprintf;
5271 files = X11/Xmu.h;
5272 files = X11/Xmu/Xmu.h;
5273 select = "^extern char \\*\tsprintf\\(\\);$";
5274
5275 c_fix = format;
5276 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5277
5278 test_text = "extern char *\tsprintf();";
5279 };
5280 /*EOF*/