Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / gnu / dist / gcc4 / fixincludes / inclhack.def
blobc72c787973aefab29ef3b5d598ea07611d0ef3e4
1 /* -*- Mode: C -*- */
3 autogen definitions fixincl;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command:
10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \
14 key='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */
19 #ifdef DEBUG
20 FIXINC_DEBUG = yes;
21 #endif
24 * On Mac OS 10.3.9, the 'long double' functions are available in
25 * libSystem, but are not prototyped in math.h.
27 fix = {
28 hackname = AAB_darwin7_9_long_double_funcs;
29 mach = "*-*-darwin7.9*";
30 files = architecture/ppc/math.h;
31 bypass = "powl";
32 replace = <<- _EndOfHeader_
33 /* This file prototypes the long double functions available on Mac OS
34 10.3.9. */
35 #ifndef __MATH__
36 # include_next <architecture/ppc/math.h>
37 # ifndef __LIBMLDBL_COMPAT
38 # ifdef __LONG_DOUBLE_128__
39 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
40 # else
41 # define __LIBMLDBL_COMPAT(sym)
42 # endif /* __LONG_DOUBLE_128__ */
43 # endif /* __LIBMLDBL_COMPAT */
44 # ifdef __cplusplus
45 extern "C" {
46 # endif
47 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
48 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
49 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
50 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
51 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
52 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
53 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
54 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
55 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
56 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
57 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
58 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
59 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
60 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
61 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
62 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
63 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
64 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
65 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
66 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
67 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
68 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
69 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
70 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
71 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
72 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
73 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
74 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
75 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
76 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
77 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
78 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
79 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
80 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
81 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
82 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
83 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
84 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
85 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
86 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
87 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
88 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
89 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
90 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
91 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
92 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
93 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
94 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
95 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
96 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
97 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
98 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
99 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
100 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
101 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
102 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
103 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
104 # ifdef __cplusplus
106 # endif
107 #endif /* __MATH__ */
108 _EndOfHeader_;
113 * ... and for the previous fix to be useful, you have to not use ""
114 * includes.
116 fix = {
117 hackname = AAB_darwin7_9_long_double_funcs_2;
118 mach = "*-*-darwin7.9*";
119 files = math.h;
120 select = '#include[ \t]+\"';
121 c_fix = format;
122 c_fix_arg = "%1<%2.h>";
124 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
126 test_text = '#include "architecture/ppc/math.h"';
131 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
133 fix = {
134 hackname = AAB_fd_zero_asm_posix_types_h;
135 files = asm/posix_types.h;
136 mach = 'i[34567]86-*-linux*';
137 bypass = '} while';
140 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
141 * the start, so that if #include_next gets another instance of
142 * the wrapper, this will follow the #include_next chain until
143 * we arrive at the real <asm/posix_types.h>.
145 replace = <<- _EndOfHeader_
146 /* This file fixes a bug in the __FD_ZERO macro
147 for older versions of the Linux kernel. */
148 #ifndef _POSIX_TYPES_H_WRAPPER
149 #include <features.h>
150 #include_next <asm/posix_types.h>
152 #if defined(__FD_ZERO) && !defined(__GLIBC__)
153 #undef __FD_ZERO
154 #define __FD_ZERO(fdsetp) \
155 do { \
156 int __d0, __d1; \
157 __asm__ __volatile__("cld ; rep ; stosl" \
158 : "=&c" (__d0), "=&D" (__d1) \
159 : "a" (0), "0" (__FDSET_LONGS), \
160 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
161 } while (0)
162 #endif
164 #define _POSIX_TYPES_H_WRAPPER
165 #endif /* _POSIX_TYPES_H_WRAPPER */
166 _EndOfHeader_;
171 * This fixes __FD_ZERO bug for glibc-1.x
173 fix = {
174 hackname = AAB_fd_zero_gnu_types_h;
175 files = gnu/types.h;
176 mach = 'i[34567]86-*-linux*';
179 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
180 * the start, so that if #include_next gets another instance of
181 * the wrapper, this will follow the #include_next chain until
182 * we arrive at the real <gnu/types.h>.
184 replace = <<- _EndOfHeader_
185 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
186 #ifndef _TYPES_H_WRAPPER
187 #include <features.h>
188 #include_next <gnu/types.h>
190 #if defined(__FD_ZERO) && !defined(__GLIBC__)
191 #undef __FD_ZERO
192 # define __FD_ZERO(fdsetp) \
193 do { \
194 int __d0, __d1; \
195 __asm__ __volatile__("cld ; rep ; stosl" \
196 : "=&c" (__d0), "=&D" (__d1) \
197 : "a" (0), "0" (__FDSET_LONGS), \
198 "1" ((__fd_set *) (fdsetp)) :"memory"); \
199 } while (0)
200 #endif
202 #define _TYPES_H_WRAPPER
203 #endif /* _TYPES_H_WRAPPER */
204 _EndOfHeader_;
209 * This fixes __FD_ZERO bug for glibc-2.0.x
211 fix = {
212 hackname = AAB_fd_zero_selectbits_h;
213 files = selectbits.h;
214 mach = 'i[34567]86-*-linux*';
217 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
218 * the start, so that if #include_next gets another instance of
219 * the wrapper, this will follow the #include_next chain until
220 * we arrive at the real <selectbits.h>.
222 replace = <<- _EndOfHeader_
223 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
224 #ifndef _SELECTBITS_H_WRAPPER
225 #include <features.h>
226 #include_next <selectbits.h>
228 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
229 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
230 && __GLIBC_MINOR__ == 0
231 #undef __FD_ZERO
232 #define __FD_ZERO(fdsetp) \\
233 do { \\
234 int __d0, __d1; \\
235 __asm__ __volatile__ ("cld; rep; stosl" \\
236 : "=&c" (__d0), "=&D" (__d1) \\
237 : "a" (0), "0" (sizeof (__fd_set) \\
238 / sizeof (__fd_mask)), \\
239 "1" ((__fd_mask *) (fdsetp)) \\
240 : "memory"); \\
241 } while (0)
242 #endif
244 #define _SELECTBITS_H_WRAPPER
245 #endif /* _SELECTBITS_H_WRAPPER */
246 _EndOfHeader_;
251 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
252 * the same interface as <stdarg.h>. No idea why they couldn't have just
253 * used the standard header.
255 fix = {
256 hackname = AAB_solaris_sys_varargs_h;
257 files = "sys/varargs.h";
258 mach = '*-*-solaris*';
259 replace = <<- _EndOfHeader_
260 #ifdef __STDC__
261 #include <stdarg.h>
262 #else
263 #include <varargs.h>
264 #endif
265 _EndOfHeader_;
270 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
271 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
272 * many other systems have similar text but correct versions of the file.
273 * To ensure only Sun's is fixed, we grep for a likely unique string.
274 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
276 fix = {
277 hackname = AAB_sun_memcpy;
278 files = memory.h;
279 select = "/\\*\t@\\(#\\)"
280 "(head/memory.h\t50.1\t "
281 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
283 replace = <<- _EndOfHeader_
284 /* This file was generated by fixincludes */
285 #ifndef __memory_h__
286 #define __memory_h__
288 #ifdef __STDC__
289 extern void *memccpy();
290 extern void *memchr();
291 extern void *memcpy();
292 extern void *memset();
293 #else
294 extern char *memccpy();
295 extern char *memchr();
296 extern char *memcpy();
297 extern char *memset();
298 #endif /* __STDC__ */
300 extern int memcmp();
302 #endif /* __memory_h__ */
303 _EndOfHeader;
308 * Completely replace <sys/varargs.h> with a file that includes gcc's
309 * stdarg.h or varargs.h files as appropriate.
311 #ifdef SVR4
312 fix = {
313 hackname = AAB_svr4_no_varargs;
314 files = sys/varargs.h;
315 replace = "/* This file was generated by fixincludes. */\n"
316 "#ifndef _SYS_VARARGS_H\n"
317 "#define _SYS_VARARGS_H\n\n"
319 "#ifdef __STDC__\n"
320 "#include <stdarg.h>\n"
321 "#else\n"
322 "#include <varargs.h>\n"
323 "#endif\n\n"
325 "#endif /* _SYS_VARARGS_H */\n";
327 #endif
331 * Completely replace <sys/byteorder.h> with a file that implements gcc's
332 * optimized byteswapping. (The original probably implemented some
333 * incompatible optimized byteswapping.)
335 fix = {
336 hackname = AAB_svr4_replace_byteorder;
337 mach = "*-*-sysv4*";
338 mach = "i[34567]86-*-sysv5*";
339 mach = "i[34567]86-*-sco3.2v5*";
340 mach = "i[34567]86-*-udk*";
341 mach = "i[34567]86-*-solaris2.[0-4]";
342 mach = "powerpcle-*-solaris2.[0-4]";
343 mach = "sparc-*-solaris2.[0-4]";
344 mach = "i[34567]86-sequent-ptx*";
345 files = sys/byteorder.h;
346 replace = <<- _EndOfHeader_
347 #ifndef _SYS_BYTEORDER_H
348 #define _SYS_BYTEORDER_H
350 /* Functions to convert `short' and `long' quantities from host byte order
351 to (internet) network byte order (i.e. big-endian).
353 Written by Ron Guilmette (rfg@ncd.com).
355 This isn't actually used by GCC. It is installed by fixinc.svr4.
357 For big-endian machines these functions are essentially no-ops.
359 For little-endian machines, we define the functions using specialized
360 asm sequences in cases where doing so yields better code (e.g. i386). */
362 #if !defined (__GNUC__) && !defined (__GNUG__)
363 #error You lose! This file is only useful with GNU compilers.
364 #endif
366 #ifndef __BYTE_ORDER__
367 /* Byte order defines. These are as defined on UnixWare 1.1, but with
368 double underscores added at the front and back. */
369 #define __LITTLE_ENDIAN__ 1234
370 #define __BIG_ENDIAN__ 4321
371 #define __PDP_ENDIAN__ 3412
372 #endif
374 #ifdef __STDC__
375 static __inline__ unsigned long htonl (unsigned long);
376 static __inline__ unsigned short htons (unsigned int);
377 static __inline__ unsigned long ntohl (unsigned long);
378 static __inline__ unsigned short ntohs (unsigned int);
379 #endif /* defined (__STDC__) */
381 #if defined (__i386__)
383 #ifndef __BYTE_ORDER__
384 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
385 #endif
387 /* Convert a host long to a network long. */
389 /* We must use a new-style function definition, so that this will also
390 be valid for C++. */
391 static __inline__ unsigned long
392 htonl (unsigned long __arg)
394 register unsigned long __result;
396 __asm__ ("xchg%B0 %b0,%h0
397 ror%L0 $16,%0
398 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
399 return __result;
402 /* Convert a host short to a network short. */
404 static __inline__ unsigned short
405 htons (unsigned int __arg)
407 register unsigned short __result;
409 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
410 return __result;
413 #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
415 #ifndef __BYTE_ORDER__
416 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
417 #endif
419 /* For other little-endian machines, using C code is just as efficient as
420 using assembly code. */
422 /* Convert a host long to a network long. */
424 static __inline__ unsigned long
425 htonl (unsigned long __arg)
427 register unsigned long __result;
429 __result = (__arg >> 24) & 0x000000ff;
430 __result |= (__arg >> 8) & 0x0000ff00;
431 __result |= (__arg << 8) & 0x00ff0000;
432 __result |= (__arg << 24) & 0xff000000;
433 return __result;
436 /* Convert a host short to a network short. */
438 static __inline__ unsigned short
439 htons (unsigned int __arg)
441 register unsigned short __result;
443 __result = (__arg << 8) & 0xff00;
444 __result |= (__arg >> 8) & 0x00ff;
445 return __result;
448 #else /* must be a big-endian machine */
450 #ifndef __BYTE_ORDER__
451 #define __BYTE_ORDER__ __BIG_ENDIAN__
452 #endif
454 /* Convert a host long to a network long. */
456 static __inline__ unsigned long
457 htonl (unsigned long __arg)
459 return __arg;
462 /* Convert a host short to a network short. */
464 static __inline__ unsigned short
465 htons (unsigned int __arg)
467 return __arg;
470 #endif /* big-endian */
472 /* Convert a network long to a host long. */
474 static __inline__ unsigned long
475 ntohl (unsigned long __arg)
477 return htonl (__arg);
480 /* Convert a network short to a host short. */
482 static __inline__ unsigned short
483 ntohs (unsigned int __arg)
485 return htons (__arg);
487 #endif
488 _EndOfHeader_;
493 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
495 fix = {
496 hackname = AAB_ultrix_ansi_compat;
497 files = ansi_compat.h;
498 select = ULTRIX;
499 replace = "/* This file intentionally left blank. */\n";
504 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
505 * Replace limits.h with a file that includes sys/limits.h.
507 fix = {
508 hackname = AAB_ultrix_limits;
509 files = limits.h;
510 mach = "*-*-ultrix4.3";
511 replace = <<- _EndOfHeader_
512 #ifndef _LIMITS_INCLUDED
513 #define _LIMITS_INCLUDED
514 #include <sys/limits.h>
515 #endif /* _LIMITS_INCLUDED */
516 _EndOfHeader_;
521 * The ULTRIX 4.3 version of memory.h duplicates definitions
522 * present in strings.h. Replace memory.h with a file that includes
523 * strings.h to prevent problems from multiple inclusion.
525 fix = {
526 hackname = AAB_ultrix_memory;
527 files = memory.h;
528 mach = "*-*-ultrix4.3";
529 replace = <<- _EndOfHeader_
530 #ifndef _MEMORY_INCLUDED
531 #define _MEMORY_INCLUDED
532 #include <strings.h>
533 #endif /* _MEMORY_INCLUDED */
534 _EndOfHeader_;
539 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
540 * Replace string.h link with a file that includes strings.h to prevent
541 * problems from multiple inclusion.
543 fix = {
544 hackname = AAB_ultrix_string;
545 files = string.h;
546 mach = "*-*-ultrix4.3";
547 replace = <<- _EndOfHeader_
548 #ifndef _STRING_INCLUDED
549 #define _STRING_INCLUDED
550 #include <strings.h>
551 #endif /* _STRING_INCLUDED */
552 _EndOfHeader_;
557 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
558 * which violates a requirement of ISO C.
560 fix = {
561 hackname = aix_pthread;
562 files = "pthread.h";
563 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
564 c_fix = format;
565 c_fix_arg = "%1 %2";
566 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
567 "{...init stuff...}";
572 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
573 * in an otherwise harmless (and #ifed out) macro definition
575 fix = {
576 hackname = aix_sysmachine;
577 files = sys/machine.h;
578 select = "\\\\ +\n";
579 c_fix = format;
580 c_fix_arg = "\\\n";
581 test_text = "#define FOO \\\n"
582 " bar \\ \n baz \\ \n bat";
587 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
588 * definition of struct rusage, so the prototype added by fixproto fails.
590 fix = {
591 hackname = aix_syswait;
592 files = sys/wait.h;
593 select = "^extern pid_t wait3\\(\\);\n";
594 select = "bos325,";
595 c_fix = format;
596 c_fix_arg = "struct rusage;\n%0";
597 test_text = "/* bos325, */\n"
598 "extern pid_t wait3();\n"
599 "\t/* pid_t wait3(int *, int, struct rusage *); */";
604 * sys/wait.h on AIX 5.2 defines macros that have both signed and
605 * unsigned types in conditional expressions.
607 fix = {
608 hackname = aix_syswait_2;
609 files = sys/wait.h;
610 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
611 c_fix = format;
612 c_fix_arg = "? (int)%1";
613 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
618 * sys/signal.h on some versions of AIX uses volatile in the typedef of
619 * sig_atomic_t, which causes gcc to generate a warning about duplicate
620 * volatile when a sig_atomic_t variable is declared volatile, as
621 * required by ANSI C.
623 fix = {
624 hackname = aix_volatile;
625 files = sys/signal.h;
626 select = "typedef volatile int sig_atomic_t";
627 c_fix = format;
628 c_fix_arg = "typedef int sig_atomic_t";
629 test_text = "typedef volatile int sig_atomic_t;";
634 * Fix __assert declaration in assert.h on Alpha OSF/1.
636 fix = {
637 hackname = alpha___assert;
638 files = "assert.h";
639 select = '__assert\(char \*, char \*, int\)';
640 c_fix = format;
641 c_fix_arg = "__assert(const char *, const char *, int)";
642 test_text = 'extern void __assert(char *, char *, int);';
647 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
649 fix = {
650 hackname = alpha___extern_prefix;
651 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n(#[ \t]*pragma[ \t]*extern_prefix.*)";
653 mach = "alpha*-dec-osf*";
654 c_fix = format;
655 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
657 test_text = "#ifdef __DECC\n"
658 "#pragma extern_prefix \"_P\"\n"
659 "# if defined(__DECC)\n"
660 "# pragma extern_prefix \"_E\"\n"
661 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
662 "# pragma extern_prefix \"\"";
667 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
669 fix = {
670 hackname = alpha___extern_prefix_standards;
671 files = standards.h;
672 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
674 mach = "alpha*-dec-osf*";
675 c_fix = format;
676 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
678 test_text = "#if (_ISO_C_SOURCE>=19990L) && !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
683 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
684 * <sys/stat.h>. The tests for __DECC are special in various ways, so
685 * alpha__extern_prefix cannot be used.
687 fix = {
688 hackname = alpha___extern_prefix_sys_stat;
689 files = sys/stat.h;
690 files = sys/mount.h;
691 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
693 mach = "alpha*-dec-osf5*";
694 c_fix = format;
695 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
697 test_text = "# if defined(__DECC)";
702 * Fix assert macro in assert.h on Alpha OSF/1.
703 * The superfluous int cast breaks C++.
705 fix = {
706 hackname = alpha_assert;
707 files = "assert.h";
708 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
709 c_fix = format;
710 c_fix_arg = "%1(EX)";
711 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 : __assert(#EX, __FILE__, __LINE__))';
716 * Fix #defines under Alpha OSF/1:
717 * The following files contain '#pragma extern_prefix "_FOO"' followed by
718 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
719 * statements is to reduce namespace pollution. While these macros work
720 * properly in most cases, they don't allow you to take a pointer to the
721 * "something" being modified. To get around this limitation, change these
722 * statements to be of the form '#define something _FOOsomething'.
724 * sed ain't egrep, lesson 2463: sed can use self-referential
725 * regular expressions. In the substitute expression below,
726 * "\\1" and "\\2" refer to subexpressions found earlier in the
727 * same match. So, we continue to use sed. "extern_prefix" will
728 * be a rare match anyway...
730 fix = {
731 hackname = alpha_bad_lval;
733 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
734 mach = "alpha*-dec-osf*";
736 sed =
737 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
738 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
740 test_text = '#pragma extern_prefix "_FOO"'"\n"
741 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
742 "#define mumble _FOOmumble";
747 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
749 fix = {
750 hackname = alpha_getopt;
751 files = "stdio.h";
752 files = "stdlib.h";
753 select = 'getopt\(int, char \*\[\], *char \*\)';
754 c_fix = format;
755 c_fix_arg = "getopt(int, char *const[], const char *)";
756 test_text = 'extern int getopt(int, char *[], char *);';
761 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
763 fix = {
764 hackname = alpha_parens;
765 files = sym.h;
766 select = '#ifndef\(__mips64\)';
767 c_fix = format;
768 c_fix_arg = "#ifndef __mips64";
769 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
774 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
776 fix = {
777 hackname = alpha_pthread;
778 files = pthread.h;
779 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)|def _PTHREAD_ENV_DECC)(.*))\n"
780 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
782 mach = "alpha*-dec-osf*";
783 c_fix = format;
784 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 || defined (__PRAGMA_EXTERN_PREFIX)\n%5";
786 test_text = "# if defined (_PTHREAD_ENV_DECC) || defined (_PTHREAD_ENV_EPCC)\n"
787 "# define _PTHREAD_USE_PTDNAM_\n"
788 "# endif\n"
789 "# ifdef _PTHREAD_ENV_DECC\n"
790 "# define _PTHREAD_USE_PTDNAM_\n"
791 "# endif";
796 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
798 fix = {
799 hackname = alpha_pthread_gcc;
800 files = pthread.h;
801 select = "#else\n# error <pthread.h>: unrecognized compiler.";
803 mach = "alpha*-dec-osf*";
804 c_fix = format;
805 c_fix_arg = "#elif defined (__GNUC__)\n"
806 "# define _PTHREAD_ENV_GCC\n"
807 "%0";
809 test_text = "# define _PTHREAD_ENV_INTELC\n"
810 "#else\n"
811 "# error <pthread.h>: unrecognized compiler.\n"
812 "#endif";
816 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
817 * incorrectly, specifying less fields in the initializers than are
818 * defined in the corresponding structure types. Use of these macros
819 * in user code results in spurious warnings.
821 fix = {
822 hackname = alpha_pthread_init;
823 files = pthread.h;
824 select = ' \* @\(#\).RCSfile: pthread\.h,v \$'
825 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
826 ' .Date: 2000/08/15 15:30:13 \$';
827 mach = "alpha*-dec-osf*";
828 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
829 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
830 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
831 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
832 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
833 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
834 test_text = "/*\n"
835 " * @(#)_RCSfile: pthread.h,v \\$ "
836 "_Revision: 1.1.33.21 \\$ (DEC) "
837 "_Date: 2000/08/15 15:30:13 \\$\n"
838 " */\n"
839 "#ifndef _PTHREAD_NOMETER_STATIC\n"
840 "# define PTHREAD_MUTEX_INITIALIZER \\\n"
841 " {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
842 "# define PTHREAD_COND_INITIALIZER \\\n"
843 " {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}\n"
844 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
845 " {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
846 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
847 " {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
848 "#else\n"
849 "# define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
850 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
851 " {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
852 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
853 " {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
854 "#endif\n\n"
855 "#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}\n"
856 "#define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \\\n"
857 " {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}\n";
861 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
862 * And OpenBSD.
864 fix = {
865 hackname = alpha_sbrk;
866 files = unistd.h;
867 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
868 c_fix = format;
869 c_fix_arg = "void *sbrk(";
870 test_text = "extern char* sbrk(ptrdiff_t increment);";
875 * Change external names of wcstok/wcsftime via asm instead of macros on
876 * Tru64 UNIX V4.0.
878 fix = {
879 hackname = alpha_wchar;
880 files = wchar.h;
882 mach = "alpha*-dec-osf4*";
883 select = "#define wcstok wcstok_r";
884 sed = "s@#define wcstok wcstok_r@extern wchar_t *wcstok __((wchar_t *, const wchar_t *, wchar_t **)) __asm__(\"wcstok_r\");@";
885 sed = "s@#define wcsftime __wcsftime_isoc@extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *, const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
886 test_text = "#define wcstok wcstok_r\n"
887 "#define wcsftime __wcsftime_isoc";
892 * For C++, avoid any typedef or macro definition of bool,
893 * and use the built in type instead.
894 * HP/UX 10.20 also has it in curses_colr/curses.h.
896 fix = {
897 hackname = avoid_bool_define;
898 files = curses.h;
899 files = curses_colr/curses.h;
900 files = term.h;
901 files = tinfo.h;
903 select = "#[ \t]*define[ \t]+bool[ \t]";
904 bypass = "__cplusplus";
906 c_fix = format;
907 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
908 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
910 test_text = "# define bool\t char \n";
914 fix = {
915 hackname = avoid_bool_type;
916 files = curses.h;
917 files = curses_colr/curses.h;
918 files = term.h;
919 files = tinfo.h;
921 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
922 bypass = "__cplusplus";
924 c_fix = format;
925 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
927 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
932 * For C++, avoid any typedef definition of wchar_t,
933 * and use the built in type instead.
934 * Don't do this for headers that are smart enough to do the right
935 * thing (recent [n]curses.h and Xlib.h).
936 * Don't do it for <linux/nls.h> which is never used from C++ anyway,
937 * and will be broken by the edit.
940 fix = {
941 hackname = avoid_wchar_t_type;
943 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
944 bypass = "__cplusplus";
945 bypass = "_LINUX_NLS_H";
946 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
948 c_fix = format;
949 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
951 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
956 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
958 fix = {
959 hackname = bad_struct_term;
960 files = curses.h;
961 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
962 c_fix = format;
963 c_fix_arg = "struct term;";
965 test_text = 'typedef struct term;';
970 * Fix one other error in this file:
971 * a mismatched quote not inside a C comment.
973 fix = {
974 hackname = badquote;
975 files = sundev/vuid_event.h;
976 select = "doesn't";
977 c_fix = format;
978 c_fix_arg = "does not";
980 test_text = "/* doesn't have matched single quotes */";
985 * check for broken assert.h that needs stdio.h
987 fix = {
988 hackname = broken_assert_stdio;
989 files = assert.h;
990 select = stderr;
991 bypass = "include.*stdio\\.h";
992 c_fix = wrap;
993 c_fix_arg = "#include <stdio.h>\n";
994 test_text = "extern FILE* stderr;";
999 * check for broken assert.h that needs stdlib.h
1001 fix = {
1002 hackname = broken_assert_stdlib;
1003 files = assert.h;
1004 select = 'exit *\(|abort *\(';
1005 bypass = "include.*stdlib\\.h";
1006 c_fix = wrap;
1007 c_fix_arg = "#ifdef __cplusplus\n"
1008 "#include <stdlib.h>\n"
1009 "#endif\n";
1010 test_text = "extern void exit ( int );";
1015 * Remove `extern double cabs' declarations from math.h.
1016 * This conflicts with C99. Discovered on AIX.
1017 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
1018 * declares cabs() to take a struct __cabs_s argument.
1019 * SunOS4 has its cabs() declaration followed by a comment which
1020 * terminates on the following line.
1021 * Darwin hides its broken cabs in architecture-specific subdirs.
1023 fix = {
1024 hackname = broken_cabs;
1025 files = "math.h";
1026 files = "architecture/ppc/math.h";
1027 files = "architecture/i386/math.h";
1028 select = "^extern[ \t]+double[ \t]+cabs";
1030 c_fix = format;
1031 c_fix_arg = "";
1032 c_fix_arg = "^extern[ \t]+double[ \t]+cabs[ \t]*\\([^\\)]*\\);";
1034 test_text = "#ifdef __STDC__\n"
1035 "extern double cabs(struct dbl_hypot);\n"
1036 "#else\n"
1037 "extern double cabs();\n"
1038 "#endif\n"
1039 "extern double cabs ( _Complex z );\n"
1040 "extern double cabs(); /* This is a comment\n"
1041 " and it ends here. */\n"
1042 "extern double cabs(struct __cabs_s);";
1047 * Various systems derived from BSD4.4 contain a macro definition
1048 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1049 * Known to be fixed in FreeBSD 5 system headers.
1051 fix = {
1052 hackname = bsd_stdio_attrs_conflict;
1053 mach = "*-*-*bsd*";
1054 mach = "*-*-*darwin*";
1055 files = stdio.h;
1056 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1057 c_fix = format;
1058 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1059 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1060 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1061 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1062 test_text = '#define vfscanf __svfscanf';
1067 * Fix various macros used to define ioctl numbers.
1068 * The traditional syntax was:
1070 * #define _CTRL(n, x) (('n'<<8)+x)
1071 * #define TCTRLCFOO _CTRL(T, 1)
1073 * but this does not work with the C standard, which disallows macro
1074 * expansion inside strings. We have to rewrite it thus:
1076 * #define _CTRL(n, x) ((n<<8)+x)
1077 * #define TCTRLCFOO _CTRL('T', 1)
1079 * The select expressions match too much, but the c_fix code is cautious.
1081 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1083 fix = {
1084 hackname = ctrl_quotes_def;
1085 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1086 c_fix = char_macro_def;
1087 c_fix_arg = "CTRL";
1090 * This is two tests in order to ensure that the "CTRL(c)" can
1091 * be selected in isolation from the multi-arg format
1093 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1094 test_text = "#define _CTRL(c) ('c'&037)";
1097 fix = {
1098 hackname = ctrl_quotes_use;
1099 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1100 c_fix = char_macro_use;
1101 c_fix_arg = "CTRL";
1102 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1107 * sys/mman.h on HP/UX is not C++ ready,
1108 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1110 * rpc/types.h on OSF1/2.0 is not C++ ready,
1111 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1113 * The problem is the declaration of malloc.
1115 fix = {
1116 hackname = cxx_unready;
1117 files = sys/mman.h;
1118 files = rpc/types.h;
1119 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1120 not within a macro. */
1121 bypass = '"C"|__BEGIN_DECLS';
1123 c_fix = wrap;
1124 c_fix_arg = "#ifdef __cplusplus\n"
1125 "extern \"C\" {\n"
1126 "#endif\n";
1127 c_fix_arg = "#ifdef __cplusplus\n"
1128 "}\n"
1129 "#endif\n";
1130 test_text = "extern void* malloc( size_t );";
1135 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1136 * bad __GNUC__ tests.
1139 fix = {
1140 hackname = darwin_gcc4_breakage;
1141 mach = "*-*-darwin*";
1142 files = AvailabilityMacros.h;
1143 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1144 c_fix = format;
1145 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1146 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1147 "(__GNUC_MINOR__ >= 1)\n";
1152 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1153 * why would you ever put it in a system header file?
1155 fix = {
1156 hackname = darwin_private_extern;
1157 mach = "*-*-darwin*";
1158 files = mach-o/dyld.h;
1159 select = "__private_extern__ [a-z_]+ _dyld_";
1160 c_fix = format;
1161 c_fix_arg = "extern";
1162 c_fix_arg = "__private_extern__";
1163 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1164 "const char *dyld_func_name,\n"
1165 "unsigned long *address);\n";
1170 * Fix <c_asm.h> on Digital UNIX V4.0:
1171 * It contains a prototype for a DEC C internal asm() function,
1172 * clashing with gcc's asm keyword. So protect this with __DECC.
1174 fix = {
1175 hackname = dec_intern_asm;
1176 files = c_asm.h;
1177 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1178 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1179 "#endif\n";
1180 test_text =
1181 "float fasm {\n"
1182 " ... asm stuff ...\n"
1183 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1188 * Fix typo in <wchar.h> on DJGPP 2.03.
1190 fix = {
1191 hackname = djgpp_wchar_h;
1192 file = wchar.h;
1193 select = "__DJ_wint_t";
1194 bypass = "sys/djtypes.h";
1195 c_fix = format;
1196 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1197 c_fix_arg = "#include <stddef.h>";
1198 test_text = "#include <stddef.h>\n"
1199 "extern __DJ_wint_t x;\n";
1204 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1206 fix = {
1207 hackname = ecd_cursor;
1208 files = "sunwindow/win_lock.h";
1209 files = "sunwindow/win_cursor.h";
1210 select = 'ecd\.cursor';
1211 c_fix = format;
1212 c_fix_arg = 'ecd_cursor';
1214 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1219 * math.h on SunOS 4 puts the declaration of matherr before the definition
1220 * of struct exception, so the prototype (added by fixproto) causes havoc.
1221 * This must appear before the math_exception fix.
1223 fix = {
1224 hackname = exception_structure;
1225 files = math.h;
1227 /* If matherr has a prototype already, the header needs no fix. */
1228 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION|[ \t]*__FP_EXCEPTION[ \t]*\*[ \t]*)';
1229 select = matherr;
1231 c_fix = wrap;
1232 c_fix_arg = "struct exception;\n";
1234 test_text = "extern int matherr();";
1239 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1240 * neither the existence of GCC 3 nor its exact feature set yet break
1241 * (by design?) when __GNUC__ is set beyond 2.
1243 fix = {
1244 hackname = freebsd_gcc3_breakage;
1245 mach = "*-*-freebsd*";
1246 files = sys/cdefs.h;
1247 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1248 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1249 c_fix = format;
1250 c_fix_arg = '%0 || __GNUC__ >= 3';
1251 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1256 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1257 * neither the existence of GCC 4 nor its exact feature set yet break
1258 * (by design?) when __GNUC__ is set beyond 3.
1260 fix = {
1261 hackname = freebsd_gcc4_breakage;
1262 mach = "*-*-freebsd*";
1263 files = sys/cdefs.h;
1264 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1265 c_fix = format;
1266 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1267 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1271 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1272 * so we replace them with versions that correspond to the
1273 * definition.
1275 fix = {
1276 hackname = glibc_mutex_init;
1277 files = pthread.h;
1278 select = '\{ *\{ *0, *\} *\}';
1279 sed = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/,+1"
1280 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/";
1281 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1282 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1283 sed = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1284 "N;s/^[ \t]*#[ \t]*"
1285 "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1286 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
1287 "# \\1\\n"
1288 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1289 "# else\\n"
1290 "# \\1\\n"
1291 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1292 "# endif/";
1293 sed = "s/{ \\(0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1294 sed = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
1295 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1297 test_text = <<- _EOText_
1298 #define PTHREAD_MUTEX_INITIALIZER \\
1299 { { 0, } }
1300 #ifdef __USE_GNU
1301 # if __WORDSIZE == 64
1302 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1303 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1304 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1305 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1306 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1307 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1308 # else
1309 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1310 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1311 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1312 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1313 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1314 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1315 # endif
1316 #endif
1317 # define PTHREAD_RWLOCK_INITIALIZER \\
1318 { { 0, } }
1319 # ifdef __USE_GNU
1320 # if __WORDSIZE == 64
1321 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1322 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1323 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1324 # else
1325 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1326 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1327 # endif
1328 # endif
1329 #define PTHREAD_COND_INITIALIZER { { 0, } }
1330 _EOText_;
1335 * Fix these files to use the types we think they should for
1336 * ptrdiff_t, size_t, and wchar_t.
1338 * This defines the types in terms of macros predefined by our 'cpp'.
1339 * This is supposedly necessary for glibc's handling of these types.
1340 * It's probably not necessary for anyone else, but it doesn't hurt.
1342 fix = {
1343 hackname = gnu_types;
1344 files = "sys/types.h";
1345 files = "stdlib.h";
1346 files = "sys/stdtypes.h";
1347 files = "stddef.h";
1348 files = "memory.h";
1349 files = "unistd.h";
1350 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1351 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1352 c_fix = gnu_type;
1353 /* The Solaris 10 headers already define these types correctly. */
1354 mach = '*-*-solaris2.1[0-9]*';
1355 not_machine = true;
1357 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1358 "typedef uint_t size_t; /* uint_t */\n"
1359 "typedef ushort_t wchar_t; /* ushort_t */";
1364 * Fix HP & Sony's use of "../machine/xxx.h"
1365 * to refer to: <machine/xxx.h>
1367 fix = {
1368 hackname = hp_inline;
1369 files = sys/spinlock.h;
1370 files = machine/machparam.h;
1371 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1373 c_fix = format;
1374 c_fix_arg = "%1<machine/%2.h>";
1376 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1377 '([a-z]+)\.h"';
1379 test_text = ' # include "../machine/mumble.h"';
1384 * Check for (...) in C++ code in HP/UX sys/file.h.
1386 fix = {
1387 hackname = hp_sysfile;
1388 files = sys/file.h;
1389 select = "HPUX_SOURCE";
1391 c_fix = format;
1392 c_fix_arg = "(struct file *, ...)";
1393 c_fix_arg = '\(\.\.\.\)';
1395 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1400 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1401 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1403 fix = {
1404 hackname = hpux10_cpp_pow_inline;
1405 files = fixinc-test-limits.h, math.h;
1406 select = <<- END_POW_INLINE
1407 ^# +ifdef +__cplusplus
1409 +inline +double +pow\(double +__d,int +__expon\) +\{
1410 [ ]+return +pow\(__d,\(double\)__expon\);
1412 +extern +"C" +\{
1413 #else
1414 # +endif
1415 END_POW_INLINE;
1417 c_fix = format;
1418 c_fix_arg = "";
1420 test_text =
1421 "# ifdef __cplusplus\n"
1422 " }\n"
1423 " inline double pow(double __d,int __expon) {\n"
1424 "\t return pow(__d,(double)__expon);\n"
1425 " }\n"
1426 ' extern "C"' " {\n"
1427 "#else\n"
1428 "# endif";
1431 fix = {
1432 hackname = hpux11_cpp_pow_inline;
1433 files = math.h;
1434 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1435 " +return pow\\(d, \\(double\\)expon\\);\n"
1436 " +\\}\n";
1437 c_fix = format;
1438 c_fix_arg = "";
1440 test_text =
1441 " inline double pow(double d,int expon) {\n"
1442 " return pow(d, (double)expon);\n"
1443 " }\n";
1448 * Fix hpux 10.X missing ctype declarations 1
1450 fix = {
1451 hackname = hpux10_ctype_declarations1;
1452 files = ctype.h;
1453 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1454 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1455 c_fix = format;
1456 c_fix_arg = "#ifdef _PROTOTYPES\n"
1457 "extern int __tolower(int);\n"
1458 "extern int __toupper(int);\n"
1459 "#else /* NOT _PROTOTYPES */\n"
1460 "extern int __tolower();\n"
1461 "extern int __toupper();\n"
1462 "#endif /* _PROTOTYPES */\n\n"
1463 "%0\n";
1465 test_text = "# define _toupper(__c) __toupper(__c)\n";
1470 * Fix hpux 10.X missing ctype declarations 2
1472 fix = {
1473 hackname = hpux10_ctype_declarations2;
1474 files = ctype.h;
1475 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1476 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1477 c_fix = format;
1478 c_fix_arg = "%0\n\n"
1479 "#ifdef _PROTOTYPES\n"
1480 " extern int _isalnum(int);\n"
1481 " extern int _isalpha(int);\n"
1482 " extern int _iscntrl(int);\n"
1483 " extern int _isdigit(int);\n"
1484 " extern int _isgraph(int);\n"
1485 " extern int _islower(int);\n"
1486 " extern int _isprint(int);\n"
1487 " extern int _ispunct(int);\n"
1488 " extern int _isspace(int);\n"
1489 " extern int _isupper(int);\n"
1490 " extern int _isxdigit(int);\n"
1491 "# else /* not _PROTOTYPES */\n"
1492 " extern int _isalnum();\n"
1493 " extern int _isalpha();\n"
1494 " extern int _iscntrl();\n"
1495 " extern int _isdigit();\n"
1496 " extern int _isgraph();\n"
1497 " extern int _islower();\n"
1498 " extern int _isprint();\n"
1499 " extern int _ispunct();\n"
1500 " extern int _isspace();\n"
1501 " extern int _isupper();\n"
1502 " extern int _isxdigit();\n"
1503 "#endif /* _PROTOTYPES */\n";
1505 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1506 " extern unsigned int *__SB_masks;\n";
1511 * Fix hpux 10.X missing stdio declarations
1513 fix = {
1514 hackname = hpux10_stdio_declarations;
1515 files = stdio.h;
1516 select = "^#[ \t]*define _iob[ \t]*__iob";
1517 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1518 c_fix = format;
1519 c_fix_arg = "%0\n\n"
1520 "# if defined(__STDC__) || defined(__cplusplus)\n"
1521 " extern int snprintf(char *, size_t, const char *, ...);\n"
1522 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1523 "# else /* not __STDC__) || __cplusplus */\n"
1524 " extern int snprintf();\n"
1525 " extern int vsnprintf();\n"
1526 "# endif /* __STDC__) || __cplusplus */\n";
1528 test_text = "# define _iob __iob\n";
1533 * Make sure hpux defines abs in header.
1535 fix = {
1536 hackname = hpux11_abs;
1537 mach = "ia64-hp-hpux11*";
1538 files = stdlib.h;
1539 select = "ifndef _MATH_INCLUDED";
1540 c_fix = format;
1541 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1542 // sed = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1543 test_text = "#ifndef _MATH_INCLUDED";
1548 * Keep HP-UX 11 from stomping on C++ math namespace
1549 * with defines for fabsf.
1551 fix = {
1552 hackname = hpux11_fabsf;
1553 files = math.h;
1554 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1555 bypass = "__cplusplus";
1557 c_fix = format;
1558 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1560 test_text =
1561 "#ifdef _PA_RISC\n"
1562 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1563 "#endif";
1568 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1569 * being defined by having it define _hpux_size_t instead.
1571 fix = {
1572 hackname = hpux11_size_t;
1573 mach = "*-hp-hpux11*";
1574 select = "__size_t";
1576 c_fix = format;
1577 c_fix_arg = "_hpux_size_t";
1579 test_text =
1580 "#define __size_t size_t\n"
1581 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1586 * Fix hpux 11.00 broken snprintf declaration
1587 * (third argument is char *, needs to be const char * to prevent
1588 * spurious warnings with -Wwrite-strings or in C++).
1590 fix = {
1591 hackname = hpux11_snprintf;
1592 files = stdio.h;
1593 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1594 ' *(char *\*, *\.\.\.\);)';
1595 c_fix = format;
1596 c_fix_arg = '%1 const %3';
1598 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1599 "extern int snprintf(char *, __size_t, char *, ...);\n"
1600 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1605 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1606 * of UINT32_C has undefined behavior according to ISO/ANSI:
1607 * the arguments to __CONCAT__ are not macro expanded before the
1608 * concatination happens so the trailing ')' in the first argument
1609 * is concatinated with the 'l' in the second argument creating an
1610 * invalid pp token. The behavior of invalid pp tokens is undefined.
1611 * GCC does not handle these invalid tokens the way the HP compiler does.
1612 * This problem will potentially occur anytime macros are used in the
1613 * arguments to __CONCAT__. A general solution to this problem would be to
1614 * insert another layer of macro between __CONCAT__ and its use
1615 * in UINT32_C. An example of this solution can be found in the C standard.
1616 * A more specific solution, the one used here, is to change the UINT32_C
1617 * macro to not used macros in the arguments to __CONCAT__.
1619 fix = {
1620 hackname = hpux11_uint32_c;
1621 files = inttypes.h;
1622 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1623 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1624 c_fix = format;
1625 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1626 test_text =
1627 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1628 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1633 * Fix hpux 11.00 broken vsnprintf declaration
1635 fix = {
1636 hackname = hpux11_vsnprintf;
1637 files = stdio.h;
1638 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1639 'const char \*,) __va__list\);';
1640 c_fix = format;
1641 c_fix_arg = "%1 __va_list);";
1643 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1644 ' __va__list);';
1649 * get rid of bogus inline definitions in HP-UX 8.0
1651 fix = {
1652 hackname = hpux8_bogus_inlines;
1653 files = math.h;
1654 select = inline;
1655 bypass = "__GNUG__";
1656 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1657 "@extern \"C\" int abs(int);@";
1658 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1659 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1660 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1661 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1662 "inline double sqr(double v) { return v**0.5; }";
1667 * Fix hpux broken ctype macros
1669 fix = {
1670 hackname = hpux_ctype_macros;
1671 files = ctype.h;
1672 select = '((: |\()__SB_masks \? )'
1673 '(__SB_masks\[__(alnum|c)\] & _IS)';
1674 c_fix = format;
1675 c_fix_arg = "%1(int)%3";
1677 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1678 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1683 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1685 fix = {
1686 hackname = hpux_htonl;
1687 files = netinet/in.h;
1688 select = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1689 "(/\\*\n"
1690 " \\* Macros for number representation conversion\\.\n"
1691 " \\*/\n"
1692 "#ifndef ntohl)";
1693 c_fix = format;
1694 c_fix_arg = "#if 1\n%1";
1696 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1697 "/*\n"
1698 " * Macros for number representation conversion.\n"
1699 " */\n"
1700 "#ifndef ntohl\n"
1701 "#define ntohl(x) (x)\n"
1702 "#define ntohs(x) (x)\n"
1703 "#define htonl(x) (x)\n"
1704 "#define htons(x) (x)\n"
1705 "#endif\n"
1706 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1711 * HP-UX long_double
1713 fix = {
1714 hackname = hpux_long_double;
1715 files = stdlib.h;
1716 select = "extern[ \t]long_double[ \t]strtold";
1717 bypass = "long_double_t";
1718 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1719 sed = "s/long_double/long double/g";
1721 test_text = "# ifndef _LONG_DOUBLE\n"
1722 "# define _LONG_DOUBLE\n"
1723 " typedef struct {\n"
1724 " unsigned int word1, word2, word3, word4;\n"
1725 " } long_double;\n"
1726 "# endif /* _LONG_DOUBLE */\n"
1727 "extern long_double strtold(const char *, char **);\n";
1732 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1734 fix = {
1735 hackname = hpux_systime;
1736 files = sys/time.h;
1737 select = "^extern struct sigevent;";
1739 c_fix = format;
1740 c_fix_arg = "struct sigevent;";
1742 test_text = 'extern struct sigevent;';
1747 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1748 * type and mpinfou is only defined when _KERNEL is set.
1750 fix = {
1751 hackname = hpux_spu_info;
1752 mach = "*-hp-hpux*";
1753 files = ia64/sys/getppdp.h;
1754 select = "^.*extern.*spu_info.*";
1756 c_fix = format;
1757 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
1759 test_text = "extern union mpinfou spu_info[];";
1762 fix = {
1763 hackname = hpux11_extern_sendfile;
1764 mach = "*-hp-hpux11.[12]*";
1765 files = sys/socket.h;
1766 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
1767 c_fix = format;
1768 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1769 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1772 fix = {
1773 hackname = hpux11_extern_sendpath;
1774 mach = "*-hp-hpux11.[12]*";
1775 files = sys/socket.h;
1776 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
1777 c_fix = format;
1778 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1779 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1782 fix = {
1783 hackname = hpux_extern_errno;
1784 mach = "*-hp-hpux10.*";
1785 mach = "*-hp-hpux11.[0-2]*";
1786 files = errno.h;
1787 select = "^[ \t]*extern int errno;$";
1788 c_fix = format;
1789 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
1790 test_text = " extern int errno;\n";
1794 * Add missing braces to pthread initializer defines.
1796 fix = {
1797 hackname = hpux_pthread_initializers;
1798 mach = "*-hp-hpux11.[0-3]*";
1799 files = sys/pthread.h;
1800 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
1801 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
1802 sed = "s@^[ \t]*1,[ \t]*\\\\"
1803 "@\t{ 1, 0 }@";
1804 sed = "/^[ \t]*0$/d";
1805 sed = "s@__PTHREAD_MUTEX_VALID, 0"
1806 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
1807 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
1808 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
1809 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1810 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1811 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
1812 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
1813 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
1814 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
1815 sed = "s@__PTHREAD_COND_VALID, 0"
1816 "@{ __PTHREAD_COND_VALID, 0 }@";
1817 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
1818 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
1819 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
1820 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
1821 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
1822 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
1823 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
1824 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
1825 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
1826 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
1827 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
1828 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
1829 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
1830 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
1831 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
1832 "}\n";
1836 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
1838 fix = {
1839 hackname = huge_val_hex;
1840 files = bits/huge_val.h;
1841 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
1842 bypass = "__builtin_huge_val";
1844 c_fix = format;
1845 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
1847 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
1852 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
1854 fix = {
1855 hackname = huge_valf_hex;
1856 files = bits/huge_val.h;
1857 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
1858 bypass = "__builtin_huge_valf";
1860 c_fix = format;
1861 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
1863 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
1868 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
1870 fix = {
1871 hackname = huge_vall_hex;
1872 files = bits/huge_val.h;
1873 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
1874 bypass = "__builtin_huge_vall";
1876 c_fix = format;
1877 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
1879 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
1884 * Fix return type of abort and free
1886 fix = {
1887 hackname = int_abort_free_and_exit;
1888 files = stdlib.h;
1889 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1890 bypass = "_CLASSIC_ANSI_TYPES";
1892 c_fix = format;
1893 c_fix_arg = "void\t%1(";
1895 test_text = "extern int abort(int);\n"
1896 "extern int free(void*);\n"
1897 "extern int exit(void*);";
1902 * Fix various macros used to define ioctl numbers.
1903 * The traditional syntax was:
1905 * #define _IO(n, x) (('n'<<8)+x)
1906 * #define TIOCFOO _IO(T, 1)
1908 * but this does not work with the C standard, which disallows macro
1909 * expansion inside strings. We have to rewrite it thus:
1911 * #define _IO(n, x) ((n<<8)+x)
1912 * #define TIOCFOO _IO('T', 1)
1914 * The select expressions match too much, but the c_fix code is cautious.
1916 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1918 fix = {
1919 hackname = io_quotes_def;
1920 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1921 c_fix = char_macro_def;
1922 c_fix_arg = "IO";
1923 test_text =
1924 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1925 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1926 "#define _IO(x,y) ('x'<<8|y)";
1927 test_text =
1928 "#define XX_IO(x) ('x'<<8|256)";
1931 fix = {
1932 hackname = io_quotes_use;
1933 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1934 "\\( *[^,']";
1935 c_fix = char_macro_use;
1936 c_fix_arg = "IO";
1937 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1938 "#define TIOCFOO \\\\\n"
1939 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1944 * Check for missing ';' in struct
1946 fix = {
1947 hackname = ip_missing_semi;
1948 files = netinet/ip.h;
1949 select = "}$";
1950 sed = "/^struct/,/^};/s/}$/};/";
1951 test_text=
1952 "struct mumble {\n"
1953 " union {\n"
1954 " int x;\n"
1955 " }\n"
1956 "}; /* mumbled struct */\n";
1961 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1962 * __restrict as restrict iff __c99. This is wrong for C++, which
1963 * needs many C99 features, but only supports __restrict.
1965 fix = {
1966 hackname = irix___restrict;
1967 files = internal/sgimacros.h;
1968 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1970 mach = "mips-sgi-irix6.5";
1971 c_fix = format;
1972 c_fix_arg = "%1"
1973 "# ifndef __cplusplus\n%2\n# endif";
1975 test_text = "#ifdef __c99\n# define __restrict restrict";
1979 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
1980 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
1981 * functions.
1983 * This was probably introduced around IRIX 6.5.18
1985 fix = {
1986 hackname = irix___generic1;
1987 files = internal/math_core.h;
1988 mach = "mips-sgi-irix6.5";
1989 select = "#define ([a-z]+)\\(x\\) *__generic.*";
1991 c_fix = format;
1992 c_fix_arg = "extern int %1(double);\n"
1993 "extern int %1f(float);\n"
1994 "extern int %1l(long double);\n"
1995 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
1996 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
1997 " : _%1l(x))\n";
1999 test_text =
2000 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2004 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2005 compiler's __generic intrinsic to define isgreater, isgreaterequal,
2006 isless, islessequal, islessgreater and isunordered functions. */
2007 fix = {
2008 hackname = irix___generic2;
2009 files = internal/math_core.h;
2010 mach = "mips-sgi-irix6.5";
2011 select = "#define ([a-z]+)\\(x,y\\) *__generic.*";
2013 c_fix = format;
2014 c_fix_arg = "#define %1(x,y) \\\n"
2015 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2016 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2017 " : _%1l(x,y))\n";
2019 test_text =
2020 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2025 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2026 * that causes the assembly preprocessor to complain about an
2027 * unterminated character constant.
2029 fix = {
2030 hackname = irix_asm_apostrophe;
2031 files = sys/asm.h;
2033 select = "^[ \t]*#.*[Ww]e're";
2034 c_fix = format;
2035 c_fix_arg = "%1 are";
2036 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
2037 test_text = "\t# and we're on vacation";
2042 * Non-traditional "const" declaration in Irix's limits.h.
2044 fix = {
2045 hackname = irix_limits_const;
2046 files = fixinc-test-limits.h, limits.h;
2047 select = "^extern const ";
2048 c_fix = format;
2049 c_fix_arg = "extern __const ";
2050 test_text = "extern const char limit; /* test limits */";
2055 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2056 * Various socket function prototypes use different types instead,
2057 * depending on the API in use (BSD, XPG4/5), but the socklen_t
2058 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
2059 * IRIX 6.5.19).
2061 fix = {
2062 hackname = irix_socklen_t;
2063 files = sys/socket.h;
2064 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2066 mach = "mips-sgi-irix6.5";
2067 c_fix = format;
2068 c_fix_arg = "%1"
2069 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2070 "typedef int socklen_t;\n"
2071 "#else\n"
2072 "%2\n"
2073 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2075 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2079 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2080 * some functions that take a va_list as
2081 * taking char *. However, GCC uses void * for va_list, so
2082 * calling vfprintf with a va_list fails in C++. */
2083 fix = {
2084 hackname = irix_stdio_va_list;
2085 files = stdio.h;
2086 files = internal/stdio_core.h;
2088 select = '/\* va_list \*/ char \*';
2089 c_fix = format;
2090 c_fix_arg = "__gnuc_va_list";
2091 test_text =
2092 "extern int printf( const char *, /* va_list */ char * );";
2097 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2098 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2100 fix = {
2101 hackname = irix_wcsftime;
2102 files = internal/wchar_core.h;
2103 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2105 mach = "mips-sgi-irix6.5";
2106 c_fix = format;
2107 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2109 test_text = "#if _NO_XOPEN5\n"
2110 "extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
2114 * Fixing ISC fmod declaration
2116 fix = {
2117 hackname = isc_fmod;
2118 files = math.h;
2119 select = 'fmod\(double\)';
2120 c_fix = format;
2121 c_fix_arg = "fmod(double, double)";
2122 test_text = "extern double fmod(double);";
2127 * On Interactive Unix 2.2, certain traditional Unix definitions
2128 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
2129 * defined, not just if _POSIX_SOURCE is defined. This makes it
2130 * impossible to compile any nontrivial program except with -posix.
2132 fix = {
2133 hackname = isc_omits_with_stdc;
2135 files = "stdio.h";
2136 files = "math.h";
2137 files = "ctype.h";
2138 files = "sys/limits.h";
2139 files = "sys/fcntl.h";
2140 files = "sys/dirent.h";
2142 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
2143 c_fix = format;
2144 c_fix_arg = '!defined(_POSIX_SOURCE)';
2145 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
2146 "\nint foo;\n#endif";
2151 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2152 * use / * * / to concatenate tokens.
2154 fix = {
2155 hackname = kandr_concat;
2156 files = "sparc/asm_linkage.h";
2157 files = "sun3/asm_linkage.h";
2158 files = "sun3x/asm_linkage.h";
2159 files = "sun4/asm_linkage.h";
2160 files = "sun4c/asm_linkage.h";
2161 files = "sun4m/asm_linkage.h";
2162 files = "sun4c/debug/asm_linkage.h";
2163 files = "sun4m/debug/asm_linkage.h";
2164 files = "arm/as_support.h";
2165 files = "arm/mc_type.h";
2166 files = "arm/xcb.h";
2167 files = "dev/chardefmac.h";
2168 files = "dev/ps_irq.h";
2169 files = "dev/screen.h";
2170 files = "dev/scsi.h";
2171 files = "sys/tty.h";
2172 files = "Xm.acorn/XmP.h";
2173 files = bsd43/bsd43_.h;
2174 select = '/\*\*/';
2175 c_fix = format;
2176 c_fix_arg = '##';
2177 test_text = "#define __CONCAT__(a,b) a/**/b";
2182 * Fix libc1 _G_va_list definition, used in declarations of several
2183 * more-or-less standard functions, for example vasprintf.
2185 fix = {
2186 hackname = libc1_G_va_list;
2187 files = _G_config.h;
2188 mach = '*-*-linux*libc1';
2189 select = 'typedef void \* _G_va_list;';
2190 c_fix = format;
2191 c_fix_arg = "typedef __builtin_va_list _G_va_list;";
2192 test_text = 'typedef void * _G_va_list;';
2197 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
2198 * versions > 1. This fix will open up the declaration for all
2199 * versions of GCC and for g++.
2201 fix = {
2202 hackname = libc1_ifdefd_memx;
2204 /* The string.h result is overwritten by AAB_ultrix_string when doing
2205 "make check" and will fail. Therefore, we add the following kludgery
2206 to insert the test_text into the special testing header. :-} */
2207 files = testing.h;
2208 files = string.h;
2210 c_fix = format;
2211 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
2212 bypass = __cplusplus;
2213 c_fix_arg = "%1";
2214 c_fix_arg =
2215 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
2216 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
2217 "(/\\* .* \\*/\n"
2218 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
2219 "#endif";
2221 test_text =
2222 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
2223 "#if defined(__STDC__) && __GNUC__ < 2\n"
2224 "/* Copy N bytes of SRC to DEST. */\n"
2225 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
2226 " size_t __n));\n"
2227 "#endif";
2231 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2232 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2233 * constant on recent versions of g++.
2235 fix = {
2236 hackname = linux_ia64_ucontext;
2237 files = "sys/ucontext.h";
2238 mach = "ia64-*-linux*";
2239 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2240 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2241 c_fix = format;
2242 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2243 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2244 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2249 * Apparently some SVR4 systems typedef longlong_t to long ?
2251 #ifdef SVR4
2252 fix = {
2253 hackname = longlong_t;
2254 select = "typedef[ \t]+(unsigned[ \t]+)?long[ \t]+(u_)?longlong_t";
2255 c_fix = format;
2256 c_fix_arg = "typedef %1long long %2longlong_t";
2257 test_text = "typedef long longlong_t\n"
2258 "typedef unsigned long u_longlong_t";
2260 #endif
2263 * Remove header file warning from sys/time.h. Autoconf's
2264 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2265 * which causes warning on LynxOS. Remove the warning.
2267 fix = {
2268 hackname = lynxos_no_warning_in_sys_time_h;
2269 files = sys/time.h;
2270 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2271 c_fix = format;
2272 c_fix_arg = "";
2273 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2278 * Add missing declaration for putenv.
2280 fix = {
2281 hackname = lynxos_missing_putenv;
2282 mach = '*-*-lynxos*';
2283 files = stdlib.h;
2284 bypass = 'putenv[ \t]*\\(';
2285 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2286 c_fix = format;
2287 c_fix_arg = "%0\n"
2288 "extern int putenv _AP((char *));";
2289 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2290 test_text = "extern char *getenv _AP((const char *));";
2295 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2297 * On NetBSD, machine is a symbolic link to an architecture specific
2298 * directory name, so we can't match a specific file name here.
2300 fix = {
2301 hackname = machine_ansi_h_va_list;
2302 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2303 bypass = '__builtin_va_list';
2305 c_fix = format;
2306 c_fix_arg = "%1__builtin_va_list";
2307 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2309 test_text = " # define _BSD_VA_LIST_\tchar**";
2314 * Fix non-ansi machine name defines
2316 fix = {
2317 hackname = machine_name;
2318 c_test = machine_name;
2319 c_fix = machine_name;
2321 test_text = "/* MACH_DIFF: */\n"
2322 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2323 "\n/* no uniform test, so be careful :-) */";
2328 * Some math.h files define struct exception (it's in the System V
2329 * Interface Definition), which conflicts with the class exception defined
2330 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2331 * This is not a great fix, but I haven't been able to think of anything
2332 * better. Note that we have to put the #ifdef/#endif blocks at beginning
2333 * and end of file, because fixproto runs after us and may insert
2334 * additional references to struct exception.
2336 fix = {
2337 hackname = math_exception;
2338 files = math.h;
2339 select = "struct exception";
2341 * This should be bypassed on __cplusplus, but some supposedly C++ C++
2342 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2343 * exception either. So currently we bypass only for glibc, based on a
2344 * comment in the fixed glibc header. Ick.
2346 bypass = 'We have a problem when using C\+\+|for C\+\+, _[a-z0-9A-Z_]+_exception; for C, exception';
2347 c_fix = wrap;
2349 c_fix_arg = "#ifdef __cplusplus\n"
2350 "#define exception __math_exception\n"
2351 "#endif\n";
2353 c_fix_arg = "#ifdef __cplusplus\n"
2354 "#undef exception\n"
2355 "#endif\n";
2357 test_text = "typedef struct exception t_math_exception;";
2362 * This looks pretty broken to me. ``dbl_max_def'' will contain
2363 * "define DBL_MAX " at the start, when what we really want is just
2364 * the value portion. Can't figure out how to write a test case
2365 * for this either :-(
2367 fix = {
2368 hackname = math_huge_val_from_dbl_max;
2369 files = math.h;
2372 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2373 * in math.h, this fix applies.
2375 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2376 bypass = "define[ \t]+DBL_MAX";
2378 shell =
2380 * See if we have a definition for DBL_MAX in float.h.
2381 * If we do, we will replace the one in math.h with that one.
2384 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2385 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2387 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2388 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2389 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2390 "\telse cat\n"
2391 "\tfi";
2393 test_text =
2394 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2395 "#define HUGE_VAL DBL_MAX";
2400 * nested comment
2402 fix = {
2403 hackname = nested_auth_des;
2404 files = rpc/rpc.h;
2405 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2406 c_fix = format;
2407 c_fix_arg = "%1*/ /*";
2408 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2413 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
2415 fix = {
2416 hackname = nested_motorola;
2417 mach = "m68k-motorola-sysv*";
2418 files = sys/limits.h;
2419 files = limits.h;
2420 select = "max # bytes atomic in write|error value returned by Math lib";
2422 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
2423 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
2424 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
2425 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
2427 test_text =
2428 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
2429 "\t\t/* PIPE */\n"
2430 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
2435 * Fixing nested comments in ISC <sys/limits.h>
2437 fix = {
2438 hackname = nested_sys_limits;
2439 files = sys/limits.h;
2440 select = CHILD_MAX;
2441 sed = "/CHILD_MAX/s,/\\* Max, Max,";
2442 sed = "/OPEN_MAX/s,/\\* Max, Max,";
2443 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
2444 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
2449 * NetBSD has a semicolon after the ending '}' for some extern "C".
2451 fix = {
2452 hackname = netbsd_extra_semicolon;
2453 mach = "*-*-netbsd*";
2454 files = sys/cdefs.h;
2455 select = "#define[ \t]*__END_DECLS[ \t]*};";
2457 c_fix = format;
2458 c_fix_arg = "#define __END_DECLS }";
2460 test_text = "#define __END_DECLS };";
2465 * NeXT 3.2 adds const prefix to some math functions.
2466 * These conflict with the built-in functions.
2468 fix = {
2469 hackname = next_math_prefix;
2470 files = ansi/math.h;
2471 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
2473 c_fix = format;
2474 c_fix_arg = "extern double %1(";
2475 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2477 test_text = "extern\tdouble\t__const__\tmumble();";
2482 * NeXT 3.2 uses the word "template" as a parameter for some
2483 * functions. GCC reports an invalid use of a reserved key word
2484 * with the built-in functions.
2486 fix = {
2487 hackname = next_template;
2488 files = bsd/libc.h;
2489 select = "[ \t]template\\)";
2491 c_fix = format;
2492 c_fix_arg = "(%1)";
2493 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2494 test_text = "extern mumble( char * template); /* fix */";
2499 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2500 * function prototypes. That conflicts with the built-in functions.
2502 fix = {
2503 hackname = next_volitile;
2504 files = ansi/stdlib.h;
2505 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
2507 c_fix = format;
2508 c_fix_arg = "extern void %1(";
2509 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2511 test_text = "extern\tvolatile\tvoid\tabort();";
2516 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2517 * Note that version 3 of the NeXT system has wait.h in a different directory,
2518 * so that this code won't do anything. But wait.h in version 3 has a
2519 * conditional, so it doesn't need this fix. So everything is okay.
2521 fix = {
2522 hackname = next_wait_union;
2523 files = sys/wait.h;
2525 select = 'wait\(union wait';
2526 c_fix = format;
2527 c_fix_arg = "wait(void";
2528 test_text = "extern pid_d wait(union wait*);";
2533 * a missing semi-colon at the end of the nodeent structure definition.
2535 fix = {
2536 hackname = nodeent_syntax;
2537 files = netdnet/dnetdb.h;
2538 select = "char[ \t]*\\*na_addr[ \t]*$";
2539 c_fix = format;
2540 c_fix_arg = "%0;";
2541 test_text = "char *na_addr\t";
2546 * obstack.h used casts as lvalues.
2548 * We need to change postincrements of casted pointers (which are
2549 * then dereferenced and assigned into) of the form
2551 * *((TYPE*)PTRVAR)++ = (VALUE)
2553 * into expressions like
2555 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2557 * which is correct for the cases used in obstack.h since PTRVAR is
2558 * of type char * and the value of the expression is not used.
2560 fix = {
2561 hackname = obstack_lvalue_cast;
2562 files = obstack.h;
2563 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2564 c_fix = format;
2565 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2566 test_text = "*((void **) (h)->next_free)++ = (aptr)";
2571 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2572 * defining regex.h related types. This causes libg++ build and usage
2573 * failures. Fixing this correctly requires checking and modifying 3 files.
2575 fix = {
2576 hackname = osf_namespace_a;
2577 files = reg_types.h;
2578 files = sys/lc_core.h;
2579 test = " -r reg_types.h";
2580 test = " -r sys/lc_core.h";
2581 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2582 test = " -z \"`grep __regex_t regex.h`\"";
2584 c_fix = format;
2585 c_fix_arg = "__%0";
2586 c_fix_arg = "reg(ex|off|match)_t";
2588 test_text = "`touch sys/lc_core.h`"
2589 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2590 "extern regex_t re;\n"
2591 "extern regoff_t ro;\n"
2592 "extern regmatch_t rm;\n";
2595 fix = {
2596 hackname = osf_namespace_c;
2597 files = regex.h;
2598 test = " -r reg_types.h";
2599 test = " -r sys/lc_core.h";
2600 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
2601 test = " -z \"`grep __regex_t regex.h`\"";
2603 select = "#include <reg_types\.h>.*";
2604 c_fix = format;
2605 c_fix_arg = "%0\n"
2606 "typedef __regex_t\tregex_t;\n"
2607 "typedef __regoff_t\tregoff_t;\n"
2608 "typedef __regmatch_t\tregmatch_t;";
2610 test_text = "#include <reg_types.h>";
2615 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2616 * The original ones fail if uninitialized externs are not common.
2617 * This is the default for all ANSI standard C++ compilers.
2619 fix = {
2620 hackname = pthread_page_size;
2621 files = pthread.h;
2622 select = "^int __page_size";
2623 c_fix = format;
2624 c_fix_arg = "extern %0";
2625 test_text = "int __page_size;";
2629 * On broken glibc-2.3.3 systems an array of incomplete structures is
2630 * passed to __sigsetjmp. Fix that to take a pointer instead.
2632 fix = {
2633 hackname = pthread_incomplete_struct_argument;
2634 files = pthread.h;
2635 select = "struct __jmp_buf_tag";
2636 c_fix = format;
2637 c_fix_arg = "%1 *%2%3";
2638 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2639 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2643 * On DYNIX/ptx, sys/mc_param.h has an embedded asm for the cpuid instruction
2644 * on the P5. This is not used by anything else so we ifdef it out.
2645 * Current GCC doesn't seem to complain about the asm, though.
2647 #ifdef PTX
2648 fix = {
2649 hackname = ptx_sys_mc_param_h;
2650 files = sys/mc_param.h;
2651 sed = "/__asm/,/}/{"
2652 "/__asm/i\\\n"
2653 "#if !defined (__GNUC__) && !defined (__GNUG__)\n"
2654 "/}/a\\\n"
2655 "#endif\n"
2656 "}";
2657 test_text = "__asm\n"
2658 "int _CPUID()\n"
2659 "{\n"
2660 " non-GNU assembly here\n"
2661 "}";
2663 #endif
2667 * Fix return type of fread and fwrite on sysV68
2669 fix = {
2670 hackname = read_ret_type;
2671 files = stdio.h;
2672 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2673 c_fix = format;
2674 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2675 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2677 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2682 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2684 fix = {
2685 hackname = rpc_xdr_lvalue_cast_a;
2686 files = rpc/xdr.h;
2687 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2688 c_fix = format;
2689 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2690 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
2691 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2695 fix = {
2696 hackname = rpc_xdr_lvalue_cast_b;
2697 files = rpc/xdr.h;
2698 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2699 c_fix = format;
2700 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2701 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2702 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2707 * function class(double x) conflicts with C++ keyword on rs/6000
2709 fix = {
2710 hackname = rs6000_double;
2711 files = math.h;
2712 select = '[^a-zA-Z_]class\(';
2714 c_fix = format;
2715 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2716 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2718 test_text = "extern int class();";
2723 * Wrong fchmod prototype on RS/6000.
2725 fix = {
2726 hackname = rs6000_fchmod;
2727 files = sys/stat.h;
2728 select = 'fchmod\(char \*';
2729 c_fix = format;
2730 c_fix_arg = "fchmod(int";
2731 test_text = "extern int fchmod(char *, mode_t);";
2736 * parameters conflict with C++ new on rs/6000
2738 fix = {
2739 hackname = rs6000_param;
2740 files = "stdio.h";
2741 files = "unistd.h";
2743 select = 'rename\(const char \*old, const char \*new\)';
2744 c_fix = format;
2745 c_fix_arg = 'rename(const char *_old, const char *_new)';
2747 test_text = 'extern int rename(const char *old, const char *new);';
2752 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2753 * __builtin_generic. We fix that usage to use the GCC equivalent.
2754 * It also has a plethora of inline functions that conflict with libstdc++.
2756 fix = {
2757 hackname = sco_math;
2758 files = math.h;
2759 files = ansi/math.h;
2760 files = posix/math.h;
2761 files = xpg4/math.h;
2762 files = xpg4v2/math.h;
2763 files = xpg4plus/math.h;
2764 files = ods_30_compat/math.h;
2765 files = oldstyle/math.h;
2766 select = "inline double abs";
2767 bypass = "__GNUG__";
2768 sed = "/#define.*__fp_class(a) \\\\/i\\\n"
2769 "#ifndef __GNUC__\n";
2770 sed =
2771 "/.*__builtin_generic/a\\\n"
2772 "#else\\\n"
2773 "#define __fp_class(a) \\\\\\\n"
2774 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
2775 " __fpclassifyl(a), \\\\\\\n"
2776 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
2777 " __fpclassifyf(a),__fpclassify(a)))\\\n"
2778 "#endif";
2780 sed = "/extern \"C\\+\\+\"/N;"
2781 "/inline double abs/i\\\n"
2782 "#ifndef __GNUC__\n";
2783 sed = "/inline long double trunc/N;"
2784 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
2785 "#endif /* ! __GNUC__ */";
2787 test_text =
2788 "#define __fp_class(a) \\\\\n"
2789 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
2795 * On SCO OpenServer prior to 5.0.7UP1, <sys/regset.h> and <ieeefp.h>
2796 * have a clash on struct _fpstate and struct fpstate.
2798 fix = {
2799 hackname = sco_regset;
2800 files = sys/regset.h;
2801 mach = "*-*-sco3.2v5*";
2802 select = "(struct[ \t]+.*)fpstate";
2803 c_fix = format;
2804 c_fix_arg = "%1rsfpstate";
2806 test_text =
2807 "union u_fps {\n"
2808 " struct\tfpstate\n"
2809 " {\n"
2810 " int whatever;\n"
2811 " }\n"
2812 "};\n"
2813 "union _u_fps {\n"
2814 " struct _fpstate\n"
2815 " {\n"
2816 " int whatever;\n"
2817 " }\n"
2818 "};\n";
2823 * The static functions lstat() and fchmod() in <sys/stat.h>
2824 * cause G++ grief since they're not wrapped in "if __cplusplus".
2826 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
2827 * tiny static wrappers that aren't C++ safe.
2829 fix = {
2830 hackname = sco_static_func;
2831 files = sys/stat.h;
2832 mach = "i?86-*-sco3.2*";
2833 select = "^static int";
2835 sed = "/^static int/i\\\n"
2836 "#if __cplusplus\\\n"
2837 "extern \"C\" {\\\n"
2838 "#endif /* __cplusplus */";
2840 sed = "/^}$/a\\\n"
2841 "#if __cplusplus\\\n"
2842 " }\\\n"
2843 "#endif /* __cplusplus */";
2845 test_text =
2846 "#ifdef __STDC__\n"
2847 "static int\tstat(const char *__f, struct stat *__p) {\n"
2848 "\treturn __stat32(__f, __p);\n"
2849 "}\n\n# else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n"
2851 "static int\tstat(__f, __p)\n"
2852 "\tchar *__f;\n"
2853 "\tstruct stat *__p;\n"
2854 "{\n"
2855 "\treturn __stat32(__f, __p);\n"
2856 "}\n"
2857 "#endif";
2862 * Fix prototype declaration of utime in sys/times.h.
2863 * In 3.2v4.0 the const is missing.
2865 fix = {
2866 hackname = sco_utime;
2867 files = sys/times.h;
2868 mach = "i?86-*-sco3.2v4*";
2870 select = '\(const char \*, struct utimbuf \*\);';
2871 c_fix = format;
2872 c_fix_arg = '(const char *, const struct utimbuf *);';
2874 test_text = "extern int utime(const char *, struct utimbuf *);";
2878 * Sun Solaris 10 defines several C99 math macros in terms of
2879 * builtins specific to the Studio compiler, in particular not
2880 * compatible with the GNU compiler.
2882 fix = {
2883 hackname = solaris_math_1;
2884 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2885 bypass = "__GNUC__";
2886 files = iso/math_c99.h;
2887 c_fix = format;
2888 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
2889 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
2890 test_text =
2891 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2892 "#undef HUGE_VAL\n"
2893 "#define HUGE_VAL __builtin_huge_val\n"
2894 "#undef HUGE_VALF\n"
2895 "#define HUGE_VALF __builtin_huge_valf\n"
2896 "#undef HUGE_VALL\n"
2897 "#define HUGE_VALL __builtin_huge_vall";
2900 fix = {
2901 hackname = solaris_math_2;
2902 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2903 bypass = "__GNUC__";
2904 files = iso/math_c99.h;
2905 c_fix = format;
2906 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
2907 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
2908 test_text =
2909 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2910 "#undef INFINITY\n"
2911 "#define INFINITY __builtin_infinity";
2914 fix = {
2915 hackname = solaris_math_3;
2916 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2917 bypass = "__GNUC__";
2918 files = iso/math_c99.h;
2919 c_fix = format;
2920 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
2921 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
2922 test_text =
2923 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2924 "#undef NAN\n"
2925 "#define NAN __builtin_nan";
2928 fix = {
2929 hackname = solaris_math_4;
2930 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2931 bypass = "__GNUC__";
2932 files = iso/math_c99.h;
2933 c_fix = format;
2934 c_fix_arg = "#define\tfpclassify(x) \\\n"
2935 " __extension__ ({ const __typeof(x) __x_fp = (x); \\\n"
2936 "\t\t isnan(__x_fp) \\\n"
2937 "\t\t ? FP_NAN \\\n"
2938 "\t\t : isinf(__x_fp) \\\n"
2939 "\t\t ? FP_INFINITE \\\n"
2940 "\t\t : isnormal(__x_fp) \\\n"
2941 "\t\t\t ? FP_NORMAL \\\n"
2942 "\t\t\t : __x_fp == 0.0 \\\n"
2943 "\t\t\t ? FP_ZERO \\\n"
2944 "\t\t\t : FP_SUBNORMAL; })";
2945 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
2946 test_text =
2947 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2948 "#undef fpclassify\n"
2949 "#define fpclassify(x) __builtin_fpclassify(x)";
2952 fix = {
2953 hackname = solaris_math_5;
2954 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2955 bypass = "__GNUC__";
2956 files = iso/math_c99.h;
2957 c_fix = format;
2958 c_fix_arg = "#define\tisfinite(x) \\\n"
2959 " __extension__ ({ const __typeof (x) __x_f = (x); \\\n"
2960 "\t\t __builtin_expect(sizeof(__x_f) == sizeof(float) \\\n"
2961 "\t\t\t ? islessequal(__builtin_fabsf(__x_f),__FLT_MAX__) \\\n"
2962 "\t\t\t : sizeof(__x_f) == sizeof(long double) \\\n"
2963 "\t\t\t ? islessequal(__builtin_fabsl(__x_f),__LDBL_MAX__) \\\n"
2964 "\t\t\t : islessequal(__builtin_fabs(__x_f),__DBL_MAX__), 1); })";
2965 c_fix_arg = "^#define[ \t]+isfinite\\(x\\)[ \t]+__builtin_isfinite\\(x\\)";
2966 test_text =
2967 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2968 "#undef isfinite\n"
2969 "#define isfinite(x) __builtin_isfinite(x)";
2972 fix = {
2973 hackname = solaris_math_6;
2974 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2975 bypass = "__GNUC__";
2976 files = iso/math_c99.h;
2977 c_fix = format;
2978 c_fix_arg = "#define\tisinf(x) \\\n"
2979 " __extension__ ({ const __typeof (x) __x_i = (x); \\\n"
2980 "\t\t __builtin_expect(sizeof(__x_i) == sizeof(float) \\\n"
2981 "\t\t\t ? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \\\n"
2982 "\t\t\t : sizeof(__x_i) == sizeof(long double) \\\n"
2983 "\t\t\t ? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__) \\\n"
2984 "\t\t\t : isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0); })";
2985 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__builtin_isinf\\(x\\)";
2986 test_text =
2987 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
2988 "#undef isinf\n"
2989 "#define isinf(x) __builtin_isinf(x)";
2992 fix = {
2993 hackname = solaris_math_7;
2994 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2995 bypass = "__GNUC__";
2996 files = iso/math_c99.h;
2997 c_fix = format;
2998 c_fix_arg = "#define\tisnormal(x) \\\n"
2999 " __extension__ ({ const __typeof(x) __x_n = (x); \\\n"
3000 "\t\t __builtin_expect(isfinite(__x_n) \\\n"
3001 "\t\t\t\t && (sizeof(__x_n) == sizeof(float) \\\n"
3002 "\t\t\t\t\t ? isgreaterequal(__builtin_fabsf(__x_n),__FLT_MIN__) \\\n"
3003 "\t\t\t\t\t : sizeof(__x_n) == sizeof(long double) \\\n"
3004 "\t\t\t\t\t ? isgreaterequal(__builtin_fabsl(__x_n),__LDBL_MIN__) \\\n"
3005 "\t\t\t\t\t : isgreaterequal(__builtin_fabs(__x_n),__DBL_MIN__)), 1); })";
3006 c_fix_arg = "^#define[ \t]+isnormal\\(x\\)[ \t]+__builtin_isnormal\\(x\\)";
3007 test_text =
3008 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3009 "#undef isnormal\n"
3010 "#define isnormal(x) __builtin_isnormal(x)";
3013 fix = {
3014 hackname = solaris_math_8;
3015 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3016 bypass = "__GNUC__";
3017 files = iso/math_c99.h;
3018 c_fix = format;
3019 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3020 "\t\t\t ? __builtin_signbitf(x) \\\n"
3021 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3022 "\t\t\t ? __builtin_signbitl(x) \\\n"
3023 "\t\t\t : __builtin_signbit(x))";
3024 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3025 test_text =
3026 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3027 "#undef signbit\n"
3028 "#define signbit(x) __builtin_signbit(x)";
3031 fix = {
3032 hackname = solaris_math_9;
3033 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3034 bypass = "__GNUC__";
3035 files = iso/math_c99.h;
3036 c_fix = format;
3037 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3038 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3039 test_text =
3040 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3041 "#undef isgreater\n"
3042 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3043 "#undef isgreaterequal\n"
3044 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3045 "#undef isless\n"
3046 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3047 "#undef islessequal\n"
3048 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3049 "#undef islessgreater\n"
3050 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3051 "#undef isunordered\n"
3052 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3056 * Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
3057 * incorrectly, so we replace them with versions that correspond to
3058 * the definition. We also explicitly name this fix "1" and the next
3059 * fix "2" because this one does not deal with the last field. This
3060 * fix needs to run before the next.
3062 fix = {
3063 hackname = solaris_mutex_init_1;
3064 select = '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI";
3065 files = pthread.h;
3066 sed = "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n"
3067 "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/";
3068 test_text =
3069 '#ident "@(#)pthread.h 1.16 97/05/05 SMI"'"\n"
3070 "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n"
3071 "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n";
3076 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3077 * "0" for the last field of the pthread_mutex_t structure, which is
3078 * of type upad64_t, which itself is typedef'd to int64_t, but with
3079 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3080 * initializer to "{0}" instead
3082 fix = {
3083 hackname = solaris_mutex_init_2;
3084 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3085 files = pthread.h;
3087 * On Solaris 10, this fix is unnecessary because upad64_t is
3088 * always defined correctly regardless of the definition of the
3089 * __STDC__ macro. The first "mach" pattern matches up to
3090 * solaris9. The second "mach" pattern will not match any two (or
3091 * more) digit solaris version, but it will match e.g. 2.5.1.
3093 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3094 c_fix = format;
3095 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3096 "%0\n"
3097 "#else\n"
3098 "%1, {0}}%4\n"
3099 "#endif";
3100 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3101 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3102 ",[ \t]*0\\}" "(|[ \t].*)$";
3103 test_text =
3104 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3105 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3106 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3107 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3108 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3109 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3110 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3115 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3116 * fields of the pthread_rwlock_t structure, which are of type
3117 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3118 * defined (e.g. by -ansi) it is a union. So change the initializer
3119 * to "{0}" instead.
3121 fix = {
3122 hackname = solaris_rwlock_init_1;
3123 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3124 files = pthread.h;
3125 mach = '*-*-solaris*';
3126 c_fix = format;
3127 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3128 "%0\n"
3129 "#else\n"
3130 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3131 "#endif";
3132 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3133 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3135 test_text =
3136 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3137 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3142 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3143 * structure. As such, it need two levels of brackets, but only
3144 * contains one. Wrap the macro definition in an extra layer.
3146 fix = {
3147 hackname = solaris_once_init_1;
3148 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3149 files = pthread.h;
3150 mach = '*-*-solaris*';
3151 c_fix = format;
3152 c_fix_arg = "%1{%2}%3";
3153 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3154 test_text =
3155 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3156 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3161 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3162 * fields of the pthread_once_t structure, which are of type
3163 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3164 * defined (e.g. by -ansi) it is a union. So change the initializer
3165 * to "{0}" instead. This test relies on solaris_once_init_1.
3167 fix = {
3168 hackname = solaris_once_init_2;
3169 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3170 files = pthread.h;
3172 * On Solaris 10, this fix is unnecessary because upad64_t is
3173 * always defined correctly regardless of the definition of the
3174 * __STDC__ macro. The first "mach" pattern matches up to
3175 * solaris9. The second "mach" pattern will not match any two (or
3176 * more) digit solaris version, but it will match e.g. 2.5.1.
3178 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3179 c_fix = format;
3180 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3181 "%0\n"
3182 "#else\n"
3183 "%1{0}, {0}, {0}, {%3}%4\n"
3184 "#endif";
3185 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3186 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3187 test_text =
3188 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3189 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3194 * Solaris 2.5.1 and 2.6 use an outdated prototype for send & recv
3195 * in sys/socket.h. This is corrected in Solaris 7 and up.
3197 fix = {
3198 hackname = solaris_socket;
3199 files = sys/socket.h;
3200 select = '@\(#\)socket.h' "[ \t]+1.[123][0-9][ \t]+9[567]/[0-9/]+ SMI";
3201 c_fix = format;
3202 c_fix_arg = "extern int %1(int, %2void *, int, int);";
3203 c_fix_arg = '^extern int (recv|send)\(int,'
3204 ' (const )*char '
3205 '\*, int, int\);';
3207 test_text = '#ident "@(#)socket.h 1.30 97/01/20 SMI"'"\n"
3208 "extern int recv(int, char *, int, int);\n"
3209 "extern int send(int, const char *, int, int);";
3214 * Solaris 2.8 has what appears to be some gross workaround for
3215 * some old version of their c++ compiler. G++ doesn't want it
3216 * either, but doesn't want to be tied to SunPRO version numbers.
3218 fix = {
3219 hackname = solaris_stdio_tag;
3220 files = stdio_tag.h;
3222 select = '__cplusplus < 54321L';
3223 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3224 "!defined(__GNUC__)" so we no longer need to fix it. */
3225 bypass = '__GNUC__';
3226 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3228 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3233 * Sun Solaris 2.5.1 doesn't define 'getpagesize' in <unistd.h>, as is done
3234 * on Solaris 2.6 and up.
3236 fix = {
3237 hackname = solaris_unistd;
3238 files = unistd.h;
3239 select = '@\(#\)unistd.h' "[ \t]+1.3[0-9][ \t]+9[567]/[0-9/]+ SMI";
3240 bypass = "getpagesize";
3241 c_fix = format;
3242 c_fix_arg = "extern int getpagesize();\n%0";
3243 c_fix_arg = '^extern (pid_t|int) getpgid\(.*\);';
3244 test_text = '#ident "@(#)unistd.h 1.33 95/08/28 SMI"'"\n"
3245 "extern pid_t getpgid(pid_t);\n"
3246 "extern int getpgid();";
3251 * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h>
3252 * functions, breaking their prototypes if that file is included afterwards.
3253 * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6
3254 * and up.
3256 fix = {
3257 hackname = solaris_widec;
3258 files = widec.h;
3259 mach = '*-*-solaris2.[0-5]';
3260 mach = '*-*-solaris2.[0-5].*';
3261 bypass = "include.*wchar\\.h";
3262 select = "#include <euc.h>";
3263 c_fix = format;
3264 c_fix_arg = "%0\n#include <wchar.h>";
3265 test_text = "#include <euc.h>";
3270 * a missing semi-colon at the end of the statsswtch structure definition.
3272 fix = {
3273 hackname = statsswtch;
3274 files = rpcsvc/rstat.h;
3275 select = "boottime$";
3276 c_fix = format;
3277 c_fix_arg = "boottime;";
3278 test_text = "struct statswtch {\n int boottime\n};";
3283 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3284 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3285 * OK too.
3287 fix = {
3288 hackname = stdio_stdarg_h;
3289 files = stdio.h;
3290 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3292 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3293 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3295 mach = '*-*-solaris2.1[0-9]*';
3296 not_machine = true;
3298 c_fix = wrap;
3300 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3302 test_text = "";
3307 * Don't use or define the name va_list in stdio.h. This is for
3308 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3309 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3310 * indicate that the header knows what it's doing -- under SUSv2,
3311 * stdio.h is required to define va_list, and we shouldn't break
3312 * that. On IRIX 6.5, internal/wchar_core.h used to get its
3313 * definition of va_list from stdio.h. Since this doesn't happen any
3314 * longer, use __gnuc_va_list there, too.
3316 fix = {
3317 hackname = stdio_va_list;
3318 files = stdio.h;
3319 files = internal/stdio_core.h;
3320 files = internal/wchar_core.h;
3321 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3323 * On Solaris 10, the definition in
3324 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3325 * there is therefore no need for this fix there.
3327 mach = '*-*-solaris2.1[0-9]*';
3328 not_machine = true;
3331 * Use __gnuc_va_list in arg types in place of va_list.
3332 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3333 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3334 * trailing parentheses and semicolon save all other systems from this.
3335 * Define __not_va_list__ (something harmless and unused)
3336 * instead of va_list.
3337 * Don't claim to have defined va_list.
3339 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3340 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3341 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3342 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3343 "s@ va_list@ __not_va_list__@\n"
3344 "s@\\*va_list@*__not_va_list__@\n"
3345 "s@ __va_list)@ __gnuc_va_list)@\n"
3346 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3347 "@typedef \\1 __not_va_list__;@\n"
3348 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3349 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3350 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3351 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3352 "s@VA_LIST@DUMMY_VA_LIST@\n"
3353 "s@_Va_LIST@_VA_LIST@";
3354 test_text = "extern void mumble( va_list);";
3359 * Fix headers that use va_list from stdio.h to use the updated
3360 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3361 * dealt with elsewhere. The presence of __gnuc_va_list,
3362 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3363 * knows what it's doing.
3365 fix = {
3366 hackname = stdio_va_list_clients;
3367 files = com_err.h;
3368 files = cps.h;
3369 files = curses.h;
3370 files = krb5.h;
3371 files = lc_core.h;
3372 files = pfmt.h;
3373 files = wchar.h;
3374 files = curses_colr/curses.h;
3375 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3376 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3377 otherwise protected. */
3378 bypass = 'include <stdarg\.h>|#ifdef va_start';
3381 * Use __gnuc_va_list in arg types in place of va_list.
3382 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3383 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3384 * trailing parentheses and semicolon save all other systems from this.
3385 * Define __not_va_list__ (something harmless and unused)
3386 * instead of va_list.
3387 * Don't claim to have defined va_list.
3389 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3390 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3391 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3392 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3393 "s@ va_list@ __not_va_list__@\n"
3394 "s@\\*va_list@*__not_va_list__@\n"
3395 "s@ __va_list)@ __gnuc_va_list)@\n"
3396 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3397 "@typedef \\1 __not_va_list__;@\n"
3398 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3399 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3400 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3401 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3402 "s@VA_LIST@DUMMY_VA_LIST@\n"
3403 "s@_Va_LIST@_VA_LIST@";
3404 test_text = "extern void mumble( va_list);";
3409 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3410 * is "!defined( __STRICT_ANSI__ )"
3412 fix = {
3413 hackname = strict_ansi_not;
3414 select = "^([ \t]*#[ \t]*if.*)"
3415 "(!__STDC__"
3416 "|__STDC__[ \t]*==[ \t]*0"
3417 "|__STDC__[ \t]*!=[ \t]*1"
3418 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3419 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3420 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3421 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3422 is not defined by GCC, so it is safe. */
3423 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3424 c_test = stdc_0_in_system_headers;
3426 c_fix = format;
3427 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3429 test_text = "#if !__STDC__ \n"
3430 "#if __STDC__ == 0\n"
3431 "#if __STDC__ != 1\n"
3432 "#if __STDC__ - 0 == 0"
3433 "/* not std C */\nint foo;\n"
3434 "\n#end-end-end-end-if :-)";
3438 * "__STDC__-0==0"
3439 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3441 fix = {
3442 hackname = strict_ansi_not_ctd;
3443 files = math.h, limits.h, stdio.h, signal.h,
3444 stdlib.h, sys/signal.h, time.h;
3446 * Starting at the beginning of a line, skip white space and
3447 * a leading "(" or "&&" or "||". One of those must be found.
3448 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3449 * expression. If these are nested, then they must accumulate
3450 * because we won't match any closing parentheses. Finally,
3451 * after skipping over all that, we must then match our suspect
3452 * phrase: "__STDC__-0==0" with or without white space.
3454 select = "^([ \t]*" '(\(|&&|\|\|)'
3455 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3456 "[ \t(]*)"
3457 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3458 c_test = stdc_0_in_system_headers;
3460 c_fix = format;
3461 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3463 test_text = "#if 1 && \\\\\n"
3464 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3465 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3466 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3467 "int foo;\n#endif";
3472 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3473 * is "defined( __STRICT_ANSI__ )"
3475 fix = {
3476 hackname = strict_ansi_only;
3477 select = "^([ \t]*#[ \t]*if.*)"
3478 "(__STDC__[ \t]*!=[ \t]*0"
3479 "|__STDC__[ \t]*==[ \t]*1"
3480 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3481 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3482 c_test = stdc_0_in_system_headers;
3484 c_fix = format;
3485 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3487 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3492 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3493 * in prototype without previous definition.
3495 fix = {
3496 hackname = struct_file;
3497 files = rpc/xdr.h;
3498 select = '^.*xdrstdio_create.*struct __file_s';
3499 c_fix = format;
3500 c_fix_arg = "struct __file_s;\n%0";
3501 test_text = "extern void xdrstdio_create( struct __file_s* );";
3506 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3507 * in prototype without previous definition.
3509 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3510 * function, and does define it.
3512 fix = {
3513 hackname = struct_sockaddr;
3514 files = rpc/auth.h;
3515 select = "^.*authdes_create.*struct sockaddr[^_]";
3516 bypass = "<sys/socket\.h>";
3517 bypass = "struct sockaddr;\n";
3518 c_fix = format;
3519 c_fix_arg = "struct sockaddr;\n%0";
3520 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3525 * Apply fix this to all OSs since this problem seems to effect
3526 * more than just SunOS.
3528 fix = {
3529 hackname = sun_auth_proto;
3530 files = rpc/auth.h;
3531 files = rpc/clnt.h;
3532 files = rpc/svc.h;
3533 files = rpc/xdr.h;
3534 bypass = "__cplusplus";
3536 * Select those files containing '(*name)()'.
3538 select = '\(\*[a-z][a-z_]*\)\(\)';
3540 c_fix = format;
3541 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3542 "#else\n%1();%2\n#endif";
3543 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3545 test_text =
3546 "struct auth_t {\n"
3547 " int (*name)(); /* C++ bad */\n"
3548 "};";
3553 * Fix bogus #ifdef on SunOS 4.1.
3555 fix = {
3556 hackname = sun_bogus_ifdef;
3557 files = "hsfs/hsfs_spec.h";
3558 files = "hsfs/iso_spec.h";
3559 select = '#ifdef(.*\|\|.*)';
3560 c_fix = format;
3561 c_fix_arg = "#if%1";
3563 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3568 * Fix the CAT macro in SunOS memvar.h.
3570 fix = {
3571 hackname = sun_catmacro;
3572 files = pixrect/memvar.h;
3573 select = "^#define[ \t]+CAT\\(a,b\\).*";
3574 c_fix = format;
3576 c_fix_arg =
3577 "#ifdef __STDC__\n"
3578 "# define CAT(a,b) a##b\n"
3579 "#else\n%0\n#endif";
3581 test_text =
3582 "#define CAT(a,b)\ta/**/b";
3587 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3588 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3590 fix = {
3591 hackname = sun_malloc;
3592 files = malloc.h;
3593 bypass = "_CLASSIC_ANSI_TYPES";
3595 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3596 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3597 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3598 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3599 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3601 test_text =
3602 "typedef char *\tmalloc_t;\n"
3603 "int \tfree();\n"
3604 "char*\tmalloc();\n"
3605 "char*\tcalloc();\n"
3606 "char*\trealloc();";
3611 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3613 fix = {
3614 hackname = sun_rusers_semi;
3615 files = rpcsvc/rusers.h;
3616 select = "_cnt$";
3617 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3618 test_text = "struct mumble\n int _cnt\n};";
3623 * signal.h on SunOS defines signal using (),
3624 * which causes trouble when compiling with g++ -pedantic.
3626 fix = {
3627 hackname = sun_signal;
3628 files = sys/signal.h;
3629 files = signal.h;
3630 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
3632 c_fix = format;
3633 c_fix_arg =
3634 "#ifdef __cplusplus\n"
3635 "void\t(*signal(...))(...);\n"
3636 "#else\n%0\n#endif";
3638 test_text = "void\t(*signal())();";
3643 * Correct the return type for strlen in strings.h in SunOS 4.
3645 fix = {
3646 hackname = sunos_strlen;
3647 files = strings.h;
3648 select = "int[ \t]*strlen\\(\\);(.*)";
3649 c_fix = format;
3650 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3651 test_text = " int\tstrlen(); /* string length */";
3656 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3657 * that is visible to any ANSI compiler using this include. Simply
3658 * delete the lines that #define some string functions to internal forms.
3660 fix = {
3661 hackname = svr4_disable_opt;
3662 files = string.h;
3663 select = '#define.*__std_hdr_';
3664 sed = '/#define.*__std_hdr_/d';
3665 test_text = "#define strlen __std_hdr_strlen\n";
3670 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
3671 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
3672 * but we still "hijack" it and redirect it to the GNU byteorder.h..
3674 #ifdef SVR5
3675 fix = {
3676 hackname = svr4_endian;
3677 files = sys/endian.h;
3678 #ifdef LATER
3680 * since we emit our own sys/byteorder.h,
3681 * this fix can never be applied to that file.
3683 files = sys/byteorder.h;
3684 #endif
3685 bypass = '__GNUC__';
3687 sed = "/#\tifdef\t__STDC__/i\\\n"
3688 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
3690 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
3692 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
3693 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
3695 #endif /* SVR5 */
3699 * Remove useless extern keyword from struct forward declarations
3700 * in <sys/stream.h> and <sys/strsubr.h>
3702 #ifdef SVR4
3703 fix = {
3704 hackname = svr4_extern_struct;
3705 files = sys/stream.h;
3706 files = sys/strsubr.h;
3707 select = 'extern struct [a-z_]*;';
3708 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
3710 #endif
3713 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
3714 * systems the file <ftw.h> contains extern declarations of these
3715 * functions followed by explicitly `static' definitions of these
3716 * functions... and that's not allowed according to ANSI C. (Note
3717 * however that on Solaris, this header file glitch has been pre-fixed by
3718 * Sun. In the Solaris version of <ftw.h> there are no static
3719 * definitions of any function so we don't need to do any of this stuff
3720 * when on Solaris.
3722 #ifdef SVR4
3723 #ifndef SOLARIS
3724 fix = {
3725 hackname = svr4_ftw;
3726 files = ftw.h;
3727 select = '^extern int ftw\(const';
3729 sed = '/^extern int ftw(const/i' "\\\n"
3730 "#if !defined(_STYPES)\\\n"
3731 "static\\\n"
3732 "#else\\\n"
3733 "extern\\\n"
3734 "#endif";
3735 sed = 's/extern \(int ftw(const.*\)$/\1/';
3736 sed = "/^extern int nftw/i\\\n"
3737 "#if defined(_STYPES)\\\n"
3738 "static\\\n"
3739 "#else\\\n"
3740 "extern\\\n"
3741 "#endif";
3742 sed = 's/extern \(int nftw.*\)$/\1/';
3743 sed = "/^extern int ftw(),/c\\\n"
3744 "#if !defined(_STYPES)\\\n"
3745 "static\\\n"
3746 "#else\\\n"
3747 "extern\\\n"
3748 "#endif\\\n"
3749 " int ftw();\\\n"
3750 "#if defined(_STYPES)\\\n"
3751 "static\\\n"
3752 "#else\\\n"
3753 "extern\\\n"
3754 "#endif\\\n"
3755 " int nftw();";
3757 #endif
3758 #endif
3762 * Fix broken decl of getcwd present on some svr4 systems.
3764 fix = {
3765 hackname = svr4_getcwd;
3766 files = stdlib.h;
3767 files = unistd.h;
3768 files = prototypes.h;
3769 select = 'getcwd\(char \*, int\)';
3771 c_fix = format;
3772 c_fix_arg = "getcwd(char *, size_t)";
3774 test_text = "extern char* getcwd(char *, int);";
3779 * Wrap some files on System V r4 and DYNIX/ptx systems with
3780 * #ifdef _KERNEL, presumably to prevent kernel headers from
3781 * leaking into userspace. This may not be necessary at all,
3782 * but it was in the old scripts, so it seems safest to keep it for now.
3784 fix = {
3785 /* Can't name this with _kernel, or the test case will hit the bypass! */
3786 hackname = svr4_krnl;
3787 /* Since I'm rather unsure about the validity of this, limit it
3788 * to the specific systems it was operating on before. It should
3789 * also be bypassed for i?86-*-sysv4.3uw2, by that rule, but I didn't
3790 * see an easy way to do that. Hopefully it will be harmless
3791 * in any case. -- Nathanael */
3792 mach = '*-*-sysv4*';
3793 mach = 'i?86-sequent-ptx*';
3794 files = fs/rfs/rf_cache.h;
3795 files = sys/erec.h;
3796 files = sys/err.h;
3797 files = sys/char.h;
3798 files = sys/getpages.h;
3799 files = sys/map.h;
3800 files = sys/cmn_err.h;
3801 files = sys/kdebugger.h;
3803 /* This bypass will match _KERNEL, __KERNEL, __KERNEL__, etc.
3804 * It will also match SVR4_KERNEL_CHECK, which means that the
3805 * testsuite case will always be bypassed. Which is fine with me. */
3806 bypass = '_KERNEL';
3808 c_fix = wrap;
3809 c_fix_arg = "#ifdef _KERNEL\n";
3810 c_fix_arg = "#endif /* _KERNEL */\n";
3812 /* There's no reasonable test for this given that we don't know exactly
3813 * what problem inspired it in the first place. */
3814 test_text = "";
3819 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
3820 * tend to conflict with the compiler's own definition of this symbol. (We
3821 * will use the compiler's definition.)
3822 * Likewise __sparc, for Solaris, and __i860, and a few others
3823 * (guessing it is necessary for all of them).
3825 #ifdef SVR4
3826 fix = {
3827 hackname = svr4_mach_defines;
3828 files = ieeefp.h;
3829 select = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
3830 sed = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
3832 #endif
3836 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
3837 * They are declared as non-static then immediately redeclared as static.
3839 #ifdef SVR5
3840 fix = {
3841 hackname = svr4_mkdev;
3842 files = sys/mkdev.h;
3843 select = '^static';
3845 sed = "/^dev_t makedev(/s/^/static /";
3846 sed = "/^major_t major(/s/^/static /";
3847 sed = "/^minor_t minor(/s/^/static /";
3849 #endif /* SVR5 */
3853 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
3854 * Also fix types of array initializers.
3856 #ifdef SVR4
3857 fix = {
3858 hackname = svr4_netcspace;
3859 files = sys/netcspace.h;
3860 select = 'NC_NPI_RAW';
3861 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
3862 sed = 's/NC_/(unsigned long) NC_/';
3864 #endif
3867 * Fix reference to NMSZ in <sys/adv.h>.
3869 #ifdef SVR4
3870 fix = {
3871 hackname = svr4_nmsz;
3872 files = sys/adv.h;
3873 select = '\[NMSZ\]';
3874 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
3876 #endif
3880 * Some SVR4 systems supposedly use these non-ANSI preprocessor directives.
3882 #ifdef SVR4
3883 fix = {
3884 hackname = svr4_preproc_lint_on;
3885 select = '#lint\(on\)';
3886 c_fix = format;
3887 c_fix_arg = 'defined(lint)';
3888 test_text = "#if #lint(on)";
3890 fix = {
3891 hackname = svr4_preproc_lint_off;
3892 select = '#lint\(off\)';
3893 c_fix = format;
3894 c_fix_arg = '!defined(lint)';
3895 test_text = "#if #lint(off)";
3897 fix = {
3898 hackname = svr4_preproc_machine;
3899 select = '#(machine|system|cpu)\(([^)]*)\)';
3900 c_fix = format;
3901 c_fix_arg = 'defined(__%1__)';
3902 test_text = "#if #machine(i386) || #system(vax) || #cpu(sparc)";
3904 #endif
3908 * Fix broken decl of profil present on some svr4 systems.
3910 fix = {
3911 hackname = svr4_profil;
3912 files = stdlib.h;
3913 files = unistd.h;
3915 select =
3916 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
3917 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
3918 prototype in <sys/profil.h>. */
3919 bypass = 'Silicon Graphics';
3920 c_fix = format;
3921 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
3923 test_text =
3924 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
3929 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
3931 #ifdef SVR4
3932 fix = {
3933 hackname = svr4_proto_form;
3934 files = sys/stat.h;
3935 select = 'const extern';
3937 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
3938 "s/(.*)\\n/( /\n"
3939 "s/;\\n/, /\n"
3940 "s/;$/)/\n" "}";
3942 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
3943 "s/(.*)\\n/( /\n"
3944 "s/;\\n/, /\n"
3945 "s/;$/)/\n" "}";
3947 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
3948 "s/(.*)\\n/( /\n"
3949 "s/;\\n/, /\n"
3950 "s/;$/)/\n" "}";
3952 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
3953 "s/(.*)\\n/( /\n"
3954 "s/;\\n/, /g\n"
3955 "s/;$/)/\n" "}";
3957 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
3958 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
3959 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
3960 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
3961 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
3962 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
3964 #endif
3967 * Add a prototyped declaration of mmap to <sys/mman.h>.
3969 #ifdef SVR4
3970 fix = {
3971 hackname = svr4_proto_mmap;
3972 files = sys/mman.h;
3973 select = '^extern caddr_t mmap();$';
3974 sed = '/^extern caddr_t mmap();$/c' "\\\n"
3975 "#ifdef __STDC__\\\n"
3976 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
3977 "#else /* !defined(__STDC__) */\\\n"
3978 "extern caddr_t mmap ();\\\n"
3979 "#endif /* !defined(__STDC__) */\\\n";
3981 #endif
3984 * Add a #define of _SIGACTION_ into <sys/signal.h>.
3986 #ifdef SVR4
3987 fix = {
3988 hackname = svr4_sigaction;
3989 files = sys/signal.h;
3990 sed = "/^struct sigaction {/i\\\n"
3991 "#define _SIGACTION_";
3992 sed = 's/(void *(\*)())/(void (*)(int))/';
3994 #endif
3998 * Correct types for signal handler constants like SIG_DFL; they might be
3999 * void (*) (), and should be void (*) (int). C++ doesn't like the
4000 * old style.
4002 fix = {
4003 hackname = svr4_sighandler_type;
4004 files = sys/signal.h;
4005 select = 'void *\(\*\)\(\)';
4006 c_fix = format;
4007 c_fix_arg = "void (*)(int)";
4008 test_text = "#define SIG_DFL (void(*)())0\n"
4009 "#define SIG_IGN (void (*)())0\n";
4013 * Put storage class at start of decl, to avoid warning.
4015 #ifdef SVR4
4016 fix = {
4017 hackname = svr4_storage_class;
4018 files = rpc/types.h;
4019 select = 'const extern';
4020 sed = 's/const extern/extern const/g';
4022 #endif
4026 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4027 * function 'getrnge' in <regexp.h> before they declare it. For these
4028 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4029 * early on.
4031 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4032 * so put the declaration right after the declaration of 'size'.
4034 * Don't do this if there is already a `static void getrnge' declaration
4035 * present, since this would cause a redeclaration error. Solaris 2.x has
4036 * such a declaration.
4038 fix = {
4039 hackname = svr4_undeclared_getrnge;
4040 files = regexp.h;
4041 select = "getrnge";
4042 bypass = "static void getrnge";
4043 c_fix = format;
4044 c_fix_arg = "%0\n"
4045 "static int getrnge ();";
4046 c_fix_arg = "^static int[ \t]+size;";
4047 test_text = "static int size;\n"
4048 "/* stuff which calls getrnge() */\n"
4049 "static getrnge()\n"
4050 "{}";
4055 * Like svr4_mach_defines, but with newfangled syntax.
4056 * Source lines are of #define __i386 #machine(i386). Delete them.
4058 #ifdef SVR5
4059 fix = {
4060 hackname = svr5_mach_defines;
4061 files = ieeefp.h;
4062 select = "#define[ \t]*__i386.*\(i386\)";
4063 sed = "/#define[ \t]*__i386.*/d";
4065 #endif /* SVR5 */
4069 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4070 * in string.h on sysV68
4071 * Correct the return type for strlen in string.h on Lynx.
4072 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4073 * Add missing const for strdup on OSF/1 V3.0.
4074 * On sysV88 layout is slightly different.
4076 fix = {
4077 hackname = sysv68_string;
4078 files = testing.h;
4079 files = string.h;
4080 bypass = "_CLASSIC_ANSI_TYPES";
4082 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4083 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4084 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4086 sed = "/^extern char$/N";
4087 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4089 sed = "/^extern int$/N";
4090 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4092 sed = "/^\tstrncmp(),$/N";
4093 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4094 '\1;' "\\\nextern unsigned int\\\n\\2/";
4096 test_text =
4097 "extern int strlen();\n"
4099 "extern int ffs(long);\n"
4101 "extern char\n"
4102 "\t*memccpy(),\n"
4103 "\tmemcpy();\n"
4105 "extern int\n"
4106 "\tstrcmp(),\n"
4107 "\tstrncmp(),\n"
4108 "\tstrlen(),\n"
4109 "\tstrspn();\n"
4111 "extern int\n"
4112 "\tstrlen(), strspn();";
4117 * Fix return type of calloc, malloc, realloc, bsearch and exit
4119 fix = {
4120 hackname = sysz_stdlib_for_sun;
4121 files = stdlib.h;
4122 bypass = "_CLASSIC_ANSI_TYPES";
4124 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4125 c_fix = format;
4126 c_fix_arg = "void *\t%1(";
4128 test_text =
4129 "extern char*\tcalloc(size_t);\n"
4130 "extern char*\tmalloc(size_t);\n"
4131 "extern char*\trealloc(void*,size_t);\n"
4132 "extern char*\tbsearch(void*,size_t,size_t);\n";
4137 * __thread is now a keyword.
4139 fix = {
4140 hackname = thread_keyword;
4141 files = "pthread.h";
4142 files = "bits/sigthread.h";
4143 select = "([* ])__thread([,)])";
4144 c_fix = format;
4145 c_fix_arg = "%1__thr%2";
4147 test_text =
4148 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4149 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4150 "extern int pthread_cancel (pthread_t __thread);";
4154 * if the #if says _cplusplus, not the double underscore __cplusplus
4155 * that it should be
4157 fix = {
4158 hackname = tinfo_cplusplus;
4159 files = tinfo.h;
4160 select = "[ \t]_cplusplus";
4162 c_fix = format;
4163 c_fix_arg = " __cplusplus";
4164 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4169 * function parameter to atexit is missing "void" on VAX Ultrix 4.3.
4171 fix = {
4172 hackname = ultrix_atexit_param;
4173 files = stdlib.h;
4174 select = 'atexit\(.*\(\)';
4176 c_fix = format;
4177 c_fix_arg = "atexit( void (*__func)( void )";
4179 test_text = "int atexit( void (*__func)() );\n";
4184 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
4186 fix = {
4187 hackname = ultrix_atof_param;
4188 files = math.h;
4189 select = "atof\\([ \t]*char";
4191 c_fix = format;
4192 c_fix_arg = "atof(const char";
4194 test_text = "extern double atof( char *__nptr);\n";
4199 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4201 fix = {
4202 hackname = ultrix_const;
4203 files = stdio.h;
4204 select = 'perror\( char \*';
4206 c_fix = format;
4207 c_fix_arg = "%1 const %3 *__";
4208 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4209 "[ \t]+(char|void) \\*__";
4211 test_text =
4212 "extern void perror( char *__s );\n"
4213 "extern int fputs( char *__s, FILE *);\n"
4214 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4215 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4216 "extern int scanf( char *__format, ...);\n";
4221 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4223 fix = {
4224 hackname = ultrix_const2;
4225 files = stdio.h;
4227 select = '\*fopen\( char \*';
4228 c_fix = format;
4229 c_fix_arg = "%1( const char *%3, const char *";
4230 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4231 "[ \t]*char[ \t]*\\*([^,]*),"
4232 "[ \t]*char[ \t]*\\*[ \t]*";
4234 test_text =
4235 "extern FILE *fopen( char *__filename, char *__type );\n"
4236 "extern int sscanf( char *__s, char *__format, ...);\n"
4237 "extern FILE *popen(char *, char *);\n"
4238 "extern char *tempnam(char*,char*);\n";
4243 * parameters not const on Ultrix V4.3.
4245 fix = {
4246 hackname = ultrix_const3;
4247 files = stdio.h;
4248 select = 'fdopen\( .*, char \*';
4250 c_fix = format;
4251 c_fix_arg = "%1 const %3 *__";
4252 c_fix_arg = "([ \t*](fdopen)\\(.*)"
4253 "[ \t]+(char|void) \\*__";
4255 test_text =
4256 "extern FILE * fdopen( int __filedes, char *__type );\n";
4261 * Ultrix V4.[35] puts the declaration of uname before the definition
4262 * of struct utsname, so the prototype (added by fixproto) causes havoc.
4264 fix = {
4265 hackname = ultrix_fix_fixproto;
4266 files = sys/utsname.h;
4267 select = ULTRIX;
4269 c_fix = format;
4270 c_fix_arg = "struct utsname;\n%0";
4271 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
4273 test_text =
4274 "/* ULTRIX's uname */\nextern\tint\tuname();";
4279 * Check for bad #ifdef line (in Ultrix 4.1)
4281 fix = {
4282 hackname = ultrix_ifdef;
4283 select = "^#ifdef KERNEL[ \t]+&&";
4284 files = sys/file.h;
4286 c_fix = format;
4287 c_fix_arg = "#if defined(KERNEL) &&";
4289 test_text =
4290 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
4295 * Add once-only latch to Ultrix V4.3 locale.h.
4297 fix = {
4298 hackname = ultrix_locale;
4299 files = locale.h;
4300 select = "@\\(#\\)locale\\.h.*6\\.1.*\\(ULTRIX\\)";
4301 c_fix = wrap;
4302 test_text =
4303 "@(#)locale.h 6.1 (ULTRIX)\n";
4308 * Strip "|| CC$gfloat" from Ultrix math headers.
4310 fix = {
4311 hackname = ultrix_math_ifdef;
4312 files = sys/limits.h;
4313 files = float.h;
4314 files = math.h;
4315 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
4316 c_fix = format;
4317 c_fix_arg = "%1";
4319 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
4324 * Avoid nested comments on Ultrix 4.3.
4326 fix = {
4327 hackname = ultrix_nested_ioctl;
4328 files = sys/ioctl.h;
4329 select = "^/\\* #define SIOCSCREEN";
4330 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
4331 test_text =
4332 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
4333 "/* screend, net/gw_screen.h */\n";
4337 fix = {
4338 hackname = ultrix_nested_svc;
4339 files = rpc/svc.h;
4340 select = "^ \\*[ \t]*int protocol; */\\*";
4341 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
4342 test_text =
4343 " *\tint protocol; /* like TCP or UDP\n";
4348 * Add missing prototype for lstat and define for S_ISLNK
4349 * in Ultrix V4.3 sys/stat.h.
4351 fix = {
4352 hackname = ultrix_stat;
4353 files = sys/stat.h;
4354 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
4355 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
4356 "\\\n"
4357 "/* macro to test for symbolic link */\\\n"
4358 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
4359 "\n";
4360 sed = "/^[ \t]*fstat(),$/a\\\n"
4361 "\tlstat(),\n";
4362 test_text =
4363 "@(#)stat.h 6.1 (ULTRIX)\n"
4364 "#define S_IFPORT S_IFIFO\n"
4365 "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */";
4370 * Check for superfluous `static' (in Ultrix 4.2)
4371 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
4373 fix = {
4374 hackname = ultrix_static;
4375 files = machine/cpu.h;
4376 select = '#include "r[34]_cpu';
4377 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
4378 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
4379 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
4380 test_text =
4381 "static struct tlb_pid_state {\n"
4382 "#include \"r3_cpu.h\"\n";
4387 * Add missing declarations to Ultrix V4.3 stdlib.h.
4389 fix = {
4390 hackname = ultrix_stdlib;
4391 files = stdlib.h;
4392 select = "@\\(#\\)stdlib\\.h.*6\\.1.*\\(ULTRIX\\)";
4394 sed = "/^char.*getenv( const char .* );.*$/a\\\n"
4395 "int\t\tsetenv( const char *__name, const char *__val, int __ovrwrt );\\\n"
4396 "void\t\tunsetenv( const char *__name );\\\n"
4397 "int\t\tputenv( char *__s );\n";
4399 sed = "/^char.*getenv();.*$/a\\\n"
4400 "int\tsetenv();\\\n"
4401 "void\tunsetenv();\\\n"
4402 "int\tputenv();\n";
4404 test_text =
4405 "@(#)stdlib.h 6.1 (ULTRIX)\n"
4406 "char * getenv( const char *__name );\n"
4407 "char *getenv();\n";
4412 * Add once-only latch to Ultrix V4.3 strings.h.
4414 fix = {
4415 hackname = ultrix_strings;
4416 files = strings.h;
4417 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
4418 c_fix = wrap;
4419 test_text =
4420 "@(#)strings.h 6.1 (ULTRIX)\n";
4425 * Add missing declarations to Ultrix V4.3 strings.h.
4427 fix = {
4428 hackname = ultrix_strings2;
4429 files = strings.h;
4430 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
4432 sed = "/^.*strncmp( const .* );.*/a\\\n"
4433 "\\\n"
4434 "extern int\\\n"
4435 "\tstrcasecmp( const char *__s1, const char *__s2),\\\n"
4436 "\tstrncasecmp( const char *__s1, const char *__s2, size_t __n );\n";
4438 sed = "/^.*strncmp();.*/a\\\n"
4439 "extern int\\\n"
4440 "\tstrcasecmp(),\\\n"
4441 "\tstrncasecmp();\n";
4443 test_text =
4444 "@(#)strings.h 6.1 (ULTRIX)\n"
4445 "\tstrncmp( const char *__s1, const char *__s2, size_t __n );\n"
4446 "\tstrncmp();\n";
4451 * Add missing declarations to Ultrix V4.3 sys/time.h.
4453 fix = {
4454 hackname = ultrix_sys_time;
4455 files = sys/time.h;
4456 select = "@\\(#\\)time\\.h.*6\\.1.*\\(ULTRIX\\)";
4458 sed = "/^extern.*time_t.*time( time_t .* );.*$/a\\\n"
4459 "\\\n"
4460 "extern int adjtime(struct timeval *, struct timeval *);\\\n"
4461 "extern int getitimer(int, struct itimerval *);\\\n"
4462 "extern int setitimer(int, struct itimerval *, struct itimerval *);\\\n"
4463 "extern int gettimeofday(struct timeval *, struct timezone *);\\\n"
4464 "extern int settimeofday(struct timeval *, struct timezone *);\\\n"
4465 "extern void profil(const void *, size_t, size_t, unsigned int);\\\n"
4466 "extern int stime(const time_t *);\\\n"
4467 "extern int utimes(const char *, const struct timeval[2]);\\\n"
4468 "extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);\n";
4470 sed = "/^extern.*double.*difftime();.*$/a\\\n"
4471 "extern\tint adjtime();\\\n"
4472 "extern\tint getitimer();\\\n"
4473 "extern\tint setitimer();\\\n"
4474 "extern\tint gettimeofday();\\\n"
4475 "extern\tint settimeofday();\\\n"
4476 "extern\tvoid profil();\\\n"
4477 "extern\tint stime();\\\n"
4478 "extern\tint utimes();\\\n"
4479 "extern\tint select();\n";
4481 test_text =
4482 "@(#)time.h 6.1 (ULTRIX)\n"
4483 "extern time_t time( time_t *__tloc );\n"
4484 "extern double difftime();\n";
4489 * Add missing declarations to Ultrix V4.3 unistd.h.
4491 fix = {
4492 hackname = ultrix_unistd;
4493 files = unistd.h;
4494 select = "@\\(#\\)unistd\\.h.*6\\.1.*\\(ULTRIX\\)";
4496 sed = "/^[ \t]*getgroups(),.*$/a\\\n"
4497 "\tgetpagesize(),\n";
4499 sed = "/^[ \t]*fork(),.*$/a\\\n"
4500 "\tvfork(),\n";
4502 test_text =
4503 "@(#)unistd.h 6.1 (ULTRIX)\n"
4504 "\tgetgroups(),\n"
4505 "\tfork(),\n";
4510 * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict"
4511 * which must be replaced by __restrict__ for GCC.
4513 fix = {
4514 hackname = unicosmk_restrict;
4515 files = stdio.h;
4516 files = stdlib.h;
4517 files = wchar.h;
4518 mach = "*-*-unicosmk*";
4519 select = "(\\*[ \t]*)restrict([ \t]+)";
4521 c_fix = format;
4522 c_fix_arg = "%1__restrict__%2";
4524 test_text = "void f (char * restrict x);";
4528 * If arpa/inet.h prototypes are incompatible with the ones we just
4529 * installed in <sys/byteorder.h>, just remove the protos.
4530 * Because of this close association, this patch must be applied only
4531 * on those systems where the replacement byteorder header is installed.
4533 fix = {
4534 hackname = uw7_byteorder_fix;
4535 files = arpa/inet.h;
4536 select = "in_port_t";
4537 test = "-f sys/byteorder.h";
4538 #ifndef SVR5
4539 mach = "*-*-sysv4*";
4540 mach = "i?86-*-sysv5*";
4541 mach = "i?86-*-udk*";
4542 mach = "i?86-*-solaris2.[0-4]";
4543 mach = "powerpcle-*-solaris2.[0-4]";
4544 mach = "sparc-*-solaris2.[0-4]";
4545 #endif /* SVR5 */
4547 c_fix = format;
4548 c_fix_arg = "";
4549 c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
4551 test_text = "extern in_port_t\thtons __P((in_port_t));\n"
4552 "extern in_port_t\tntohs __P((in_port_t));"
4553 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
4554 "echo '/* DUMMY */' >> sys/byteorder.h`";
4559 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4561 fix = {
4562 hackname = va_i960_macro;
4563 files = arch/i960/archI960.h;
4564 select = "__(vsiz|vali|vpad|alignof__)";
4566 c_fix = format;
4567 c_fix_arg = "__vx%1";
4569 test_text =
4570 "extern int __vsiz vsiz;\n"
4571 "extern int __vali vali;\n"
4572 "extern int __vpad vpad;\n"
4573 "#define __alignof__(x) ...";
4578 * AIX and Interix headers define NULL to be cast to a void pointer,
4579 * which is illegal in ANSI C++.
4581 fix = {
4582 hackname = void_null;
4583 files = curses.h;
4584 files = dbm.h;
4585 files = locale.h;
4586 files = stdio.h;
4587 files = stdlib.h;
4588 files = string.h;
4589 files = time.h;
4590 files = unistd.h;
4591 files = sys/dir.h;
4592 files = sys/param.h;
4593 files = sys/types.h;
4594 /* avoid changing C++ friendly NULL */
4595 bypass = __cplusplus;
4596 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4597 c_fix = format;
4598 c_fix_arg = "#define NULL 0";
4599 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4604 * Make VxWorks header which is almost gcc ready fully gcc ready.
4606 fix = {
4607 hackname = vxworks_gcc_problem;
4608 files = types/vxTypesBase.h;
4609 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4611 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4612 "#if 1/";
4614 sed = "/[ \t]size_t/i\\\n"
4615 "#ifndef _GCC_SIZE_T\\\n"
4616 "#define _GCC_SIZE_T\n";
4618 sed = "/[ \t]size_t/a\\\n"
4619 "#endif\n";
4621 sed = "/[ \t]ptrdiff_t/i\\\n"
4622 "#ifndef _GCC_PTRDIFF_T\\\n"
4623 "#define _GCC_PTRDIFF_T\n";
4625 sed = "/[ \t]ptrdiff_t/a\\\n"
4626 "#endif\n";
4628 sed = "/[ \t]wchar_t/i\\\n"
4629 "#ifndef _GCC_WCHAR_T\\\n"
4630 "#define _GCC_WCHAR_T\n";
4632 sed = "/[ \t]wchar_t/a\\\n"
4633 "#endif\n";
4635 test_text =
4636 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4637 "typedef unsigned int size_t;\n"
4638 "typedef long ptrdiff_t;\n"
4639 "typedef unsigned short wchar_t;\n"
4640 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4645 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4647 fix = {
4648 hackname = vxworks_needs_vxtypes;
4649 files = time.h;
4650 select = "uint_t([ \t]+_clocks_per_sec)";
4651 c_fix = format;
4652 c_fix_arg = "unsigned int%1";
4653 test_text = "uint_t\t_clocks_per_sec;";
4658 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4660 fix = {
4661 hackname = vxworks_needs_vxworks;
4662 files = sys/stat.h;
4663 test = " -r types/vxTypesOld.h";
4664 test = " -n \"`egrep '#include' $file`\"";
4665 test = " -n \"`egrep ULONG $file`\"";
4666 select = "#[ \t]define[ \t]+__INCstath";
4668 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4669 "#include <types/vxTypesOld.h>\n";
4671 test_text = "`touch types/vxTypesOld.h`"
4672 "#include </dev/null> /* ULONG */\n"
4673 "# define\t__INCstath <sys/stat.h>";
4678 * Another bad dependency in VxWorks 5.2 <time.h>.
4680 fix = {
4681 hackname = vxworks_time;
4682 files = time.h;
4683 test = " -r vxWorks.h";
4685 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4686 c_fix = format;
4688 c_fix_arg =
4689 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4690 "#ifdef __cplusplus\n"
4691 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4692 "#else\n"
4693 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4694 "#endif\n"
4695 "#define __gcc_VOIDFUNCPTR_defined\n"
4696 "#endif\n"
4697 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4699 test_text = "`touch vxWorks.h`"
4700 "#define VOIDFUNCPTR (void(*)())";
4705 * WindISS math.h headers include bogus extern declarations of
4706 * numerous math functions that conflict with libstdc++-v3.
4708 fix = {
4709 hackname = windiss_math1;
4710 files = math.h;
4711 mach = "*-*-windiss";
4712 sed = "s|inline long double cosl.*|#ifndef __GNUC__|";
4714 test_text = "inline long double cosl(long double);";
4717 fix = {
4718 hackname = windiss_math2;
4719 files = math.h;
4720 mach = "*-*-windiss";
4721 sed = "s|/\\* long double declarations \\*/|"
4722 "#endif /* __GNUC__ */|";
4724 test_text = "/* long double declarations */";
4728 * WindISS headers include "diab/va_list.h" instead of "stdarg.h"
4730 fix = {
4731 select = '(#include.*)diab/va_list.h';
4732 hackname = windiss_valist;
4733 sed = "s|diab/va_list.h|stdarg.h|";
4734 mach = "*-*-windiss";
4736 test_text = "#include <diab/va_list.h>";
4740 * There are several name conflicts with C++ reserved words in X11 header
4741 * files. These are fixed in some versions, so don't do the fixes if
4742 * we find __cplusplus in the file. These were found on the RS/6000.
4744 fix = {
4745 hackname = x11_class;
4746 files = X11/ShellP.h;
4747 bypass = __cplusplus;
4748 select = "^([ \t]*char \\*)class;(.*)";
4749 c_fix = format;
4750 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4751 "#else\n%1class;%2\n#endif";
4752 test_text =
4753 "struct {\n"
4754 " char *class;\n"
4755 "} mumble;\n";
4760 * class in Xm/BaseClassI.h
4762 fix = {
4763 hackname = x11_class_usage;
4764 files = Xm/BaseClassI.h;
4765 bypass = "__cplusplus";
4767 select = " class\\)";
4768 c_fix = format;
4769 c_fix_arg = " c_class)";
4771 test_text = "extern mumble (int class);\n";
4776 * new in Xm/Traversal.h
4778 fix = {
4779 hackname = x11_new;
4780 files = Xm/Traversal.h;
4781 bypass = __cplusplus;
4783 sed = "/Widget\told, new;/i\\\n"
4784 "#ifdef __cplusplus\\\n"
4785 "\tWidget\told, c_new;\\\n"
4786 "#else\n";
4788 sed = "/Widget\told, new;/a\\\n"
4789 "#endif\n";
4791 sed = "s/Widget new,/Widget c_new,/g";
4792 test_text =
4793 "struct wedge {\n"
4794 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
4795 "};\nextern Wedged( Widget new, Widget old );";
4800 * Incorrect sprintf declaration in X11/Xmu.h
4802 fix = {
4803 hackname = x11_sprintf;
4804 files = X11/Xmu.h;
4805 files = X11/Xmu/Xmu.h;
4806 select = "^extern char \\*\tsprintf\\(\\);$";
4808 c_fix = format;
4809 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4811 test_text = "extern char *\tsprintf();";
4814 /*EOF*/