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