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