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";
35 test
-text
= ''; /* no way to test
*/
41 c_fix_arg
= <<- _EOArg_
43 #if defined __GNUG__
&& defined _LARGE_FILES
&& defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
52 /* Alias the symbols using asm
*/
54 extern int
fgetpos(FILE
*, fpos64_t *)
__asm__("fgetpos64");
55 extern FILE
*fopen(const char
*, const char *)
__asm__("fopen64");
56 extern FILE
*freopen(const char
*, const char
*, FILE *)
__asm__("freopen64");
57 extern int
fseeko(FILE
*, off64_t
, int
) __asm__("fseeko64");
58 extern int
fsetpos(FILE
*, const fpos64_t *)
__asm__("fsetpos64");
59 extern off64_t
ftello(FILE *)
__asm__("ftello64");
69 * On Mac OS
10.3.9, the
'long double' functions are available in
70 * libSystem
, but are not prototyped in math.h.
73 hackname
= AAB_darwin7_9_long_double_funcs
;
74 mach
= "*-*-darwin7.9*";
75 files
= architecture
/ppc
/math.h
;
77 replace
= <<- _EndOfHeader_
78 /* This file prototypes the long double functions available on Mac OS
82 # define __APPLE_CC__
1345
83 # include_next
<architecture
/ppc
/math.h
>
85 # define __APPLE_CC__
1
86 # ifndef __LIBMLDBL_COMPAT
87 # ifdef __LONG_DOUBLE_128__
88 # define
__LIBMLDBL_COMPAT(sym
) __asm("_" #sym
"$LDBL128")
90 # define
__LIBMLDBL_COMPAT(sym
)
91 # endif
/* __LONG_DOUBLE_128__
*/
92 # endif
/* __LIBMLDBL_COMPAT
*/
96 extern long double
acosl( long double
) __LIBMLDBL_COMPAT(acosl
);
97 extern long double
asinl( long double
) __LIBMLDBL_COMPAT(asinl
);
98 extern long double
atanl( long double
) __LIBMLDBL_COMPAT(atanl
);
99 extern long double
atan2l( long double
, long double
) __LIBMLDBL_COMPAT(atan2l
);
100 extern long double
cosl( long double
) __LIBMLDBL_COMPAT(cosl
);
101 extern long double
sinl( long double
) __LIBMLDBL_COMPAT(sinl
);
102 extern long double
tanl( long double
) __LIBMLDBL_COMPAT(tanl
);
103 extern long double
acoshl( long double
) __LIBMLDBL_COMPAT(acoshl
);
104 extern long double
asinhl( long double
) __LIBMLDBL_COMPAT(asinhl
);
105 extern long double
atanhl( long double
) __LIBMLDBL_COMPAT(atanhl
);
106 extern long double
coshl( long double
) __LIBMLDBL_COMPAT(coshl
);
107 extern long double
sinhl( long double
) __LIBMLDBL_COMPAT(sinhl
);
108 extern long double
tanhl( long double
) __LIBMLDBL_COMPAT(tanhl
);
109 extern long double
expl( long double
) __LIBMLDBL_COMPAT(expl
);
110 extern long double
exp2l( long double
) __LIBMLDBL_COMPAT(exp2l
);
111 extern long double
expm1l( long double
) __LIBMLDBL_COMPAT(expm1l
);
112 extern long double
logl( long double
) __LIBMLDBL_COMPAT(logl
);
113 extern long double
log10l( long double
) __LIBMLDBL_COMPAT(log10l
);
114 extern long double
log2l( long double
) __LIBMLDBL_COMPAT(log2l
);
115 extern long double
log1pl( long double
) __LIBMLDBL_COMPAT(log1pl
);
116 extern long double
logbl( long double
) __LIBMLDBL_COMPAT(logbl
);
117 extern long double
modfl( long double
, long double
* ) __LIBMLDBL_COMPAT(modfl
);
118 extern long double
ldexpl( long double
, int
) __LIBMLDBL_COMPAT(ldexpl
);
119 extern long double
frexpl( long double
, int
* ) __LIBMLDBL_COMPAT(frexpl
);
120 extern int
ilogbl( long double
) __LIBMLDBL_COMPAT(ilogbl
);
121 extern long double
scalbnl( long double
, int
) __LIBMLDBL_COMPAT(scalbnl
);
122 extern long double
scalblnl( long double
, long int
) __LIBMLDBL_COMPAT(scalblnl
);
123 extern long double
fabsl( long double
) __LIBMLDBL_COMPAT(fabsl
);
124 extern long double
cbrtl( long double
) __LIBMLDBL_COMPAT(cbrtl
);
125 extern long double
hypotl( long double
, long double
) __LIBMLDBL_COMPAT(hypotl
);
126 extern long double
powl( long double
, long double
) __LIBMLDBL_COMPAT(powl
);
127 extern long double
sqrtl( long double
) __LIBMLDBL_COMPAT(sqrtl
);
128 extern long double
erfl( long double
) __LIBMLDBL_COMPAT(erfl
);
129 extern long double
erfcl( long double
) __LIBMLDBL_COMPAT(erfcl
);
130 extern long double
lgammal( long double
) __LIBMLDBL_COMPAT(lgammal
);
131 extern long double
tgammal( long double
) __LIBMLDBL_COMPAT(tgammal
);
132 extern long double
ceill( long double
) __LIBMLDBL_COMPAT(ceill
);
133 extern long double
floorl( long double
) __LIBMLDBL_COMPAT(floorl
);
134 extern long double
nearbyintl( long double
) __LIBMLDBL_COMPAT(nearbyintl
);
135 extern long double
rintl( long double
) __LIBMLDBL_COMPAT(rintl
);
136 extern long int
lrintl( long double
) __LIBMLDBL_COMPAT(lrintl
);
137 extern long long int
llrintl( long double
) __LIBMLDBL_COMPAT(llrintl
);
138 extern long double
roundl( long double
) __LIBMLDBL_COMPAT(roundl
);
139 extern long int
lroundl( long double
) __LIBMLDBL_COMPAT(lroundl
);
140 extern long long int
llroundl( long double
) __LIBMLDBL_COMPAT(llroundl
);
141 extern long double
truncl( long double
) __LIBMLDBL_COMPAT(truncl
);
142 extern long double
fmodl( long double
, long double
) __LIBMLDBL_COMPAT(fmodl
);
143 extern long double
remainderl( long double
, long double
) __LIBMLDBL_COMPAT(remainderl
);
144 extern long double
remquol( long double
, long double
, int
* ) __LIBMLDBL_COMPAT(remquol
);
145 extern long double
copysignl( long double
, long double
) __LIBMLDBL_COMPAT(copysignl
);
146 extern long double
nanl( const char
* ) __LIBMLDBL_COMPAT(nanl
);
147 extern long double
nextafterl( long double
, long double
) __LIBMLDBL_COMPAT(nextafterl
);
148 extern long double
nexttowardl( long double
, long double
) __LIBMLDBL_COMPAT(nexttowardl
);
149 extern long double
fdiml( long double
, long double
) __LIBMLDBL_COMPAT(fdiml
);
150 extern long double
fmaxl( long double
, long double
) __LIBMLDBL_COMPAT(fmaxl
);
151 extern long double
fminl( long double
, long double
) __LIBMLDBL_COMPAT(fminl
);
152 extern long double
fmal( long double
, long double
, long double
) __LIBMLDBL_COMPAT(fmal
);
156 #endif
/* __MATH__
*/
162 * ... and for the previous fix to be useful
, you have to not use
""
166 hackname
= AAB_darwin7_9_long_double_funcs_2
;
167 mach
= "*-*-darwin7.9*";
169 select
= '#include[ \t]+\"';
171 c_fix_arg
= "%1<%2.h>";
173 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
175 test_text
= '#include "architecture/ppc/math.h"';
180 * This fixes __FD_ZERO bug for linux
2.x.
y (x
<= 2 && y
<= some n
)
183 hackname
= AAB_fd_zero_asm_posix_types_h
;
184 files
= asm
/posix_types.h
;
185 mach
= 'i[34567]86-*-linux*';
188 bypass
= 'posix_types_64';
191 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper
, not
192 * the start
, so that if #include_next gets another instance of
193 * the wrapper
, this will follow the #include_next chain until
194 * we arrive at the real
<asm
/posix_types.h
>.
196 replace
= <<- _EndOfHeader_
197 /* This file fixes a bug in the __FD_ZERO macro
198 for older versions of the Linux kernel.
*/
199 #ifndef _POSIX_TYPES_H_WRAPPER
200 #include
<features.h
>
201 #include_next
<asm
/posix_types.h
>
203 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
205 #define
__FD_ZERO(fdsetp
) \
208 __asm__
__volatile__("cld ; rep ; stosl" \
209 : "=&c" (__d0
), "=&D" (__d1
) \
210 : "a" (0), "0" (__FDSET_LONGS
), \
211 "1" ((__kernel_fd_set *)
(fdsetp
)) :"memory"); \
215 #define _POSIX_TYPES_H_WRAPPER
216 #endif
/* _POSIX_TYPES_H_WRAPPER
*/
222 * This fixes __FD_ZERO bug for glibc
-1.x
225 hackname
= AAB_fd_zero_gnu_types_h
;
227 mach
= 'i[34567]86-*-linux*';
230 * Define _TYPES_H_WRAPPER at the end of the wrapper
, not
231 * the start
, so that if #include_next gets another instance of
232 * the wrapper
, this will follow the #include_next chain until
233 * we arrive at the real
<gnu
/types.h
>.
235 replace
= <<- _EndOfHeader_
236 /* This file fixes a bug in the __FD_ZERO macro present in glibc
1.x.
*/
237 #ifndef _TYPES_H_WRAPPER
238 #include
<features.h
>
239 #include_next
<gnu
/types.h
>
241 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
243 # define
__FD_ZERO(fdsetp
) \
246 __asm__
__volatile__("cld ; rep ; stosl" \
247 : "=&c" (__d0
), "=&D" (__d1
) \
248 : "a" (0), "0" (__FDSET_LONGS
), \
249 "1" ((__fd_set *)
(fdsetp
)) :"memory"); \
253 #define _TYPES_H_WRAPPER
254 #endif
/* _TYPES_H_WRAPPER
*/
260 * This fixes __FD_ZERO bug for glibc
-2.0.x
263 hackname
= AAB_fd_zero_selectbits_h
;
264 files
= selectbits.h
;
265 mach
= 'i[34567]86-*-linux*';
268 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper
, not
269 * the start
, so that if #include_next gets another instance of
270 * the wrapper
, this will follow the #include_next chain until
271 * we arrive at the real
<selectbits.h
>.
273 replace
= <<- _EndOfHeader_
274 /* This file fixes a bug in the __FD_ZERO macro present in glibc
2.0.x.
*/
275 #ifndef _SELECTBITS_H_WRAPPER
276 #include
<features.h
>
277 #include_next
<selectbits.h
>
279 #if
defined(__FD_ZERO
) && defined(__GLIBC__
) \\
280 && defined(__GLIBC_MINOR__
) && __GLIBC__
== 2 \\
281 && __GLIBC_MINOR__
== 0
283 #define
__FD_ZERO(fdsetp
) \\
286 __asm__
__volatile__ ("cld; rep; stosl" \\
287 : "=&c" (__d0
), "=&D" (__d1
) \\
288 : "a" (0), "0" (sizeof (__fd_set
) \\
289 / sizeof (__fd_mask
)), \\
290 "1" ((__fd_mask *)
(fdsetp
)) \\
295 #define _SELECTBITS_H_WRAPPER
296 #endif
/* _SELECTBITS_H_WRAPPER
*/
302 * Solaris
<sys
/varargs.h
> is a
DDK (aka kernel
-land
) header providing
303 * the same interface as
<stdarg.h
>. No idea why they couldn
't have just
304 * used the standard header.
307 hackname = AAB_solaris_sys_varargs_h;
308 files = "sys/varargs.h";
309 mach = '*-*-solaris
*';
310 replace = <<- _EndOfHeader_
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
322 * declaration on Sun OS
4.x. We must only fix this on Sun OS
4.x
, because
323 * many other systems have similar text but correct versions of the file.
324 * To ensure only Sun
's is fixed, we grep for a likely unique string.
325 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
328 hackname = AAB_sun_memcpy;
330 select = "/\\*\t@\\(#\\)"
331 "(head/memory.h\t50.1\t "
332 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
334 replace = <<- _EndOfHeader_
335 /* This file was generated by fixincludes */
340 extern void *memccpy();
341 extern void *memchr();
342 extern void *memcpy();
343 extern void *memset();
345 extern char *memccpy();
346 extern char *memchr();
347 extern char *memcpy();
348 extern char *memset();
349 #endif /* __STDC__ */
353 #endif /* __memory_h__ */
359 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
360 * which violates a requirement of ISO C.
363 hackname = aix_pthread;
365 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
368 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
369 "{...init stuff...}";
374 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
375 * in an otherwise harmless (and #ifed out) macro definition
378 hackname = aix_sysmachine;
379 files = sys/machine.h;
383 test_text = "#define FOO \\\n"
384 " bar \\ \n baz \\ \n bat";
389 * sys/wait.h on AIX 5.2 defines macros that have both signed and
390 * unsigned types in conditional expressions.
393 hackname = aix_syswait_2;
395 select = '\? (\
(\
(\
(\
(unsigned
[^
)]*\
)[^
)]*\
) >> [^
)]*\
) \
& 0xff\
) : -1)';
397 c_fix_arg = "? (int)%1";
398 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
403 * sys/signal.h on some versions of AIX uses volatile in the typedef of
404 * sig_atomic_t, which causes gcc to generate a warning about duplicate
405 * volatile when a sig_atomic_t variable is declared volatile, as
406 * required by ANSI C.
409 hackname = aix_volatile;
410 files = sys/signal.h;
411 select = "typedef volatile int sig_atomic_t";
413 c_fix_arg = "typedef int sig_atomic_t";
414 test_text = "typedef volatile int sig_atomic_t;";
419 * Fix __assert declaration in assert.h on Alpha OSF/1.
422 hackname = alpha___assert;
424 select = '__assert\
(char \
*, char \
*, int\
)';
426 c_fix_arg = "__assert(const char *, const char *, int)";
427 test_text = 'extern void
__assert(char
*, char
*, int
);';
432 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
435 hackname = alpha___extern_prefix;
436 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
437 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
439 mach = "alpha*-dec-osf*";
441 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
443 test_text = "#ifdef __DECC\n"
444 "#pragma extern_prefix \"_P\"\n"
445 "# if defined(__DECC)\n"
446 "# pragma extern_prefix \"_E\"\n"
447 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
448 "# pragma extern_prefix \"\"";
453 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
456 hackname = alpha___extern_prefix_standards;
458 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
460 mach = "alpha*-dec-osf*";
462 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
464 test_text = "#if (_ISO_C_SOURCE>=19990L) "
465 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
470 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
471 * <sys/stat.h>. The tests for __DECC are special in various ways, so
472 * alpha__extern_prefix cannot be used.
475 hackname = alpha___extern_prefix_sys_stat;
478 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
480 mach = "alpha*-dec-osf5*";
482 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
484 test_text = "# if defined(__DECC)";
489 * Fix assert macro in assert.h on Alpha OSF/1.
490 * The superfluous int cast breaks C++.
493 hackname = alpha_assert;
495 select = '(#define assert\
(EX\
).*)\
(\
(int\
) \
(EX\
)\
)';
497 c_fix_arg = "%1(EX)";
498 test_text = '#define
assert(EX
) (((int
) (EX
)) ?
(void
)0 '
499 ': __assert(#EX
, __FILE__
, __LINE__
))';
504 * Fix #defines under Alpha OSF/1:
505 * The following files contain '#pragma extern_prefix
"_FOO"' followed by
506 * a '#define
something(x
,y
,z
) _FOOsomething(x
,y
,z
)'. The intent of these
507 * statements is to reduce namespace pollution. While these macros work
508 * properly in most cases, they don't allow you to take a pointer to the
509 * "something" being modified. To get around this limitation
, change these
510 * statements to be of the form
'#define something _FOOsomething'.
512 * sed ain
't egrep, lesson 2463: sed can use self-referential
513 * regular expressions. In the substitute expression below,
514 * "\\1" and "\\2" refer to subexpressions found earlier in the
515 * same match. So, we continue to use sed. "extern_prefix" will
516 * be a rare match anyway...
519 hackname = alpha_bad_lval;
521 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
522 mach = "alpha*-dec-osf*";
525 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
526 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
528 test_text = '#pragma extern_prefix
"_FOO"'"\n"
529 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
530 "#define mumble _FOOmumble";
535 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
538 hackname = alpha_getopt;
541 select = 'getopt\
(int
, char \
*\
[\
], *char \
*\
)';
543 c_fix_arg = "getopt(int, char *const[], const char *)";
544 test_text = 'extern int
getopt(int
, char
*[], char *)
;';
549 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
552 hackname = alpha_if_semicolon;
554 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
556 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
557 test_text = ' struct sockaddr vmif_paddr
/* protocol address
*/';
562 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
565 hackname = alpha_parens;
567 select = '#ifndef\
(__mips64\
)';
569 c_fix_arg = "#ifndef __mips64";
570 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
575 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
578 hackname = alpha_pthread;
580 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
581 "|def _PTHREAD_ENV_DECC)(.*))\n"
582 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
584 mach = "alpha*-dec-osf*";
586 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
587 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
589 test_text = "# if defined (_PTHREAD_ENV_DECC) "
590 "|| defined (_PTHREAD_ENV_EPCC)\n"
591 "# define _PTHREAD_USE_PTDNAM_\n"
593 "# ifdef _PTHREAD_ENV_DECC\n"
594 "# define _PTHREAD_USE_PTDNAM_\n"
600 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
603 hackname = alpha_pthread_gcc;
605 select = "#else\n# error <pthread.h>: unrecognized compiler.";
607 mach = "alpha*-dec-osf*";
609 c_fix_arg = "#elif defined (__GNUC__)\n"
610 "# define _PTHREAD_ENV_GCC\n"
613 test_text = "# define _PTHREAD_ENV_INTELC\n"
615 "# error <pthread.h>: unrecognized compiler.\n"
621 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
622 * incorrectly, specifying less fields in the initializers than are
623 * defined in the corresponding structure types. Use of these macros
624 * in user code results in spurious warnings.
627 hackname = alpha_pthread_init;
629 select = ' \
* @\
(#\
).RCSfile
: pthread\.h
,v \$
'
630 ' .Revision
: 1\
.1\
.33\
.21 \$ \
(DEC\
)'
631 ' .Date
: 2000/08/15 15:30:13 \$
';
632 mach = "alpha*-dec-osf*";
633 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
634 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
635 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
636 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
637 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
638 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
639 test_text = <<- _EOText_
641 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
643 #ifndef _PTHREAD_NOMETER_STATIC
644 # define PTHREAD_MUTEX_INITIALIZER \
645 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
646 # define PTHREAD_COND_INITIALIZER \
647 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
648 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
649 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
650 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
651 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
653 # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
654 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
655 {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
656 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
657 {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
660 #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
661 #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
662 {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
668 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
672 hackname = alpha_sbrk;
674 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
676 c_fix_arg = "void *sbrk(";
677 test_text = "extern char* sbrk(ptrdiff_t increment);";
682 * Change external names of wcstok/wcsftime via asm instead of macros on
686 hackname = alpha_wchar;
689 mach = "alpha*-dec-osf4*";
690 select = "#define wcstok wcstok_r";
691 sed = "s@#define wcstok wcstok_r@"
692 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, "
693 "wchar_t **)) __asm__(\"wcstok_r\");@";
694 sed = "s@#define wcsftime __wcsftime_isoc@"
695 "extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *"
696 ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
697 test_text = "#define wcstok wcstok_r\n"
698 "#define wcsftime __wcsftime_isoc";
703 * For C++, avoid any typedef or macro definition of bool,
704 * and use the built in type instead.
705 * HP/UX 10.20 also has it in curses_colr/curses.h.
708 hackname = avoid_bool_define;
710 files = curses_colr/curses.h;
714 select = "#[ \t]*define[ \t]+bool[ \t]";
715 bypass = "__cplusplus";
718 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
719 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
721 test_text = "# define bool\t char \n";
726 hackname = avoid_bool_type;
728 files = curses_colr/curses.h;
732 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
733 bypass = "__cplusplus";
736 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
738 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
743 * For C++, avoid any typedef definition of wchar_t,
744 * and use the built in type instead.
745 * Don't do this for headers that are smart enough to do the right
746 * thing (recent
[n
]curses.h and Xlib.h
).
747 * Don
't do it for <linux/nls.h> which is never used from C++ anyway,
748 * and will be broken by the edit.
752 hackname = avoid_wchar_t_type;
754 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
755 bypass = "__cplusplus";
756 bypass = "_LINUX_NLS_H";
757 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
760 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
762 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
767 * Fix `typedef struct term;' on hppa1.1
-hp
-hpux9.
770 hackname
= bad_struct_term
;
772 select
= "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
774 c_fix_arg
= "struct term;";
776 test_text
= 'typedef struct term;';
781 * Fix one other error in this file
:
782 * a mismatched quote not inside a C comment.
786 files
= sundev
/vuid_event.h
;
789 c_fix_arg
= "does not";
791 test_text
= "/* doesn't have matched single quotes */";
796 * check for broken assert.h that needs stdio.h
799 hackname
= broken_assert_stdio
;
802 bypass
= "include.*stdio\\.h";
804 c_fix_arg
= "#include <stdio.h>\n";
805 test_text
= "extern FILE* stderr;";
810 * check for broken assert.h that needs stdlib.h
813 hackname
= broken_assert_stdlib
;
815 select
= 'exit *\(|abort *\(';
816 bypass
= "include.*stdlib\\.h";
818 c_fix_arg
= "#ifdef __cplusplus\n"
819 "#include <stdlib.h>\n"
821 test_text
= "extern void exit ( int );";
826 * Remove `extern double cabs
' declarations from math.h.
827 * This conflicts with C99. Discovered on AIX.
828 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
829 * declares cabs() to take a struct __cabs_s argument.
830 * SunOS4 has its cabs() declaration followed by a comment which
831 * terminates on the following line.
832 * Darwin hides its broken cabs in architecture-specific subdirs.
835 hackname = broken_cabs;
836 files = math.h, "architecture/*/math.h";
837 select = "^extern[ \t]+double[ \t]+cabs";
839 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
840 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
842 test_text = "#ifdef __STDC__\n"
843 "extern double cabs(struct dbl_hypot);\n"
845 "extern double cabs();\n"
847 "extern double cabs ( _Complex z );\n"
848 "extern double cabs(); /* This is a comment\n"
849 " and it ends here. */\n"
850 "extern double cabs(struct __cabs_s);\n"
851 "extern long double cabsl( struct __cabsl_s );";
856 * Fixup Darwin's broken check for __builtin_nanf.
859 hackname
= broken_nan
;
861 * It is tempting to omit the first
"files" entry. Do not.
862 * The testing machinery will take the first
"files" entry as the name
863 * of a test file to play with. It would be a nuisance to have a directory
866 files
= "architecture/ppc/math.h";
867 files
= "architecture/*/math.h";
868 select
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
872 test_text
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
877 * Various systems derived from BSD4.4 contain a macro definition
878 * for vfscanf that interacts badly with requirements of builtin
-attrs.def.
879 * Known to be fixed in FreeBSD
5 system headers.
882 hackname
= bsd_stdio_attrs_conflict
;
884 mach
= "*-*-*darwin*";
886 select
= "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
888 c_fix_arg
= '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
889 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
890 'int vfscanf(FILE *, const char *, __builtin_va_list) '
891 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
892 test_text
= '#define vfscanf __svfscanf';
897 * Fix various macros used to define ioctl numbers.
898 * The traditional syntax was
:
900 * #define
_CTRL(n
, x
) (('n'<<8)+x
)
901 * #define TCTRLCFOO
_CTRL(T
, 1)
903 * but this does not work with the C standard
, which disallows macro
904 * expansion inside strings. We have to rewrite it thus
:
906 * #define
_CTRL(n
, x
) ((n
<<8)+x
)
907 * #define TCTRLCFOO
_CTRL('T', 1)
909 * The select expressions match too much
, but the c_fix code is cautious.
911 * CTRL might be
: CTRL _CTRL ISCTRL BSD43_CTRL ...
914 hackname
= ctrl_quotes_def
;
915 select
= "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
916 c_fix
= char_macro_def
;
920 * This is two tests in order to ensure that the
"CTRL(c)" can
921 * be selected in isolation from the multi
-arg format
923 test_text
= "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
924 test_text
= "#define _CTRL(c) ('c'&037)";
928 hackname
= ctrl_quotes_use
;
929 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
930 c_fix
= char_macro_use
;
932 test_text
= "#define TCTRLFOO BSD43_CTRL(T, 1)";
937 * sys
/mman.h on HP
/UX is not C
++ ready
,
938 * even though NO_IMPLICIT_EXTERN_C is defined on HP
/UX.
940 * rpc
/types.h on OSF1
/2.0 is not C
++ ready
,
941 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
943 * The problem is the declaration of malloc.
946 hackname
= cxx_unready
;
949 select
= '[^#]+malloc.*;'; /* Catch any form of declaration
950 not within a macro.
*/
951 bypass
= '"C"|__BEGIN_DECLS';
954 c_fix_arg
= "#ifdef __cplusplus\n"
957 c_fix_arg
= "#ifdef __cplusplus\n"
960 test_text
= "extern void* malloc( size_t );";
965 * On darwin8 and earlier
, mach
-o
/swap.h isn
't properly guarded
966 * by 'extern
"C"'. On darwin7 some mach/ headers aren't properly guarded.
969 hackname
= darwin_externc
;
970 mach
= "*-*-darwin*";
971 files
= mach
-o
/swap.h
;
972 files
= mach
/mach_time.h
;
973 files
= mach
/mach_traps.h
;
974 files
= mach
/message.h
;
976 files
= mach
/semaphore.h
;
977 bypass
= "extern \"C\"";
978 bypass
= "__BEGIN_DECLS";
980 c_fix_arg
= "#ifdef __cplusplus\n"
983 c_fix_arg
= "#ifdef __cplusplus\n"
986 test_text
= "extern void swap_fat_header();\n";
991 * AvailabilityMacros.h on Darwin breaks with GCC
4.0, because of
992 * bad __GNUC__ tests.
996 hackname
= darwin_gcc4_breakage
;
997 mach
= "*-*-darwin*";
998 files
= AvailabilityMacros.h
;
999 select
= "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1001 c_fix_arg
= "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1002 test_text
= "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1003 "(__GNUC_MINOR__ >= 1)\n";
1008 * __private_extern__ doesn
't exist in FSF GCC. Even if it did,
1009 * why would you ever put it in a system header file?
1012 hackname = darwin_private_extern;
1013 mach = "*-*-darwin*";
1014 files = mach-o/dyld.h;
1015 select = "__private_extern__ [a-z_]+ _dyld_";
1017 c_fix_arg = "extern";
1018 c_fix_arg = "__private_extern__";
1019 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1020 "const char *dyld_func_name,\n"
1021 "unsigned long *address);\n";
1026 * Fix <c_asm.h> on Digital UNIX V4.0:
1027 * It contains a prototype for a DEC C internal asm() function,
1028 * clashing with gcc's asm keyword. So protect this with __DECC.
1031 hackname
= dec_intern_asm
;
1033 sed
= "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1034 sed
= "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1038 " ... asm stuff ...\n"
1039 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1044 * Fix typo in
<wchar.h
> on DJGPP
2.03.
1047 hackname
= djgpp_wchar_h
;
1049 select
= "__DJ_wint_t";
1050 bypass
= "sys/djtypes.h";
1052 c_fix_arg
= "%0\n#include <sys/djtypes.h>";
1053 c_fix_arg
= "#include <stddef.h>";
1054 test_text
= "#include <stddef.h>\n"
1055 "extern __DJ_wint_t x;\n";
1060 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1063 hackname
= ecd_cursor
;
1064 files
= "sunwindow/win_lock.h";
1065 files
= "sunwindow/win_cursor.h";
1066 select
= 'ecd\.cursor';
1068 c_fix_arg
= 'ecd_cursor';
1070 test_text
= "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1075 * Between
8/24/1998 and
2/17/2001, FreeBSD system headers presume
1076 * neither the existence of GCC
3 nor its exact feature set yet break
1077 * (by design?
) when __GNUC__ is set beyond
2.
1080 hackname
= freebsd_gcc3_breakage
;
1081 mach
= "*-*-freebsd*";
1082 files
= sys
/cdefs.h
;
1083 select
= '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1084 bypass
= '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1086 c_fix_arg
= '%0 || __GNUC__ >= 3';
1087 test_text
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1092 * Some releases of FreeBSD
4 and FreeBSD
5.0 and
5.1 system headers presume
1093 * neither the existence of GCC
4 nor its exact feature set yet break
1094 * (by design?
) when __GNUC__ is set beyond
3.
1097 hackname
= freebsd_gcc4_breakage
;
1098 mach
= "*-*-freebsd*";
1099 files
= sys
/cdefs.h
;
1100 select
= '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1102 c_fix_arg
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1103 test_text
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1108 * Some versions of glibc don
't expect the C99 inline semantics.
1111 hackname = glibc_c99_inline_1;
1112 files = features.h, '*/features.h
';
1113 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1115 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1117 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1118 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1119 # define __USE_EXTERN_INLINES 1
1126 * Similar, but a version that didn't have __NO_INLINE__
1129 hackname
= glibc_c99_inline_1a
;
1130 files
= features.h
, '*/features.h';
1131 select
= "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1132 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1134 c_fix_arg
= "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1136 #if
__GNUC_PREREQ (2, 7) && defined __OPTIMIZE__
&& !defined __OPTIMIZE_SIZE__
1137 # define __USE_EXTERN_INLINES
1
1144 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1145 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1146 * The remaining glibc_c99_inline_
* fixes deal with some of those headers.
1149 hackname
= glibc_c99_inline_2
;
1150 files
= sys
/stat.h
, '*/sys/stat.h';
1151 select
= "extern __inline__ int";
1152 sed
= "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
1153 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1154 "__inline__ int \\1/";
1155 sed
= "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
1156 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1157 "__inline__ int __REDIRECT\\1 (\\2/";
1158 sed
= "s/^extern __inline__ int/"
1159 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1162 extern int
fstat64 (int __fd
, struct stat64
*__buf
) __THROW
__nonnull ((2));
1163 extern __inline__ int
1164 __NTH (fstat64 (int __fd
, struct stat64
*__statbuf
))
1171 hackname
= glibc_c99_inline_3
;
1172 files
= bits
/string2.h
, '*/bits/string2.h';
1173 select
= "extern __inline";
1174 bypass
= "__extern_inline|__GNU_STDC_INLINE__";
1176 c_fix_arg
= "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1177 c_fix_arg
= "^# ifdef __cplusplus$";
1180 # define __STRING_INLINE inline
1182 # define __STRING_INLINE extern __inline
1189 hackname
= glibc_c99_inline_4
;
1190 files
= sys
/sysmacros.h
, '*/sys/sysmacros.h', wchar.h
, '*/wchar.h';
1191 bypass
= "__extern_inline|__gnu_inline__";
1192 select
= "(^| )extern __inline";
1194 c_fix_arg
= "%0 __attribute__ ((__gnu_inline__))";
1196 __extension__ extern __inline unsigned int
1197 extern __inline unsigned int
1202 /* glibc
-2.3.5 defines pthread mutex initializers incorrectly
,
1203 * so we replace them with versions that correspond to the
1207 hackname
= glibc_mutex_init
;
1209 select
= '\{ *\{ *0, *\} *\}';
1210 sed
= "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1211 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1212 sed
= "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1213 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1214 sed
= "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1215 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1216 sed
= "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1217 "N;s/^[ \t]*#[ \t]*"
1218 "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1219 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n"
1221 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1224 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n"
1226 sed
= "s/{ \\(0, 0, 0, 0, 0, 0, "
1227 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1228 sed
= "/define[ \t]\\+PTHREAD_COND_INITIALIZER/"
1229 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1231 test_text
= <<- _EOText_
1232 #define PTHREAD_MUTEX_INITIALIZER
\\
1235 # if __WORDSIZE
== 64
1236 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
\\
1237 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP
} }
1238 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
\\
1239 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP
} }
1240 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
\\
1241 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP
} }
1243 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
\\
1244 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP
} }
1245 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
\\
1246 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP
} }
1247 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
\\
1248 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP
} }
1251 # define PTHREAD_RWLOCK_INITIALIZER
\\
1254 # if __WORDSIZE
== 64
1255 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
\\
1256 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1257 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
} }
1259 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
\\
1260 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
} }
1263 #define PTHREAD_COND_INITIALIZER
{ { 0, } }
1268 /* glibc
's tgmath.h relies on an expression that is not an integer
1269 constant expression being treated as it was by GCC 4.4 and
1272 hackname = glibc_tgmath;
1274 select = '\
(\
(\
(type\
) 0.25\
) && \
(\
(type\
) 0.25 - 1\
)\
)';
1275 bypass = "__floating_type \\\\\n.*__builtin_classify_type";
1277 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1278 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1282 * Fix these files to use the types we think they should for
1283 * ptrdiff_t, size_t, and wchar_t.
1285 * This defines the types in terms of macros predefined by our 'cpp
'.
1286 * This is supposedly necessary for glibc's handling of these types.
1287 * It
's probably not necessary for anyone else, but it doesn't hurt.
1290 hackname
= gnu_types
;
1291 files
= "sys/types.h";
1293 files
= "sys/stdtypes.h";
1297 bypass
= '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1298 select
= "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1300 /* The Solaris
10 headers already define these types correctly.
*/
1301 mach
= '*-*-solaris2.1[0-9]*';
1304 test_text
= "typedef long int ptrdiff_t; /* long int */\n"
1305 "typedef uint_t size_t; /* uint_t */\n"
1306 "typedef ushort_t wchar_t; /* ushort_t */";
1311 * Fix HP
& Sony
's use of "../machine/xxx.h"
1312 * to refer to: <machine/xxx.h>
1315 hackname = hp_inline;
1316 files = sys/spinlock.h;
1317 files = machine/machparam.h;
1318 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1321 c_fix_arg = "%1<machine
/%2.h
>";
1323 c_fix_arg = "([ \t]*#
[ \t]*include
[ \t]+)" '"\.\.
/machine
/'
1326 test_text = ' # include "..
/machine
/mumble.h
"';
1331 * Check for (...) in C++ code in HP/UX sys/file.h.
1334 hackname = hp_sysfile;
1336 select = "HPUX_SOURCE
";
1339 c_fix_arg = "(struct file
*, ...
)";
1340 c_fix_arg = '\(\.\.\.\)';
1342 test_text = "extern void
foo(...
); /* HPUX_SOURCE
- bad varargs
*/";
1347 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1348 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1351 hackname = hppa_hpux_fp_macros;
1352 mach = "hppa
*-hp
-hpux11
*";
1354 select = "#
[ \t]*define
[ \t]*FP_NORMAL.
*\n"
1355 "#
[ \t]*define
[ \t]*FP_ZERO.
*\n"
1356 "#
[ \t]*define
[ \t]*FP_INFINITE.
*\n"
1357 "#
[ \t]*define
[ \t]*FP_SUBNORMAL.
*\n"
1358 "#
[ \t]*define
[ \t]*FP_NAN.
*\n";
1360 c_fix_arg = <<- _EOFix_
1361 #endif /* _INCLUDE_HPUX_SOURCE */
1363 #if defined(_INCLUDE_HPUX_SOURCE) || \
1364 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1367 #ifdef _INCLUDE_HPUX_SOURCE
1372 "# define FP_NORMAL
0\n"
1373 "# define FP_ZERO
1\n"
1374 "# define FP_INFINITE
2\n"
1375 "# define FP_SUBNORMAL
3\n"
1376 "# define FP_NAN
4\n";
1381 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1382 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1385 hackname = hpux10_cpp_pow_inline;
1386 files = fixinc-test-limits.h, math.h;
1387 select = <<- END_POW_INLINE
1388 ^# +ifdef +__cplusplus
1390 +inline +double +pow\(double +__d,int +__expon\) +\{
1391 [ ]+return +pow\(__d,\(double\)__expon\);
1402 "# ifdef __cplusplus
\n"
1404 " inline double
pow(double __d
,int __expon
) {\n"
1405 "\t return
pow(__d
,(double
)__expon
);\n"
1407 ' extern "C
"' " {\n"
1413 hackname = hpux11_cpp_pow_inline;
1415 select = " +inline double pow
\\(double d
,int expon
\\) \\{\n"
1416 " +return pow
\\(d
, \\(double
\\)expon
\\);\n"
1422 " inline double
pow(double d
,int expon
) {\n"
1423 " return
pow(d
, (double
)expon
);\n"
1429 * Fix hpux 10.X missing ctype declarations 1
1432 hackname = hpux10_ctype_declarations1;
1434 select = "^#
[ \t]*define _toupper
\\(__c
\\)[ \t]*__toupper
\\(__c
\\)";
1435 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*__tolower
[ \t]*\\(";
1437 c_fix_arg = "#ifdef _PROTOTYPES
\n"
1438 "extern int
__tolower(int
);\n"
1439 "extern int
__toupper(int
);\n"
1440 "#else
/* NOT _PROTOTYPES
*/\n"
1441 "extern int
__tolower();\n"
1442 "extern int
__toupper();\n"
1443 "#endif
/* _PROTOTYPES
*/\n\n"
1446 test_text = "# define
_toupper(__c
) __toupper(__c
)\n";
1451 * Fix hpux 10.X missing ctype declarations 2
1454 hackname = hpux10_ctype_declarations2;
1456 select = "^# if defined
\\(_SB_CTYPE_MACROS
\\) && \\!defined
\\(__lint
\\)";
1457 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*_isalnum
[ \t]*\\(";
1459 c_fix_arg = "%0\n\n"
1460 "#ifdef _PROTOTYPES
\n"
1461 " extern int
_isalnum(int
);\n"
1462 " extern int
_isalpha(int
);\n"
1463 " extern int
_iscntrl(int
);\n"
1464 " extern int
_isdigit(int
);\n"
1465 " extern int
_isgraph(int
);\n"
1466 " extern int
_islower(int
);\n"
1467 " extern int
_isprint(int
);\n"
1468 " extern int
_ispunct(int
);\n"
1469 " extern int
_isspace(int
);\n"
1470 " extern int
_isupper(int
);\n"
1471 " extern int
_isxdigit(int
);\n"
1472 "# else
/* not _PROTOTYPES
*/\n"
1473 " extern int
_isalnum();\n"
1474 " extern int
_isalpha();\n"
1475 " extern int
_iscntrl();\n"
1476 " extern int
_isdigit();\n"
1477 " extern int
_isgraph();\n"
1478 " extern int
_islower();\n"
1479 " extern int
_isprint();\n"
1480 " extern int
_ispunct();\n"
1481 " extern int
_isspace();\n"
1482 " extern int
_isupper();\n"
1483 " extern int
_isxdigit();\n"
1484 "#endif
/* _PROTOTYPES
*/\n";
1486 test_text = "# if
defined(_SB_CTYPE_MACROS
) && !defined(__lint
)\n"
1487 " extern unsigned int
*__SB_masks
;\n";
1492 * Fix hpux 10.X missing stdio declarations
1495 hackname = hpux10_stdio_declarations;
1497 select = "^#
[ \t]*define _iob
[ \t]*__iob
";
1498 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*vsnprintf
[ \t]*\\(";
1500 c_fix_arg = "%0\n\n"
1501 "# if
defined(__STDC__
) ||
defined(__cplusplus
)\n"
1502 " extern int
snprintf(char
*, size_t
, const char
*, ...
);\n"
1503 " extern int
vsnprintf(char
*, size_t
, const char
*, __va_list
);\n"
1504 "# else
/* not __STDC__
) || __cplusplus
*/\n"
1505 " extern int
snprintf();\n"
1506 " extern int
vsnprintf();\n"
1507 "# endif
/* __STDC__
) || __cplusplus
*/\n";
1509 test_text = "# define _iob __iob
\n";
1514 * Make sure hpux defines abs in header.
1517 hackname = hpux11_abs;
1518 mach = "ia64
-hp
-hpux11
*";
1520 select = "ifndef _MATH_INCLUDED
";
1522 c_fix_arg = "if
!defined(_MATH_INCLUDED
) ||
defined(__GNUG__
)";
1523 test_text = "#ifndef _MATH_INCLUDED
";
1528 * Keep HP-UX 11 from stomping on C++ math namespace
1529 * with defines for fabsf.
1532 hackname = hpux11_fabsf;
1534 select = "^
[ \t]*#
[ \t]*define
[ \t]+fabsf
\\(.
*";
1535 bypass = "__cplusplus
";
1538 c_fix_arg = "#ifndef __cplusplus
\n%0\n#endif
";
1542 "# define
fabsf(x
) ((float
)fabs((double
)(float
)(x
)))\n"
1548 * Fix C99 constant in __POINTER_SET define.
1551 hackname = hpux11_pthread_const;
1552 mach = "*-hp
-hpux11.
[0-3]*";
1553 files = sys/pthread.h;
1554 select = "^#define
[ \t]*__POINTER_SET
[ \t]*\\(\\(void
\\*\\) 1LL\\)";
1557 c_fix_arg = "#define __POINTER_SET
\t\t((void *)
1L)";
1558 test_text = "#define __POINTER_SET
\t\t((void *)
1LL)";
1563 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1564 * being defined by having it define _hpux_size_t instead.
1567 hackname = hpux11_size_t;
1568 mach = "*-hp
-hpux11
*";
1569 select = "__size_t
";
1572 c_fix_arg = "_hpux_size_t
";
1575 "#define __size_t size_t
\n"
1576 " extern int
getpwuid_r( char
*, __size_t
, struct passwd
**)
;\n";
1581 * Fix hpux 11.00 broken snprintf declaration
1582 * (third argument is char *, needs to be const char * to prevent
1583 * spurious warnings with -Wwrite-strings or in C++).
1586 hackname = hpux11_snprintf;
1588 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
1589 ' *(char *\*, *\.\.\.\);)';
1591 c_fix_arg = '%1 const %3';
1593 test_text = "extern int
snprintf(char
*, size_t
, char
*, ...
);\n"
1594 "extern int
snprintf(char
*, __size_t
, char
*, ...
);\n"
1595 "extern int
snprintf(char
*, _hpux_size_t
, char
*, ...
);";
1600 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1601 * of UINT32_C has undefined behavior according to ISO/ANSI:
1602 * the arguments to __CONCAT__ are not macro expanded before the
1603 * concatination happens so the trailing ')' in the first argument
1604 * is concatinated with the 'l' in the second argument creating an
1605 * invalid pp token. The behavior of invalid pp tokens is undefined.
1606 * GCC does not handle these invalid tokens the way the HP compiler does.
1607 * This problem will potentially occur anytime macros are used in the
1608 * arguments to __CONCAT__. A general solution to this problem would be to
1609 * insert another layer of macro between __CONCAT__ and its use
1610 * in UINT32_C. An example of this solution can be found in the C standard.
1611 * A more specific solution, the one used here, is to change the UINT32_C
1612 * macro to not used macros in the arguments to __CONCAT__.
1615 hackname = hpux11_uint32_c;
1617 select = "^#define UINT32_C
\\(__c
\\)[ \t]*"
1618 "__CONCAT__
\\(__CONCAT_U__
\\(__c
\\),l
\\)";
1620 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1622 "#define
CONCAT_U__(__c
)\t__CONCAT__
(__c
,u
)\n"
1623 "#define
UINT32_C(__c
)\t__CONCAT__
(__CONCAT_U__(__c
),l
)";
1628 * Fix hpux 11.00 broken vsnprintf declaration
1631 hackname = hpux11_vsnprintf;
1633 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1634 'const char \*,) __va__list\);';
1636 c_fix_arg = "%1 __va_list
);";
1638 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1644 * get rid of bogus inline definitions in HP-UX 8.0
1647 hackname = hpux8_bogus_inlines;
1650 bypass = "__GNUG__
";
1651 sed = "s@inline int
abs(int
[a
-z
][a
-z
]*)
{.
*}"
1652 "@extern
\"C
\" int
abs(int
);@
";
1653 sed = "s@inline double
abs(double
[a
-z
][a
-z
]*)
{.
*}@@
";
1654 sed = "s@inline int
sqr(int
[a
-z
][a
-z
]*)
{.
*}@@
";
1655 sed = "s@inline double
sqr(double
[a
-z
][a
-z
]*)
{.
*}@@
";
1656 test_text = "inline int
abs(int v
) { return (v
>=0)?v
:-v
; }\n"
1657 "inline double
sqr(double v
) { return v
**0.5; }";
1662 * Fix hpux broken ctype macros
1665 hackname = hpux_ctype_macros;
1667 select = '((: |\()__SB_masks \? )'
1668 '(__SB_masks\[__(alnum|c)\] & _IS)';
1670 c_fix_arg = "%1(int
)%3";
1672 test_text = ": __SB_masks ? __SB_masks
[__alnum
] & _ISCNTRL
\n"
1673 "# define
isalpha(__c
) (__SB_masks ? __SB_masks
[__c
] & _IS
\n";
1678 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1681 hackname = hpux_htonl;
1682 files = netinet/in.h;
1683 select = "#ifndef _XOPEN_SOURCE_EXTENDED
\n"
1685 " \\* Macros for number representation conversion
\\.
\n"
1689 c_fix_arg = "#if
1\n%1";
1691 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED
\n"
1693 " * Macros for number representation conversion.
\n"
1696 "#define
ntohl(x
) (x
)\n"
1697 "#define
ntohs(x
) (x
)\n"
1698 "#define
htonl(x
) (x
)\n"
1699 "#define
htons(x
) (x
)\n"
1701 "#endif
/* ! _XOPEN_SOURCE_EXTENDED
*/";
1709 hackname = hpux_long_double;
1711 select = "extern
[ \t]long_double
[ \t]strtold
";
1712 bypass = "long_double_t
";
1713 sed = "/^#
[ \t]*ifndef _LONG_DOUBLE
/,/\\/\\* _LONG_DOUBLE
\\*\\//D
";
1714 sed = "s
/long_double
/long double
/g
";
1716 test_text = "# ifndef _LONG_DOUBLE
\n"
1717 "# define _LONG_DOUBLE
\n"
1718 " typedef struct
{\n"
1719 " unsigned int word1
, word2
, word3
, word4
;\n"
1721 "# endif
/* _LONG_DOUBLE
*/\n"
1722 "extern long_double
strtold(const char
*, char
**)
;\n";
1727 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1730 hackname = hpux_systime;
1732 select = "^extern struct sigevent
;";
1735 c_fix_arg = "struct sigevent
;";
1737 test_text = 'extern struct sigevent;';
1742 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
1743 * type and mpinfou is only defined when _KERNEL is set.
1746 hackname = hpux_spu_info;
1747 mach = "*-hp
-hpux
*";
1749 * It is tempting to omit the first "files
" entry. Do not.
1750 * The testing machinery will take the first "files
" entry as the name
1751 * of a test file to play with. It would be a nuisance to have a directory
1752 * with the name "*".
1754 files = "ia64
/sys
/getppdp.h
";
1755 files = "*/sys
/getppdp.h
";
1756 select = "^.
*extern.
*spu_info.
*";
1759 c_fix_arg = "#ifdef _KERNEL
\n%0\n#endif
";
1761 test_text = "extern union mpinfou spu_info
[];";
1765 hackname = hpux11_extern_sendfile;
1766 mach = "*-hp
-hpux11.
[12]*";
1767 files = sys/socket.h;
1768 select = "^
[ \t]*extern sbsize_t sendfile.
*\n.
*, int
\\)\\);\n";
1770 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T
\n%0#endif
\n";
1771 test_text = " extern sbsize_t sendfile
__((int
, int
, off_t
, bsize_t
,\n const struct iovec
*, int
));\n";
1775 hackname = hpux11_extern_sendpath;
1776 mach = "*-hp
-hpux11.
[12]*";
1777 files = sys/socket.h;
1778 select = "^
[ \t]*extern sbsize_t sendpath.
*\n.
*, int
\\)\\);\n";
1780 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T
\n%0#endif
\n";
1781 test_text = " extern sbsize_t sendpath
__((int
, int
, off_t
, bsize_t
,\n const struct iovec
*, int
));\n";
1785 hackname = hpux_extern_errno;
1786 mach = "*-hp
-hpux10.
*";
1787 mach = "*-hp
-hpux11.
[0-2]*";
1789 select = "^
[ \t]*extern int errno
;$
";
1791 c_fix_arg = "#ifdef __cplusplus
\nextern
\"C
\" {\n#endif
\n%0\n#ifdef __cplusplus
\n}\n#endif
";
1792 test_text = " extern int errno
;\n";
1797 * Add missing braces to pthread initializer defines.
1800 hackname = hpux_pthread_initializers;
1801 mach = "*-hp
-hpux11.
[0-3]*";
1802 files = sys/pthread.h;
1803 sed = "s@^
[ \t]*1, 1, 1, 1,[ \t]*\\\\"
1804 "@
\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@
";
1805 sed = "s@^
[ \t]*1,[ \t]*\\\\"
1807 sed = "/^
[ \t]*0$
/d
";
1808 sed = "s@__PTHREAD_MUTEX_VALID
, 0"
1809 "@
{ __PTHREAD_MUTEX_VALID
, 0 }@
";
1810 sed = "s@^
[ \t]*0, 0, -1, 0,[ \t]*\\\\"
1811 "@
\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@
";
1812 sed = "s@
0, __LWP_MTX_VALID
, 0, 1, 1, 1, 1,[ \t]*\\\\"
1813 "@
{ 0, __LWP_MTX_VALID
}, { 0, 1, 1, 1, 1 },\t\t\t\\\\@
";
1814 sed = "s@^
[ \t]*__LWP_MTX_VALID
, 0, 1, 1, 1, 1,[ \t]*\\\\"
1815 "@
\t{ 0, __LWP_MTX_VALID
}, { 0, 1, 1, 1, 1 },\t\t\t\\\\@
";
1816 sed = "s@^
[ \t]*0, 0[ \t]*\\\\"
1817 "@
\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@
";
1818 sed = "s@__PTHREAD_COND_VALID
, 0"
1819 "@
{ __PTHREAD_COND_VALID
, 0 }@
";
1820 sed = "s@__LWP_COND_VALID
, 0,[ \t]*\\\\"
1821 "@
{ __LWP_COND_VALID
, 0 },\t\t\t\t\t\\\\@
";
1822 sed = "s@__PTHREAD_RWLOCK_VALID
, 0"
1823 "@
{ __PTHREAD_RWLOCK_VALID
, 0 }@
";
1824 sed = "s@__LWP_RWLOCK_VALID
, 0,[ \t]*\\\\"
1825 "@
{ __LWP_RWLOCK_VALID
, 0 },\t\t\t\t\t\\\\@
";
1826 sed = "s@^
[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
1827 "@
\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@
";
1828 test_text = "#define PTHREAD_MUTEX_INITIALIZER
{\t\t\t\t\t\\\\\n"
1829 "\t__PTHREAD_MUTEX_VALID
, 0,\t\t\t\t\t\\\\\n"
1830 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE
),\t\t\\\\\n"
1831 "\t__SPNLCK_INITIALIZER
,\t\t\t\t\t\t\\\\\n"
1832 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
1833 "\t0, __LWP_MTX_VALID
, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
1834 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
1839 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
1842 hackname = huge_val_hex;
1843 files = bits/huge_val.h;
1844 select = "^#
[ \t]*define
[ \t]*HUGE_VAL
[ \t].
*0x1\\.0p.
*";
1845 bypass = "__builtin_huge_val
";
1848 c_fix_arg = "#define
HUGE_VAL (__builtin_huge_val())\n";
1850 test_text = "# define HUGE_VAL
\t(__extension__
0x1.0p2047
)";
1855 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
1858 hackname = huge_valf_hex;
1859 files = bits/huge_val.h;
1860 select = "^#
[ \t]*define
[ \t]*HUGE_VALF
[ \t].
*0x1\\.0p.
*";
1861 bypass = "__builtin_huge_valf
";
1864 c_fix_arg = "#define
HUGE_VALF (__builtin_huge_valf())\n";
1866 test_text = "# define
HUGE_VALF (__extension__
0x1.0p255f
)";
1871 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
1874 hackname = huge_vall_hex;
1875 files = bits/huge_val.h;
1876 select = "^#
[ \t]*define
[ \t]*HUGE_VALL
[ \t].
*0x1\\.0p.
*";
1877 bypass = "__builtin_huge_vall
";
1880 c_fix_arg = "#define
HUGE_VALL (__builtin_huge_vall())\n";
1882 test_text = "# define
HUGE_VALL (__extension__
0x1.0p32767L
)";
1887 * Fix return type of abort and free
1890 hackname = int_abort_free_and_exit;
1892 select = "int
[ \t]+(abort|free|exit
)[ \t]*\\(";
1893 bypass = "_CLASSIC_ANSI_TYPES
";
1896 c_fix_arg = "void
\t%1(";
1898 test_text = "extern int
abort(int
);\n"
1899 "extern int
free(void*)
;\n"
1900 "extern int
exit(void*)
;";
1905 * Fix various macros used to define ioctl numbers.
1906 * The traditional syntax was:
1908 * #define _IO(n, x) (('n'<<8)+x)
1909 * #define TIOCFOO _IO(T, 1)
1911 * but this does not work with the C standard, which disallows macro
1912 * expansion inside strings. We have to rewrite it thus:
1914 * #define _IO(n, x) ((n<<8)+x)
1915 * #define TIOCFOO _IO('T', 1)
1917 * The select expressions match too much, but the c_fix code is cautious.
1919 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1922 hackname = io_quotes_def;
1923 select = "define
[ \t]+[A
-Z0
-9_
]+IO
[A
-Z
]*\\([a
-zA
-Z
][,)]";
1924 c_fix = char_macro_def;
1927 "#define
BSD43__IOWR(n
, x
) (('n'<<8)+x
)\n"
1928 "#define
_IOWN(x
,y
,t
) (_IOC_IN|
(((t
)&_IOCPARM_MASK
)<<16)|
('x'<<8)|y
)\n"
1929 "#define
_IO(x
,y
) ('x'<<8|y
)";
1931 "#define
XX_IO(x
) ('x'<<8|
256)";
1935 hackname = io_quotes_use;
1936 select = "define
[ \t]+[A
-Z0
-9_
]+[ \t]+[A
-Z0
-9_
]+IO
[A
-Z
]*[ \t]*"
1938 c_fix = char_macro_use;
1940 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1941 "#define TIOCFOO \\\\\n"
1942 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1947 * Check for missing ';' in struct
1950 hackname = ip_missing_semi;
1951 files = netinet/ip.h;
1953 sed = "/^struct/,/^};/s/}$/};/";
1959 "}; /* mumbled struct */\n";
1964 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1965 * __restrict as restrict iff __c99. This is wrong for C++, which
1966 * needs many C99 features, but only supports __restrict.
1969 hackname = irix___restrict;
1970 files = internal/sgimacros.h;
1971 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1973 mach = "mips-sgi-irix6.5";
1976 "# ifndef __cplusplus\n%2\n# endif";
1978 test_text = "#ifdef __c99\n# define __restrict restrict";
1982 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
1983 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
1986 * This was probably introduced around IRIX 6.5.18
1989 hackname = irix___generic1;
1990 files = internal/math_core.h;
1991 mach = "mips-sgi-irix6.5";
1992 select = "#define ([a-z]+)\\(x\\) *__generic.*";
1995 c_fix_arg = "extern int %1(double);\n"
1996 "extern int %1f(float);\n"
1997 "extern int %1l(long double);\n"
1998 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
1999 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
2003 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2007 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2008 compiler's __generic intrinsic to define isgreater
, isgreaterequal
,
2009 isless
, islessequal
, islessgreater and isunordered functions.
*/
2011 hackname
= irix___generic2
;
2012 files
= internal
/math_core.h
;
2013 mach
= "mips-sgi-irix6.5";
2014 select
= "#define ([a-z]+)\\(x,y\\) *__generic.*";
2017 c_fix_arg
= "#define %1(x,y) \\\n"
2018 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2019 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2023 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2028 * IRIX
5.2's <sys/asm.h> contains an asm comment with a contraction
2029 * that causes the assembly preprocessor to complain about an
2030 * unterminated character constant.
2033 hackname = irix_asm_apostrophe;
2036 select = "^[ \t]*#.*[Ww]e're
";
2038 c_fix_arg = "%1 are
";
2039 c_fix_arg = "^
([ \t]*#.
*[Ww
]e
)'re";
2040 test_text = "\t# and we're on vacation
";
2045 * Non-traditional "const
" declaration in Irix's limits.h.
2048 hackname = irix_limits_const;
2049 files = fixinc-test-limits.h, limits.h;
2050 select = "^extern const
";
2052 c_fix_arg = "extern __const
";
2053 test_text = "extern const char limit
; /* test limits
*/";
2058 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2059 * Various socket function prototypes use different types instead,
2060 * depending on the API in use (BSD, XPG4/5), but the socklen_t
2061 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
2065 hackname = irix_socklen_t;
2066 files = sys/socket.h;
2067 select = "(#define _SOCKLEN_T
\n)(typedef u_int32_t socklen_t
;)";
2069 mach = "mips
-sgi
-irix6.5
";
2072 "#if _NO_XOPEN4
&& _NO_XOPEN5
\n"
2073 "typedef int socklen_t
;\n"
2076 "#endif
/* _NO_XOPEN4
&& _NO_XOPEN5
*/";
2078 test_text = "#define _SOCKLEN_T
\ntypedef u_int32_t socklen_t
;";
2082 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2086 hackname = irix_stdint_c99;
2088 select = "(#ifndef __c99
\n)(#error This header file is to be used only for c99 mode compilations
)";
2090 mach = "mips
-sgi
-irix6.5
";
2092 c_fix_arg = "#if
0\n"
2095 "#ifndef __c99
\n#error This header file is to be used only for c99 mode compilations
\n#else
";
2100 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2101 * some functions that take a va_list as
2102 * taking char *. However, GCC uses void * for va_list, so
2103 * calling vfprintf with a va_list fails in C++. */
2105 hackname = irix_stdio_va_list;
2107 files = internal/stdio_core.h;
2109 select = '/\* va_list \*/ char \*';
2111 c_fix_arg = "__gnuc_va_list
";
2113 "extern int
printf( const char
*, /* va_list
*/ char
* );";
2118 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2119 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2122 hackname = irix_wcsftime;
2123 files = internal/wchar_core.h;
2124 select = "#if _NO_XOPEN5
\n(extern size_t
[ \t]+wcsftime.
*const char \
*.*)
";
2126 mach = "mips
-sgi
-irix6.5
";
2128 c_fix_arg = "#if _NO_XOPEN5
&& !defined(__c99
)\n%1";
2130 test_text = "#if _NO_XOPEN5
\n"
2131 "extern size_t
wcsftime(wchar_t
*, "
2132 "__SGI_LIBC_NAMESPACE_QUALIFIER size_t
, const char
*, "
2133 "const struct tm *)
;";
2137 * Fixing ISC fmod declaration
2140 hackname = isc_fmod;
2142 select = 'fmod\(double\)';
2144 c_fix_arg = "fmod(double
, double
)";
2145 test_text = "extern double
fmod(double
);";
2150 * On Interactive Unix 2.2, certain traditional Unix definitions
2151 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
2152 * defined, not just if _POSIX_SOURCE is defined. This makes it
2153 * impossible to compile any nontrivial program except with -posix.
2156 hackname = isc_omits_with_stdc;
2161 files = "sys
/limits.h
";
2162 files = "sys
/fcntl.h
";
2163 files = "sys
/dirent.h
";
2165 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
2167 c_fix_arg = '!defined(_POSIX_SOURCE)';
2168 test_text = "#if
!defined(__STDC__
) && !defined(_POSIX_SOURCE
) /* ?
! */"
2169 "\nint foo
;\n#endif
";
2174 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2175 * use / * * / to concatenate tokens.
2178 hackname = kandr_concat;
2179 files = "sparc
/asm_linkage.h
";
2180 files = "sun
*/asm_linkage.h
";
2181 files = "arm
/as_support.h
";
2182 files = "arm
/mc_type.h
";
2183 files = "arm
/xcb.h
";
2184 files = "dev
/chardefmac.h
";
2185 files = "dev
/ps_irq.h
";
2186 files = "dev
/screen.h
";
2187 files = "dev
/scsi.h
";
2188 files = "sys
/tty.h
";
2189 files = "Xm.acorn
/XmP.h
";
2190 files = bsd43/bsd43_.h;
2194 test_text = "#define
__CONCAT__(a
,b
) a
/**/b
";
2198 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2199 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2200 * constant on recent versions of g++.
2203 hackname = linux_ia64_ucontext;
2204 files = "sys
/ucontext.h
";
2205 mach = "ia64
-*-linux
*";
2206 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2207 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2209 c_fix_arg = "__builtin_offsetof \
(struct sigcontext
, sc_gr
[0]\
)";
2210 test_text = "# define _SC_GR0_OFFSET
\t\\\\\n"
2211 "\t(((char *)
&((struct sigcontext *)
0)->sc_gr
[0]) - (char *)
0)\n";
2216 * Remove header file warning from sys/time.h. Autoconf's
2217 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2218 * which causes warning on LynxOS. Remove the warning.
2221 hackname = lynxos_no_warning_in_sys_time_h;
2223 select = "#warning
[ \t]+Using
<time.h
> instead of
<sys
/time.h
>";
2226 test_text = "#warning Using
<time.h
> instead of
<sys
/time.h
>";
2231 * Add missing declaration for putenv.
2234 hackname = lynxos_missing_putenv;
2235 mach = '*-*-lynxos*';
2237 bypass = 'putenv[ \t]*\\(';
2238 select = "extern char
\\*getenv
[ \t]*_AP
\\(\\(const char
\\*\\)\\);";
2241 "extern int putenv
_AP((char *)
);";
2242 c_fix_arg = "extern char
\\*getenv
[ \t]*_AP
\\(\\(const char
\\*\\)\\);";
2243 test_text = "extern char
*getenv
_AP((const char *)
);";
2248 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2250 * On NetBSD, machine is a symbolic link to an architecture specific
2251 * directory name, so we can't match a specific file name here.
2254 hackname = machine_ansi_h_va_list;
2255 select = "define
[ \t]+_BSD_VA_LIST_
[ \t]";
2256 bypass = '__builtin_va_list';
2259 c_fix_arg = "%1__builtin_va_list
";
2260 c_fix_arg = "(define
[ \t]+_BSD_VA_LIST_
[ \t]+).
*";
2262 test_text = " # define _BSD_VA_LIST_
\tchar
**";
2267 * Fix non-ansi machine name defines
2270 hackname = machine_name;
2271 c_test = machine_name;
2272 c_fix = machine_name;
2274 test_text = "/* MACH_DIFF
: */\n"
2275 "#if
defined( i386
) ||
defined( sparc
) ||
defined( vax
)"
2276 "\n/* no uniform test
, so be careful
:-) */";
2281 * Some math.h files define struct exception (it's in the System V
2282 * Interface Definition), which conflicts with the class exception defined
2283 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2284 * This is not a great fix, but I haven't been able to think of anything
2288 hackname = math_exception;
2290 select = "struct exception
";
2292 * This should be bypassed on __cplusplus, but some supposedly C++ C++
2293 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2294 * exception either. So currently we bypass only for glibc, based on a
2295 * comment in the fixed glibc header. Ick.
2297 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2298 '_[a-z0-9A-Z_]+_exception; for C, exception';
2301 c_fix_arg = "#ifdef __cplusplus
\n"
2302 "#define exception __math_exception
\n"
2305 c_fix_arg = "#ifdef __cplusplus
\n"
2306 "#undef exception
\n"
2309 test_text = "typedef struct exception t_math_exception
;";
2314 * This looks pretty broken to me. ``dbl_max_def'' will contain
2315 * "define DBL_MAX
" at the start, when what we really want is just
2316 * the value portion. Can't figure out how to write a test case
2317 * for this either :-(
2320 hackname = math_huge_val_from_dbl_max;
2324 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2325 * in math.h, this fix applies.
2327 select = "define
[ \t]+HUGE_VAL
[ \t]+DBL_MAX
";
2328 bypass = "define
[ \t]+DBL_MAX
";
2332 * See if we have a definition for DBL_MAX in float.h.
2333 * If we do, we will replace the one in math.h with that one.
2336 "\tdbl_max_def
=`egrep
'define[ \t]+DBL_MAX[ \t]+.*' float.h
"
2337 "| sed
's/.*DBL_MAX[ \t]*//' 2>/dev
/null`
\n\n"
2339 "\tif
( test
-n
\"$
{dbl_max_def
}\" ) > /dev
/null
2>&1\n"
2340 "\tthen sed
-e
'/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2341 "s@DBL_MAX@'\"$dbl_max_def@
\"\n"
2346 "`echo
'#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`
\n"
2347 "#define HUGE_VAL DBL_MAX
";
2355 hackname = nested_auth_des;
2357 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2359 c_fix_arg = "%1*/ /*";
2360 test_text = "/*#include
<rpc
/auth_des.h
> /* skip this
*/";
2365 * Fixing nested comments in ISC <sys/limits.h>
2368 hackname = nested_sys_limits;
2369 files = sys/limits.h;
2371 sed = "/CHILD_MAX
/s
,/\\* Max
, Max
,";
2372 sed = "/OPEN_MAX
/s
,/\\* Max
, Max
,";
2373 test_text = "/*\n#define CHILD_MAX
20 /* Max
, Max
, ...
*/ /*\n"
2374 "#define OPEN_MAX
20 /* Max
, Max
, ...
*/\n";
2379 * Some versions of NetBSD don't expect the C99 inline semantics.
2382 hackname = netbsd_c99_inline_1;
2383 mach = "*-*-netbsd
*";
2385 select = "extern __inline int
";
2388 c_fix_arg = "extern
\n"
2389 "#ifdef __GNUC_STDC_INLINE__
\n"
2390 "__attribute__((__gnu_inline__
))\n"
2394 test_text = "extern __inline int
\nsigaddset
(sigset_t
*set
, int signo
)\n{}";
2399 hackname = netbsd_c99_inline_2;
2400 mach = "*-*-netbsd
*";
2402 select = "#define _SIGINLINE extern __inline
";
2405 c_fix_arg = <<- _EOArg_
2406 #ifdef __GNUC_STDC_INLINE__
2407 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2413 test_text = "#define _SIGINLINE extern __inline
";
2418 * NetBSD has a semicolon after the ending '}' for some extern "C
".
2421 hackname = netbsd_extra_semicolon;
2422 mach = "*-*-netbsd
*";
2423 files = sys/cdefs.h;
2424 select = "#define
[ \t]*__END_DECLS
[ \t]*};";
2427 c_fix_arg = "#define __END_DECLS
}";
2429 test_text = "#define __END_DECLS
};";
2433 /* newlib's stdint.h has several failures to conform to C99. The fix
2434 for these removed a comment that can be matched to identify unfixed
2437 hackname = newlib_stdint_1;
2439 select = "@todo
- Add support for wint_t types
";
2440 sed = "s@#define INT32_MIN.
*@#define
INT32_MIN (-INT32_MAX
- 1)@
";
2441 sed = "s@#define INT32_MAX.
*@#define INT32_MAX __INT32_MAX__@
";
2442 sed = "s@#define UINT32_MAX.
*@#define UINT32_MAX __UINT32_MAX__@
";
2443 sed = "s@#define INT_LEAST32_MIN.
*@#define
INT_LEAST32_MIN (-INT_LEAST32_MAX
- 1)@
";
2444 sed = "s@#define INT_LEAST32_MAX.
*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@
";
2445 sed = "s@#define UINT_LEAST32_MAX.
*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@
";
2446 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2447 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2448 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2449 sed = "s@#define SIZE_MAX.
*@#define SIZE_MAX __SIZE_MAX__@
";
2450 sed = "s@#define PTRDIFF_MIN.
*@#define
PTRDIFF_MIN (-PTRDIFF_MAX
- 1)@
";
2451 sed = "s@#define PTRDIFF_MAX.
*@#define PTRDIFF_MAX __PTRDIFF_MAX__@
";
2452 sed = "s@#define UINT8_C.
*@#define
UINT8_C(c
) __UINT8_C(c
)@
";
2453 sed = "s@#define UINT16_C.
*@#define
UINT16_C(c
) __UINT16_C(c
)@
";
2454 test_text = "/* @todo
- Add support for wint_t types.
*/\n"
2455 "#define
INT32_MIN (-2147483647-1)\n"
2456 "#define INT32_MAX
2147483647\n"
2457 "#define UINT32_MAX
4294967295U\n"
2458 "#define
INT_LEAST32_MIN (-2147483647-1)\n"
2459 "#define INT_LEAST32_MAX
2147483647\n"
2460 "#define UINT_LEAST32_MAX
4294967295U\n"
2461 "#define INT_FAST8_MIN INT8_MIN
\n"
2462 "#define INT_FAST8_MAX INT8_MAX
\n"
2463 "#define UINT_FAST8_MAX UINT8_MAX
\n"
2464 "#define
SIZE_MAX (__STDINT_EXP(LONG_MAX
) * 2UL + 1)\n"
2465 "#define
PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX
) - 1L)\n"
2466 "#define PTRDIFF_MAX
__STDINT_EXP(LONG_MAX
)\n"
2467 "#define
UINT8_C(x
) x##U
\n"
2468 "#define
UINT16_C(x
) x##U
";
2473 hackname = newlib_stdint_2;
2475 select = "@todo
- Add support for wint_t types
";
2477 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__
\n"
2478 "#define
INTMAX_MIN (-INTMAX_MAX
- 1)\n"
2479 "#define UINTMAX_MAX __UINTMAX_MAX__
\n"
2480 "#define WCHAR_MAX __WCHAR_MAX__
\n"
2481 "#define WCHAR_MIN __WCHAR_MIN__
\n"
2482 "#define WINT_MAX __WINT_MAX__
\n"
2483 "#define WINT_MIN __WINT_MIN__
\n\n"
2485 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2486 test_text = "/* @todo
- Add support for wint_t types.
*/\n"
2487 "/** Macros for minimum
-width integer constant expressions
*/";
2492 * NeXT 3.2 adds const prefix to some math functions.
2493 * These conflict with the built-in functions.
2496 hackname = next_math_prefix;
2497 files = ansi/math.h;
2498 select = "^extern
[ \t]+double
[ \t]+__const__
[ \t]";
2501 c_fix_arg = "extern double
%1(";
2502 c_fix_arg = "^extern
[ \t]+double
[ \t]+__const__
[ \t]+([a
-z
]+)\\(";
2504 test_text = "extern
\tdouble
\t__const__
\tmumble
();";
2509 * NeXT 3.2 uses the word "template
" as a parameter for some
2510 * functions. GCC reports an invalid use of a reserved key word
2511 * with the built-in functions.
2514 hackname = next_template;
2516 select = "[ \t]template
\\)";
2520 c_fix_arg = "\\(([^
)]*)
[ \t]template
\\)";
2521 test_text = "extern
mumble( char
* template
); /* fix
*/";
2526 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
2527 * function prototypes. That conflicts with the built-in functions.
2530 hackname = next_volitile;
2531 files = ansi/stdlib.h;
2532 select = "^extern
[ \t]+volatile
[ \t]+void
[ \t]";
2535 c_fix_arg = "extern void
%1(";
2536 c_fix_arg = "^extern
[ \t]+volatile
[ \t]+void
[ \t]+(exit|abort
)\\(";
2538 test_text = "extern
\tvolatile
\tvoid
\tabort
();";
2543 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2544 * Note that version 3 of the NeXT system has wait.h in a different directory,
2545 * so that this code won't do anything. But wait.h in version 3 has a
2546 * conditional, so it doesn't need this fix. So everything is okay.
2549 hackname = next_wait_union;
2552 select = 'wait\(union wait';
2554 c_fix_arg = "wait(void
";
2555 test_text = "extern pid_d
wait(union wait*)
;";
2560 * a missing semi-colon at the end of the nodeent structure definition.
2563 hackname = nodeent_syntax;
2564 files = netdnet/dnetdb.h;
2565 select = "char
[ \t]*\\*na_addr
[ \t]*$
";
2568 test_text = "char
*na_addr
\t";
2572 * Fix OpenBSD's NULL definition.
2575 hackname = openbsd_null_definition;
2576 mach = "*-*-openbsd
*";
2577 files = locale.h, stddef.h, stdio.h, string.h,
2578 time.h, unistd.h, wchar.h, sys/param.h;
2579 select = "__GNUG__
";
2581 c_fix_arg = "#ifndef NULL
\n"
2582 "#ifdef __cplusplus
\n"
2584 "#define NULL
\t__null
\n"
2585 "#else
\t /* ! __GNUG__
*/\n"
2586 "#define NULL
\t0L\n"
2587 "#endif
\t /* __GNUG__
*/\n"
2588 "#else
\t /* ! __cplusplus
*/\n"
2589 "#define NULL
\t((void *)
0)\n"
2590 "#endif
\t /* __cplusplus
*/\n"
2591 "#endif
\t /* !NULL
*/";
2593 c_fix_arg = "^#ifndef
[ \t]*NULL
\n"
2594 "^#ifdef
[ \t]*__GNUG__
\n"
2595 "^#define
[ \t]*NULL
[ \t]*__null
\n"
2597 "^#define
[ \t]*NULL
[ \t]*0L\n"
2603 "#define NULL __null
\n"
2611 * obstack.h used casts as lvalues.
2613 * We need to change postincrements of casted pointers (which are
2614 * then dereferenced and assigned into) of the form
2616 * *((TYPE*)PTRVAR)++ = (VALUE)
2618 * into expressions like
2620 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
2622 * which is correct for the cases used in obstack.h since PTRVAR is
2623 * of type char * and the value of the expression is not used.
2626 hackname = obstack_lvalue_cast;
2628 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
2630 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
2631 test_text = "*((void
**)
(h
)->next_free
)++ = (aptr
)";
2635 * Fix OpenBSD's va_start define.
2638 hackname = openbsd_va_start;
2639 mach = "*-*-openbsd
*";
2641 select = '__builtin_stdarg_start';
2643 c_fix_arg = __builtin_va_start;
2645 test_text = "#define
va_start(v
,l
) __builtin_stdarg_start((v
),l
)";
2649 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2650 * defining regex.h related types. This causes libg++ build and usage
2651 * failures. Fixing this correctly requires checking and modifying 3 files.
2654 hackname = osf_namespace_a;
2655 files = reg_types.h;
2656 files = sys/lc_core.h;
2657 test = " -r reg_types.h
";
2658 test = " -r sys
/lc_core.h
";
2659 test = " -n
\"`grep
'} regex_t;' reg_types.h`
\"";
2660 test = " -z
\"`grep __regex_t regex.h`
\"";
2664 c_fix_arg = "reg(ex|off|match
)_t
";
2666 test_text = "`touch sys
/lc_core.h`
"
2667 "typedef struct
{\n int stuff
, mo_suff
;\n} regex_t
;\n"
2668 "extern regex_t re
;\n"
2669 "extern regoff_t ro
;\n"
2670 "extern regmatch_t rm
;\n";
2674 hackname = osf_namespace_c;
2676 test = " -r reg_types.h
";
2677 test = " -r sys
/lc_core.h
";
2678 test = " -n
\"`grep
'} regex_t;' reg_types.h`
\"";
2679 test = " -z
\"`grep __regex_t regex.h`
\"";
2681 select = "#include
<reg_types\.h
>.
*";
2684 "typedef __regex_t
\tregex_t
;\n"
2685 "typedef __regoff_t
\tregoff_t
;\n"
2686 "typedef __regmatch_t
\tregmatch_t
;";
2688 test_text = "#include
<reg_types.h
>";
2693 * On broken glibc-2.3.3 systems an array of incomplete structures is
2694 * passed to __sigsetjmp. Fix that to take a pointer instead.
2697 hackname = pthread_incomplete_struct_argument;
2699 select = "struct __jmp_buf_tag
";
2701 c_fix_arg = "%1 *%2%3";
2702 c_fix_arg = "^
(extern int __sigsetjmp
\\(struct __jmp_buf_tag
) (__env
)\\[1\\](.*)$
";
2703 test_text = "extern int
__sigsetjmp (struct __jmp_buf_tag __env
[1], int __savemask
);";
2707 * Fix return type of fread and fwrite on sysV68
2710 hackname = read_ret_type;
2712 select = "extern int
\t.
*, fread
\\(\\), fwrite
\\(\\)";
2714 c_fix_arg = "extern unsigned int
fread(), fwrite();\n%1%2";
2715 c_fix_arg = "(extern int
\t.*)
, fread
\\(\\), fwrite
\\(\\)(.*)
";
2717 test_text = "extern int
\tfclose
(), fflush(), fread(), fwrite(), foo();";
2722 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
2725 hackname = rpc_xdr_lvalue_cast_a;
2727 select = "#define
[ \t]*IXDR_GET_LONG.
*\\\\\n.
*__extension__.
*";
2729 c_fix_arg = "#define
IXDR_GET_LONG(buf
) ((long
)IXDR_GET_U_INT32(buf
))";
2730 test_text = "#define
IXDR_GET_LONG(buf
) \\\\\n"
2731 "\t((long
)ntohl((u_long
)*__extension__((u_int32_t*)
(buf
))++))";
2736 hackname = rpc_xdr_lvalue_cast_b;
2738 select = "#define
[ \t]*IXDR_PUT_LONG.
*\\\\\n.
*__extension__.
*";
2740 c_fix_arg = "#define
IXDR_PUT_LONG(buf
, v
) ((long
)IXDR_PUT_INT32(buf
, (long
)(v
)))";
2741 test_text = "#define
IXDR_PUT_LONG(buf
, v
) \\\\\n"
2742 "\t(*__extension__((u_int32_t*)(buf
))++ = (long
)htonl((u_long
)(v
)))";
2747 * function class(double x) conflicts with C++ keyword on rs/6000
2750 hackname = rs6000_double;
2752 select = '[^a-zA-Z_]class\(';
2755 c_fix_arg = "#ifndef __cplusplus
\n%0\n#endif
";
2756 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
2758 test_text = "extern int
class();";
2763 * Wrong fchmod prototype on RS/6000.
2766 hackname = rs6000_fchmod;
2768 select = 'fchmod\(char \*';
2770 c_fix_arg = "fchmod(int
";
2771 test_text = "extern int
fchmod(char
*, mode_t
);";
2776 * parameters conflict with C++ new on rs/6000
2779 hackname = rs6000_param;
2783 select = 'rename\(const char \*old, const char \*new\)';
2785 c_fix_arg = 'rename(const char *_old, const char *_new)';
2787 test_text = 'extern int rename(const char *old, const char *new);';
2792 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2793 * __builtin_generic. We fix that usage to use the GCC equivalent.
2794 * It also has a plethora of inline functions that conflict with libstdc++.
2797 hackname = sco_math;
2798 files = math.h, '*/math.h';
2799 select = "inline double abs
";
2800 bypass = "__GNUG__
";
2801 sed = "/#define.
*__fp_class(a
) \\\\/i
\\\n"
2802 "#ifndef __GNUC__
\n";
2804 "/.
*__builtin_generic
/a
\\\n"
2806 "#define
__fp_class(a
) \\\\\\\n"
2807 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a
),long double
),\\\\\\\n"
2808 " __fpclassifyl(a
), \\\\\\\n"
2809 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a
), float
), \\\\\\\n"
2810 " __fpclassifyf(a
),__fpclassify(a
)))\\\n"
2813 sed = "/extern
\"C
\\+\\+\"/N
;"
2814 "/inline double abs
/i
\\\n"
2815 "#ifndef __GNUC__
\n";
2816 sed = "/inline long double trunc
/N
;"
2817 "/inline long double trunc.
*}.
*extern
\"C
\\+\\+\"/a
\\\n"
2818 "#endif
/* ! __GNUC__
*/";
2821 "#define
__fp_class(a
) \\\\\n"
2822 " __builtin_generic(a
,\"ld
:__fplcassifyl
;f
:__fpclassifyf
;:__fpclassify
\")\n";
2828 * Sun Solaris 10 defines several C99 math macros in terms of
2829 * builtins specific to the Studio compiler, in particular not
2830 * compatible with the GNU compiler.
2833 hackname = solaris_math_1;
2834 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2835 bypass = "__GNUC__
";
2836 files = iso/math_c99.h;
2838 c_fix_arg = "#define
\tHUGE_VA
%1\t(__builtin_huge_va
%2())";
2839 c_fix_arg = "^#define
[ \t]+HUGE_VA([LF
]+)[ \t]+__builtin_huge_va([lf
]+)";
2841 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2843 "#define HUGE_VAL __builtin_huge_val
\n"
2844 "#undef HUGE_VALF
\n"
2845 "#define HUGE_VALF __builtin_huge_valf
\n"
2846 "#undef HUGE_VALL
\n"
2847 "#define HUGE_VALL __builtin_huge_vall
";
2851 hackname = solaris_math_2;
2852 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2853 bypass = "__GNUC__
";
2854 files = iso/math_c99.h;
2856 c_fix_arg = "#define
\tINFINITY
\t(__builtin_inff())";
2857 c_fix_arg = "^#define
[ \t]+INFINITY
[ \t]+__builtin_infinity
";
2859 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2861 "#define INFINITY __builtin_infinity
";
2865 hackname = solaris_math_3;
2866 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2867 bypass = "__GNUC__
";
2868 files = iso/math_c99.h;
2870 c_fix_arg = "#define
\tNAN
\t\t(__builtin_nanf(\"\"))";
2871 c_fix_arg = "^#define
[ \t]+NAN
[ \t]+__builtin_nan
";
2873 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2875 "#define NAN __builtin_nan
";
2879 hackname = solaris_math_4;
2880 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2881 bypass = "__GNUC__
";
2882 files = iso/math_c99.h;
2884 c_fix_arg = "#define
\tfpclassify
(x
) \\\n"
2885 " __builtin_fpclassify(FP_NAN
, FP_INFINITE
, FP_NORMAL
, FP_SUBNORMAL
, FP_ZERO
, (x
))";
2886 c_fix_arg = "^#define
[ \t]+fpclassify
\\(x
\\)[ \t]+__builtin_fpclassify
\\(x
\\)";
2888 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2889 "#undef fpclassify
\n"
2890 "#define
fpclassify(x
) __builtin_fpclassify(x
)";
2894 hackname = solaris_math_8;
2895 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2896 bypass = "__GNUC__
";
2897 files = iso/math_c99.h;
2899 c_fix_arg = "#define
\tsignbit
(x
)\t(sizeof(x
) == sizeof(float
) \\\n"
2900 "\t\t\t ?
__builtin_signbitf(x
) \\\n"
2901 "\t\t\t : sizeof(x
) == sizeof(long double
) \\\n"
2902 "\t\t\t ?
__builtin_signbitl(x
) \\\n"
2903 "\t\t\t : __builtin_signbit(x
))";
2904 c_fix_arg = "^#define
[ \t]+signbit
\\(x
\\)[ \t]+__builtin_signbit
\\(x
\\)";
2906 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2908 "#define
signbit(x
) __builtin_signbit(x
)";
2912 hackname = solaris_math_9;
2913 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2914 bypass = "__GNUC__
";
2915 files = iso/math_c99.h;
2917 c_fix_arg = "#define
\t%1(x
, y
)%2__builtin_
%1(x
, y
)";
2918 c_fix_arg = "^#define
[ \t]+([a
-z
]+)\\(x
, y
\\)([ \t]+)\\(\\(x
\\) __builtin_
[a
-z
]+\\(y
\\)\\)";
2920 '#ident "@
(#
)math_c99.h
1.9 04/11/01 SMI
"'"\n"
2921 "#undef isgreater
\n"
2922 "#define
isgreater(x
, y
) ((x
) __builtin_isgreater(y
))\n"
2923 "#undef isgreaterequal
\n"
2924 "#define
isgreaterequal(x
, y
) ((x
) __builtin_isgreaterequal(y
))\n"
2926 "#define
isless(x
, y
) ((x
) __builtin_isless(y
))\n"
2927 "#undef islessequal
\n"
2928 "#define
islessequal(x
, y
) ((x
) __builtin_islessequal(y
))\n"
2929 "#undef islessgreater
\n"
2930 "#define
islessgreater(x
, y
) ((x
) __builtin_islessgreater(y
))\n"
2931 "#undef isunordered
\n"
2932 "#define
isunordered(x
, y
) ((x
) __builtin_isunordered(y
))";
2936 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
2937 * exception. Provide an alternative using GCC's builtin.
2941 hackname = solaris_math_10;
2942 select = '@\(#\)math_c99.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2943 files = iso/math_c99.h;
2945 c_fix_arg = "#define
\tisinf
(x
) __builtin_isinf(x
)";
2946 c_fix_arg = "^#define
[ \t]+isinf
\\(x
\\)[ \t]+__extension__
\\([ \t]*\\\\\n"
2947 "[ \t]*\\{[ \t]*__typeof
\\(x
\\)[ \t]*__x_i
[ \t]*=[ \t]*\\(x
\\);[ \t]*\\\\\n"
2948 "[ \t]*__x_i
[ \t]*==[ \t]*\\(__typeof
\\(__x_i
\\)\\)[ \t]*INFINITY
[ \t]*\\|
\\|
[ \t]*\\\\\n"
2949 "[ \t]*__x_i
[ \t]*==[ \t]*\\(__typeof
\\(__x_i
\\)\\)[ \t]*\\(-INFINITY
\\);[ \t]*\\}\\)";
2951 '#pragma ident "@
(#
)math_c99.h
1.12 07/01/21 SMI
"'"\n"
2953 "#define
isinf(x
) __extension__( \\\\\n"
2954 " { __typeof(x
) __x_i
= (x
); \\\\\n"
2955 " __x_i
== (__typeof(__x_i
)) INFINITY ||
\\\\\n"
2956 " __x_i
== (__typeof(__x_i
)) (-INFINITY
); })";
2960 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2961 * "0" for the last field of the pthread_mutex_t structure, which is
2962 * of type upad64_t, which itself is typedef'd to int64_t, but with
2963 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2964 * initializer to "{0}" instead
2967 hackname = solaris_mutex_init_2;
2968 select = '@\(#\)pthread.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
2971 * On Solaris 10, this fix is unnecessary because upad64_t is
2972 * always defined correctly regardless of the definition of the
2973 * __STDC__ macro. The first "mach
" pattern matches up to
2974 * solaris9. The second "mach
" pattern will not match any two (or
2975 * more) digit solaris version, but it will match e.g. 2.5.1.
2977 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
2979 c_fix_arg = "#if __STDC__
- 0 == 0 && !defined(_NO_LONGLONG
)\n"
2984 c_fix_arg = "(^#define
[ \t]+PTHREAD_(MUTEX|COND
)_INITIALIZER
[ \t]+"
2985 "(|
/\
*.
*\
*/[ \t]*\\\\\n[ \t]*)
\\{.*)
"
2986 ",[ \t]*0\\}" "(|
[ \t].*)$
";
2988 '#ident "@
(#
)pthread.h
1.26 98/04/12 SMI
"'"\n"
2989 "#define PTHREAD_MUTEX_INITIALIZER
\t{{{0},0}, {{{0}}}, 0}\n"
2990 "#define PTHREAD_COND_INITIALIZER
\t{{{0}, 0}, 0}\t/* DEFAULTCV
*/\n"
2991 "#define PTHREAD_MUTEX_INITIALIZER
/* = DEFAULTMUTEX
*/ \\\\\n"
2992 " {{0, 0, 0, DEFAULT_TYPE
, _MUTEX_MAGIC
}, {{{0}}}, 0}\n"
2993 "#define PTHREAD_COND_INITIALIZER
/* = DEFAULTCV
*/ \\\\\n"
2994 " {{{0, 0, 0, 0}, DEFAULT_TYPE
, _COND_MAGIC
}, 0}";
2999 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3000 * fields of the pthread_rwlock_t structure, which are of type
3001 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3002 * defined (e.g. by -ansi) it is a union. So change the initializer
3006 hackname = solaris_rwlock_init_1;
3007 select = '@\(#\)pthread.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
3009 mach = '*-*-solaris*';
3011 c_fix_arg = "#if __STDC__
- 0 == 0 && !defined(_NO_LONGLONG
)\n"
3014 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3016 c_fix_arg = "(^#define
[ \t]+PTHREAD_RWLOCK_INITIALIZER
[ \t]+)"
3017 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$
";
3020 '#ident "@
(#
)pthread.h
1.26 98/04/12 SMI
"'"\n"
3021 "#define PTHREAD_RWLOCK_INITIALIZER
\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3026 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3027 * structure. As such, it need two levels of brackets, but only
3028 * contains one. Wrap the macro definition in an extra layer.
3031 hackname = solaris_once_init_1;
3032 select = '@\(#\)pthread.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
3034 mach = '*-*-solaris*';
3036 c_fix_arg = "%1{%2}%3";
3037 c_fix_arg = "(^#define
[ \t]+PTHREAD_ONCE_INIT
[ \t]+\\{)([^
}]+)(\\})[ \t]*$
";
3039 '#pragma ident "@
(#
)pthread.h
1.37 04/09/28 SMI
"'"\n"
3040 "#define PTHREAD_ONCE_INIT
\t{0, 0, 0, PTHREAD_ONCE_NOTDONE
}";
3045 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3046 * fields of the pthread_once_t structure, which are of type
3047 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3048 * defined (e.g. by -ansi) it is a union. So change the initializer
3049 * to "{0}" instead. This test relies on solaris_once_init_1.
3052 hackname = solaris_once_init_2;
3053 select = '@\(#\)pthread.h' "[ \t]+1.
[0-9]+[ \t]+[0-9/]+ SMI
";
3056 * On Solaris 10, this fix is unnecessary because upad64_t is
3057 * always defined correctly regardless of the definition of the
3058 * __STDC__ macro. The first "mach
" pattern matches up to
3059 * solaris9. The second "mach
" pattern will not match any two (or
3060 * more) digit solaris version, but it will match e.g. 2.5.1.
3062 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3064 c_fix_arg = "#if __STDC__
- 0 == 0 && !defined(_NO_LONGLONG
)\n"
3067 "%1{0}, {0}, {0}, {%3}%4\n"
3069 c_fix_arg = "(^#define
[ \t]+PTHREAD_ONCE_INIT
[ \t]+\\{\\{)"
3070 "(0, 0, 0, )(PTHREAD_
[A
-Z_
]+)(\\}\\})[ \t]*$
";
3072 '#ident "@
(#
)pthread.h
1.26 98/04/12 SMI
"'"\n"
3073 "#define PTHREAD_ONCE_INIT
\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE
}}\n";
3078 * Solaris 2.8 has what appears to be some gross workaround for
3079 * some old version of their c++ compiler. G++ doesn't want it
3080 * either, but doesn't want to be tied to SunPRO version numbers.
3083 hackname = solaris_stdio_tag;
3084 files = stdio_tag.h;
3086 select = '__cplusplus < 54321L';
3087 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3088 "!defined(__GNUC__
)" so we no longer need to fix it. */
3089 bypass = '__GNUC__';
3090 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3092 test_text = "#if
\tdefined
(__cplusplus
) && (__cplusplus
< 54321L)";
3097 * a missing semi-colon at the end of the statsswtch structure definition.
3100 hackname = statsswtch;
3101 files = rpcsvc/rstat.h;
3102 select = "boottime$
";
3104 c_fix_arg = "boottime
;";
3105 test_text = "struct statswtch
{\n int boottime
\n};";
3110 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3111 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3115 hackname = stdio_stdarg_h;
3117 bypass = "include.
*(stdarg\.h|machine
/ansi\.h
)";
3119 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3120 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3122 mach = '*-*-solaris2.1[0-9]*';
3127 c_fix_arg = "#define __need___va_list
\n#include
<stdarg.h
>\n";
3134 * Don't use or define the name va_list in stdio.h. This is for
3135 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3136 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3137 * indicate that the header knows what it's doing -- under SUSv2,
3138 * stdio.h is required to define va_list, and we shouldn't break
3139 * that. On IRIX 6.5, internal/wchar_core.h used to get its
3140 * definition of va_list from stdio.h. Since this doesn't happen any
3141 * longer, use __gnuc_va_list there, too.
3144 hackname = stdio_va_list;
3146 files = internal/stdio_core.h;
3147 files = internal/wchar_core.h;
3148 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3150 * On Solaris 10, the definition in
3151 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3152 * there is therefore no need for this fix there.
3154 mach = '*-*-solaris2.1[0-9]*';
3158 * Use __gnuc_va_list in arg types in place of va_list.
3159 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3160 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3161 * trailing parentheses and semicolon save all other systems from this.
3162 * Define __not_va_list__ (something harmless and unused)
3163 * instead of va_list.
3164 * Don't claim to have defined va_list.
3166 sed = "s@
[ \t]va_list
\\([ \t)]\\)@ __gnuc_va_list
\\1@
\n"
3167 "s@
(va_list
)&@
(__gnuc_va_list
)\\&@
\n"
3168 "s@ _VA_LIST_
));@ __gnuc_va_list
));@
\n"
3169 "s@ __VA_LIST__
));@ __gnuc_va_list
));@
\n"
3170 "s@ va_list@ __not_va_list__@
\n"
3171 "s@
\\*va_list@
*__not_va_list__@
\n"
3172 "s@ __va_list
)@ __gnuc_va_list
)@
\n"
3173 "s@typedef
[ \t]\\(.
*\\)[ \t]va_list
[ \t]*;"
3174 "@typedef
\\1 __not_va_list__
;@
\n"
3175 "s@typedef
[ \t]*__va_list__@typedef __gnuc_va_list@
\n"
3176 "s@GNUC_VA_LIST@GNUC_Va_LIST@
\n"
3177 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@
\n"
3178 "s@_NEED___VA_LIST@_NEED___Va_LIST@
\n"
3179 "s@VA_LIST@DUMMY_VA_LIST@
\n"
3180 "s@_Va_LIST@_VA_LIST@
";
3181 test_text = "extern void
mumble( va_list
);";
3186 * Fix headers that use va_list from stdio.h to use the updated
3187 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3188 * dealt with elsewhere. The presence of __gnuc_va_list,
3189 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3190 * knows what it's doing.
3193 hackname = stdio_va_list_clients;
3201 files = curses_colr/curses.h;
3202 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3203 /* Don't fix, if we use va_list from stdarg.h, or if the use is
3204 otherwise protected. */
3205 bypass = 'include <stdarg\.h>|#ifdef va_start';
3208 * Use __gnuc_va_list in arg types in place of va_list.
3209 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3210 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
3211 * trailing parentheses and semicolon save all other systems from this.
3212 * Define __not_va_list__ (something harmless and unused)
3213 * instead of va_list.
3214 * Don't claim to have defined va_list.
3216 sed = "s@
[ \t]va_list
\\([ \t)]\\)@ __gnuc_va_list
\\1@
\n"
3217 "s@
(va_list
)&@
(__gnuc_va_list
)\\&@
\n"
3218 "s@ _VA_LIST_
));@ __gnuc_va_list
));@
\n"
3219 "s@ __VA_LIST__
));@ __gnuc_va_list
));@
\n"
3220 "s@ va_list@ __not_va_list__@
\n"
3221 "s@
\\*va_list@
*__not_va_list__@
\n"
3222 "s@ __va_list
)@ __gnuc_va_list
)@
\n"
3223 "s@typedef
[ \t]\\(.
*\\)[ \t]va_list
[ \t]*;"
3224 "@typedef
\\1 __not_va_list__
;@
\n"
3225 "s@typedef
[ \t]*__va_list__@typedef __gnuc_va_list@
\n"
3226 "s@GNUC_VA_LIST@GNUC_Va_LIST@
\n"
3227 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@
\n"
3228 "s@_NEED___VA_LIST@_NEED___Va_LIST@
\n"
3229 "s@VA_LIST@DUMMY_VA_LIST@
\n"
3230 "s@_Va_LIST@_VA_LIST@
";
3231 test_text = "extern void
mumble( va_list
);";
3236 * "!__STDC__
" or "__STDC__
==0" or "__STDC__
!=1" or "__STDC__
-0==0"
3237 * is "!defined( __STRICT_ANSI__
)"
3240 hackname = strict_ansi_not;
3241 select = "^
([ \t]*#
[ \t]*if.*)
"
3243 "|__STDC__
[ \t]*==[ \t]*0"
3244 "|__STDC__
[ \t]*!=[ \t]*1"
3245 "|__STDC__
[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3246 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3247 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3248 /* GNU gmp.h uses "__STDC__
!= 1" only if __SCO_VERSION__, which
3249 is not defined by GCC, so it is safe. */
3250 bypass = '__SCO_VERSION__.*__STDC__ != 1';
3251 c_test = stdc_0_in_system_headers;
3254 c_fix_arg = "%1 !defined(__STRICT_ANSI__
)";
3256 test_text = "#if
!__STDC__
\n"
3257 "#if __STDC__
== 0\n"
3258 "#if __STDC__
!= 1\n"
3259 "#if __STDC__
- 0 == 0"
3260 "/* not std C
*/\nint foo
;\n"
3261 "\n#end
-end
-end
-end
-if
:-)";
3266 * is "!defined( __STRICT_ANSI__
)" on continued #if-s
3269 hackname = strict_ansi_not_ctd;
3270 files = math.h, limits.h, stdio.h, signal.h,
3271 stdlib.h, sys/signal.h, time.h;
3273 * Starting at the beginning of a line, skip white space and
3274 * a leading "(" or "&&" or "||
". One of those must be found.
3275 * Then, zero, one or more copies of a "defined(_FOO_BAR_
) &&"
3276 * expression. If these are nested, then they must accumulate
3277 * because we won't match any closing parentheses. Finally,
3278 * after skipping over all that, we must then match our suspect
3279 * phrase: "__STDC__
-0==0" with or without white space.
3281 select = "^
([ \t]*" '(\(|&&|\|\|)'
3282 "([ \t(]*!*[ \t]*defined
\\([a
-zA
-Z_0
-9]+\\)[ \t]*[|
&][|
&])*"
3284 "(__STDC__
[ \t]*(|
-[ \t]*0[ \t]*)
==[ \t]*0)";
3285 c_test = stdc_0_in_system_headers;
3288 c_fix_arg = "%1 !defined(__STRICT_ANSI__
)";
3290 test_text = "#if
1 && \\\\\n"
3291 "&& defined(mumbling
) |
& (__STDC__
- 0 == 0) \\\\\n"
3292 "( __STDC__
== 0 && !defined(_XOPEN_SOURCE
) \\\\\n"
3293 "|| __STDC__
- 0 == 0 ) /* not std C
*/\n"
3299 * "__STDC__
!=0" or "__STDC__
==1" or "__STDC__
-0==1"
3300 * is "defined( __STRICT_ANSI__
)"
3303 hackname = strict_ansi_only;
3304 select = "^
([ \t]*#
[ \t]*if.*)
"
3305 "(__STDC__
[ \t]*!=[ \t]*0"
3306 "|__STDC__
[ \t]*==[ \t]*1"
3307 "|__STDC__
[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3308 "|__STDC__
[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3309 c_test = stdc_0_in_system_headers;
3312 c_fix_arg = "%1 defined(__STRICT_ANSI__
)";
3314 test_text = "#if __STDC__
== 1 /* is std C
\n */\nint foo
;\n#endif
";
3319 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3320 * in prototype without previous definition.
3323 hackname = struct_file;
3325 select = '^.*xdrstdio_create.*struct __file_s';
3327 c_fix_arg = "struct __file_s
;\n%0";
3328 test_text = "extern void
xdrstdio_create( struct __file_s
* );";
3333 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3334 * in prototype without previous definition.
3336 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3337 * function, and does define it.
3340 hackname = struct_sockaddr;
3342 select = "^.
*authdes_create.
*struct sockaddr
[^_
]";
3343 bypass = "<sys
/socket\.h
>";
3344 bypass = "struct sockaddr
;\n";
3346 c_fix_arg = "struct sockaddr
;\n%0";
3347 test_text = "extern AUTH
* authdes_create( struct sockaddr
* );";
3352 * Apply fix this to all OSs since this problem seems to effect
3353 * more than just SunOS.
3356 hackname = sun_auth_proto;
3361 bypass = "__cplusplus
";
3363 * Select those files containing '(*name)()'.
3365 select = '\(\*[a-z][a-z_]*\)\(\)';
3368 c_fix_arg = "#ifdef __cplusplus
\n%1(...
);%2\n"
3369 "#else
\n%1();%2\n#endif
";
3370 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
3374 " int (*name)(); /* C++ bad */\n"
3380 * Fix bogus #ifdef on SunOS 4.1.
3383 hackname = sun_bogus_ifdef;
3384 files = "hsfs/hsfs_spec.h";
3385 files = "hsfs/iso_spec.h";
3386 select = '#ifdef(.*\|\|.*)';
3388 c_fix_arg = "#if%1";
3390 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
3395 * Fix the CAT macro in SunOS memvar.h.
3398 hackname = sun_catmacro;
3399 files = pixrect/memvar.h;
3400 select = "^#define[ \t]+CAT\\(a,b\\).*";
3405 "# define CAT(a,b) a##b\n"
3406 "#else\n%0\n#endif";
3409 "#define CAT(a,b)\ta/**/b";
3414 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
3415 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
3418 hackname = sun_malloc;
3420 bypass = "_CLASSIC_ANSI_TYPES";
3422 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
3423 sed = "s/int[ \t][ \t]*free/void\tfree/g";
3424 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
3425 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
3426 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
3429 "typedef char *\tmalloc_t;\n"
3431 "char*\tmalloc();\n"
3432 "char*\tcalloc();\n"
3433 "char*\trealloc();";
3438 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
3441 hackname = sun_rusers_semi;
3442 files = rpcsvc/rusers.h;
3444 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
3445 test_text = "struct mumble\n int _cnt\n};";
3450 * signal.h on SunOS defines signal using (),
3451 * which causes trouble when compiling with g++ -pedantic.
3454 hackname = sun_signal;
3455 files = sys/signal.h;
3457 select = "^void\t" '\
(\
*signal\
(\
)\
)\
(\
);.
*';
3461 "#ifdef __cplusplus\n"
3462 "void\t(*signal(...))(...);\n"
3463 "#else\n%0\n#endif";
3465 test_text = "void\t(*signal())();";
3470 * Correct the return type for strlen in strings.h in SunOS 4.
3473 hackname = sunos_strlen;
3475 select = "int[ \t]*strlen\\(\\);(.*)";
3477 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
3478 test_text = " int\tstrlen(); /* string length */";
3483 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
3484 * that is visible to any ANSI compiler using this include. Simply
3485 * delete the lines that #define some string functions to internal forms.
3488 hackname = svr4_disable_opt;
3490 select = '#define.
*__std_hdr_
';
3491 sed = '/#define.
*__std_hdr_
/d
';
3492 test_text = "#define strlen __std_hdr_strlen\n";
3497 * Fix broken decl of getcwd present on some svr4 systems.
3500 hackname = svr4_getcwd;
3503 files = prototypes.h;
3504 select = 'getcwd\
(char \
*, int\
)';
3507 c_fix_arg = "getcwd(char *, size_t)";
3509 test_text = "extern char* getcwd(char *, int);";
3514 * Fix broken decl of profil present on some svr4 systems.
3517 hackname = svr4_profil;
3522 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
3523 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
3524 prototype in <sys/profil.h>. */
3525 bypass = 'Silicon Graphics
';
3527 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
3530 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
3535 * Correct types for signal handler constants like SIG_DFL; they might be
3536 * void (*) (), and should be void (*) (int). C++ doesn't like the
3540 hackname
= svr4_sighandler_type
;
3541 files
= sys
/signal.h
;
3542 select
= 'void *\(\*\)\(\)';
3544 c_fix_arg
= "void (*)(int)";
3545 test_text
= "#define SIG_DFL (void(*)())0\n"
3546 "#define SIG_IGN (void (*)())0\n";
3551 * Some SysV r4 systems
, including Sequent
's DYNIX/ptx, use the local
3552 * function 'getrnge
' in <regexp.h> before they declare it. For these
3553 * systems add a 'static int
' declaration of 'getrnge
' into <regexp.h>
3556 * 'getrnge
' traditionally manipulates a file-scope global called 'size
',
3557 * so put the declaration right after the declaration of 'size
'.
3559 * Don't do this if there is already a `static void getrnge
' declaration
3560 * present, since this would cause a redeclaration error. Solaris 2.x has
3561 * such a declaration.
3564 hackname = svr4_undeclared_getrnge;
3567 bypass = "static void getrnge";
3570 "static int getrnge ();";
3571 c_fix_arg = "^static int[ \t]+size;";
3572 test_text = "static int size;\n"
3573 "/* stuff which calls getrnge() */\n"
3574 "static getrnge()\n"
3580 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
3581 * in string.h on sysV68
3582 * Correct the return type for strlen in string.h on Lynx.
3583 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
3584 * Add missing const for strdup on OSF/1 V3.0.
3585 * On sysV88 layout is slightly different.
3588 hackname = sysv68_string;
3591 bypass = "_CLASSIC_ANSI_TYPES";
3593 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
3594 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
3595 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
3597 sed = "/^extern char$/N";
3598 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
3600 sed = "/^extern int$/N";
3601 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
3603 sed = "/^\tstrncmp(),$/N";
3604 sed = 's
/^\
(' "\t" 'strncmp()\
),\n\
(' "\t" 'strlen(),\
)$
/'
3605 '\
1;' "\\\nextern unsigned int\\\n\\2/";
3608 "extern int strlen();\n"
3610 "extern int ffs(long);\n"
3623 "\tstrlen(), strspn();";
3628 * Fix return type of calloc, malloc, realloc, bsearch and exit
3631 hackname = sysz_stdlib_for_sun;
3633 bypass = "_CLASSIC_ANSI_TYPES";
3635 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
3637 c_fix_arg = "void *\t%1(";
3640 "extern char*\tcalloc(size_t);\n"
3641 "extern char*\tmalloc(size_t);\n"
3642 "extern char*\trealloc(void*,size_t);\n"
3643 "extern char*\tbsearch(void*,size_t,size_t);\n";
3648 * __thread is now a keyword.
3651 hackname = thread_keyword;
3652 files = "pthread.h";
3653 files = "bits/sigthread.h";
3654 select = "([* ])__thread([,)])";
3656 c_fix_arg = "%1__thr%2";
3659 "extern int pthread_create (pthread_t *__restrict __thread,\n"
3660 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
3661 "extern int pthread_cancel (pthread_t __thread);";
3665 * if the #if says _cplusplus, not the double underscore __cplusplus
3669 hackname = tinfo_cplusplus;
3671 select = "[ \t]_cplusplus";
3674 c_fix_arg = " __cplusplus";
3675 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
3680 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3683 hackname = ultrix_const;
3685 select = 'perror\
( char \
*';
3688 c_fix_arg = "%1 const %3 *__";
3689 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3690 "[ \t]+(char|void) \\*__";
3693 "extern void perror( char *__s );\n"
3694 "extern int fputs( char *__s, FILE *);\n"
3695 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3696 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3697 "extern int scanf( char *__format, ...);\n";
3702 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3705 hackname = ultrix_const2;
3708 select = '\
*fopen\
( char \
*';
3710 c_fix_arg = "%1( const char *%3, const char *";
3711 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3712 "[ \t]*char[ \t]*\\*([^,]*),"
3713 "[ \t]*char[ \t]*\\*[ \t]*";
3716 "extern FILE *fopen( char *__filename, char *__type );\n"
3717 "extern int sscanf( char *__s, char *__format, ...);\n"
3718 "extern FILE *popen(char *, char *);\n"
3719 "extern char *tempnam(char*,char*);\n";
3724 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3727 hackname = va_i960_macro;
3728 files = arch/i960/archI960.h;
3729 select = "__(vsiz|vali|vpad|alignof__)";
3732 c_fix_arg = "__vx%1";
3735 "extern int __vsiz vsiz;\n"
3736 "extern int __vali vali;\n"
3737 "extern int __vpad vpad;\n"
3738 "#define __alignof__(x) ...";
3743 * AIX and Interix headers define NULL to be cast to a void pointer,
3744 * which is illegal in ANSI C++.
3747 hackname = void_null;
3757 files = sys/param.h;
3758 files = sys/types.h;
3759 /* avoid changing C++ friendly NULL */
3760 bypass = __cplusplus;
3761 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3763 c_fix_arg = "#define NULL 0";
3764 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3769 * Make VxWorks header which is almost gcc ready fully gcc ready.
3772 hackname = vxworks_gcc_problem;
3773 files = types/vxTypesBase.h;
3774 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3776 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3779 sed = "/[ \t]size_t/i\\\n"
3780 "#ifndef _GCC_SIZE_T\\\n"
3781 "#define _GCC_SIZE_T\n";
3783 sed = "/[ \t]size_t/a\\\n"
3786 sed = "/[ \t]ptrdiff_t/i\\\n"
3787 "#ifndef _GCC_PTRDIFF_T\\\n"
3788 "#define _GCC_PTRDIFF_T\n";
3790 sed = "/[ \t]ptrdiff_t/a\\\n"
3793 sed = "/[ \t]wchar_t/i\\\n"
3794 "#ifndef _GCC_WCHAR_T\\\n"
3795 "#define _GCC_WCHAR_T\n";
3797 sed = "/[ \t]wchar_t/a\\\n"
3801 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3802 "typedef unsigned int size_t;\n"
3803 "typedef long ptrdiff_t;\n"
3804 "typedef unsigned short wchar_t;\n"
3805 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3810 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3813 hackname = vxworks_needs_vxtypes;
3815 select = "uint_t([ \t]+_clocks_per_sec)";
3817 c_fix_arg = "unsigned int%1";
3818 test_text = "uint_t\t_clocks_per_sec;";
3823 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3826 hackname = vxworks_needs_vxworks;
3828 test = " -r types/vxTypesOld.h";
3829 test = " -n \"`egrep '#include
' $file`\"";
3830 test = " -n \"`egrep ULONG $file`\"";
3831 select = "#[ \t]define[ \t]+__INCstath";
3833 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3834 "#include <types/vxTypesOld.h>\n";
3836 test_text = "`touch types/vxTypesOld.h`"
3837 "#include </dev/null> /* ULONG */\n"
3838 "# define\t__INCstath <sys/stat.h>";
3843 * Another bad dependency in VxWorks 5.2 <time.h>.
3846 hackname = vxworks_time;
3848 test = " -r vxWorks.h";
3850 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3854 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3855 "#ifdef __cplusplus\n"
3856 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3858 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3860 "#define __gcc_VOIDFUNCPTR_defined\n"
3862 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3864 test_text = "`touch vxWorks.h`"
3865 "#define VOIDFUNCPTR (void(*)())";
3870 * There are several name conflicts with C++ reserved words in X11 header
3871 * files. These are fixed in some versions, so don't do the fixes if
3872 * we find __cplusplus in the file. These were found on the RS
/6000.
3875 hackname
= x11_class
;
3876 files
= X11
/ShellP.h
;
3877 bypass
= __cplusplus
;
3878 select
= "^([ \t]*char \\*)class;(.*)";
3880 c_fix_arg
= "#ifdef __cplusplus\n%1c_class;%2\n"
3881 "#else\n%1class;%2\n#endif";
3890 * class in Xm
/BaseClassI.h
3893 hackname
= x11_class_usage
;
3894 files
= Xm
/BaseClassI.h
;
3895 bypass
= "__cplusplus";
3897 select
= " class\\)";
3899 c_fix_arg
= " c_class)";
3901 test_text
= "extern mumble (int class);\n";
3906 * new in Xm
/Traversal.h
3910 files
= Xm
/Traversal.h
;
3911 bypass
= __cplusplus
;
3913 sed
= "/Widget\told, new;/i\\\n"
3914 "#ifdef __cplusplus\\\n"
3915 "\tWidget\told, c_new;\\\n"
3918 sed
= "/Widget\told, new;/a\\\n"
3921 sed
= "s/Widget new,/Widget c_new,/g";
3924 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
3925 "};\nextern Wedged( Widget new, Widget old );";
3930 * Incorrect sprintf declaration in X11
/Xmu.h
3933 hackname
= x11_sprintf
;
3935 files
= X11
/Xmu
/Xmu.h
;
3936 select
= "^extern char \\*\tsprintf\\(\\);$";
3939 c_fix_arg
= "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3941 test_text
= "extern char *\tsprintf();";