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