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 \
12 trailer
='^/\*EOF\*[/]' \
14 key
='hackname[ ]*=[ ]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes
: */
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g
++
25 * because cstdio udefs everything from stdio.h
, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g
++ and
-D_LARGE_FILES
31 hackname
= AAB_aix_stdio
;
33 select
= "define fopen fopen64";
41 "#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus\n"
42 "#define __need__aix_stdio_h_fix\n"
43 "#ifdef __need__aix_stdio_h_fix\n"
50 "/* Alias the symbols using asm */\n"
52 "extern int fgetpos(FILE *, fpos64_t *) __asm__(\"fgetpos64\");\n"
53 "extern FILE *fopen(const char *, const char *) __asm__(\"fopen64\");\n"
54 "extern FILE *freopen(const char *, const char *, FILE *) __asm__(\"freopen64\");\n"
55 "extern int fseeko(FILE *, off64_t, int) __asm__(\"fseeko64\");\n"
56 "extern int fsetpos(FILE *, const fpos64_t *) __asm__(\"fsetpos64\");\n"
57 "extern off64_t ftello(FILE *) __asm__(\"ftello64\");\n"
66 * On Mac OS
10.3.9, the
'long double' functions are available in
67 * libSystem
, but are not prototyped in math.h.
70 hackname
= AAB_darwin7_9_long_double_funcs
;
71 mach
= "*-*-darwin7.9*";
72 files
= architecture
/ppc
/math.h
;
74 replace
= <<- _EndOfHeader_
75 /* This file prototypes the long double functions available on Mac OS
79 # define __APPLE_CC__
1345
80 # include_next
<architecture
/ppc
/math.h
>
82 # define __APPLE_CC__
1
83 # ifndef __LIBMLDBL_COMPAT
84 # ifdef __LONG_DOUBLE_128__
85 # define
__LIBMLDBL_COMPAT(sym
) __asm("_" #sym
"$LDBL128")
87 # define
__LIBMLDBL_COMPAT(sym
)
88 # endif
/* __LONG_DOUBLE_128__
*/
89 # endif
/* __LIBMLDBL_COMPAT
*/
93 extern long double
acosl( long double
) __LIBMLDBL_COMPAT(acosl
);
94 extern long double
asinl( long double
) __LIBMLDBL_COMPAT(asinl
);
95 extern long double
atanl( long double
) __LIBMLDBL_COMPAT(atanl
);
96 extern long double
atan2l( long double
, long double
) __LIBMLDBL_COMPAT(atan2l
);
97 extern long double
cosl( long double
) __LIBMLDBL_COMPAT(cosl
);
98 extern long double
sinl( long double
) __LIBMLDBL_COMPAT(sinl
);
99 extern long double
tanl( long double
) __LIBMLDBL_COMPAT(tanl
);
100 extern long double
acoshl( long double
) __LIBMLDBL_COMPAT(acoshl
);
101 extern long double
asinhl( long double
) __LIBMLDBL_COMPAT(asinhl
);
102 extern long double
atanhl( long double
) __LIBMLDBL_COMPAT(atanhl
);
103 extern long double
coshl( long double
) __LIBMLDBL_COMPAT(coshl
);
104 extern long double
sinhl( long double
) __LIBMLDBL_COMPAT(sinhl
);
105 extern long double
tanhl( long double
) __LIBMLDBL_COMPAT(tanhl
);
106 extern long double
expl( long double
) __LIBMLDBL_COMPAT(expl
);
107 extern long double
exp2l( long double
) __LIBMLDBL_COMPAT(exp2l
);
108 extern long double
expm1l( long double
) __LIBMLDBL_COMPAT(expm1l
);
109 extern long double
logl( long double
) __LIBMLDBL_COMPAT(logl
);
110 extern long double
log10l( long double
) __LIBMLDBL_COMPAT(log10l
);
111 extern long double
log2l( long double
) __LIBMLDBL_COMPAT(log2l
);
112 extern long double
log1pl( long double
) __LIBMLDBL_COMPAT(log1pl
);
113 extern long double
logbl( long double
) __LIBMLDBL_COMPAT(logbl
);
114 extern long double
modfl( long double
, long double
* ) __LIBMLDBL_COMPAT(modfl
);
115 extern long double
ldexpl( long double
, int
) __LIBMLDBL_COMPAT(ldexpl
);
116 extern long double
frexpl( long double
, int
* ) __LIBMLDBL_COMPAT(frexpl
);
117 extern int
ilogbl( long double
) __LIBMLDBL_COMPAT(ilogbl
);
118 extern long double
scalbnl( long double
, int
) __LIBMLDBL_COMPAT(scalbnl
);
119 extern long double
scalblnl( long double
, long int
) __LIBMLDBL_COMPAT(scalblnl
);
120 extern long double
fabsl( long double
) __LIBMLDBL_COMPAT(fabsl
);
121 extern long double
cbrtl( long double
) __LIBMLDBL_COMPAT(cbrtl
);
122 extern long double
hypotl( long double
, long double
) __LIBMLDBL_COMPAT(hypotl
);
123 extern long double
powl( long double
, long double
) __LIBMLDBL_COMPAT(powl
);
124 extern long double
sqrtl( long double
) __LIBMLDBL_COMPAT(sqrtl
);
125 extern long double
erfl( long double
) __LIBMLDBL_COMPAT(erfl
);
126 extern long double
erfcl( long double
) __LIBMLDBL_COMPAT(erfcl
);
127 extern long double
lgammal( long double
) __LIBMLDBL_COMPAT(lgammal
);
128 extern long double
tgammal( long double
) __LIBMLDBL_COMPAT(tgammal
);
129 extern long double
ceill( long double
) __LIBMLDBL_COMPAT(ceill
);
130 extern long double
floorl( long double
) __LIBMLDBL_COMPAT(floorl
);
131 extern long double
nearbyintl( long double
) __LIBMLDBL_COMPAT(nearbyintl
);
132 extern long double
rintl( long double
) __LIBMLDBL_COMPAT(rintl
);
133 extern long int
lrintl( long double
) __LIBMLDBL_COMPAT(lrintl
);
134 extern long long int
llrintl( long double
) __LIBMLDBL_COMPAT(llrintl
);
135 extern long double
roundl( long double
) __LIBMLDBL_COMPAT(roundl
);
136 extern long int
lroundl( long double
) __LIBMLDBL_COMPAT(lroundl
);
137 extern long long int
llroundl( long double
) __LIBMLDBL_COMPAT(llroundl
);
138 extern long double
truncl( long double
) __LIBMLDBL_COMPAT(truncl
);
139 extern long double
fmodl( long double
, long double
) __LIBMLDBL_COMPAT(fmodl
);
140 extern long double
remainderl( long double
, long double
) __LIBMLDBL_COMPAT(remainderl
);
141 extern long double
remquol( long double
, long double
, int
* ) __LIBMLDBL_COMPAT(remquol
);
142 extern long double
copysignl( long double
, long double
) __LIBMLDBL_COMPAT(copysignl
);
143 extern long double
nanl( const char
* ) __LIBMLDBL_COMPAT(nanl
);
144 extern long double
nextafterl( long double
, long double
) __LIBMLDBL_COMPAT(nextafterl
);
145 extern long double
nexttowardl( long double
, long double
) __LIBMLDBL_COMPAT(nexttowardl
);
146 extern long double
fdiml( long double
, long double
) __LIBMLDBL_COMPAT(fdiml
);
147 extern long double
fmaxl( long double
, long double
) __LIBMLDBL_COMPAT(fmaxl
);
148 extern long double
fminl( long double
, long double
) __LIBMLDBL_COMPAT(fminl
);
149 extern long double
fmal( long double
, long double
, long double
) __LIBMLDBL_COMPAT(fmal
);
153 #endif
/* __MATH__
*/
159 * ... and for the previous fix to be useful
, you have to not use
""
163 hackname
= AAB_darwin7_9_long_double_funcs_2
;
164 mach
= "*-*-darwin7.9*";
166 select
= '#include[ \t]+\"';
168 c_fix_arg
= "%1<%2.h>";
170 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
172 test_text
= '#include "architecture/ppc/math.h"';
177 * This fixes __FD_ZERO bug for linux
2.x.
y (x
<= 2 && y
<= some n
)
180 hackname
= AAB_fd_zero_asm_posix_types_h
;
181 files
= asm
/posix_types.h
;
182 mach
= 'i[34567]86-*-linux*';
185 bypass
= 'posix_types_64';
188 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper
, not
189 * the start
, so that if #include_next gets another instance of
190 * the wrapper
, this will follow the #include_next chain until
191 * we arrive at the real
<asm
/posix_types.h
>.
193 replace
= <<- _EndOfHeader_
194 /* This file fixes a bug in the __FD_ZERO macro
195 for older versions of the Linux kernel.
*/
196 #ifndef _POSIX_TYPES_H_WRAPPER
197 #include
<features.h
>
198 #include_next
<asm
/posix_types.h
>
200 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
202 #define
__FD_ZERO(fdsetp
) \
205 __asm__
__volatile__("cld ; rep ; stosl" \
206 : "=&c" (__d0
), "=&D" (__d1
) \
207 : "a" (0), "0" (__FDSET_LONGS
), \
208 "1" ((__kernel_fd_set *)
(fdsetp
)) :"memory"); \
212 #define _POSIX_TYPES_H_WRAPPER
213 #endif
/* _POSIX_TYPES_H_WRAPPER
*/
219 * This fixes __FD_ZERO bug for glibc
-1.x
222 hackname
= AAB_fd_zero_gnu_types_h
;
224 mach
= 'i[34567]86-*-linux*';
227 * Define _TYPES_H_WRAPPER at the end of the wrapper
, not
228 * the start
, so that if #include_next gets another instance of
229 * the wrapper
, this will follow the #include_next chain until
230 * we arrive at the real
<gnu
/types.h
>.
232 replace
= <<- _EndOfHeader_
233 /* This file fixes a bug in the __FD_ZERO macro present in glibc
1.x.
*/
234 #ifndef _TYPES_H_WRAPPER
235 #include
<features.h
>
236 #include_next
<gnu
/types.h
>
238 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
240 # define
__FD_ZERO(fdsetp
) \
243 __asm__
__volatile__("cld ; rep ; stosl" \
244 : "=&c" (__d0
), "=&D" (__d1
) \
245 : "a" (0), "0" (__FDSET_LONGS
), \
246 "1" ((__fd_set *)
(fdsetp
)) :"memory"); \
250 #define _TYPES_H_WRAPPER
251 #endif
/* _TYPES_H_WRAPPER
*/
257 * This fixes __FD_ZERO bug for glibc
-2.0.x
260 hackname
= AAB_fd_zero_selectbits_h
;
261 files
= selectbits.h
;
262 mach
= 'i[34567]86-*-linux*';
265 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper
, not
266 * the start
, so that if #include_next gets another instance of
267 * the wrapper
, this will follow the #include_next chain until
268 * we arrive at the real
<selectbits.h
>.
270 replace
= <<- _EndOfHeader_
271 /* This file fixes a bug in the __FD_ZERO macro present in glibc
2.0.x.
*/
272 #ifndef _SELECTBITS_H_WRAPPER
273 #include
<features.h
>
274 #include_next
<selectbits.h
>
276 #if
defined(__FD_ZERO
) && defined(__GLIBC__
) \\
277 && defined(__GLIBC_MINOR__
) && __GLIBC__
== 2 \\
278 && __GLIBC_MINOR__
== 0
280 #define
__FD_ZERO(fdsetp
) \\
283 __asm__
__volatile__ ("cld; rep; stosl" \\
284 : "=&c" (__d0
), "=&D" (__d1
) \\
285 : "a" (0), "0" (sizeof (__fd_set
) \\
286 / sizeof (__fd_mask
)), \\
287 "1" ((__fd_mask *)
(fdsetp
)) \\
292 #define _SELECTBITS_H_WRAPPER
293 #endif
/* _SELECTBITS_H_WRAPPER
*/
299 * Solaris
<sys
/varargs.h
> is a
DDK (aka kernel
-land
) header providing
300 * the same interface as
<stdarg.h
>. No idea why they couldn
't have just
301 * used the standard header.
304 hackname = AAB_solaris_sys_varargs_h;
305 files = "sys/varargs.h";
306 mach = '*-*-solaris
*';
307 replace = <<- _EndOfHeader_
318 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
319 * declaration on Sun OS
4.x. We must only fix this on Sun OS
4.x
, because
320 * many other systems have similar text but correct versions of the file.
321 * To ensure only Sun
's is fixed, we grep for a likely unique string.
322 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
325 hackname = AAB_sun_memcpy;
327 select = "/\\*\t@\\(#\\)"
328 "(head/memory.h\t50.1\t "
329 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
331 replace = <<- _EndOfHeader_
332 /* This file was generated by fixincludes */
337 extern void *memccpy();
338 extern void *memchr();
339 extern void *memcpy();
340 extern void *memset();
342 extern char *memccpy();
343 extern char *memchr();
344 extern char *memcpy();
345 extern char *memset();
346 #endif /* __STDC__ */
350 #endif /* __memory_h__ */
356 * Completely replace <sys/varargs.h> with a file that includes gcc's
357 * stdarg.h or varargs.h files as appropriate.
361 hackname
= AAB_svr4_no_varargs
;
362 files
= sys
/varargs.h
;
363 replace
= "/* This file was generated by fixincludes. */\n"
364 "#ifndef _SYS_VARARGS_H\n"
365 "#define _SYS_VARARGS_H\n\n"
368 "#include <stdarg.h>\n"
370 "#include <varargs.h>\n"
373 "#endif /* _SYS_VARARGS_H */\n";
379 * Completely replace
<sys
/byteorder.h
> with a file that implements gcc
's
380 * optimized byteswapping. (The original probably implemented some
381 * incompatible optimized byteswapping.)
384 hackname = AAB_svr4_replace_byteorder;
386 mach = "i[34567]86-*-sysv5*";
387 mach = "i[34567]86-*-sco3.2v5*";
388 mach = "i[34567]86-*-udk*";
389 mach = "i[34567]86-*-solaris2.[0-4]";
390 mach = "powerpcle-*-solaris2.[0-4]";
391 mach = "sparc-*-solaris2.[0-4]";
392 mach = "i[34567]86-sequent-ptx*";
393 files = sys/byteorder.h;
394 replace = <<- _EndOfHeader_
395 #ifndef _SYS_BYTEORDER_H
396 #define _SYS_BYTEORDER_H
398 /* Functions to convert `short' and `long
' quantities from host byte order
399 to (internet) network byte order (i.e. big-endian).
401 Written by Ron Guilmette (rfg@ncd.com).
403 This isn't actually used by GCC. It is installed by fixinc.svr4.
405 For big
-endian machines these functions are essentially no
-ops.
407 For little
-endian machines
, we define the functions using specialized
408 asm sequences in cases where doing so yields better
code (e.g. i386
).
*/
410 #if
!defined (__GNUC__
) && !defined (__GNUG__
)
411 #error You lose
! This file is only useful with GNU compilers.
414 #ifndef __BYTE_ORDER__
415 /* Byte order defines. These are as defined on UnixWare
1.1, but with
416 double underscores added at the front and back.
*/
417 #define __LITTLE_ENDIAN__
1234
418 #define __BIG_ENDIAN__
4321
419 #define __PDP_ENDIAN__
3412
423 static __inline__ unsigned long
htonl (unsigned long
);
424 static __inline__ unsigned short
htons (unsigned int
);
425 static __inline__ unsigned long
ntohl (unsigned long
);
426 static __inline__ unsigned short
ntohs (unsigned int
);
427 #endif
/* defined (__STDC__
) */
429 #if
defined (__i386__
)
431 #ifndef __BYTE_ORDER__
432 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
435 /* Convert a host long to a network long.
*/
437 /* We must use a new
-style function definition
, so that this will also
439 static __inline__ unsigned long
440 htonl (unsigned long __arg
)
442 register unsigned long __result
;
444 __asm__ ("xchg%B0 %b0,%h0
446 xchg%B0 %b0,%h0" : "=q" (__result
) : "0" (__arg
));
450 /* Convert a host short to a network short.
*/
452 static __inline__ unsigned short
453 htons (unsigned int __arg
)
455 register unsigned short __result
;
457 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result
) : "0" (__arg
));
461 #
elif (defined (__ns32k__
) ||
defined (__vax__
) ||
defined (__arm__
))
463 #ifndef __BYTE_ORDER__
464 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
467 /* For other little
-endian machines
, using C code is just as efficient as
468 using assembly code.
*/
470 /* Convert a host long to a network long.
*/
472 static __inline__ unsigned long
473 htonl (unsigned long __arg
)
475 register unsigned long __result
;
477 __result
= (__arg
>> 24) & 0x000000ff;
478 __result |
= (__arg
>> 8) & 0x0000ff00;
479 __result |
= (__arg
<< 8) & 0x00ff0000;
480 __result |
= (__arg
<< 24) & 0xff000000;
484 /* Convert a host short to a network short.
*/
486 static __inline__ unsigned short
487 htons (unsigned int __arg
)
489 register unsigned short __result
;
491 __result
= (__arg
<< 8) & 0xff00;
492 __result |
= (__arg
>> 8) & 0x00ff;
496 #else
/* must be a big
-endian machine
*/
498 #ifndef __BYTE_ORDER__
499 #define __BYTE_ORDER__ __BIG_ENDIAN__
502 /* Convert a host long to a network long.
*/
504 static __inline__ unsigned long
505 htonl (unsigned long __arg
)
510 /* Convert a host short to a network short.
*/
512 static __inline__ unsigned short
513 htons (unsigned int __arg
)
518 #endif
/* big
-endian
*/
520 /* Convert a network long to a host long.
*/
522 static __inline__ unsigned long
523 ntohl (unsigned long __arg
)
525 return
htonl (__arg
);
528 /* Convert a network short to a host short.
*/
530 static __inline__ unsigned short
531 ntohs (unsigned int __arg
)
533 return
htons (__arg
);
541 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
544 hackname
= AAB_ultrix_ansi_compat
;
545 files
= ansi_compat.h
;
547 replace
= "/* This file intentionally left blank. */\n";
552 * The Ultrix
4.3 file limits.h is a symbolic link to sys
/limits.h.
553 * Replace limits.h with a file that includes sys
/limits.h.
556 hackname
= AAB_ultrix_limits
;
558 mach
= "*-*-ultrix4.3";
559 replace
= <<- _EndOfHeader_
560 #ifndef _LIMITS_INCLUDED
561 #define _LIMITS_INCLUDED
562 #include
<sys
/limits.h
>
563 #endif
/* _LIMITS_INCLUDED
*/
569 * The ULTRIX
4.3 version of memory.h duplicates definitions
570 * present in strings.h. Replace memory.h with a file that includes
571 * strings.h to prevent problems from multiple inclusion.
574 hackname
= AAB_ultrix_memory
;
576 mach
= "*-*-ultrix4.3";
577 replace
= <<- _EndOfHeader_
578 #ifndef _MEMORY_INCLUDED
579 #define _MEMORY_INCLUDED
581 #endif
/* _MEMORY_INCLUDED
*/
587 * The Ultrix
4.3 file string.h is a symbolic link to strings.h.
588 * Replace string.h link with a file that includes strings.h to prevent
589 * problems from multiple inclusion.
592 hackname
= AAB_ultrix_string
;
594 mach
= "*-*-ultrix4.3";
595 replace
= <<- _EndOfHeader_
596 #ifndef _STRING_INCLUDED
597 #define _STRING_INCLUDED
599 #endif
/* _STRING_INCLUDED
*/
605 * pthread.h on AIX
4.3.3 tries to define a macro without whitspace
606 * which violates a requirement of ISO C.
609 hackname
= aix_pthread
;
611 select
= "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
614 test_text
= "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
615 "{...init stuff...}";
620 * sys
/machine.h on AIX
4.3.3 puts whitespace between a \ and a newline
621 * in an otherwise
harmless (and #ifed out
) macro definition
624 hackname
= aix_sysmachine
;
625 files
= sys
/machine.h
;
629 test_text
= "#define FOO \\\n"
630 " bar \\ \n baz \\ \n bat";
635 * sys
/wait.h on AIX
3.2.5 puts the declaration of wait3 before the
636 * definition of struct rusage
, so the prototype added by fixproto fails.
639 hackname
= aix_syswait
;
641 select
= "^extern pid_t wait3\\(\\);\n";
644 c_fix_arg
= "struct rusage;\n%0";
645 test_text
= "/* bos325, */\n"
646 "extern pid_t wait3();\n"
647 "\t/* pid_t wait3(int *, int, struct rusage *); */";
652 * sys
/wait.h on AIX
5.2 defines macros that have both signed and
653 * unsigned types in conditional expressions.
656 hackname
= aix_syswait_2
;
658 select
= '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
660 c_fix_arg
= "? (int)%1";
661 test_text
= "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
666 * sys
/signal.h on some versions of AIX uses volatile in the typedef of
667 * sig_atomic_t
, which causes gcc to generate a warning about duplicate
668 * volatile when a sig_atomic_t variable is declared volatile
, as
669 * required by ANSI C.
672 hackname
= aix_volatile
;
673 files
= sys
/signal.h
;
674 select
= "typedef volatile int sig_atomic_t";
676 c_fix_arg
= "typedef int sig_atomic_t";
677 test_text
= "typedef volatile int sig_atomic_t;";
682 * Fix __assert declaration in assert.h on Alpha OSF
/1.
685 hackname
= alpha___assert
;
687 select
= '__assert\(char \*, char \*, int\)';
689 c_fix_arg
= "__assert(const char *, const char *, int)";
690 test_text
= 'extern void __assert(char *, char *, int);';
695 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4
/5 headers.
698 hackname
= alpha___extern_prefix
;
699 select
= "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
700 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
702 mach
= "alpha*-dec-osf*";
704 c_fix_arg
= "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
706 test_text
= "#ifdef __DECC\n"
707 "#pragma extern_prefix \"_P\"\n"
708 "# if defined(__DECC)\n"
709 "# pragma extern_prefix \"_E\"\n"
710 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
711 "# pragma extern_prefix \"\"";
716 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4
/5 <standards.h
>.
719 hackname
= alpha___extern_prefix_standards
;
721 select
= ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
723 mach
= "alpha*-dec-osf*";
725 c_fix_arg
= "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
727 test_text
= "#if (_ISO_C_SOURCE>=19990L) "
728 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
733 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5
<sys
/mount.h
> and
734 * <sys
/stat.h
>. The tests for __DECC are special in various ways
, so
735 * alpha__extern_prefix cannot be used.
738 hackname
= alpha___extern_prefix_sys_stat
;
741 select
= "#[ \t]*if[ \t]*defined\\(__DECC\\)";
743 mach
= "alpha*-dec-osf5*";
745 c_fix_arg
= "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
747 test_text
= "# if defined(__DECC)";
752 * Fix assert macro in assert.h on Alpha OSF
/1.
753 * The superfluous int cast breaks C
++.
756 hackname
= alpha_assert
;
758 select
= '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
760 c_fix_arg
= "%1(EX)";
761 test_text
= '#define assert(EX) (((int) (EX)) ? (void)0 '
762 ': __assert(#EX, __FILE__, __LINE__))';
767 * Fix #defines under Alpha OSF
/1:
768 * The following files contain
'#pragma extern_prefix "_FOO"' followed by
769 * a
'#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
770 * statements is to reduce namespace pollution. While these macros work
771 * properly in most cases
, they don
't allow you to take a pointer to the
772 * "something" being modified. To get around this limitation, change these
773 * statements to be of the form '#define something _FOOsomething
'.
775 * sed ain't egrep
, lesson
2463: sed can use self
-referential
776 * regular expressions. In the substitute expression below
,
777 * "\\1" and
"\\2" refer to subexpressions found earlier in the
778 * same match. So
, we continue to use sed.
"extern_prefix" will
779 * be a rare match anyway...
782 hackname
= alpha_bad_lval
;
784 select
= "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
785 mach
= "alpha*-dec-osf*";
788 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
789 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
791 test_text
= '#pragma extern_prefix "_FOO"'"\n"
792 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
793 "#define mumble _FOOmumble";
798 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF
/1 and AIX.
801 hackname
= alpha_getopt
;
804 select
= 'getopt\(int, char \*\[\], *char \*\)';
806 c_fix_arg
= "getopt(int, char *const[], const char *)";
807 test_text
= 'extern int getopt(int, char *[], char *);';
812 * Remove erroneous parentheses in sym.h on Alpha OSF
/1.
815 hackname
= alpha_parens
;
817 select
= '#ifndef\(__mips64\)';
819 c_fix_arg
= "#ifndef __mips64";
820 test_text
= "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
825 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX
<pthread.h
>.
828 hackname
= alpha_pthread
;
830 select
= "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
831 "|def _PTHREAD_ENV_DECC)(.*))\n"
832 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
834 mach
= "alpha*-dec-osf*";
836 c_fix_arg
= "%2 defined (_PTHREAD_ENV_DECC)%4 "
837 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
839 test_text
= "# if defined (_PTHREAD_ENV_DECC) "
840 "|| defined (_PTHREAD_ENV_EPCC)\n"
841 "# define _PTHREAD_USE_PTDNAM_\n"
843 "# ifdef _PTHREAD_ENV_DECC\n"
844 "# define _PTHREAD_USE_PTDNAM_\n"
850 * Recognize GCC in Tru64 UNIX V5.1B
<pthread.h
>.
853 hackname
= alpha_pthread_gcc
;
855 select
= "#else\n# error <pthread.h>: unrecognized compiler.";
857 mach
= "alpha*-dec-osf*";
859 c_fix_arg
= "#elif defined (__GNUC__)\n"
860 "# define _PTHREAD_ENV_GCC\n"
863 test_text
= "# define _PTHREAD_ENV_INTELC\n"
865 "# error <pthread.h>: unrecognized compiler.\n"
870 * Compaq Tru64 v5.1 defines all of its PTHREAD_
*_INITIALIZER macros
871 * incorrectly
, specifying less fields in the initializers than are
872 * defined in the corresponding structure types. Use of these macros
873 * in user code results in spurious warnings.
876 hackname
= alpha_pthread_init
;
878 select
= ' \* @\(#\).RCSfile: pthread\.h,v \$'
879 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
880 ' .Date: 2000/08/15 15:30:13 \$';
881 mach
= "alpha*-dec-osf*";
882 sed
= "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
883 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
884 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
885 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
886 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
887 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
889 " * @(#)_RCSfile: pthread.h,v \\$ "
890 "_Revision: 1.1.33.21 \\$ (DEC) "
891 "_Date: 2000/08/15 15:30:13 \\$\n"
893 "#ifndef _PTHREAD_NOMETER_STATIC\n"
894 "# define PTHREAD_MUTEX_INITIALIZER \\\n"
895 " {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
896 "# define PTHREAD_COND_INITIALIZER \\\n"
897 " {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}\n"
898 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
899 " {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
900 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
901 " {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
903 "# define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}\n"
904 "# define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \\\n"
905 " {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}\n"
906 "# define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \\\n"
907 " {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}\n"
909 "#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}\n"
910 "#define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \\\n"
911 " {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}\n";
915 * Fix return value of sbrk in unistd.h on Alpha OSF
/1 V2.0
919 hackname
= alpha_sbrk
;
921 select
= "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
923 c_fix_arg
= "void *sbrk(";
924 test_text
= "extern char* sbrk(ptrdiff_t increment);";
929 * Change external names of wcstok
/wcsftime via asm instead of macros on
933 hackname
= alpha_wchar
;
936 mach
= "alpha*-dec-osf4*";
937 select
= "#define wcstok wcstok_r";
938 sed
= "s@#define wcstok wcstok_r@"
939 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
940 "wchar_t **)) __asm__(\"wcstok_r\");@";
941 sed
= "s@#define wcsftime __wcsftime_isoc@"
942 "extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *"
943 ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
944 test_text
= "#define wcstok wcstok_r\n"
945 "#define wcsftime __wcsftime_isoc";
950 * For C
++, avoid any typedef or macro definition of bool
,
951 * and use the built in type instead.
952 * HP
/UX
10.20 also has it in curses_colr
/curses.h.
955 hackname
= avoid_bool_define
;
957 files
= curses_colr
/curses.h
;
961 select
= "#[ \t]*define[ \t]+bool[ \t]";
962 bypass
= "__cplusplus";
965 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
966 c_fix_arg
= "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
968 test_text
= "# define bool\t char \n";
973 hackname
= avoid_bool_type
;
975 files
= curses_colr
/curses.h
;
979 select
= "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
980 bypass
= "__cplusplus";
983 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
985 test_text
= "typedef unsigned int\tbool \t; /* bool\n type */";
990 * For C
++, avoid any typedef definition of wchar_t
,
991 * and use the built in type instead.
992 * Don
't do this for headers that are smart enough to do the right
993 * thing (recent [n]curses.h and Xlib.h).
994 * Don't do it for
<linux
/nls.h
> which is never used from C
++ anyway
,
995 * and will be broken by the edit.
999 hackname
= avoid_wchar_t_type
;
1001 select
= "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1002 bypass
= "__cplusplus";
1003 bypass
= "_LINUX_NLS_H";
1004 bypass
= "XFree86: xc/lib/X11/Xlib\\.h";
1007 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
1009 test_text
= "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1014 * Fix `typedef struct term
;' on hppa1.1-hp-hpux9.
1017 hackname = bad_struct_term;
1019 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1021 c_fix_arg = "struct term;";
1023 test_text = 'typedef struct term
;';
1028 * Fix one other error in this file:
1029 * a mismatched quote not inside a C comment.
1032 hackname = badquote;
1033 files = sundev/vuid_event.h;
1036 c_fix_arg = "does not
";
1038 test_text = "/* doesn
't have matched single quotes */";
1043 * check for broken assert.h that needs stdio.h
1046 hackname = broken_assert_stdio;
1049 bypass = "include.*stdio\\.h";
1051 c_fix_arg = "#include <stdio.h>\n";
1052 test_text = "extern FILE* stderr;";
1057 * check for broken assert.h that needs stdlib.h
1060 hackname = broken_assert_stdlib;
1062 select = 'exit
*\
(|abort
*\
(';
1063 bypass = "include.*stdlib\\.h";
1065 c_fix_arg = "#ifdef __cplusplus\n"
1066 "#include <stdlib.h>\n"
1068 test_text = "extern void exit ( int );";
1073 * Remove `extern double cabs' declarations from math.h.
1074 * This conflicts with C99. Discovered on AIX.
1075 * IRIX
5 and IRIX
6 before
6.5.18 (where C99 support was introduced
)
1076 * declares
cabs() to take a struct __cabs_s argument.
1077 * SunOS4 has its
cabs() declaration followed by a comment which
1078 * terminates on the following line.
1079 * Darwin hides its broken cabs in architecture
-specific subdirs.
1082 hackname
= broken_cabs
;
1083 files
= math.h
, "architecture/*/math.h";
1084 select
= "^extern[ \t]+double[ \t]+cabs";
1086 sed
= "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1087 sed
= "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1089 test_text
= "#ifdef __STDC__\n"
1090 "extern double cabs(struct dbl_hypot);\n"
1092 "extern double cabs();\n"
1094 "extern double cabs ( _Complex z );\n"
1095 "extern double cabs(); /* This is a comment\n"
1096 " and it ends here. */\n"
1097 "extern double cabs(struct __cabs_s);\n"
1098 "extern long double cabsl( struct __cabsl_s );";
1102 * Fixup Darwin
's broken check for __builtin_nanf.
1106 hackname = broken_nan;
1108 * It is tempting to omit the first "files" entry. Do not.
1109 * The testing machinery will take the first "files" entry as the name
1110 * of a test file to play with. It would be a nuisance to have a directory
1111 * with the name "*".
1113 files = "architecture/ppc/math.h";
1114 files = "architecture/*/math.h";
1115 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1118 c_fix_arg = "#if 1";
1119 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1124 * Various systems derived from BSD4.4 contain a macro definition
1125 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
1126 * Known to be fixed in FreeBSD 5 system headers.
1129 hackname = bsd_stdio_attrs_conflict;
1131 mach = "*-*-*darwin*";
1133 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1135 c_fix_arg = '#define
_BSD_STRING(_BSD_X
) _BSD_STRINGX(_BSD_X
)' "\n"
1136 '#define
_BSD_STRINGX(_BSD_X
) #_BSD_X
' "\n"
1137 'int
vfscanf(FILE
*, const char
*, __builtin_va_list
) '
1138 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__
) "__svfscanf");';
1139 test_text = '#define vfscanf __svfscanf
';
1144 * Fix various macros used to define ioctl numbers.
1145 * The traditional syntax was:
1147 * #define _CTRL(n, x) (('n
'<<8)+x)
1148 * #define TCTRLCFOO _CTRL(T, 1)
1150 * but this does not work with the C standard, which disallows macro
1151 * expansion inside strings. We have to rewrite it thus:
1153 * #define _CTRL(n, x) ((n<<8)+x)
1154 * #define TCTRLCFOO _CTRL('T
', 1)
1156 * The select expressions match too much, but the c_fix code is cautious.
1158 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1161 hackname = ctrl_quotes_def;
1162 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1163 c_fix = char_macro_def;
1167 * This is two tests in order to ensure that the "CTRL(c)" can
1168 * be selected in isolation from the multi-arg format
1170 test_text = "#define BSD43_CTRL(n, x) (('n
'<<8)+x)\n";
1171 test_text = "#define _CTRL(c) ('c
'&037)";
1175 hackname = ctrl_quotes_use;
1176 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1177 c_fix = char_macro_use;
1179 test_text = "#define TCTRLFOO
BSD43_CTRL(T
, 1)";
1184 * sys/mman.h on HP/UX is not C++ ready,
1185 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1187 * rpc/types.h on OSF1/2.0 is not C++ ready,
1188 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1190 * The problem is the declaration of malloc.
1193 hackname = cxx_unready;
1195 files = rpc/types.h;
1196 select = '[^#]+malloc.*;'; /* Catch any form of declaration
1197 not within a macro. */
1198 bypass = '"C
"|__BEGIN_DECLS';
1201 c_fix_arg = "#ifdef __cplusplus
\n"
1204 c_fix_arg = "#ifdef __cplusplus
\n"
1207 test_text = "extern void
* malloc( size_t
);";
1212 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1213 * by 'extern "C
"'. On darwin7 some mach/ headers aren't properly guarded.
1216 hackname = darwin_externc;
1217 mach = "*-*-darwin
*";
1218 files = mach-o/swap.h;
1219 files = mach/mach_time.h;
1220 files = mach/mach_traps.h;
1221 files = mach/message.h;
1223 files = mach/semaphore.h;
1224 bypass = "extern
\"C
\"";
1225 bypass = "__BEGIN_DECLS
";
1227 c_fix_arg = "#ifdef __cplusplus
\n"
1230 c_fix_arg = "#ifdef __cplusplus
\n"
1233 test_text = "extern void
swap_fat_header();\n";
1238 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1239 * bad __GNUC__ tests.
1243 hackname = darwin_gcc4_breakage;
1244 mach = "*-*-darwin
*";
1245 files = AvailabilityMacros.h;
1246 select = "\\(__GNUC__
>= 3\\) && \\(__GNUC_MINOR__
>= 1\\)";
1248 c_fix_arg = "((__GNUC__
>= 4) ||
(__GNUC__
== 3 && __GNUC_MINOR__
>= 1))";
1249 test_text = "#if
defined(__GNUC__
) && (__GNUC__
>= 3) && "
1250 "(__GNUC_MINOR__
>= 1)\n";
1255 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1256 * why would you ever put it in a system header file?
1259 hackname = darwin_private_extern;
1260 mach = "*-*-darwin
*";
1261 files = mach-o/dyld.h;
1262 select = "__private_extern__
[a
-z_
]+ _dyld_
";
1264 c_fix_arg = "extern
";
1265 c_fix_arg = "__private_extern__
";
1266 test_text = "__private_extern__ int
_dyld_func_lookup(\n"
1267 "const char
*dyld_func_name
,\n"
1268 "unsigned long
*address
);\n";
1273 * Fix <c_asm.h> on Digital UNIX V4.0:
1274 * It contains a prototype for a DEC C internal asm() function,
1275 * clashing with gcc's asm keyword. So protect this with __DECC.
1278 hackname = dec_intern_asm;
1280 sed = "/^
[ \t]*float
[ \t]*fasm
/i
\\\n#ifdef __DECC
\n";
1281 sed = "/^
[ \t]*#
[ \t]*pragma
[ \t]*intrinsic([ \t]*dasm
/a
\\\n"
1285 " ... asm stuff ...
\n"
1286 "};\n#pragma
intrinsic( dasm
)\n/* END ASM TEST
*/";
1291 * Fix typo in <wchar.h> on DJGPP 2.03.
1294 hackname = djgpp_wchar_h;
1296 select = "__DJ_wint_t
";
1297 bypass = "sys
/djtypes.h
";
1299 c_fix_arg = "%0\n#include
<sys
/djtypes.h
>";
1300 c_fix_arg = "#include
<stddef.h
>";
1301 test_text = "#include
<stddef.h
>\n"
1302 "extern __DJ_wint_t x
;\n";
1307 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1310 hackname = ecd_cursor;
1311 files = "sunwindow
/win_lock.h
";
1312 files = "sunwindow
/win_cursor.h
";
1313 select = 'ecd\.cursor';
1315 c_fix_arg = 'ecd_cursor';
1317 test_text = "#ifdef ecd.cursor
\n#error bogus
\n#endif
/* ecd
+cursor
*/";
1322 * math.h on SunOS 4 puts the declaration of matherr before the definition
1323 * of struct exception, so the prototype (added by fixproto) causes havoc.
1324 * This must appear before the math_exception fix.
1327 hackname = exception_structure;
1330 /* If matherr has a prototype already, the header needs no fix. */
1331 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION|[ \t]*__FP_EXCEPTION[ \t]*\*[ \t]*)';
1335 c_fix_arg = "struct exception
;\n";
1337 test_text = "extern int
matherr();";
1342 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1343 * neither the existence of GCC 3 nor its exact feature set yet break
1344 * (by design?) when __GNUC__ is set beyond 2.
1347 hackname = freebsd_gcc3_breakage;
1348 mach = "*-*-freebsd
*";
1349 files = sys/cdefs.h;
1350 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1351 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1353 c_fix_arg = '%0 || __GNUC__ >= 3';
1354 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1359 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1360 * neither the existence of GCC 4 nor its exact feature set yet break
1361 * (by design?) when __GNUC__ is set beyond 3.
1364 hackname = freebsd_gcc4_breakage;
1365 mach = "*-*-freebsd
*";
1366 files = sys/cdefs.h;
1367 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1369 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1370 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1375 * Some versions of glibc don't expect the C99 inline semantics.
1378 hackname = glibc_c99_inline_1;
1379 files = features.h, '*/features.h';
1380 select = "^
*&& !defined __OPTIMIZE_SIZE__
&& !defined __NO_INLINE__$
";
1382 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__
)";
1384 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1385 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1386 # define __USE_EXTERN_INLINES 1
1393 * Similar, but a version that didn't have __NO_INLINE__
1396 hackname = glibc_c99_inline_1a;
1397 files = features.h, '*/features.h';
1398 select = "(\\) && defined __OPTIMIZE__
&& !defined __OPTIMIZE_SIZE__
)\n"
1399 "(#
[ \t]*define
[ \t]*__USE_EXTERN_INLINES
[ \t]*1)";
1401 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__
)\n%2";
1403 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1404 # define __USE_EXTERN_INLINES 1
1411 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1412 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1413 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1416 hackname = glibc_c99_inline_2;
1417 files = sys/stat.h, '*/sys/stat.h';
1418 select = "extern __inline__ int
";
1419 sed = "s
/extern int
\\(stat
\\|lstat
\\|fstat
\\|mknod
\\)/"
1420 "#ifdef __GNUC_GNU_INLINE__
\\\nextern
\\\n#endif
\\\n"
1421 "__inline__ int
\\1/";
1422 sed = "s
/extern int __REDIRECT
\\(_NTH
\\|
\\) (\\(stat
\\|lstat
\\|fstat
\\)/"
1423 "#ifdef __GNUC_GNU_INLINE__
\\\nextern
\\\n#endif
\\\n"
1424 "__inline__ int __REDIRECT
\\1 (\\2/";
1425 sed = "s
/^extern __inline__ int
/"
1426 "#ifdef __GNUC_GNU_INLINE__
\\\nextern
\\\n#endif
\\\n"
1429 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1430 extern __inline__ int
1431 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1438 hackname = glibc_c99_inline_3;
1439 files = bits/string2.h, '*/bits/string2.h';
1440 select = "extern __inline
";
1441 bypass = "__extern_inline|__GNU_STDC_INLINE__
";
1443 c_fix_arg = "# if
defined(__cplusplus
) ||
defined(__GNUC_STDC_INLINE__
)";
1444 c_fix_arg = "^# ifdef __cplusplus$
";
1447 # define __STRING_INLINE inline
1449 # define __STRING_INLINE extern __inline
1456 hackname = glibc_c99_inline_4;
1457 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1458 bypass = "__extern_inline|__gnu_inline__
";
1459 select = "(^|
)extern __inline
";
1461 c_fix_arg = "%0 __attribute__ ((__gnu_inline__
))";
1463 __extension__ extern __inline unsigned int
1464 extern __inline unsigned int
1469 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1470 * so we replace them with versions that correspond to the
1474 hackname = glibc_mutex_init;
1476 select = '\{ *\{ *0, *\} *\}';
1477 sed = "/define
[ \t]\\+PTHREAD_MUTEX_INITIALIZER
[ \t]*\\\\/,+1"
1478 "s
/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/";
1479 sed = "s
/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_
\\(RECURSIVE
\\|ERRORCHECK
\\|ADAPTIVE
\\)_NP
\\) }/{ \\1, 0 }/";
1480 sed = "s
/{ \\(0, 0, 0, PTHREAD_MUTEX_
\\(RECURSIVE
\\|ERRORCHECK
\\|ADAPTIVE
\\)_NP
\\) }/{ \\1, 0, 0 }/";
1481 sed = "/define
[ \t]\\+PTHREAD_RWLOCK_INITIALIZER
[ \t]*\\\\/"
1482 "N
;s
/^
[ \t]*#
[ \t]*"
1483 "\\(define
[ \t]\\+PTHREAD_RWLOCK_INITIALIZER
[ \t]*\\\\\\)\\n
"
1484 "[ \t]*{ { 0, } }/# if __WORDSIZE
== 64\\n
"
1486 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n
"
1489 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n
"
1491 sed = "s
/{ \\(0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
\\) }/{ \\1, 0 }/";
1492 sed = "/define
[ \t]\\+PTHREAD_COND_INITIALIZER
/"
1493 "s
/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *)
0, 0, 0 } }/";
1495 test_text = <<- _EOText_
1496 #define PTHREAD_MUTEX_INITIALIZER \\
1499 # if __WORDSIZE == 64
1500 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1501 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1502 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1503 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1504 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1505 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1507 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1508 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1509 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1510 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1511 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1512 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1515 # define PTHREAD_RWLOCK_INITIALIZER \\
1518 # if __WORDSIZE == 64
1519 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1520 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1521 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1523 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1524 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1527 #define PTHREAD_COND_INITIALIZER { { 0, } }
1533 * Fix these files to use the types we think they should for
1534 * ptrdiff_t, size_t, and wchar_t.
1536 * This defines the types in terms of macros predefined by our 'cpp'.
1537 * This is supposedly necessary for glibc's handling of these types.
1538 * It's probably not necessary for anyone else, but it doesn't hurt.
1541 hackname = gnu_types;
1542 files = "sys
/types.h
";
1544 files = "sys
/stdtypes.h
";
1548 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1549 select = "^
[ \t]*typedef
[ \t]+.
*[ \t](ptrdiff|size|wchar
)_t
;";
1551 /* The Solaris 10 headers already define these types correctly. */
1552 mach = '*-*-solaris2.1[0-9]*';
1555 test_text = "typedef long int ptrdiff_t
; /* long int
*/\n"
1556 "typedef uint_t size_t
; /* uint_t
*/\n"
1557 "typedef ushort_t wchar_t
; /* ushort_t
*/";
1562 * Fix HP & Sony's use of "..
/machine
/xxx.h
"
1563 * to refer to: <machine/xxx.h>
1566 hackname = hp_inline;
1567 files = sys/spinlock.h;
1568 files = machine/machparam.h;
1569 select = "[ \t]*#
[ \t]*include
[ \t]+" '"\.\.
/machine
/';
1572 c_fix_arg = "%1<machine/%2.h>";
1574 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
1577 test_text = ' # include
"../machine/mumble.h"';
1582 * Check for (...) in C++ code in HP/UX sys/file.h.
1585 hackname = hp_sysfile;
1587 select = "HPUX_SOURCE";
1590 c_fix_arg = "(struct file *, ...)";
1591 c_fix_arg = '\
(\.\.\.\
)';
1593 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1598 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1599 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1602 hackname = hpux10_cpp_pow_inline;
1603 files = fixinc-test-limits.h, math.h;
1604 select = <<- END_POW_INLINE
1605 ^# +ifdef +__cplusplus
1607 +inline +double +pow\(double +__d,int +__expon\) +\{
1608 [ ]+return +pow\(__d,\(double\)__expon\);
1619 "# ifdef __cplusplus\n"
1621 " inline double pow(double __d,int __expon) {\n"
1622 "\t return pow(__d,(double)__expon);\n"
1624 ' extern
"C"' " {\n"
1630 hackname = hpux11_cpp_pow_inline;
1632 select = " +inline double pow\\(double d,int expon\\) \\{\n"
1633 " +return pow\\(d, \\(double\\)expon\\);\n"
1639 " inline double pow(double d,int expon) {\n"
1640 " return pow(d, (double)expon);\n"
1646 hackname = hppa_hpux_fp_macros;
1647 mach = "hppa*-hp-hpux11*";
1649 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1650 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1651 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1652 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1653 "#[ \t]*define[ \t]*FP_NAN.*\n";
1655 c_fix_arg = "#endif /* _INCLUDE_HPUX_SOURCE */\n\n#if defined(_INCLUDE_HPUX_SOURCE) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))\n%0#endif\n\n#ifdef _INCLUDE_HPUX_SOURCE\n";
1658 "# define FP_NORMAL 0\n"
1659 "# define FP_ZERO 1\n"
1660 "# define FP_INFINITE 2\n"
1661 "# define FP_SUBNORMAL 3\n"
1662 "# define FP_NAN 4\n";
1667 * Fix hpux 10.X missing ctype declarations 1
1670 hackname = hpux10_ctype_declarations1;
1672 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1673 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1675 c_fix_arg = "#ifdef _PROTOTYPES\n"
1676 "extern int __tolower(int);\n"
1677 "extern int __toupper(int);\n"
1678 "#else /* NOT _PROTOTYPES */\n"
1679 "extern int __tolower();\n"
1680 "extern int __toupper();\n"
1681 "#endif /* _PROTOTYPES */\n\n"
1684 test_text = "# define _toupper(__c) __toupper(__c)\n";
1689 * Fix hpux 10.X missing ctype declarations 2
1692 hackname = hpux10_ctype_declarations2;
1694 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1695 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1697 c_fix_arg = "%0\n\n"
1698 "#ifdef _PROTOTYPES\n"
1699 " extern int _isalnum(int);\n"
1700 " extern int _isalpha(int);\n"
1701 " extern int _iscntrl(int);\n"
1702 " extern int _isdigit(int);\n"
1703 " extern int _isgraph(int);\n"
1704 " extern int _islower(int);\n"
1705 " extern int _isprint(int);\n"
1706 " extern int _ispunct(int);\n"
1707 " extern int _isspace(int);\n"
1708 " extern int _isupper(int);\n"
1709 " extern int _isxdigit(int);\n"
1710 "# else /* not _PROTOTYPES */\n"
1711 " extern int _isalnum();\n"
1712 " extern int _isalpha();\n"
1713 " extern int _iscntrl();\n"
1714 " extern int _isdigit();\n"
1715 " extern int _isgraph();\n"
1716 " extern int _islower();\n"
1717 " extern int _isprint();\n"
1718 " extern int _ispunct();\n"
1719 " extern int _isspace();\n"
1720 " extern int _isupper();\n"
1721 " extern int _isxdigit();\n"
1722 "#endif /* _PROTOTYPES */\n";
1724 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1725 " extern unsigned int *__SB_masks;\n";
1730 * Fix hpux 10.X missing stdio declarations
1733 hackname = hpux10_stdio_declarations;
1735 select = "^#[ \t]*define _iob[ \t]*__iob";
1736 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
1738 c_fix_arg = "%0\n\n"
1739 "# if defined(__STDC__) || defined(__cplusplus)\n"
1740 " extern int snprintf(char *, size_t, const char *, ...);\n"
1741 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
1742 "# else /* not __STDC__) || __cplusplus */\n"
1743 " extern int snprintf();\n"
1744 " extern int vsnprintf();\n"
1745 "# endif /* __STDC__) || __cplusplus */\n";
1747 test_text = "# define _iob __iob\n";
1752 * Make sure hpux defines abs in header.
1755 hackname = hpux11_abs;
1756 mach = "ia64-hp-hpux11*";
1758 select = "ifndef _MATH_INCLUDED";
1760 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1761 // sed = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1762 test_text = "#ifndef _MATH_INCLUDED";
1767 * Keep HP-UX 11 from stomping on C++ math namespace
1768 * with defines for fabsf.
1771 hackname = hpux11_fabsf;
1773 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1774 bypass = "__cplusplus";
1777 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1781 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1787 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1788 * being defined by having it define _hpux_size_t instead.
1791 hackname = hpux11_size_t;
1792 mach = "*-hp-hpux11*";
1793 select = "__size_t";
1796 c_fix_arg = "_hpux_size_t";
1799 "#define __size_t size_t\n"
1800 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1805 * Fix hpux 11.00 broken snprintf declaration
1806 * (third argument is char *, needs to be const char * to prevent
1807 * spurious warnings with -Wwrite-strings or in C++).
1810 hackname = hpux11_snprintf;
1812 select = '(extern int snprintf
*\
(char
*\
*, *(|__|_hpux_
)size_t
,)'
1813 ' *(char
*\
*, *\.\.\.\
);)';
1815 c_fix_arg = '%1 const
%3';
1817 test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
1818 "extern int snprintf(char *, __size_t, char *, ...);\n"
1819 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
1824 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1825 * of UINT32_C has undefined behavior according to ISO/ANSI:
1826 * the arguments to __CONCAT__ are not macro expanded before the
1827 * concatination happens so the trailing ')' in the first argument
1828 * is concatinated with the 'l
' in the second argument creating an
1829 * invalid pp token. The behavior of invalid pp tokens is undefined.
1830 * GCC does not handle these invalid tokens the way the HP compiler does.
1831 * This problem will potentially occur anytime macros are used in the
1832 * arguments to __CONCAT__. A general solution to this problem would be to
1833 * insert another layer of macro between __CONCAT__ and its use
1834 * in UINT32_C. An example of this solution can be found in the C standard.
1835 * A more specific solution, the one used here, is to change the UINT32_C
1836 * macro to not used macros in the arguments to __CONCAT__.
1839 hackname = hpux11_uint32_c;
1841 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1842 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1844 c_fix_arg = '#define
UINT32_C(__c
) __CONCAT__(__c
,ul
)';
1846 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1847 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1852 * Fix hpux 11.00 broken vsnprintf declaration
1855 hackname = hpux11_vsnprintf;
1857 select = '(extern int vsnprintf\
(char \
*, _
[hpux
]*_size_t
, '
1858 'const char \
*,) __va__list\
);';
1860 c_fix_arg = "%1 __va_list);";
1862 test_text = 'extern int
vsnprintf(char
*, _hpux_size_t
, const char
*,'
1868 * get rid of bogus inline definitions in HP-UX 8.0
1871 hackname = hpux8_bogus_inlines;
1874 bypass = "__GNUG__";
1875 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1876 "@extern \"C\" int abs(int);@";
1877 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1878 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1879 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1880 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1881 "inline double sqr(double v) { return v**0.5; }";
1886 * Fix hpux broken ctype macros
1889 hackname = hpux_ctype_macros;
1891 select = '((: |\
()__SB_masks
\? )'
1892 '(__SB_masks\
[__(alnum|c
)\
] & _IS
)';
1894 c_fix_arg = "%1(int)%3";
1896 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1897 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1902 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1905 hackname = hpux_htonl;
1906 files = netinet/in.h;
1907 select = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1909 " \\* Macros for number representation conversion\\.\n"
1913 c_fix_arg = "#if 1\n%1";
1915 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
1917 " * Macros for number representation conversion.\n"
1920 "#define ntohl(x) (x)\n"
1921 "#define ntohs(x) (x)\n"
1922 "#define htonl(x) (x)\n"
1923 "#define htons(x) (x)\n"
1925 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
1933 hackname = hpux_long_double;
1935 select = "extern[ \t]long_double[ \t]strtold";
1936 bypass = "long_double_t";
1937 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1938 sed = "s/long_double/long double/g";
1940 test_text = "# ifndef _LONG_DOUBLE\n"
1941 "# define _LONG_DOUBLE\n"
1942 " typedef struct {\n"
1943 " unsigned int word1, word2, word3, word4;\n"
1945 "# endif /* _LONG_DOUBLE */\n"
1946 "extern long_double strtold(const char *, char **);\n";
1951 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1954 hackname = hpux_systime;
1956 select = "^extern struct sigevent;";
1959 c_fix_arg = "struct sigevent;";
1961 test_text = 'extern struct sigevent
;';
1966 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1967 * type and mpinfou is only defined when _KERNEL is set.
1970 hackname = hpux_spu_info;
1971 mach = "*-hp-hpux*";
1972 files = ia64/sys/getppdp.h;
1973 select = "^.*extern.*spu_info.*";
1976 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
1978 test_text = "extern union mpinfou spu_info[];";
1982 hackname = hpux11_extern_sendfile;
1983 mach = "*-hp-hpux11.[12]*";
1984 files = sys/socket.h;
1985 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
1987 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1988 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
1992 hackname = hpux11_extern_sendpath;
1993 mach = "*-hp-hpux11.[12]*";
1994 files = sys/socket.h;
1995 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
1997 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
1998 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2002 hackname = hpux_extern_errno;
2003 mach = "*-hp-hpux10.*";
2004 mach = "*-hp-hpux11.[0-2]*";
2006 select = "^[ \t]*extern int errno;$";
2008 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2009 test_text = " extern int errno;\n";
2013 * Fix C99 constant in __POINTER_SET define.
2016 hackname = hpux11_pthread_const;
2017 mach = "*-hp-hpux11.[0-3]*";
2018 files = sys/pthread.h;
2019 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2022 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2023 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2027 * Add missing braces to pthread initializer defines.
2030 hackname = hpux_pthread_initializers;
2031 mach = "*-hp-hpux11.[0-3]*";
2032 files = sys/pthread.h;
2033 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2034 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2035 sed = "s@^[ \t]*1,[ \t]*\\\\"
2037 sed = "/^[ \t]*0$/d";
2038 sed = "s@__PTHREAD_MUTEX_VALID, 0"
2039 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2040 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2041 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2042 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2043 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2044 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2045 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2046 sed = "s@^[ \t]*0, 0[ \t]*\\\\"
2047 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2048 sed = "s@__PTHREAD_COND_VALID, 0"
2049 "@{ __PTHREAD_COND_VALID, 0 }@";
2050 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2051 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2052 sed = "s@__PTHREAD_RWLOCK_VALID, 0"
2053 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2054 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2055 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2056 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2057 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2058 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2059 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2060 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2061 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2062 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2063 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2064 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2069 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2072 hackname = huge_val_hex;
2073 files = bits/huge_val.h;
2074 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2075 bypass = "__builtin_huge_val";
2078 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2080 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2085 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2088 hackname = huge_valf_hex;
2089 files = bits/huge_val.h;
2090 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2091 bypass = "__builtin_huge_valf";
2094 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2096 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2101 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2104 hackname = huge_vall_hex;
2105 files = bits/huge_val.h;
2106 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2107 bypass = "__builtin_huge_vall";
2110 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2112 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2117 * Fix return type of abort and free
2120 hackname = int_abort_free_and_exit;
2122 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2123 bypass = "_CLASSIC_ANSI_TYPES";
2126 c_fix_arg = "void\t%1(";
2128 test_text = "extern int abort(int);\n"
2129 "extern int free(void*);\n"
2130 "extern int exit(void*);";
2135 * Fix various macros used to define ioctl numbers.
2136 * The traditional syntax was:
2138 * #define _IO(n, x) (('n
'<<8)+x)
2139 * #define TIOCFOO _IO(T, 1)
2141 * but this does not work with the C standard, which disallows macro
2142 * expansion inside strings. We have to rewrite it thus:
2144 * #define _IO(n, x) ((n<<8)+x)
2145 * #define TIOCFOO _IO('T
', 1)
2147 * The select expressions match too much, but the c_fix code is cautious.
2149 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2152 hackname = io_quotes_def;
2153 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2154 c_fix = char_macro_def;
2157 "#define BSD43__IOWR(n, x) (('n
'<<8)+x)\n"
2158 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x
'<<8)|y)\n"
2159 "#define _IO(x,y) ('x
'<<8|y)";
2161 "#define XX_IO(x) ('x
'<<8|256)";
2165 hackname = io_quotes_use;
2166 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2168 c_fix = char_macro_use;
2170 test_text = "#define TIOCFOO
BSD43__IOWR(T
, 1)\n"
2171 "#define TIOCFOO
\\\\\n"
2172 "BSD43__IOWR(T
, 1) /* Some are multi
-line
*/";
2177 * Check for missing ';' in struct
2180 hackname = ip_missing_semi;
2181 files = netinet/ip.h;
2183 sed = "/^struct
/,/^
};/s
/}$
/};/";
2189 "}; /* mumbled struct
*/\n";
2194 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
2195 * __restrict as restrict iff __c99. This is wrong for C++, which
2196 * needs many C99 features, but only supports __restrict.
2199 hackname = irix___restrict;
2200 files = internal/sgimacros.h;
2201 select = "(#ifdef __c99
\n)(#
[ \t]*define __restrict restrict
)";
2203 mach = "mips
-sgi
-irix6.5
";
2206 "# ifndef __cplusplus
\n%2\n# endif
";
2208 test_text = "#ifdef __c99
\n# define __restrict restrict
";
2212 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
2213 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
2216 * This was probably introduced around IRIX 6.5.18
2219 hackname = irix___generic1;
2220 files = internal/math_core.h;
2221 mach = "mips
-sgi
-irix6.5
";
2222 select = "#
define ([a
-z
]+)\\(x
\\) *__generic.
*";
2225 c_fix_arg = "extern int
%1(double
);\n"
2226 "extern int
%1f(float
);\n"
2227 "extern int
%1l(long double
);\n"
2228 "#define
%1(x
) (sizeof(x
) == sizeof(double
) ? _
%1(x
) \\\n"
2229 " : sizeof(x
) == sizeof(float
) ? _
%1f(x
) \\\n"
2233 "#define
isnan(x
) __generic(x
,,, _isnan
, _isnanf
, _isnanl
,,,)(x
)\n";
2237 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2238 compiler's __generic intrinsic to define isgreater, isgreaterequal,
2239 isless, islessequal, islessgreater and isunordered functions. */
2241 hackname = irix___generic2;
2242 files = internal/math_core.h;
2243 mach = "mips
-sgi
-irix6.5
";
2244 select = "#
define ([a
-z
]+)\\(x
,y
\\) *__generic.
*";
2247 c_fix_arg = "#define
%1(x
,y
) \\\n"
2248 " ((sizeof(x
)<=4 && sizeof(y
)<=4) ? _
%1f(x
,y
) \\\n"
2249 " : (sizeof(x
)<=8 && sizeof(y
)<=8) ? _
%1(x
,y
) \\\n"
2253 "#define
isless(x
,y
) __generic(x
,y
,, _isless
, _islessf
, _islessl
,,,)(x
,y
)";
2258 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2259 * that causes the assembly preprocessor to complain about an
2260 * unterminated character constant.
2263 hackname = irix_asm_apostrophe;
2266 select = "^
[ \t]*#.
*[Ww
]e
're";
2268 c_fix_arg = "%1 are";
2269 c_fix_arg = "^([ \t]*#.*[Ww]e)'re
";
2270 test_text = "\t# and we
're on vacation";
2275 * Non-traditional "const" declaration in Irix's limits.h.
2278 hackname
= irix_limits_const
;
2279 files
= fixinc
-test
-limits.h
, limits.h
;
2280 select
= "^extern const ";
2282 c_fix_arg
= "extern __const ";
2283 test_text
= "extern const char limit; /* test limits */";
2288 * IRIX
6.5.1[78] <sys
/socket.h
> has a broken definition of socklen_t.
2289 * Various socket function prototypes use different types instead
,
2290 * depending on the API in
use (BSD
, XPG4
/5), but the socklen_t
2291 * definition doesn
't reflect this (SGI Bug Id 864477, fixed in
2295 hackname = irix_socklen_t;
2296 files = sys/socket.h;
2297 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2299 mach = "mips-sgi-irix6.5";
2302 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2303 "typedef int socklen_t;\n"
2306 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2308 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2312 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2316 hackname = irix_stdint_c99;
2318 select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
2320 mach = "mips-sgi-irix6.5";
2322 c_fix_arg = "#if 0\n"
2325 "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
2330 * IRIX 5.x's stdio.h and IRIX
6.5's internal/stdio_core.h declare
2331 * some functions that take a va_list as
2332 * taking char *. However, GCC uses void * for va_list, so
2333 * calling vfprintf with a va_list fails in C++. */
2335 hackname = irix_stdio_va_list;
2337 files = internal/stdio_core.h;
2339 select = '/\
* va_list \
*/ char \
*';
2341 c_fix_arg = "__gnuc_va_list";
2343 "extern int printf( const char *, /* va_list */ char * );";
2348 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2349 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2352 hackname = irix_wcsftime;
2353 files = internal/wchar_core.h;
2354 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2356 mach = "mips-sgi-irix6.5";
2358 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2360 test_text = "#if _NO_XOPEN5\n"
2361 "extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
2365 * Fixing ISC fmod declaration
2368 hackname = isc_fmod;
2370 select = 'fmod\
(double\
)';
2372 c_fix_arg = "fmod(double, double)";
2373 test_text = "extern double fmod(double);";
2378 * On Interactive Unix 2.2, certain traditional Unix definitions
2379 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
2380 * defined, not just if _POSIX_SOURCE is defined. This makes it
2381 * impossible to compile any nontrivial program except with -posix.
2384 hackname = isc_omits_with_stdc;
2389 files = "sys/limits.h";
2390 files = "sys/fcntl.h";
2391 files = "sys/dirent.h";
2393 select = '!defined\
(__STDC__\
) && !defined\
(_POSIX_SOURCE\
)';
2395 c_fix_arg = '!defined(_POSIX_SOURCE
)';
2396 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
2397 "\nint foo;\n#endif";
2402 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2403 * use / * * / to concatenate tokens.
2406 hackname = kandr_concat;
2407 files = "sparc/asm_linkage.h";
2408 files = "sun*/asm_linkage.h";
2409 files = "arm/as_support.h";
2410 files = "arm/mc_type.h";
2411 files = "arm/xcb.h";
2412 files = "dev/chardefmac.h";
2413 files = "dev/ps_irq.h";
2414 files = "dev/screen.h";
2415 files = "dev/scsi.h";
2416 files = "sys/tty.h";
2417 files = "Xm.acorn/XmP.h";
2418 files = bsd43/bsd43_.h;
2422 test_text = "#define __CONCAT__(a,b) a/**/b";
2427 * Fix libc1 _G_va_list definition, used in declarations of several
2428 * more-or-less standard functions, for example vasprintf.
2431 hackname = libc1_G_va_list;
2432 files = _G_config.h;
2433 mach = '*-*-linux
*libc1
';
2434 select = 'typedef void \
* _G_va_list
;';
2436 c_fix_arg = "typedef __builtin_va_list _G_va_list;";
2437 test_text = 'typedef void
* _G_va_list
;';
2442 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
2443 * versions > 1. This fix will open up the declaration for all
2444 * versions of GCC and for g++.
2447 hackname = libc1_ifdefd_memx;
2449 /* The string.h result is overwritten by AAB_ultrix_string when doing
2450 "make check" and will fail. Therefore, we add the following kludgery
2451 to insert the test_text into the special testing header. :-} */
2456 select = "' is a built
-in function for gcc
2\\.x
\\.
\\*/";
2457 bypass = __cplusplus;
2460 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
2461 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
2463 "extern
[a
-z_
]+ mem.
*(\n[^#
].*)
*;)\n"
2467 "/* \\`memcpy
' is a built-in function for gcc 2.x. */\n"
2468 "#if defined(__STDC__) && __GNUC__ < 2\n"
2469 "/* Copy N bytes of SRC to DEST. */\n"
2470 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
2476 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2477 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2478 * constant on recent versions of g
++.
2481 hackname
= linux_ia64_ucontext
;
2482 files
= "sys/ucontext.h";
2483 mach
= "ia64-*-linux*";
2484 select
= '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2485 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2487 c_fix_arg
= "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2488 test_text
= "# define _SC_GR0_OFFSET\t\\\\\n"
2489 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2494 * Apparently some SVR4 systems typedef longlong_t to long ?
2498 hackname
= longlong_t
;
2499 select
= "typedef[ \t]+(unsigned[ \t]+)?long[ \t]+(u_)?longlong_t";
2501 c_fix_arg
= "typedef %1long long %2longlong_t";
2502 test_text
= "typedef long longlong_t\n"
2503 "typedef unsigned long u_longlong_t";
2508 * Remove header file warning from sys
/time.h. Autoconf
's
2509 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2510 * which causes warning on LynxOS. Remove the warning.
2513 hackname = lynxos_no_warning_in_sys_time_h;
2515 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2518 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2523 * Add missing declaration for putenv.
2526 hackname = lynxos_missing_putenv;
2527 mach = '*-*-lynxos
*';
2529 bypass = 'putenv
[ \t]*\\(';
2530 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2533 "extern int putenv _AP((char *));";
2534 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2535 test_text = "extern char *getenv _AP((const char *));";
2540 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2542 * On NetBSD, machine is a symbolic link to an architecture specific
2543 * directory name, so we can't match a specific file name here.
2546 hackname
= machine_ansi_h_va_list
;
2547 select
= "define[ \t]+_BSD_VA_LIST_[ \t]";
2548 bypass
= '__builtin_va_list';
2551 c_fix_arg
= "%1__builtin_va_list";
2552 c_fix_arg
= "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2554 test_text
= " # define _BSD_VA_LIST_\tchar**";
2559 * Fix non
-ansi machine name defines
2562 hackname
= machine_name
;
2563 c_test
= machine_name
;
2564 c_fix
= machine_name
;
2566 test_text
= "/* MACH_DIFF: */\n"
2567 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2568 "\n/* no uniform test, so be careful :-) */";
2573 * Some math.h files define struct
exception (it
's in the System V
2574 * Interface Definition), which conflicts with the class exception defined
2575 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2576 * This is not a great fix, but I haven't been able to think of anything
2577 * better. Note that we have to put the #ifdef
/#endif blocks at beginning
2578 * and end of file
, because fixproto runs after us and may insert
2579 * additional references to struct exception.
2582 hackname
= math_exception
;
2584 select
= "struct exception";
2586 * This should be bypassed on __cplusplus
, but some supposedly C
++ C
++
2587 * aware headers
, such as Solaris
8 and
9, don
't wrap their struct
2588 * exception either. So currently we bypass only for glibc, based on a
2589 * comment in the fixed glibc header. Ick.
2591 bypass = 'We have a problem when using C\
+\
+|for C\
+\
+, _
[a
-z0
-9A
-Z_
]+_exception
; for C
, exception
';
2594 c_fix_arg = "#ifdef __cplusplus\n"
2595 "#define exception __math_exception\n"
2598 c_fix_arg = "#ifdef __cplusplus\n"
2599 "#undef exception\n"
2602 test_text = "typedef struct exception t_math_exception;";
2607 * This looks pretty broken to me. ``dbl_max_def'' will contain
2608 * "define DBL_MAX " at the start, when what we really want is just
2609 * the value portion. Can't figure out how to write a test case
2610 * for this either
:-(
2613 hackname
= math_huge_val_from_dbl_max
;
2617 * IF HUGE_VAL is defined to be DBL_MAX
*and
* DBL_MAX is _not_ defined
2618 * in math.h
, this fix applies.
2620 select
= "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2621 bypass
= "define[ \t]+DBL_MAX";
2625 * See if we have a definition for DBL_MAX in float.h.
2626 * If we do
, we will replace the one in math.h with that one.
2629 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2630 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2632 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2633 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2634 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2639 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2640 "#define HUGE_VAL DBL_MAX";
2648 hackname
= nested_auth_des
;
2650 select
= '(/\*.*rpc/auth_des\.h>.*)/\*';
2652 c_fix_arg
= "%1*/ /*";
2653 test_text
= "/*#include <rpc/auth_des.h> /* skip this */";
2658 * Fix nested comments in Motorola
's <limits.h> and <sys/limits.h>
2661 hackname = nested_motorola;
2662 mach = "m68k-motorola-sysv*";
2663 files = sys/limits.h;
2665 select = "max # bytes atomic in write|error value returned by Math lib";
2667 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
2668 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
2669 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
2670 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
2673 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
2675 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
2680 * Fixing nested comments in ISC <sys/limits.h>
2683 hackname = nested_sys_limits;
2684 files = sys/limits.h;
2686 sed = "/CHILD_MAX/s,/\\* Max, Max,";
2687 sed = "/OPEN_MAX/s,/\\* Max, Max,";
2688 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
2689 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
2694 * Some versions of NetBSD don't expect the C99 inline semantics.
2697 hackname
= netbsd_c99_inline_1
;
2698 mach
= "*-*-netbsd*";
2700 select
= "extern __inline int";
2703 c_fix_arg
= "extern\n#ifdef __GNUC_STDC_INLINE__\n__attribute__((__gnu_inline__))\n#endif\n__inline int";
2705 test_text
= "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2710 hackname
= netbsd_c99_inline_2
;
2711 mach
= "*-*-netbsd*";
2713 select
= "#define _SIGINLINE extern __inline";
2716 c_fix_arg
= <<- _EOArg_
2717 #ifdef __GNUC_STDC_INLINE__
2718 #define _SIGINLINE extern
__attribute__((__gnu_inline__
)) __inline
2724 test_text
= "#define _SIGINLINE extern __inline";
2729 * NetBSD has a semicolon after the ending
'}' for some extern
"C".
2732 hackname
= netbsd_extra_semicolon
;
2733 mach
= "*-*-netbsd*";
2734 files
= sys
/cdefs.h
;
2735 select
= "#define[ \t]*__END_DECLS[ \t]*};";
2738 c_fix_arg
= "#define __END_DECLS }";
2740 test_text
= "#define __END_DECLS };";
2745 * NeXT
3.2 adds const prefix to some math functions.
2746 * These conflict with the built
-in functions.
2749 hackname
= next_math_prefix
;
2750 files
= ansi
/math.h
;
2751 select
= "^extern[ \t]+double[ \t]+__const__[ \t]";
2754 c_fix_arg
= "extern double %1(";
2755 c_fix_arg
= "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2757 test_text
= "extern\tdouble\t__const__\tmumble();";
2762 * NeXT
3.2 uses the word
"template" as a parameter for some
2763 * functions. GCC reports an invalid use of a reserved key word
2764 * with the built
-in functions.
2767 hackname
= next_template
;
2769 select
= "[ \t]template\\)";
2773 c_fix_arg
= "\\(([^)]*)[ \t]template\\)";
2774 test_text
= "extern mumble( char * template); /* fix */";
2779 * NeXT
3.2 includes the keyword volatile in the
abort() and
exit()
2780 * function prototypes. That conflicts with the built
-in functions.
2783 hackname
= next_volitile
;
2784 files
= ansi
/stdlib.h
;
2785 select
= "^extern[ \t]+volatile[ \t]+void[ \t]";
2788 c_fix_arg
= "extern void %1(";
2789 c_fix_arg
= "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2791 test_text
= "extern\tvolatile\tvoid\tabort();";
2796 * NeXT
2.0 defines
'int wait(union wait*)', which conflicts with Posix
.1.
2797 * Note that version
3 of the NeXT system has wait.h in a different directory
,
2798 * so that this code won
't do anything. But wait.h in version 3 has a
2799 * conditional, so it doesn't need this fix. So everything is okay.
2802 hackname
= next_wait_union
;
2805 select
= 'wait\(union wait';
2807 c_fix_arg
= "wait(void";
2808 test_text
= "extern pid_d wait(union wait*);";
2813 * a missing semi
-colon at the end of the nodeent structure definition.
2816 hackname
= nodeent_syntax
;
2817 files
= netdnet
/dnetdb.h
;
2818 select
= "char[ \t]*\\*na_addr[ \t]*$";
2821 test_text
= "char *na_addr\t";
2826 * obstack.h used casts as lvalues.
2828 * We need to change postincrements of casted
pointers (which are
2829 * then dereferenced and assigned into
) of the form
2831 * *((TYPE*)PTRVAR
)++ = (VALUE
)
2833 * into expressions like
2835 * ((*((TYPE*)PTRVAR
) = (VALUE
)), (PTRVAR
+= sizeof (TYPE)))
2837 * which is correct for the cases used in obstack.h since PTRVAR is
2838 * of type char
* and the value of the expression is not used.
2841 hackname
= obstack_lvalue_cast
;
2843 select
= '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2845 c_fix_arg
= "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2846 test_text
= "*((void **) (h)->next_free)++ = (aptr)";
2851 * sys
/lc_core.h on some versions of OSF1
/4.x pollutes the namespace by
2852 * defining regex.h related types. This causes libg
++ build and usage
2853 * failures. Fixing this correctly requires checking and modifying
3 files.
2856 hackname
= osf_namespace_a
;
2857 files
= reg_types.h
;
2858 files
= sys
/lc_core.h
;
2859 test
= " -r reg_types.h";
2860 test
= " -r sys/lc_core.h";
2861 test
= " -n \"`grep '} regex_t;' reg_types.h`\"";
2862 test
= " -z \"`grep __regex_t regex.h`\"";
2866 c_fix_arg
= "reg(ex|off|match)_t";
2868 test_text
= "`touch sys/lc_core.h`"
2869 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
2870 "extern regex_t re;\n"
2871 "extern regoff_t ro;\n"
2872 "extern regmatch_t rm;\n";
2876 hackname
= osf_namespace_c
;
2878 test
= " -r reg_types.h";
2879 test
= " -r sys/lc_core.h";
2880 test
= " -n \"`grep '} regex_t;' reg_types.h`\"";
2881 test
= " -z \"`grep __regex_t regex.h`\"";
2883 select
= "#include <reg_types\.h>.*";
2886 "typedef __regex_t\tregex_t;\n"
2887 "typedef __regoff_t\tregoff_t;\n"
2888 "typedef __regmatch_t\tregmatch_t;";
2890 test_text
= "#include <reg_types.h>";
2895 * Fix __page_size
* declarations in pthread.h AIX
4.1.
[34].
2896 * The original ones fail if uninitialized externs are not common.
2897 * This is the default for all ANSI standard C
++ compilers.
2900 hackname
= pthread_page_size
;
2902 select
= "^int __page_size";
2904 c_fix_arg
= "extern %0";
2905 test_text
= "int __page_size;";
2909 * On broken glibc
-2.3.3 systems an array of incomplete structures is
2910 * passed to __sigsetjmp. Fix that to take a pointer instead.
2913 hackname
= pthread_incomplete_struct_argument
;
2915 select
= "struct __jmp_buf_tag";
2917 c_fix_arg
= "%1 *%2%3";
2918 c_fix_arg
= "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
2919 test_text
= "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
2923 * On DYNIX
/ptx
, sys
/mc_param.h has an embedded asm for the cpuid instruction
2924 * on the P5. This is not used by anything else so we ifdef it out.
2925 * Current GCC doesn
't seem to complain about the asm, though.
2929 hackname = ptx_sys_mc_param_h;
2930 files = sys/mc_param.h;
2931 sed = "/__asm/,/}/{"
2933 "#if !defined (__GNUC__) && !defined (__GNUG__)\n"
2937 test_text = "__asm\n"
2940 " non-GNU assembly here\n"
2947 * Fix return type of fread and fwrite on sysV68
2950 hackname = read_ret_type;
2952 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
2954 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
2955 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
2957 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
2962 * Fix casts as lvalues in glibc's
<rpc
/xdr.h
>.
2965 hackname
= rpc_xdr_lvalue_cast_a
;
2967 select
= "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
2969 c_fix_arg
= "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
2970 test_text
= "#define IXDR_GET_LONG(buf) \\\\\n"
2971 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
2976 hackname
= rpc_xdr_lvalue_cast_b
;
2978 select
= "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
2980 c_fix_arg
= "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
2981 test_text
= "#define IXDR_PUT_LONG(buf, v) \\\\\n"
2982 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
2987 * function
class(double x
) conflicts with C
++ keyword on rs
/6000
2990 hackname
= rs6000_double
;
2992 select
= '[^a-zA-Z_]class\(';
2995 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
2996 c_fix_arg
= '^.*[^a-zA-Z_]class\(.*';
2998 test_text
= "extern int class();";
3003 * Wrong fchmod prototype on RS
/6000.
3006 hackname
= rs6000_fchmod
;
3008 select
= 'fchmod\(char \*';
3010 c_fix_arg
= "fchmod(int";
3011 test_text
= "extern int fchmod(char *, mode_t);";
3016 * parameters conflict with C
++ new on rs
/6000
3019 hackname
= rs6000_param
;
3023 select
= 'rename\(const char \*old, const char \*new\)';
3025 c_fix_arg
= 'rename(const char *_old, const char *_new)';
3027 test_text
= 'extern int rename(const char *old, const char *new);';
3032 * On OpenServer and on UnixWare
7, <math.h
> uses the native compiler
3033 * __builtin_generic. We fix that usage to use the GCC equivalent.
3034 * It also has a plethora of inline functions that conflict with libstdc
++.
3037 hackname
= sco_math
;
3038 files
= math.h
, '*/math.h';
3039 select
= "inline double abs";
3040 bypass
= "__GNUG__";
3041 sed
= "/#define.*__fp_class(a) \\\\/i\\\n"
3042 "#ifndef __GNUC__\n";
3044 "/.*__builtin_generic/a\\\n"
3046 "#define __fp_class(a) \\\\\\\n"
3047 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
3048 " __fpclassifyl(a), \\\\\\\n"
3049 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
3050 " __fpclassifyf(a),__fpclassify(a)))\\\n"
3053 sed
= "/extern \"C\\+\\+\"/N;"
3054 "/inline double abs/i\\\n"
3055 "#ifndef __GNUC__\n";
3056 sed
= "/inline long double trunc/N;"
3057 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
3058 "#endif /* ! __GNUC__ */";
3061 "#define __fp_class(a) \\\\\n"
3062 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
3068 * On SCO OpenServer prior to
5.0.7UP
1, <sys
/regset.h
> and
<ieeefp.h
>
3069 * have a clash on struct _fpstate and struct fpstate.
3072 hackname
= sco_regset
;
3073 files
= sys
/regset.h
;
3074 mach
= "*-*-sco3.2v5*";
3075 select
= "(struct[ \t]+.*)fpstate";
3077 c_fix_arg
= "%1rsfpstate";
3081 " struct\tfpstate\n"
3087 " struct _fpstate\n"
3096 * The static functions
lstat() and
fchmod() in
<sys
/stat.h
>
3097 * cause G
++ grief since they
're not wrapped in "if __cplusplus".
3099 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
3100 * tiny static wrappers that aren't C
++ safe.
3103 hackname
= sco_static_func
;
3105 mach
= "i?86-*-sco3.2*";
3106 select
= "^static int";
3108 sed
= "/^static int/i\\\n"
3109 "#if __cplusplus\\\n"
3110 "extern \"C\" {\\\n"
3111 "#endif /* __cplusplus */";
3114 "#if __cplusplus\\\n"
3116 "#endif /* __cplusplus */";
3120 "static int\tstat(const char *__f, struct stat *__p) {\n"
3121 "\treturn __stat32(__f, __p);\n"
3122 "}\n\n# else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n"
3124 "static int\tstat(__f, __p)\n"
3126 "\tstruct stat *__p;\n"
3128 "\treturn __stat32(__f, __p);\n"
3135 * Fix prototype declaration of utime in sys
/times.h.
3136 * In
3.2v4.0 the const is missing.
3139 hackname
= sco_utime
;
3140 files
= sys
/times.h
;
3141 mach
= "i?86-*-sco3.2v4*";
3143 select
= '\(const char \*, struct utimbuf \*\);';
3145 c_fix_arg
= '(const char *, const struct utimbuf *);';
3147 test_text
= "extern int utime(const char *, struct utimbuf *);";
3151 * Sun Solaris
10 defines several C99 math macros in terms of
3152 * builtins specific to the Studio compiler
, in particular not
3153 * compatible with the GNU compiler.
3156 hackname
= solaris_math_1
;
3157 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3158 bypass
= "__GNUC__";
3159 files
= iso
/math_c99.h
;
3161 c_fix_arg
= "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3162 c_fix_arg
= "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3164 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3166 "#define HUGE_VAL __builtin_huge_val\n"
3167 "#undef HUGE_VALF\n"
3168 "#define HUGE_VALF __builtin_huge_valf\n"
3169 "#undef HUGE_VALL\n"
3170 "#define HUGE_VALL __builtin_huge_vall";
3174 hackname
= solaris_math_2
;
3175 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3176 bypass
= "__GNUC__";
3177 files
= iso
/math_c99.h
;
3179 c_fix_arg
= "#define\tINFINITY\t(__builtin_inff())";
3180 c_fix_arg
= "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3182 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3184 "#define INFINITY __builtin_infinity";
3188 hackname
= solaris_math_3
;
3189 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3190 bypass
= "__GNUC__";
3191 files
= iso
/math_c99.h
;
3193 c_fix_arg
= "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3194 c_fix_arg
= "^#define[ \t]+NAN[ \t]+__builtin_nan";
3196 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3198 "#define NAN __builtin_nan";
3202 hackname
= solaris_math_4
;
3203 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3204 bypass
= "__GNUC__";
3205 files
= iso
/math_c99.h
;
3207 c_fix_arg
= "#define\tfpclassify(x) \\\n"
3208 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3209 c_fix_arg
= "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3211 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3212 "#undef fpclassify\n"
3213 "#define fpclassify(x) __builtin_fpclassify(x)";
3217 hackname
= solaris_math_8
;
3218 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3219 bypass
= "__GNUC__";
3220 files
= iso
/math_c99.h
;
3222 c_fix_arg
= "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3223 "\t\t\t ? __builtin_signbitf(x) \\\n"
3224 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3225 "\t\t\t ? __builtin_signbitl(x) \\\n"
3226 "\t\t\t : __builtin_signbit(x))";
3227 c_fix_arg
= "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3229 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3231 "#define signbit(x) __builtin_signbit(x)";
3235 hackname
= solaris_math_9
;
3236 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3237 bypass
= "__GNUC__";
3238 files
= iso
/math_c99.h
;
3240 c_fix_arg
= "#define\t%1(x, y)%2__builtin_%1(x, y)";
3241 c_fix_arg
= "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3243 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3244 "#undef isgreater\n"
3245 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3246 "#undef isgreaterequal\n"
3247 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3249 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3250 "#undef islessequal\n"
3251 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3252 "#undef islessgreater\n"
3253 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3254 "#undef isunordered\n"
3255 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3259 * On Solaris
11, if you do
isinf(NaN
) you
'll get a floating point
3260 * exception. Provide an alternative using GCC's builtin.
3264 hackname
= solaris_math_10
;
3265 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3266 files
= iso
/math_c99.h
;
3268 c_fix_arg
= "#define\tisinf(x) __builtin_isinf(x)";
3269 c_fix_arg
= "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3270 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3271 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3272 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3274 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3276 "#define isinf(x) __extension__( \\\\\n"
3277 " { __typeof(x) __x_i = (x); \\\\\n"
3278 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3279 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3283 * Sun Solaris
2.5.1, 2.6 defines PTHREAD_
{MUTEX|COND
}_INITIALIZER
3284 * incorrectly
, so we replace them with versions that correspond to
3285 * the definition. We also explicitly name this fix
"1" and the next
3286 * fix
"2" because this one does not deal with the last field. This
3287 * fix needs to run before the next.
3290 hackname
= solaris_mutex_init_1
;
3291 select
= '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI";
3293 sed
= "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n"
3294 "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/";
3296 '#ident "@(#)pthread.h 1.16 97/05/05 SMI"'"\n"
3297 "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n"
3298 "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n";
3303 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3304 * "0" for the last field of the pthread_mutex_t structure
, which is
3305 * of type upad64_t
, which itself is typedef
'd to int64_t, but with
3306 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3307 * initializer to "{0}" instead
3310 hackname = solaris_mutex_init_2;
3311 select = '@\
(#\
)pthread.h
' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3314 * On Solaris 10, this fix is unnecessary because upad64_t is
3315 * always defined correctly regardless of the definition of the
3316 * __STDC__ macro. The first "mach" pattern matches up to
3317 * solaris9. The second "mach" pattern will not match any two (or
3318 * more) digit solaris version, but it will match e.g. 2.5.1.
3320 mach = '*-*-solaris2.
[0-9]', '*-*-solaris2.
[0-9][!0-9]*';
3322 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3327 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3328 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3329 ",[ \t]*0\\}" "(|[ \t].*)$";
3331 '#ident
"@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3332 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3333 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3334 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n"
3335 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3336 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n"
3337 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3342 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3343 * fields of the pthread_rwlock_t structure, which are of type
3344 * upad64_t, which itself is typedef'd to int64_t
, but with __STDC__
3345 * defined (e.g. by
-ansi
) it is a union. So change the initializer
3349 hackname
= solaris_rwlock_init_1
;
3350 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3352 mach
= '*-*-solaris*';
3354 c_fix_arg
= "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3357 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3359 c_fix_arg
= "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3360 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3363 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3364 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3369 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3370 * structure. As such
, it need two levels of brackets
, but only
3371 * contains one. Wrap the macro definition in an extra layer.
3374 hackname
= solaris_once_init_1
;
3375 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3377 mach
= '*-*-solaris*';
3379 c_fix_arg
= "%1{%2}%3";
3380 c_fix_arg
= "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3382 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3383 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3388 * Sun Solaris defines PTHREAD_ONCE_INIT with a
"0" for some
3389 * fields of the pthread_once_t structure
, which are of type
3390 * upad64_t
, which itself is typedef
'd to int64_t, but with __STDC__
3391 * defined (e.g. by -ansi) it is a union. So change the initializer
3392 * to "{0}" instead. This test relies on solaris_once_init_1.
3395 hackname = solaris_once_init_2;
3396 select = '@\
(#\
)pthread.h
' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3399 * On Solaris 10, this fix is unnecessary because upad64_t is
3400 * always defined correctly regardless of the definition of the
3401 * __STDC__ macro. The first "mach" pattern matches up to
3402 * solaris9. The second "mach" pattern will not match any two (or
3403 * more) digit solaris version, but it will match e.g. 2.5.1.
3405 mach = '*-*-solaris2.
[0-9]', '*-*-solaris2.
[0-9][!0-9]*';
3407 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3410 "%1{0}, {0}, {0}, {%3}%4\n"
3412 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3413 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3415 '#ident
"@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3416 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3421 * Solaris 2.5.1 and 2.6 use an outdated prototype for send & recv
3422 * in sys/socket.h. This is corrected in Solaris 7 and up.
3425 hackname = solaris_socket;
3426 files = sys/socket.h;
3427 select = '@\
(#\
)socket.h
' "[ \t]+1.[123][0-9][ \t]+9[567]/[0-9/]+ SMI";
3429 c_fix_arg = "extern int %1(int, %2void *, int, int);";
3430 c_fix_arg = '^extern
int (recv|send
)\
(int
,'
3434 test_text = '#ident
"@(#)socket.h 1.30 97/01/20 SMI"'"\n"
3435 "extern int recv(int, char *, int, int);\n"
3436 "extern int send(int, const char *, int, int);";
3441 * Solaris 2.8 has what appears to be some gross workaround for
3442 * some old version of their c++ compiler. G++ doesn't want it
3443 * either
, but doesn
't want to be tied to SunPRO version numbers.
3446 hackname = solaris_stdio_tag;
3447 files = stdio_tag.h;
3449 select = '__cplusplus
< 54321L';
3450 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3451 "!defined(__GNUC__)" so we no longer need to fix it. */
3452 bypass = '__GNUC__
';
3453 sed = 's
/defined(__cplusplus
) && (__cplusplus
< 54321L)/0/';
3455 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3460 * Sun Solaris 2.5.1 doesn't define
'getpagesize' in
<unistd.h
>, as is done
3461 * on Solaris
2.6 and up.
3464 hackname
= solaris_unistd
;
3466 select
= '@\(#\)unistd.h' "[ \t]+1.3[0-9][ \t]+9[567]/[0-9/]+ SMI";
3467 bypass
= "getpagesize";
3469 c_fix_arg
= "extern int getpagesize();\n%0";
3470 c_fix_arg
= '^extern (pid_t|int) getpgid\(.*\);';
3471 test_text
= '#ident "@(#)unistd.h 1.33 95/08/28 SMI"'"\n"
3472 "extern pid_t getpgid(pid_t);\n"
3473 "extern int getpgid();";
3478 * <widec.h
> until Solaris
2.5.1 defines macros for a couple of
<wchar.h
>
3479 * functions
, breaking their prototypes if that file is included afterwards.
3480 * Include
<wchar.h
> early to avoid this issue
, as is done on Solaris
2.6
3484 hackname
= solaris_widec
;
3486 mach
= '*-*-solaris2.[0-5]';
3487 mach
= '*-*-solaris2.[0-5].*';
3488 bypass
= "include.*wchar\\.h";
3489 select
= "#include <euc.h>";
3491 c_fix_arg
= "%0\n#include <wchar.h>";
3492 test_text
= "#include <euc.h>";
3497 * a missing semi
-colon at the end of the statsswtch structure definition.
3500 hackname
= statsswtch
;
3501 files
= rpcsvc
/rstat.h
;
3502 select
= "boottime$";
3504 c_fix_arg
= "boottime;";
3505 test_text
= "struct statswtch {\n int boottime\n};";
3510 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3511 * On
4BSD
-derived systems
, stdio.h defers to machine
/ansi.h
; that
's
3515 hackname = stdio_stdarg_h;
3517 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3519 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3520 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3522 mach = '*-*-solaris2.1
[0-9]*';
3527 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3534 * Don't use or define the name va_list in stdio.h. This is for
3535 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3536 * of __gnuc_va_list
, __DJ_va_list
, or _G_va_list is taken to
3537 * indicate that the header knows what it
's doing -- under SUSv2,
3538 * stdio.h is required to define va_list, and we shouldn't break
3539 * that. On IRIX
6.5, internal
/wchar_core.h used to get its
3540 * definition of va_list from stdio.h. Since this doesn
't happen any
3541 * longer, use __gnuc_va_list there, too.
3544 hackname = stdio_va_list;
3546 files = internal/stdio_core.h;
3547 files = internal/wchar_core.h;
3548 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list
';
3550 * On Solaris 10, the definition in
3551 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3552 * there is therefore no need for this fix there.
3554 mach = '*-*-solaris2.1
[0-9]*';
3558 * Use __gnuc_va_list in arg types in place of va_list.
3559 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3560 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3561 * trailing parentheses and semicolon save all other systems from this.
3562 * Define
__not_va_list__ (something harmless and unused
)
3563 * instead of va_list.
3564 * Don
't claim to have defined va_list.
3566 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3567 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3568 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3569 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3570 "s@ va_list@ __not_va_list__@\n"
3571 "s@\\*va_list@*__not_va_list__@\n"
3572 "s@ __va_list)@ __gnuc_va_list)@\n"
3573 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3574 "@typedef \\1 __not_va_list__;@\n"
3575 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3576 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3577 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3578 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3579 "s@VA_LIST@DUMMY_VA_LIST@\n"
3580 "s@_Va_LIST@_VA_LIST@";
3581 test_text = "extern void mumble( va_list);";
3586 * Fix headers that use va_list from stdio.h to use the updated
3587 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3588 * dealt with elsewhere. The presence of __gnuc_va_list,
3589 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3590 * knows what it's doing.
3593 hackname
= stdio_va_list_clients
;
3601 files
= curses_colr
/curses.h
;
3602 bypass
= '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3603 /* Don
't fix, if we use va_list from stdarg.h, or if the use is
3604 otherwise protected. */
3605 bypass = 'include
<stdarg\.h
>|#ifdef va_start
';
3608 * Use __gnuc_va_list in arg types in place of va_list.
3609 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3610 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3611 * trailing parentheses and semicolon save all other systems from this.
3612 * Define
__not_va_list__ (something harmless and unused
)
3613 * instead of va_list.
3614 * Don
't claim to have defined va_list.
3616 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3617 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3618 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3619 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3620 "s@ va_list@ __not_va_list__@\n"
3621 "s@\\*va_list@*__not_va_list__@\n"
3622 "s@ __va_list)@ __gnuc_va_list)@\n"
3623 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3624 "@typedef \\1 __not_va_list__;@\n"
3625 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3626 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3627 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3628 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3629 "s@VA_LIST@DUMMY_VA_LIST@\n"
3630 "s@_Va_LIST@_VA_LIST@";
3631 test_text = "extern void mumble( va_list);";
3636 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3637 * is "!defined( __STRICT_ANSI__ )"
3640 hackname = strict_ansi_not;
3641 select = "^([ \t]*#[ \t]*if.*)"
3643 "|__STDC__[ \t]*==[ \t]*0"
3644 "|__STDC__[ \t]*!=[ \t]*1"
3645 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3646 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3647 bypass = 'GNU and MIPS C compilers define __STDC__ differently
';
3648 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3649 is not defined by GCC, so it is safe. */
3650 bypass = '__SCO_VERSION__.
*__STDC__
!= 1';
3651 c_test = stdc_0_in_system_headers;
3654 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3656 test_text = "#if !__STDC__ \n"
3657 "#if __STDC__ == 0\n"
3658 "#if __STDC__ != 1\n"
3659 "#if __STDC__ - 0 == 0"
3660 "/* not std C */\nint foo;\n"
3661 "\n#end-end-end-end-if :-)";
3666 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
3669 hackname = strict_ansi_not_ctd;
3670 files = math.h, limits.h, stdio.h, signal.h,
3671 stdlib.h, sys/signal.h, time.h;
3673 * Starting at the beginning of a line, skip white space and
3674 * a leading "(" or "&&" or "||". One of those must be found.
3675 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3676 * expression. If these are nested, then they must accumulate
3677 * because we won't match any closing parentheses. Finally
,
3678 * after skipping over all that
, we must then match our suspect
3679 * phrase
: "__STDC__-0==0" with or without white space.
3681 select
= "^([ \t]*" '(\(|&&|\|\|)'
3682 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3684 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3685 c_test
= stdc_0_in_system_headers
;
3688 c_fix_arg
= "%1 !defined(__STRICT_ANSI__)";
3690 test_text
= "#if 1 && \\\\\n"
3691 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3692 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3693 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3699 * "__STDC__!=0" or
"__STDC__==1" or
"__STDC__-0==1"
3700 * is
"defined( __STRICT_ANSI__ )"
3703 hackname
= strict_ansi_only
;
3704 select
= "^([ \t]*#[ \t]*if.*)"
3705 "(__STDC__[ \t]*!=[ \t]*0"
3706 "|__STDC__[ \t]*==[ \t]*1"
3707 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3708 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3709 c_test
= stdc_0_in_system_headers
;
3712 c_fix_arg
= "%1 defined(__STRICT_ANSI__)";
3714 test_text
= "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3719 * IRIX
4.0.5 <rpc
/xdr.h
> uses struct __file_s
3720 * in prototype without previous definition.
3723 hackname
= struct_file
;
3725 select
= '^.*xdrstdio_create.*struct __file_s';
3727 c_fix_arg
= "struct __file_s;\n%0";
3728 test_text
= "extern void xdrstdio_create( struct __file_s* );";
3733 * IRIX
4.0.5 <rpc
/auth.h
> uses struct sockaddr
3734 * in prototype without previous definition.
3736 * Don
't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3737 * function, and does define it.
3740 hackname = struct_sockaddr;
3742 select = "^.*authdes_create.*struct sockaddr[^_]";
3743 bypass = "<sys/socket\.h>";
3744 bypass = "struct sockaddr;\n";
3746 c_fix_arg = "struct sockaddr;\n%0";
3747 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3752 * Apply fix this to all OSs since this problem seems to effect
3753 * more than just SunOS.
3756 hackname = sun_auth_proto;
3761 bypass = "__cplusplus";
3763 * Select those files containing '(*name)()'.
3765 select = '\(\*[a-z][a-z_]*\)\(\)';
3768 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
3769 "#else\n%1();%2\n#endif";
3770 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3774 " int (*name)(); /* C++ bad */\n"
3780 * Fix bogus #ifdef on SunOS 4.1.
3783 hackname = sun_bogus_ifdef;
3784 files = "hsfs/hsfs_spec.h";
3785 files = "hsfs/iso_spec.h";
3786 select = '#
ifdef(.
*\|\|.*)
';
3788 c_fix_arg = "#if%1";
3790 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3795 * Fix the CAT macro in SunOS memvar.h.
3798 hackname = sun_catmacro;
3799 files = pixrect/memvar.h;
3800 select = "^#define[ \t]+CAT\\(a,b\\).*";
3805 "# define CAT(a,b) a##b\n"
3806 "#else\n%0\n#endif";
3809 "#define CAT(a,b)\ta/**/b";
3814 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3815 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3818 hackname = sun_malloc;
3820 bypass = "_CLASSIC_ANSI_TYPES";
3822 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3823 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3824 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3825 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3826 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3829 "typedef char *\tmalloc_t;\n"
3831 "char*\tmalloc();\n"
3832 "char*\tcalloc();\n"
3833 "char*\trealloc();";
3838 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3841 hackname = sun_rusers_semi;
3842 files = rpcsvc/rusers.h;
3844 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3845 test_text = "struct mumble\n int _cnt\n};";
3850 * signal.h on SunOS defines signal using (),
3851 * which causes trouble when compiling with g++ -pedantic.
3854 hackname = sun_signal;
3855 files = sys/signal.h;
3857 select = "^void\t" '\
(\
*signal\
(\
)\
)\
(\
);.
*';
3861 "#ifdef __cplusplus\n"
3862 "void\t(*signal(...))(...);\n"
3863 "#else\n%0\n#endif";
3865 test_text = "void\t(*signal())();";
3870 * Correct the return type for strlen in strings.h in SunOS 4.
3873 hackname = sunos_strlen;
3875 select = "int[ \t]*strlen\\(\\);(.*)";
3877 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3878 test_text = " int\tstrlen(); /* string length */";
3883 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3884 * that is visible to any ANSI compiler using this include. Simply
3885 * delete the lines that #define some string functions to internal forms.
3888 hackname = svr4_disable_opt;
3890 select = '#define.
*__std_hdr_
';
3891 sed = '/#define.
*__std_hdr_
/d
';
3892 test_text = "#define strlen __std_hdr_strlen\n";
3897 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
3898 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
3899 * but we still "hijack" it and redirect it to the GNU byteorder.h..
3903 hackname = svr4_endian;
3904 files = sys/endian.h;
3907 * since we emit our own sys/byteorder.h,
3908 * this fix can never be applied to that file.
3910 files = sys/byteorder.h;
3912 bypass = '__GNUC__
';
3914 sed = "/#\tifdef\t__STDC__/i\\\n"
3915 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
3917 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
3919 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
3920 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
3926 * Remove useless extern keyword from struct forward declarations
3927 * in <sys/stream.h> and <sys/strsubr.h>
3931 hackname = svr4_extern_struct;
3932 files = sys/stream.h;
3933 files = sys/strsubr.h;
3934 select = 'extern struct
[a
-z_
]*;';
3935 sed = 's
/extern struct \
([a
-z
][a
-z_
]*\
)/struct \
1/';
3940 * Fix declarations of `ftw' and `nftw
' in <ftw.h>. On some/most SVR4
3941 * systems the file <ftw.h> contains extern declarations of these
3942 * functions followed by explicitly `static' definitions of these
3943 * functions... and that
's not allowed according to ANSI C. (Note
3944 * however that on Solaris, this header file glitch has been pre-fixed by
3945 * Sun. In the Solaris version of <ftw.h> there are no static
3946 * definitions of any function so we don't need to do any of this stuff
3952 hackname
= svr4_ftw
;
3954 select
= '^extern int ftw\(const';
3956 sed
= '/^extern int ftw(const/i' "\\\n"
3957 "#if !defined(_STYPES)\\\n"
3962 sed
= 's/extern \(int ftw(const.*\)$/\1/';
3963 sed
= "/^extern int nftw/i\\\n"
3964 "#if defined(_STYPES)\\\n"
3969 sed
= 's/extern \(int nftw.*\)$/\1/';
3970 sed
= "/^extern int ftw(),/c\\\n"
3971 "#if !defined(_STYPES)\\\n"
3977 "#if defined(_STYPES)\\\n"
3989 * Fix broken decl of getcwd present on some svr4 systems.
3992 hackname
= svr4_getcwd
;
3995 files
= prototypes.h
;
3996 select
= 'getcwd\(char \*, int\)';
3999 c_fix_arg
= "getcwd(char *, size_t)";
4001 test_text
= "extern char* getcwd(char *, int);";
4006 * Wrap some files on System V r4 and DYNIX
/ptx systems with
4007 * #ifdef _KERNEL
, presumably to prevent kernel headers from
4008 * leaking into userspace. This may not be necessary at all
,
4009 * but it was in the old scripts
, so it seems safest to keep it for now.
4012 /* Can
't name this with _kernel, or the test case will hit the bypass! */
4013 hackname = svr4_krnl;
4014 /* Since I'm rather unsure about the validity of this
, limit it
4015 * to the specific systems it was operating on before. It should
4016 * also be bypassed for i?
86-*-sysv4.3uw2
, by that rule
, but I didn
't
4017 * see an easy way to do that. Hopefully it will be harmless
4018 * in any case. -- Nathanael */
4019 mach = '*-*-sysv4
*';
4020 mach = 'i?
86-sequent
-ptx
*';
4021 files = fs/rfs/rf_cache.h;
4025 files = sys/getpages.h;
4027 files = sys/cmn_err.h;
4028 files = sys/kdebugger.h;
4030 /* This bypass will match _KERNEL, __KERNEL, __KERNEL__, etc.
4031 * It will also match SVR4_KERNEL_CHECK, which means that the
4032 * testsuite case will always be bypassed. Which is fine with me. */
4036 c_fix_arg = "#ifdef _KERNEL\n";
4037 c_fix_arg = "#endif /* _KERNEL */\n";
4039 /* There's no reasonable test for this given that we don
't know exactly
4040 * what problem inspired it in the first place. */
4046 * Delete any #defines of `__i386' which may be present in
<ieeefp.h
>. They
4047 * tend to conflict with the compiler
's own definition of this symbol. (We
4048 * will use the compiler's definition.
)
4049 * Likewise __sparc
, for Solaris
, and __i860
, and a few others
4050 * (guessing it is necessary for all of them
).
4054 hackname
= svr4_mach_defines
;
4056 select
= "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
4057 sed
= "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
4063 * Fix declarations of `makedev
', `major', and `minor
' in <sys/mkdev.h>.
4064 * They are declared as non-static then immediately redeclared as static.
4068 hackname = svr4_mkdev;
4069 files = sys/mkdev.h;
4072 sed = "/^dev_t makedev(/s/^/static /";
4073 sed = "/^major_t major(/s/^/static /";
4074 sed = "/^minor_t minor(/s/^/static /";
4080 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
4081 * Also fix types of array initializers.
4085 hackname = svr4_netcspace;
4086 files = sys/netcspace.h;
4087 select = 'NC_NPI_RAW
';
4088 sed = 's
/NC_NPI_RAW
/NC_TPI_RAW
/g
';
4089 sed = 's
/NC_
/(unsigned long
) NC_
/';
4094 * Fix reference to NMSZ in <sys/adv.h>.
4098 hackname = svr4_nmsz;
4100 select = '\
[NMSZ\
]';
4101 sed = 's
/\
[NMSZ\
]/\
[RFS_NMSZ\
]/g
';
4107 * Some SVR4 systems supposedly use these non-ANSI preprocessor directives.
4111 hackname = svr4_preproc_lint_on;
4112 select = '#lint\
(on\
)';
4114 c_fix_arg = 'defined(lint
)';
4115 test_text = "#if #lint(on)";
4118 hackname = svr4_preproc_lint_off;
4119 select = '#lint\
(off\
)';
4121 c_fix_arg = '!defined(lint
)';
4122 test_text = "#if #lint(off)";
4125 hackname = svr4_preproc_machine;
4126 select = '#
(machine|system|cpu
)\
(([^
)]*)\
)';
4128 c_fix_arg = 'defined(__
%1__
)';
4129 test_text = "#if #machine(i386) || #system(vax) || #cpu(sparc)";
4135 * Fix broken decl of profil present on some svr4 systems.
4138 hackname = svr4_profil;
4143 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
4144 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
4145 prototype in <sys/profil.h>. */
4146 bypass = 'Silicon Graphics
';
4148 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
4151 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
4156 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
4160 hackname = svr4_proto_form;
4162 select = 'const extern
';
4164 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
4169 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
4174 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
4179 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
4184 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
4185 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
4186 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
4187 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
4188 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
4189 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
4194 * Add a prototyped declaration of mmap to <sys/mman.h>.
4198 hackname = svr4_proto_mmap;
4200 select = '^extern caddr_t
mmap();$
';
4201 sed = '/^extern caddr_t
mmap();$
/c
' "\\\n"
4202 "#ifdef __STDC__\\\n"
4203 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
4204 "#else /* !defined(__STDC__) */\\\n"
4205 "extern caddr_t mmap ();\\\n"
4206 "#endif /* !defined(__STDC__) */\\\n";
4211 * Add a #define of _SIGACTION_ into <sys/signal.h>.
4215 hackname = svr4_sigaction;
4216 files = sys/signal.h;
4217 sed = "/^struct sigaction {/i\\\n"
4218 "#define _SIGACTION_";
4219 sed = 's
/(void
*(\*)
())/(void (*)(int))/';
4225 * Correct types for signal handler constants like SIG_DFL; they might be
4226 * void (*) (), and should be void (*) (int). C++ doesn't like the
4230 hackname = svr4_sighandler_type;
4231 files = sys/signal.h;
4232 select = 'void *\(\*\)\(\)';
4234 c_fix_arg = "void (*)(int)";
4235 test_text = "#define SIG_DFL (void(*)())0\n"
4236 "#define SIG_IGN (void (*)())0\n";
4240 * Put storage class at start of decl, to avoid warning.
4244 hackname = svr4_storage_class;
4245 files = rpc/types.h;
4246 select = 'const extern';
4247 sed = 's/const extern/extern const/g';
4253 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4254 * function 'getrnge' in <regexp.h> before they declare it. For these
4255 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4258 * 'getrnge' traditionally manipulates a file-scope global called 'size',
4259 * so put the declaration right after the declaration of 'size'.
4261 * Don't do this if there is already a `static void getrnge' declaration
4262 * present, since this would cause a redeclaration error. Solaris 2.x has
4263 * such a declaration.
4266 hackname = svr4_undeclared_getrnge;
4269 bypass = "static void getrnge";
4272 "static int getrnge ();";
4273 c_fix_arg = "^static int[ \t]+size;";
4274 test_text = "static int size;\n"
4275 "/* stuff which calls getrnge() */\n"
4276 "static getrnge()\n"
4282 * Like svr4_mach_defines, but with newfangled syntax.
4283 * Source lines are of #define __i386 #machine(i386). Delete them.
4287 hackname = svr5_mach_defines;
4289 select = "#define[ \t]*__i386.*\(i386\)";
4290 sed = "/#define[ \t]*__i386.*/d";
4296 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4297 * in string.h on sysV68
4298 * Correct the return type for strlen in string.h on Lynx.
4299 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4300 * Add missing const for strdup on OSF/1 V3.0.
4301 * On sysV88 layout is slightly different.
4304 hackname = sysv68_string;
4307 bypass = "_CLASSIC_ANSI_TYPES";
4309 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4310 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4311 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4313 sed = "/^extern char$/N";
4314 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4316 sed = "/^extern int$/N";
4317 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4319 sed = "/^\tstrncmp(),$/N";
4320 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4321 '\1;' "\\\nextern unsigned int\\\n\\2/";
4324 "extern int strlen();\n"
4326 "extern int ffs(long);\n"
4339 "\tstrlen(), strspn();";
4344 * Fix return type of calloc, malloc, realloc, bsearch and exit
4347 hackname = sysz_stdlib_for_sun;
4349 bypass = "_CLASSIC_ANSI_TYPES";
4351 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4353 c_fix_arg = "void *\t%1(";
4356 "extern char*\tcalloc(size_t);\n"
4357 "extern char*\tmalloc(size_t);\n"
4358 "extern char*\trealloc(void*,size_t);\n"
4359 "extern char*\tbsearch(void*,size_t,size_t);\n";
4364 * __thread is now a keyword.
4367 hackname = thread_keyword;
4368 files = "pthread.h";
4369 files = "bits/sigthread.h";
4370 select = "([* ])__thread([,)])";
4372 c_fix_arg = "%1__thr%2";
4375 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4376 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4377 "extern int pthread_cancel (pthread_t __thread);";
4381 * if the #if says _cplusplus, not the double underscore __cplusplus
4385 hackname = tinfo_cplusplus;
4387 select = "[ \t]_cplusplus";
4390 c_fix_arg = " __cplusplus";
4391 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4396 * function parameter to atexit is missing "void" on VAX Ultrix 4.3.
4399 hackname = ultrix_atexit_param;
4401 select = 'atexit\(.*\(\)';
4404 c_fix_arg = "atexit( void (*__func)( void )";
4406 test_text = "int atexit( void (*__func)() );\n";
4411 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
4414 hackname = ultrix_atof_param;
4416 select = "atof\\([ \t]*char";
4419 c_fix_arg = "atof(const char";
4421 test_text = "extern double atof( char *__nptr);\n";
4426 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4429 hackname = ultrix_const;
4431 select = 'perror\( char \*';
4434 c_fix_arg = "%1 const %3 *__";
4435 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4436 "[ \t]+(char|void
) \\*__
";
4439 "extern void
perror( char
*__s
);\n"
4440 "extern int
fputs( char
*__s
, FILE *)
;\n"
4441 "extern size_t
fwrite( void
*__ptr
, size_t
, size_t
, FILE *)
;\n"
4442 "extern int
fscanf( FILE
*__stream
, char
*__format
, ...
);\n"
4443 "extern int
scanf( char
*__format
, ...
);\n";
4448 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4451 hackname = ultrix_const2;
4454 select = '\*fopen\( char \*';
4456 c_fix_arg = "%1( const char
*%3, const char
*";
4457 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam
))\\("
4458 "[ \t]*char
[ \t]*\\*([^
,]*)
,"
4459 "[ \t]*char
[ \t]*\\*[ \t]*";
4462 "extern FILE
*fopen( char
*__filename
, char
*__type
);\n"
4463 "extern int
sscanf( char
*__s
, char
*__format
, ...
);\n"
4464 "extern FILE
*popen(char
*, char *)
;\n"
4465 "extern char
*tempnam(char
*,char*)
;\n";
4470 * parameters not const on Ultrix V4.3.
4473 hackname = ultrix_const3;
4475 select = 'fdopen\( .*, char \*';
4478 c_fix_arg = "%1 const
%3 *__
";
4479 c_fix_arg = "([ \t*](fdopen
)\\(.*)
"
4480 "[ \t]+(char|void
) \\*__
";
4483 "extern FILE
* fdopen( int __filedes
, char
*__type
);\n";
4488 * Ultrix V4.[35] puts the declaration of uname before the definition
4489 * of struct utsname, so the prototype (added by fixproto) causes havoc.
4492 hackname = ultrix_fix_fixproto;
4493 files = sys/utsname.h;
4497 c_fix_arg = "struct utsname
;\n%0";
4498 c_fix_arg = "^
[ \t]*extern
[ \t]*int
[ \t]*uname
\\(\\);";
4501 "/* ULTRIX
's uname */\nextern\tint\tuname();";
4506 * Check for bad #ifdef line (in Ultrix 4.1)
4509 hackname = ultrix_ifdef;
4510 select = "^#ifdef KERNEL[ \t]+&&";
4514 c_fix_arg = "#if defined(KERNEL) &&";
4517 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
4522 * Add once-only latch to Ultrix V4.3 locale.h.
4525 hackname = ultrix_locale;
4527 select = "@\\(#\\)locale\\.h.*6\\.1.*\\(ULTRIX\\)";
4530 "@(#)locale.h 6.1 (ULTRIX)\n";
4535 * Strip "|| CC$gfloat" from Ultrix math headers.
4538 hackname = ultrix_math_ifdef;
4539 files = sys/limits.h;
4542 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
4546 test_text = '#if
defined(__GFLOAT
) || CC\$gfloat
';
4551 * Avoid nested comments on Ultrix 4.3.
4554 hackname = ultrix_nested_ioctl;
4555 files = sys/ioctl.h;
4556 select = "^/\\* #define SIOCSCREEN";
4557 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
4559 "/* #define SIOCSCREENON _IOWR('i
', 49, int)"
4560 "/* screend, net/gw_screen.h */\n";
4565 hackname = ultrix_nested_svc;
4567 select = "^ \\*[ \t]*int protocol; */\\*";
4568 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
4570 " *\tint protocol; /* like TCP or UDP\n";
4575 * Add missing prototype for lstat and define for S_ISLNK
4576 * in Ultrix V4.3 sys/stat.h.
4579 hackname = ultrix_stat;
4581 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
4582 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
4584 "/* macro to test for symbolic link */\\\n"
4585 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
4587 sed = "/^[ \t]*fstat(),$/a\\\n"
4590 "@(#)stat.h 6.1 (ULTRIX)\n"
4591 "#define S_IFPORT S_IFIFO\n"
4592 "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */";
4597 * Check for superfluous `static' (in Ultrix
4.2)
4598 * On Ultrix
4.3, includes of other
files (r3_cpu.h
,r4_cpu.h
) is broken.
4601 hackname
= ultrix_static
;
4602 files
= machine
/cpu.h
;
4603 select
= '#include "r[34]_cpu';
4604 sed
= "s/^static struct tlb_pid_state/struct tlb_pid_state/";
4605 sed
= 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
4606 sed
= 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
4608 "static struct tlb_pid_state {\n"
4609 "#include \"r3_cpu.h\"\n";
4614 * Add missing declarations to Ultrix V4.3 stdlib.h.
4617 hackname
= ultrix_stdlib
;
4619 select
= "@\\(#\\)stdlib\\.h.*6\\.1.*\\(ULTRIX\\)";
4621 sed
= "/^char.*getenv( const char .* );.*$/a\\\n"
4622 "int\t\tsetenv( const char *__name, const char *__val, int __ovrwrt );\\\n"
4623 "void\t\tunsetenv( const char *__name );\\\n"
4624 "int\t\tputenv( char *__s );\n";
4626 sed
= "/^char.*getenv();.*$/a\\\n"
4627 "int\tsetenv();\\\n"
4628 "void\tunsetenv();\\\n"
4632 "@(#)stdlib.h 6.1 (ULTRIX)\n"
4633 "char * getenv( const char *__name );\n"
4634 "char *getenv();\n";
4639 * Add once
-only latch to Ultrix V4.3 strings.h.
4642 hackname
= ultrix_strings
;
4644 select
= "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
4647 "@(#)strings.h 6.1 (ULTRIX)\n";
4652 * Add missing declarations to Ultrix V4.3 strings.h.
4655 hackname
= ultrix_strings2
;
4657 select
= "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
4659 sed
= "/^.*strncmp( const .* );.*/a\\\n"
4662 "\tstrcasecmp( const char *__s1, const char *__s2),\\\n"
4663 "\tstrncasecmp( const char *__s1, const char *__s2, size_t __n );\n";
4665 sed
= "/^.*strncmp();.*/a\\\n"
4667 "\tstrcasecmp(),\\\n"
4668 "\tstrncasecmp();\n";
4671 "@(#)strings.h 6.1 (ULTRIX)\n"
4672 "\tstrncmp( const char *__s1, const char *__s2, size_t __n );\n"
4678 * Add missing declarations to Ultrix V4.3 sys
/time.h.
4681 hackname
= ultrix_sys_time
;
4683 select
= "@\\(#\\)time\\.h.*6\\.1.*\\(ULTRIX\\)";
4685 sed
= "/^extern.*time_t.*time( time_t .* );.*$/a\\\n"
4687 "extern int adjtime(struct timeval *, struct timeval *);\\\n"
4688 "extern int getitimer(int, struct itimerval *);\\\n"
4689 "extern int setitimer(int, struct itimerval *, struct itimerval *);\\\n"
4690 "extern int gettimeofday(struct timeval *, struct timezone *);\\\n"
4691 "extern int settimeofday(struct timeval *, struct timezone *);\\\n"
4692 "extern void profil(const void *, size_t, size_t, unsigned int);\\\n"
4693 "extern int stime(const time_t *);\\\n"
4694 "extern int utimes(const char *, const struct timeval[2]);\\\n"
4695 "extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);\n";
4697 sed
= "/^extern.*double.*difftime();.*$/a\\\n"
4698 "extern\tint adjtime();\\\n"
4699 "extern\tint getitimer();\\\n"
4700 "extern\tint setitimer();\\\n"
4701 "extern\tint gettimeofday();\\\n"
4702 "extern\tint settimeofday();\\\n"
4703 "extern\tvoid profil();\\\n"
4704 "extern\tint stime();\\\n"
4705 "extern\tint utimes();\\\n"
4706 "extern\tint select();\n";
4709 "@(#)time.h 6.1 (ULTRIX)\n"
4710 "extern time_t time( time_t *__tloc );\n"
4711 "extern double difftime();\n";
4716 * Add missing declarations to Ultrix V4.3 unistd.h.
4719 hackname
= ultrix_unistd
;
4721 select
= "@\\(#\\)unistd\\.h.*6\\.1.*\\(ULTRIX\\)";
4723 sed
= "/^[ \t]*getgroups(),.*$/a\\\n"
4724 "\tgetpagesize(),\n";
4726 sed
= "/^[ \t]*fork(),.*$/a\\\n"
4730 "@(#)unistd.h 6.1 (ULTRIX)\n"
4737 * On Cray Unicos
/Mk some standard headers use the C99 keyword
"restrict"
4738 * which must be replaced by __restrict__ for GCC.
4741 hackname
= unicosmk_restrict
;
4745 mach
= "*-*-unicosmk*";
4746 select
= "(\\*[ \t]*)restrict([ \t]+)";
4749 c_fix_arg
= "%1__restrict__%2";
4751 test_text
= "void f (char * restrict x);";
4755 * If arpa
/inet.h prototypes are incompatible with the ones we just
4756 * installed in
<sys
/byteorder.h
>, just remove the protos.
4757 * Because of this close association
, this patch must be applied only
4758 * on those systems where the replacement byteorder header is installed.
4761 hackname
= uw7_byteorder_fix
;
4762 files
= arpa
/inet.h
;
4763 select
= "in_port_t";
4764 test
= "-f sys/byteorder.h";
4766 mach
= "*-*-sysv4*";
4767 mach
= "i?86-*-sysv5*";
4768 mach
= "i?86-*-udk*";
4769 mach
= "i?86-*-solaris2.[0-4]";
4770 mach
= "powerpcle-*-solaris2.[0-4]";
4771 mach
= "sparc-*-solaris2.[0-4]";
4776 c_fix_arg
= "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
4778 test_text
= "extern in_port_t\thtons __P((in_port_t));\n"
4779 "extern in_port_t\tntohs __P((in_port_t));"
4780 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
4781 "echo '/* DUMMY */' >> sys/byteorder.h`";
4786 * Fix definitions of macros used by va
-i960.h in VxWorks header file.
4789 hackname
= va_i960_macro
;
4790 files
= arch
/i960
/archI960.h
;
4791 select
= "__(vsiz|vali|vpad|alignof__)";
4794 c_fix_arg
= "__vx%1";
4797 "extern int __vsiz vsiz;\n"
4798 "extern int __vali vali;\n"
4799 "extern int __vpad vpad;\n"
4800 "#define __alignof__(x) ...";
4805 * AIX and Interix headers define NULL to be cast to a void pointer
,
4806 * which is illegal in ANSI C
++.
4809 hackname
= void_null
;
4819 files
= sys
/param.h
;
4820 files
= sys
/types.h
;
4821 /* avoid changing C
++ friendly NULL
*/
4822 bypass
= __cplusplus
;
4823 select
= "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4825 c_fix_arg
= "#define NULL 0";
4826 test_text
= "# define\tNULL \t((void *)0) /* typed NULL */";
4831 * Make VxWorks header which is almost gcc ready fully gcc ready.
4834 hackname
= vxworks_gcc_problem
;
4835 files
= types
/vxTypesBase.h
;
4836 select
= "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4838 sed
= "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4841 sed
= "/[ \t]size_t/i\\\n"
4842 "#ifndef _GCC_SIZE_T\\\n"
4843 "#define _GCC_SIZE_T\n";
4845 sed
= "/[ \t]size_t/a\\\n"
4848 sed
= "/[ \t]ptrdiff_t/i\\\n"
4849 "#ifndef _GCC_PTRDIFF_T\\\n"
4850 "#define _GCC_PTRDIFF_T\n";
4852 sed
= "/[ \t]ptrdiff_t/a\\\n"
4855 sed
= "/[ \t]wchar_t/i\\\n"
4856 "#ifndef _GCC_WCHAR_T\\\n"
4857 "#define _GCC_WCHAR_T\n";
4859 sed
= "/[ \t]wchar_t/a\\\n"
4863 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4864 "typedef unsigned int size_t;\n"
4865 "typedef long ptrdiff_t;\n"
4866 "typedef unsigned short wchar_t;\n"
4867 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4872 * Fix VxWorks
<time.h
> to not require including
<vxTypes.h
>.
4875 hackname
= vxworks_needs_vxtypes
;
4877 select
= "uint_t([ \t]+_clocks_per_sec)";
4879 c_fix_arg
= "unsigned int%1";
4880 test_text
= "uint_t\t_clocks_per_sec;";
4885 * Fix VxWorks
<sys
/stat.h
> to not require including
<vxWorks.h
>.
4888 hackname
= vxworks_needs_vxworks
;
4890 test
= " -r types/vxTypesOld.h";
4891 test
= " -n \"`egrep '#include' $file`\"";
4892 test
= " -n \"`egrep ULONG $file`\"";
4893 select
= "#[ \t]define[ \t]+__INCstath";
4895 sed
= "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4896 "#include <types/vxTypesOld.h>\n";
4898 test_text
= "`touch types/vxTypesOld.h`"
4899 "#include </dev/null> /* ULONG */\n"
4900 "# define\t__INCstath <sys/stat.h>";
4905 * Another bad dependency in VxWorks
5.2 <time.h
>.
4908 hackname
= vxworks_time
;
4910 test
= " -r vxWorks.h";
4912 select
= "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4916 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4917 "#ifdef __cplusplus\n"
4918 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4920 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4922 "#define __gcc_VOIDFUNCPTR_defined\n"
4924 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4926 test_text
= "`touch vxWorks.h`"
4927 "#define VOIDFUNCPTR (void(*)())";
4932 * WindISS math.h headers include bogus extern declarations of
4933 * numerous math functions that conflict with libstdc
++-v3.
4936 hackname
= windiss_math1
;
4938 mach
= "*-*-windiss";
4939 sed
= "s|inline long double cosl.*|#ifndef __GNUC__|";
4941 test_text
= "inline long double cosl(long double);";
4945 hackname
= windiss_math2
;
4947 mach
= "*-*-windiss";
4948 sed
= "s|/\\* long double declarations \\*/|"
4949 "#endif /* __GNUC__ */|";
4951 test_text
= "/* long double declarations */";
4955 * WindISS headers include
"diab/va_list.h" instead of
"stdarg.h"
4958 select
= '(#include.*)diab/va_list.h';
4959 hackname
= windiss_valist
;
4960 sed
= "s|diab/va_list.h|stdarg.h|";
4961 mach
= "*-*-windiss";
4963 test_text
= "#include <diab/va_list.h>";
4967 * There are several name conflicts with C
++ reserved words in X11 header
4968 * files. These are fixed in some versions
, so don
't do the fixes if
4969 * we find __cplusplus in the file. These were found on the RS/6000.
4972 hackname = x11_class;
4973 files = X11/ShellP.h;
4974 bypass = __cplusplus;
4975 select = "^([ \t]*char \\*)class;(.*)";
4977 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4978 "#else\n%1class;%2\n#endif";
4987 * class in Xm/BaseClassI.h
4990 hackname = x11_class_usage;
4991 files = Xm/BaseClassI.h;
4992 bypass = "__cplusplus";
4994 select = " class\\)";
4996 c_fix_arg = " c_class)";
4998 test_text = "extern mumble (int class);\n";
5003 * new in Xm/Traversal.h
5007 files = Xm/Traversal.h;
5008 bypass = __cplusplus;
5010 sed = "/Widget\told, new;/i\\\n"
5011 "#ifdef __cplusplus\\\n"
5012 "\tWidget\told, c_new;\\\n"
5015 sed = "/Widget\told, new;/a\\\n"
5018 sed = "s/Widget new,/Widget c_new,/g";
5021 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
5022 "};\nextern Wedged( Widget new, Widget old );";
5027 * Incorrect sprintf declaration in X11/Xmu.h
5030 hackname = x11_sprintf;
5032 files = X11/Xmu/Xmu.h;
5033 select = "^extern char \\*\tsprintf\\(\\);$";
5036 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5038 test_text = "extern char *\tsprintf();";