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[ \t]*=[ \t]*(.*);'
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");
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g
++ and
-D_LARGE_FILES
73 hackname
= AAB_aix_fcntl
;
75 select
= "define open[ \t]open64";
77 test
-text
= ''; /* no way to test
*/
83 c_fix_arg
= <<- _EOArg_
85 #if defined __GNUG__
&& defined _LARGE_FILES
&& defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
91 /* Alias the symbols using asm
*/
93 extern int
open(const char
*, int
, ...
) __asm__("open64");
94 extern int
creat(const char
*, mode_t
) __asm__("creat64");
95 #
if (_XOPEN_SOURCE
>= 700)
96 extern int
openat(int
, const char
*, int
, ...
) __asm__("open64at");
106 * On Mac OS
10.3.9, the
'long double' functions are available in
107 * libSystem
, but are not prototyped in math.h.
110 hackname
= AAB_darwin7_9_long_double_funcs
;
111 mach
= "*-*-darwin7.9*";
112 files
= architecture
/ppc
/math.h
;
114 replace
= <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
119 # define __APPLE_CC__
1345
120 # include_next
<architecture
/ppc
/math.h
>
122 # define __APPLE_CC__
1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define
__LIBMLDBL_COMPAT(sym
) __asm("_" #sym
"$LDBL128")
127 # define
__LIBMLDBL_COMPAT(sym
)
128 # endif
/* __LONG_DOUBLE_128__
*/
129 # endif
/* __LIBMLDBL_COMPAT
*/
133 extern long double
acosl( long double
) __LIBMLDBL_COMPAT(acosl
);
134 extern long double
asinl( long double
) __LIBMLDBL_COMPAT(asinl
);
135 extern long double
atanl( long double
) __LIBMLDBL_COMPAT(atanl
);
136 extern long double
atan2l( long double
, long double
) __LIBMLDBL_COMPAT(atan2l
);
137 extern long double
cosl( long double
) __LIBMLDBL_COMPAT(cosl
);
138 extern long double
sinl( long double
) __LIBMLDBL_COMPAT(sinl
);
139 extern long double
tanl( long double
) __LIBMLDBL_COMPAT(tanl
);
140 extern long double
acoshl( long double
) __LIBMLDBL_COMPAT(acoshl
);
141 extern long double
asinhl( long double
) __LIBMLDBL_COMPAT(asinhl
);
142 extern long double
atanhl( long double
) __LIBMLDBL_COMPAT(atanhl
);
143 extern long double
coshl( long double
) __LIBMLDBL_COMPAT(coshl
);
144 extern long double
sinhl( long double
) __LIBMLDBL_COMPAT(sinhl
);
145 extern long double
tanhl( long double
) __LIBMLDBL_COMPAT(tanhl
);
146 extern long double
expl( long double
) __LIBMLDBL_COMPAT(expl
);
147 extern long double
exp2l( long double
) __LIBMLDBL_COMPAT(exp2l
);
148 extern long double
expm1l( long double
) __LIBMLDBL_COMPAT(expm1l
);
149 extern long double
logl( long double
) __LIBMLDBL_COMPAT(logl
);
150 extern long double
log10l( long double
) __LIBMLDBL_COMPAT(log10l
);
151 extern long double
log2l( long double
) __LIBMLDBL_COMPAT(log2l
);
152 extern long double
log1pl( long double
) __LIBMLDBL_COMPAT(log1pl
);
153 extern long double
logbl( long double
) __LIBMLDBL_COMPAT(logbl
);
154 extern long double
modfl( long double
, long double
* ) __LIBMLDBL_COMPAT(modfl
);
155 extern long double
ldexpl( long double
, int
) __LIBMLDBL_COMPAT(ldexpl
);
156 extern long double
frexpl( long double
, int
* ) __LIBMLDBL_COMPAT(frexpl
);
157 extern int
ilogbl( long double
) __LIBMLDBL_COMPAT(ilogbl
);
158 extern long double
scalbnl( long double
, int
) __LIBMLDBL_COMPAT(scalbnl
);
159 extern long double
scalblnl( long double
, long int
) __LIBMLDBL_COMPAT(scalblnl
);
160 extern long double
fabsl( long double
) __LIBMLDBL_COMPAT(fabsl
);
161 extern long double
cbrtl( long double
) __LIBMLDBL_COMPAT(cbrtl
);
162 extern long double
hypotl( long double
, long double
) __LIBMLDBL_COMPAT(hypotl
);
163 extern long double
powl( long double
, long double
) __LIBMLDBL_COMPAT(powl
);
164 extern long double
sqrtl( long double
) __LIBMLDBL_COMPAT(sqrtl
);
165 extern long double
erfl( long double
) __LIBMLDBL_COMPAT(erfl
);
166 extern long double
erfcl( long double
) __LIBMLDBL_COMPAT(erfcl
);
167 extern long double
lgammal( long double
) __LIBMLDBL_COMPAT(lgammal
);
168 extern long double
tgammal( long double
) __LIBMLDBL_COMPAT(tgammal
);
169 extern long double
ceill( long double
) __LIBMLDBL_COMPAT(ceill
);
170 extern long double
floorl( long double
) __LIBMLDBL_COMPAT(floorl
);
171 extern long double
nearbyintl( long double
) __LIBMLDBL_COMPAT(nearbyintl
);
172 extern long double
rintl( long double
) __LIBMLDBL_COMPAT(rintl
);
173 extern long int
lrintl( long double
) __LIBMLDBL_COMPAT(lrintl
);
174 extern long long int
llrintl( long double
) __LIBMLDBL_COMPAT(llrintl
);
175 extern long double
roundl( long double
) __LIBMLDBL_COMPAT(roundl
);
176 extern long int
lroundl( long double
) __LIBMLDBL_COMPAT(lroundl
);
177 extern long long int
llroundl( long double
) __LIBMLDBL_COMPAT(llroundl
);
178 extern long double
truncl( long double
) __LIBMLDBL_COMPAT(truncl
);
179 extern long double
fmodl( long double
, long double
) __LIBMLDBL_COMPAT(fmodl
);
180 extern long double
remainderl( long double
, long double
) __LIBMLDBL_COMPAT(remainderl
);
181 extern long double
remquol( long double
, long double
, int
* ) __LIBMLDBL_COMPAT(remquol
);
182 extern long double
copysignl( long double
, long double
) __LIBMLDBL_COMPAT(copysignl
);
183 extern long double
nanl( const char
* ) __LIBMLDBL_COMPAT(nanl
);
184 extern long double
nextafterl( long double
, long double
) __LIBMLDBL_COMPAT(nextafterl
);
185 extern long double
nexttowardl( long double
, long double
) __LIBMLDBL_COMPAT(nexttowardl
);
186 extern long double
fdiml( long double
, long double
) __LIBMLDBL_COMPAT(fdiml
);
187 extern long double
fmaxl( long double
, long double
) __LIBMLDBL_COMPAT(fmaxl
);
188 extern long double
fminl( long double
, long double
) __LIBMLDBL_COMPAT(fminl
);
189 extern long double
fmal( long double
, long double
, long double
) __LIBMLDBL_COMPAT(fmal
);
193 #endif
/* __MATH__
*/
198 * This fixes __FD_ZERO bug for linux
2.x.
y (x
<= 2 && y
<= some n
)
201 hackname
= AAB_fd_zero_asm_posix_types_h
;
202 files
= asm
/posix_types.h
;
203 mach
= 'i[34567]86-*-linux*';
206 bypass
= 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper
, not
210 * the start
, so that if #include_next gets another instance of
211 * the wrapper
, this will follow the #include_next chain until
212 * we arrive at the real
<asm
/posix_types.h
>.
214 replace
= <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel.
*/
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include
<features.h
>
219 #include_next
<asm
/posix_types.h
>
221 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
223 #define
__FD_ZERO(fdsetp
) \
226 __asm__
__volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0
), "=&D" (__d1
) \
228 : "a" (0), "0" (__FDSET_LONGS
), \
229 "1" ((__kernel_fd_set *)
(fdsetp
)) :"memory"); \
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif
/* _POSIX_TYPES_H_WRAPPER
*/
239 * This fixes __FD_ZERO bug for glibc
-1.x
242 hackname
= AAB_fd_zero_gnu_types_h
;
244 mach
= 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper
, not
248 * the start
, so that if #include_next gets another instance of
249 * the wrapper
, this will follow the #include_next chain until
250 * we arrive at the real
<gnu
/types.h
>.
252 replace
= <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc
1.x.
*/
254 #ifndef _TYPES_H_WRAPPER
255 #include
<features.h
>
256 #include_next
<gnu
/types.h
>
258 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
260 # define
__FD_ZERO(fdsetp
) \
263 __asm__
__volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0
), "=&D" (__d1
) \
265 : "a" (0), "0" (__FDSET_LONGS
), \
266 "1" ((__fd_set *)
(fdsetp
)) :"memory"); \
270 #define _TYPES_H_WRAPPER
271 #endif
/* _TYPES_H_WRAPPER
*/
276 * This fixes __FD_ZERO bug for glibc
-2.0.x
279 hackname
= AAB_fd_zero_selectbits_h
;
280 files
= selectbits.h
;
281 mach
= 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper
, not
285 * the start
, so that if #include_next gets another instance of
286 * the wrapper
, this will follow the #include_next chain until
287 * we arrive at the real
<selectbits.h
>.
289 replace
= <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc
2.0.x.
*/
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include
<features.h
>
293 #include_next
<selectbits.h
>
295 #if
defined(__FD_ZERO
) && defined(__GLIBC__
) \\
296 && defined(__GLIBC_MINOR__
) && __GLIBC__
== 2 \\
297 && __GLIBC_MINOR__
== 0
299 #define
__FD_ZERO(fdsetp
) \\
302 __asm__
__volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0
), "=&D" (__d1
) \\
304 : "a" (0), "0" (sizeof (__fd_set
) \\
305 / sizeof (__fd_mask
)), \\
306 "1" ((__fd_mask *)
(fdsetp
)) \\
311 #define _SELECTBITS_H_WRAPPER
312 #endif
/* _SELECTBITS_H_WRAPPER
*/
317 * Solaris
<sys
/varargs.h
> is a
DDK (aka kernel
-land
) header providing
318 * the same interface as
<stdarg.h
>. No idea why they couldn
't have just
319 * used the standard header.
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris
*';
325 replace = <<- _EndOfHeader_
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS
4.x. We must only fix this on Sun OS
4.x
, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun
's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
342 hackname = AAB_sun_memcpy;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
367 #endif /* __memory_h__ */
372 * Fix assert.h on VxWorks:
375 hackname = AAB_vxworks_assert;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
391 #if defined(__STDC__) || defined(__cplusplus)
392 extern void __assert (const char*);
394 extern void __assert ();
398 #define assert(ign) ((void)0)
401 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
402 #define ASSERT_STRINGIFY_HELPER(str) #str
404 #define assert(test) ((void) \
405 ((test) ? ((void)0) : \
406 __assert("Assertion failed: " #test ", file " \
407 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
418 * Add needed include to regs.h (NOT the gcc header) on VxWorks
422 hackname = AAB_vxworks_regs_vxtypes;
424 mach = "*-*-vxworks*";
426 replace = <<- _EndOfHeader_
429 #include <types/vxTypesOld.h>
430 #include_next <arch/../regs.h>
436 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
439 hackname = AAB_vxworks_unistd;
441 mach = "*-*-vxworks*";
443 replace = <<- _EndOfHeader_
446 #include_next <unistd.h>
449 #define STDIN_FILENO 0
451 #ifndef STDOUT_FILENO
452 #define STDOUT_FILENO 1
454 #ifndef STDERR_FILENO
455 #define STDERR_FILENO 2
457 #endif /* _UNISTD_H */
462 * assert.h on AIX 7 redefines static_assert as _Static_assert without
466 hackname = aix_assert;
469 select = "#define[ \t]static_assert[ \t]_Static_assert";
471 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
472 test_text = "#define static_assert _Static_assert";
476 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
477 * which only is provided by AIX xlc C99.
480 hackname = aix_complex;
483 select = "#define[ \t]_Complex_I[ \t]__I";
485 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
486 test_text = "#define _Complex_I __I\n";
490 * On AIX some headers are not properly guarded by 'extern
"C"'.
493 hackname = aix_externc;
499 files = sys/localedef.h;
501 bypass = "extern \"C\"";
503 c_fix_arg = "#ifdef __cplusplus\n"
506 c_fix_arg = "#ifdef __cplusplus\n"
509 test_text = "extern int __n_pthreads;\n";
513 * On AIX sys/socket.h assumes C++.
516 hackname = aix_externcpp1;
518 files = "sys/socket.h";
519 select = "#ifdef __cplusplus";
521 c_fix_arg = "#ifdef __cplusplus\n"
523 test_text = "#ifdef __cplusplus";
528 hackname = aix_externcpp2;
530 files = "sys/socket.h";
531 select = "#else /\\* __cplusplus \\*/";
533 c_fix_arg = "} /* extern \"C++\" */\n"
534 "#else /* __cplusplus */";
535 test_text = "#else /* __cplusplus */";
540 * malloc.h on AIX6 uses XLC++ specific builtin syntax
543 hackname = aix_malloc;
546 select = "#ifdef __cplusplus";
548 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
549 test_text = "#ifdef __cplusplus";
553 * net/if_arp.h defines a variable fc_softc instead of adding a
554 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
557 hackname = aix_net_if_arp;
559 files = "net/if_arp.h";
560 select = "^struct fc_softc \\{";
562 c_fix_arg = "typedef struct _fc_softc {";
563 test_text = "struct fc_softc {\n int a;\n};";
567 * Fix AIX definition of NULL for G++.
572 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
573 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
575 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
577 c_fix_arg = <<- _EOFix_
582 #else /* ! __GNUG__ */
584 #endif /* __GNUG__ */
585 #else /* ! __cplusplus */
586 #define NULL ((void *)0)
587 #endif /* __cplusplus */
590 test_text = "# define\tNULL \t(0L) /* typed NULL */";
594 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
595 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
599 hackname = aix_once_init_1;
602 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
605 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
607 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
612 hackname = aix_once_init_2;
615 select = "[ \t]0 \\\\\n"
618 c_fix_arg = " 0 \\\n"
620 test_text = " 0 \\\\\n"
625 hackname = aix_mutex_initializer_1;
628 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
631 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
633 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
638 hackname = aix_cond_initializer_1;
641 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
644 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
646 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
651 hackname = aix_rwlock_initializer_1;
654 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
657 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
659 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
664 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
665 * which violates a requirement of ISO C.
668 hackname = aix_pthread;
670 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
673 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
674 "{...init stuff...}";
678 * AIX stdint.h fixes.
681 hackname = aix_stdint_1;
683 files = stdint-aix.h, stdint.h;
684 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
685 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
687 c_fix_arg = "#define UINT8_MAX (255)\n"
688 "#define UINT16_MAX (65535)";
689 test_text = "#define UINT8_MAX (255U)\n"
690 "#define UINT16_MAX (65535U)";
697 hackname = aix_stdint_2;
699 files = stdint-aix.h, stdint.h;
700 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
701 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
702 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
704 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
705 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
706 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
708 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
709 "#define INTPTR_MAX 9223372036854775807L\n"
710 "#define UINTPTR_MAX 18446744073709551615UL\n"
712 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
713 "#define INTPTR_MAX 2147483647L\n"
714 "#define UINTPTR_MAX 4294967295UL";
715 test_text = "#define INTPTR_MIN INT64_MIN\n"
716 "#define INTPTR_MAX INT64_MAX\n"
717 "#define UINTPTR_MAX UINT64_MAX\n"
719 "#define INTPTR_MIN INT32_MIN\n"
720 "#define INTPTR_MAX INT32_MAX\n"
721 "#define UINTPTR_MAX UINT32_MAX";
728 hackname = aix_stdint_3;
730 files = stdint-aix.h, stdint.h;
731 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
732 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
734 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
735 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
737 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
738 "#define PTRDIFF_MAX 9223372036854775807L\n"
740 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
741 "#define PTRDIFF_MAX 2147483647L";
742 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
743 "#define PTRDIFF_MAX INT64_MAX\n"
745 "#define PTRDIFF_MIN INT32_MIN\n"
746 "#define PTRDIFF_MAX INT32_MAX";
753 hackname = aix_stdint_4;
755 files = stdint-aix.h, stdint.h;
756 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
758 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
760 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
762 "#define SIZE_MAX 4294967295UL";
763 test_text = "#define SIZE_MAX UINT64_MAX\n"
765 "#define SIZE_MAX UINT32_MAX";
772 hackname = aix_stdint_5;
774 files = stdint-aix.h, stdint.h;
775 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
776 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
778 c_fix_arg = "#define UINT8_C(c) c\n"
779 "#define UINT16_C(c) c";
780 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
781 "#define UINT16_C(c) __CONCAT__(c,U)";
785 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
786 produces wrong code with G++.
789 hackname = aix_stdio_inline;
792 select = "#ifdef __cplusplus\\\n"
796 c_fix_arg = "#ifdef __cplusplus\n"
799 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
801 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
805 * stdlib.h on AIX uses #define on malloc and friends.
808 hackname = aix_stdlib_malloc;
811 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
813 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
814 test_text = "#define malloc __linux_malloc";
818 hackname = aix_stdlib_realloc;
821 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
823 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
824 test_text = "#define realloc __linux_realloc";
828 hackname = aix_stdlib_calloc;
831 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
833 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
834 test_text = "#define calloc __linux_calloc";
838 hackname = aix_stdlib_valloc;
841 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
843 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
844 test_text = "#define valloc __linux_valloc";
848 hackname = aix_stdlib_vec_malloc;
851 select = "#define[ \t]+malloc[ \t]+vec_malloc";
853 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
854 test_text = "#define malloc vec_malloc";
858 hackname = aix_stdlib_vec_calloc;
861 select = "#define[ \t]+calloc[ \t]+vec_calloc";
863 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
864 test_text = "#define calloc vec_calloc";
868 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
871 hackname = aix_strtof_const;
874 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
876 c_fix_arg = "%1(const char *, char **);";
877 test_text = "extern float strtof(char *, char **);";
881 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
882 * in an otherwise harmless (and #ifed out) macro definition
885 hackname = aix_sysmachine;
887 files = sys/machine.h;
891 test_text = "#define FOO \\\n"
892 " bar \\ \n baz \\ \n bat";
896 * sys/wait.h on AIX 5.2 defines macros that have both signed and
897 * unsigned types in conditional expressions.
900 hackname = aix_syswait_2;
903 select = '\? (\
(\
(\
(\
(unsigned
[^
)]*\
)[^
)]*\
) >> [^
)]*\
) \
& 0xff\
) : -1)';
905 c_fix_arg = "? (int)%1";
906 test_text = "#define WSTOPSIG(__x) "
907 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
911 * sys/signal.h on some versions of AIX uses volatile in the typedef of
912 * sig_atomic_t, which causes gcc to generate a warning about duplicate
913 * volatile when a sig_atomic_t variable is declared volatile, as
914 * required by ANSI C.
917 hackname = aix_volatile;
919 files = sys/signal.h;
920 select = "typedef volatile int sig_atomic_t";
922 c_fix_arg = "typedef int sig_atomic_t";
923 test_text = "typedef volatile int sig_atomic_t;";
927 * Fix __assert declaration in assert.h on Alpha OSF/1.
930 hackname = alpha___assert;
932 select = '__assert\
(char \
*, char \
*, int\
)';
934 c_fix_arg = "__assert(const char *, const char *, int)";
935 test_text = 'extern void
__assert(char
*, char
*, int
);';
939 * Fix assert macro in assert.h on Alpha OSF/1.
940 * The superfluous int cast breaks C++.
943 hackname = alpha_assert;
945 select = "(#[ \t]*" 'define assert\
(EX\
).*)\
(\
(int\
) \
(EX\
)\
)';
947 c_fix_arg = "%1(EX)";
948 test_text = '#define
assert(EX
) (((int
) (EX
)) ?
(void
)0 '
949 ': __assert(#EX
, __FILE__
, __LINE__
))';
953 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
956 hackname = alpha_getopt;
959 select = 'getopt\
(int
, char \
*\
[\
], *char \
*\
)';
961 c_fix_arg = "getopt(int, char *const[], const char *)";
962 test_text = 'extern int
getopt(int
, char
*[], char *)
;';
966 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
969 hackname = alpha_if_semicolon;
971 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
973 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
974 test_text = ' struct sockaddr vmif_paddr
/* protocol address
*/';
978 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
981 hackname = alpha_parens;
983 select = '#ifndef\
(__mips64\
)';
985 c_fix_arg = "#ifndef __mips64";
986 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
990 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
994 hackname = alpha_sbrk;
996 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
998 c_fix_arg = "void *sbrk(";
999 test_text = "extern char* sbrk(ptrdiff_t increment);";
1003 * For C++, avoid any typedef or macro definition of bool,
1004 * and use the built in type instead.
1005 * HP/UX 10.20 also has it in curses_colr/curses.h.
1008 hackname = avoid_bool_define;
1010 files = curses_colr/curses.h;
1014 select = "#[ \t]*define[ \t]+bool[ \t]";
1015 bypass = "__cplusplus";
1018 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1019 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1021 test_text = "# define bool\t char \n";
1028 hackname = avoid_bool_type;
1030 files = curses_colr/curses.h;
1034 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1035 bypass = "__cplusplus";
1038 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1040 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1044 * For C++, avoid any typedef definition of wchar_t,
1045 * and use the built in type instead.
1046 * Don't do this for headers that are smart enough to do the right
1047 * thing (recent
[n
]curses.h and Xlib.h
).
1048 * Don
't do it for <linux/nls.h> which is never used from C++ anyway,
1049 * and will be broken by the edit.
1053 hackname = avoid_wchar_t_type;
1055 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1056 bypass = "__cplusplus";
1057 bypass = "_LINUX_NLS_H";
1058 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1061 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1063 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1067 * Fix `typedef struct term;' on hppa1.1
-hp
-hpux9.
1070 hackname
= bad_struct_term
;
1072 select
= "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1074 c_fix_arg
= "struct term;";
1076 test_text
= 'typedef struct term;';
1080 * Fix one other error in this file
:
1081 * a mismatched quote not inside a C comment.
1084 hackname
= badquote
;
1085 files
= sundev
/vuid_event.h
;
1088 c_fix_arg
= "does not";
1090 test_text
= "/* doesn't have matched single quotes */";
1094 * check for broken assert.h that needs stdio.h
1097 hackname
= broken_assert_stdio
;
1100 bypass
= "include.*stdio\\.h";
1102 c_fix_arg
= "#include <stdio.h>\n";
1103 test_text
= "extern FILE* stderr;";
1107 * check for broken assert.h that needs stdlib.h
1110 hackname
= broken_assert_stdlib
;
1112 select
= 'exit *\(|abort *\(';
1113 bypass
= "include.*stdlib\\.h";
1115 c_fix_arg
= "#ifdef __cplusplus\n"
1116 "#include <stdlib.h>\n"
1118 test_text
= "extern void exit ( int );";
1122 * Remove `extern double cabs
' declarations from math.h.
1123 * This conflicts with C99. Discovered on AIX.
1124 * Darwin hides its broken cabs in architecture-specific subdirs.
1127 hackname = broken_cabs;
1128 files = math.h, "architecture/*/math.h";
1129 select = "^extern[ \t]+double[ \t]+cabs";
1131 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1132 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1134 test_text = "#ifdef __STDC__\n"
1135 "extern double cabs(struct dbl_hypot);\n"
1137 "extern double cabs();\n"
1139 "extern double cabs ( _Complex z );";
1143 * Fixup Darwin's broken check for __builtin_nanf.
1146 hackname
= broken_nan
;
1148 * It is tempting to omit the first
"files" entry. Do not.
1149 * The testing machinery will take the first
"files" entry as the name
1150 * of a test file to play with. It would be a nuisance to have a directory
1151 * with the name
"*".
1153 files
= "architecture/ppc/math.h";
1154 files
= "architecture/*/math.h";
1155 select
= '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1158 c_fix_arg
= "#if 1";
1159 test_text
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1163 * Various systems derived from BSD4.4 contain a macro definition
1164 * for vfscanf that interacts badly with requirements of builtin
-attrs.def.
1165 * Known to be fixed in FreeBSD
5 system headers.
1168 hackname
= bsd_stdio_attrs_conflict
;
1170 mach
= "*-*-*darwin*";
1172 select
= "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1174 c_fix_arg
= '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1175 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1176 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1177 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1178 test_text
= '#define vfscanf __svfscanf';
1182 * Fix various macros used to define ioctl numbers.
1183 * The traditional syntax was
:
1185 * #define
_CTRL(n
, x
) (('n'<<8)+x
)
1186 * #define TCTRLCFOO
_CTRL(T
, 1)
1188 * but this does not work with the C standard
, which disallows macro
1189 * expansion inside strings. We have to rewrite it thus
:
1191 * #define
_CTRL(n
, x
) ((n
<<8)+x
)
1192 * #define TCTRLCFOO
_CTRL('T', 1)
1194 * The select expressions match too much
, but the c_fix code is cautious.
1196 * CTRL might be
: CTRL _CTRL ISCTRL BSD43_CTRL ...
1199 hackname
= ctrl_quotes_def
;
1200 select
= "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1201 c_fix
= char_macro_def
;
1205 * This is two tests in order to ensure that the
"CTRL(c)" can
1206 * be selected in isolation from the multi
-arg format
1208 test_text
= "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1209 test_text
= "#define _CTRL(c) ('c'&037)";
1213 * Fix various macros used to define ioctl numbers.
1216 hackname
= ctrl_quotes_use
;
1217 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1218 c_fix
= char_macro_use
;
1220 test_text
= "#define TCTRLFOO BSD43_CTRL(T, 1)";
1224 * sys
/mman.h on HP
/UX is not C
++ ready
,
1225 * even though NO_IMPLICIT_EXTERN_C is defined on HP
/UX.
1227 * rpc
/types.h on OSF1
/2.0 is not C
++ ready
,
1228 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1230 * The problem is the declaration of malloc.
1233 hackname
= cxx_unready
;
1235 files
= rpc
/types.h
;
1236 select
= '[^#]+malloc.*;'; /* Catch any form of declaration
1237 not within a macro.
*/
1238 bypass
= '"C"|__BEGIN_DECLS';
1241 c_fix_arg
= "#ifdef __cplusplus\n"
1244 c_fix_arg
= "#ifdef __cplusplus\n"
1247 test_text
= "extern void* malloc( size_t );";
1251 * macOS
10.12 <AvailabilityInternal.h
> uses
__attribute__((availability
))
1255 hackname
= darwin_availabilityinternal
;
1256 mach
= "*-*-darwin*";
1257 files
= AvailabilityInternal.h
;
1258 select
= "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1260 c_fix_arg
= <<- _EOFix_
1261 #if
defined(__has_attribute
)
1262 #if
__has_attribute(availability
)
1272 test_text
= "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1273 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1277 * For the AAB_darwin7_9_long_double_funcs fix to be useful
,
1278 * you have to not use
"" includes.
1281 hackname
= darwin_9_long_double_funcs_2
;
1282 mach
= "*-*-darwin7.9*";
1284 select
= '#include[ \t]+\"';
1286 c_fix_arg
= "%1<%2.h>";
1288 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1290 test_text
= '#include "architecture/ppc/math.h"';
1294 * On darwin8 and earlier
, mach
-o
/swap.h isn
't properly guarded
1295 * by 'extern
"C"'. On darwin7 some mach/ headers aren't properly guarded.
1298 hackname
= darwin_externc
;
1299 mach
= "*-*-darwin*";
1300 files
= mach
-o
/swap.h
;
1301 files
= mach
/mach_time.h
;
1302 files
= mach
/mach_traps.h
;
1303 files
= mach
/message.h
;
1305 files
= mach
/semaphore.h
;
1306 bypass
= "extern \"C\"";
1307 bypass
= "__BEGIN_DECLS";
1309 c_fix_arg
= "#ifdef __cplusplus\n"
1312 c_fix_arg
= "#ifdef __cplusplus\n"
1315 test_text
= "extern void swap_fat_header();\n";
1319 * AvailabilityMacros.h on Darwin breaks with GCC
4.0, because of
1320 * bad __GNUC__ tests.
1323 hackname
= darwin_gcc4_breakage
;
1324 mach
= "*-*-darwin*";
1325 files
= AvailabilityMacros.h
;
1326 select
= "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1328 c_fix_arg
= "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1329 test_text
= "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1330 "(__GNUC_MINOR__ >= 1)\n";
1334 * Before Mac OS X
10.8 <i386
/setjmp.h
> doesn
't mark longjump noreturn.
1337 hackname = darwin_longjmp_noreturn;
1338 mach = "*-*-darwin*";
1339 files = "i386/setjmp.h";
1341 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1343 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1345 test_text = "void siglongjmp(sigjmp_buf, int);";
1349 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1352 hackname = darwin_os_trace_1;
1353 mach = "*-*-darwin*";
1355 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1358 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1362 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1363 * extension without guard.
1366 hackname = darwin_os_trace_2;
1367 mach = "*-*-darwin*";
1369 select = "typedef.*\\^os_trace_payload_t.*";
1371 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1372 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1376 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1377 * os_trace_payload_t typedef, too.
1380 hackname = darwin_os_trace_3;
1381 mach = "*-*-darwin*";
1383 select = <<- _EOSelect_
1387 _os_trace.*os_trace_payload_t payload);
1390 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1391 test_text = <<- _EOText_
1392 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1393 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1395 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1397 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1398 OS_EXPORT OS_NOTHROW
1400 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1405 * __private_extern__ doesn't exist in FSF GCC. Even if it did
,
1406 * why would you ever put it in a system header file?
1409 hackname
= darwin_private_extern
;
1410 mach
= "*-*-darwin*";
1411 files
= mach
-o
/dyld.h
;
1412 select
= "__private_extern__ [a-z_]+ _dyld_";
1414 c_fix_arg
= "extern";
1415 c_fix_arg
= "__private_extern__";
1416 test_text
= "__private_extern__ int _dyld_func_lookup(\n"
1417 "const char *dyld_func_name,\n"
1418 "unsigned long *address);\n";
1422 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1423 * unsigned constants.
1426 hackname
= darwin_stdint_1
;
1427 mach
= "*-*-darwin*";
1428 files
= stdint
-darwin.h
, stdint.h
;
1430 c_fix_arg
= "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1431 select
= "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1432 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1433 test_text
= "#define UINT8_C(v) (v ## U)\n"
1434 "#define UINT16_C(v) (v ## U)";
1438 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1442 hackname
= darwin_stdint_2
;
1443 mach
= "*-*-darwin*";
1444 files
= stdint
-darwin.h
, stdint.h
;
1446 c_fix_arg
= "#if __WORDSIZE == 64\n"
1447 "#define INTPTR_MAX 9223372036854775807L\n"
1448 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1450 "#define INTPTR_MAX 2147483647L\n"
1451 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1453 select
= "#if __WORDSIZE == 64\n"
1454 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1455 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1457 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1458 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1460 test_text
= "#if __WORDSIZE == 64\n"
1461 "#define INTPTR_MIN INT64_MIN\n"
1462 "#define INTPTR_MAX INT64_MAX\n"
1464 "#define INTPTR_MIN INT32_MIN\n"
1465 "#define INTPTR_MAX INT32_MAX\n"
1470 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1473 hackname
= darwin_stdint_3
;
1474 mach
= "*-*-darwin*";
1475 files
= stdint
-darwin.h
, stdint.h
;
1477 c_fix_arg
= "#if __WORDSIZE == 64\n"
1478 "#define UINTPTR_MAX 18446744073709551615UL\n"
1480 "#define UINTPTR_MAX 4294967295UL\n"
1482 select
= "#if __WORDSIZE == 64\n"
1483 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1485 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1487 test_text
= "#if __WORDSIZE == 64\n"
1488 "#define UINTPTR_MAX UINT64_MAX\n"
1490 "#define UINTPTR_MAX UINT32_MAX\n"
1495 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1498 hackname
= darwin_stdint_4
;
1499 mach
= "*-*-darwin*";
1500 files
= stdint
-darwin.h
, stdint.h
;
1502 c_fix_arg
= "#if __WORDSIZE == 64\n"
1503 "#define SIZE_MAX 18446744073709551615UL\n"
1505 "#define SIZE_MAX 4294967295UL\n"
1507 select
= "#if __WORDSIZE == 64\n"
1508 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1510 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1512 test_text
= "#if __WORDSIZE == 64\n"
1513 "#define SIZE_MAX UINT64_MAX\n"
1515 "#define SIZE_MAX UINT32_MAX\n"
1520 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_
{MIN,MAX}
1521 * with a wrong type.
1524 hackname
= darwin_stdint_5
;
1525 mach
= "*-*-darwin*";
1526 files
= stdint
-darwin.h
, stdint.h
;
1528 c_fix_arg
= "#if __WORDSIZE == 64\n"
1529 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1530 "#define INTMAX_MAX 9223372036854775807L\n"
1531 "#define UINTMAX_MAX 18446744073709551615UL\n"
1533 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1534 "#define INTMAX_MAX 9223372036854775807LL\n"
1535 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1537 select
= "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1538 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1540 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1541 test_text
= "#define INTMAX_MIN INT64_MIN\n"
1542 "#define INTMAX_MAX INT64_MAX\n"
1544 "#define UINTMAX_MAX UINT64_MAX";
1548 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_C
1549 * with a wrong type.
1552 hackname
= darwin_stdint_6
;
1553 mach
= "*-*-darwin*";
1554 files
= stdint
-darwin.h
, stdint.h
;
1556 c_fix_arg
= "#if __WORDSIZE == 64\n"
1557 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1558 "#define PTRDIFF_MAX 9223372036854775807L\n"
1560 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1561 "#define PTRDIFF_MAX 2147483647\n"
1563 select
= "#if __WORDSIZE == 64\n"
1564 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1565 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1567 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1568 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1570 test_text
= "#if __WORDSIZE == 64\n"
1571 "#define PTRDIFF_MIN INT64_MIN\n"
1572 "#define PTRDIFF_MAX INT64_MAX\n"
1574 "#define PTRDIFF_MIN INT32_MIN\n"
1575 "#define PTRDIFF_MAX INT32_MAX\n"
1580 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_C
1581 * with a wrong type.
1584 hackname
= darwin_stdint_7
;
1585 mach
= "*-*-darwin*";
1586 files
= stdint
-darwin.h
, stdint.h
;
1588 c_fix_arg
= "#if __WORDSIZE == 64\n"
1589 "#define INTMAX_C(v) (v ## L)\n"
1590 "#define UINTMAX_C(v) (v ## UL)\n"
1592 "#define INTMAX_C(v) (v ## LL)\n"
1593 "#define UINTMAX_C(v) (v ## ULL)\n"
1595 select
= "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1596 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1597 test_text
= "#define INTMAX_C(v) (v ## LL)\n"
1598 "#define UINTMAX_C(v) (v ## ULL)";
1602 * Fix
<c_asm.h
> on Digital UNIX V4.0
:
1603 * It contains a prototype for a
DEC C internal
asm() function
,
1604 * clashing with gcc
's asm keyword. So protect this with __DECC.
1607 hackname = dec_intern_asm;
1609 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1610 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1614 " ... asm stuff ...\n"
1615 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1619 * Fix typo in <wchar.h> on DJGPP 2.03.
1622 hackname = djgpp_wchar_h;
1624 select = "__DJ_wint_t";
1625 bypass = "sys/djtypes.h";
1627 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1628 c_fix_arg = "#include <stddef.h>";
1629 test_text = "#include <stddef.h>\n"
1630 "extern __DJ_wint_t x;\n";
1634 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1637 hackname = ecd_cursor;
1638 files = "sunwindow/win_lock.h";
1639 files = "sunwindow/win_cursor.h";
1640 select = 'ecd\.cursor
';
1642 c_fix_arg = 'ecd_cursor
';
1644 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1648 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1649 * that fails when compiling for SSE-less 32-bit x86.
1652 hackname = feraiseexcept_nosse_divbyzero;
1653 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1654 files = bits/fenv.h, '*/bits
/fenv.h
';
1655 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1656 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1657 bypass = "\"fdivp .*; fwait\"";
1660 c_fix_arg = <<- _EOText_
1661 # ifdef __SSE_MATH__
1664 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1665 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1669 test_text = <<- _EOText_
1670 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1675 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1676 * that fails when compiling for SSE-less 32-bit x86.
1679 hackname = feraiseexcept_nosse_invalid;
1680 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1681 files = bits/fenv.h, '*/bits
/fenv.h
';
1682 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1683 ": \"x\" \\(__f\\)\\);$";
1684 bypass = "\"fdiv .*; fwait\"";
1687 c_fix_arg = <<- _EOText_
1688 # ifdef __SSE_MATH__
1691 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1692 %1 : "=t" (__f) : "0" (__f));
1696 test_text = <<- _EOText_
1697 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1702 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1703 * neither the existence of GCC 3 nor its exact feature set yet break
1704 * (by design?) when __GNUC__ is set beyond 2.
1707 hackname = freebsd_gcc3_breakage;
1708 mach = "*-*-freebsd*";
1709 files = sys/cdefs.h;
1710 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7$
';
1711 bypass = '__GNUC__
[ \t]*([>=]=[ \t]*[3-9]|
>[ \t]*2)';
1713 c_fix_arg = '%0 || __GNUC__
>= 3';
1714 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7';
1718 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1719 * neither the existence of GCC 4 nor its exact feature set yet break
1720 * (by design?) when __GNUC__ is set beyond 3.
1723 hackname = freebsd_gcc4_breakage;
1724 mach = "*-*-freebsd*";
1725 files = sys/cdefs.h;
1726 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 \|\| __GNUC__
== 3$
';
1728 c_fix_arg = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
>= 3';
1729 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
== 3';
1733 * Some versions of glibc don't expect the C99 inline semantics.
1736 hackname
= glibc_c99_inline_1
;
1737 files
= features.h
, '*/features.h';
1738 select
= "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1740 c_fix_arg
= "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1742 #if
__GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1743 && !defined __OPTIMIZE_SIZE__
&& !defined __NO_INLINE__
1744 # define __USE_EXTERN_INLINES
1
1750 * Similar
, but a version that didn
't have __NO_INLINE__
1753 hackname = glibc_c99_inline_1a;
1754 files = features.h, '*/features.h
';
1755 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1756 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1758 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1760 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1761 # define __USE_EXTERN_INLINES 1
1767 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1768 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1769 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1772 hackname = glibc_c99_inline_2;
1773 files = sys/stat.h, '*/sys
/stat.h
';
1774 select = "extern __inline__ int";
1775 sed = "s/extern int \\(stat\\)/"
1776 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1777 "__inline__ int \\1/";
1778 sed = "s/extern int \\([lf]stat\\)/"
1779 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1780 "__inline__ int \\1/";
1781 sed = "s/extern int \\(mknod\\)/"
1782 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1783 "__inline__ int \\1/";
1784 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1785 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1786 "__inline__ int __REDIRECT\\1 (\\2/";
1787 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1788 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1789 "__inline__ int __REDIRECT\\1 (\\2/";
1790 sed = "s/^extern __inline__ int/"
1791 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1794 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1795 extern __inline__ int
1796 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1802 * glibc_c99_inline_3
1805 hackname = glibc_c99_inline_3;
1806 files = bits/string2.h, '*/bits
/string2.h
';
1807 select = "extern __inline";
1808 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1810 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1811 c_fix_arg = "^# ifdef __cplusplus$";
1814 # define __STRING_INLINE inline
1816 # define __STRING_INLINE extern __inline
1822 * glibc_c99_inline_4
1825 hackname = glibc_c99_inline_4;
1826 files = sys/sysmacros.h, '*/sys
/sysmacros.h
', wchar.h, '*/wchar.h
',
1827 pthread.h, '*/pthread.h
';
1828 bypass = "__extern_inline|__gnu_inline__";
1829 select = "(^| )extern __inline";
1831 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1833 __extension__ extern __inline unsigned int
1834 extern __inline unsigned int
1838 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1839 * so we replace them with versions that correspond to the
1843 hackname = glibc_mutex_init;
1845 select = '\
{ *\
{ *0, *\
} *\
}';
1846 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1847 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1848 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1849 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1850 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1851 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1852 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1853 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1854 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1855 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1856 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1857 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1858 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1859 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1860 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1861 "N;s/^[ \t]*#[ \t]*"
1862 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1863 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1865 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1868 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1870 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1871 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1872 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1873 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1875 test_text = <<- _EOText_
1876 #define PTHREAD_MUTEX_INITIALIZER \\
1879 # if __WORDSIZE == 64
1880 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1881 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1882 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1883 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1884 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1885 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1887 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1888 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1889 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1890 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1891 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1892 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1895 # define PTHREAD_RWLOCK_INITIALIZER \\
1898 # if __WORDSIZE == 64
1899 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1900 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1901 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1903 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1904 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1907 #define PTHREAD_COND_INITIALIZER { { 0, } }
1911 /* glibc versions before 2.5 have a version of stdint.h that defines
1912 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1913 versions with stdint.h based on those glibc versions. */
1915 hackname = glibc_stdint;
1917 select = "GNU C Library";
1919 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1920 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1921 test_text = "/* This file is part of the GNU C Library. */\n"
1922 "# define UINT8_C(c)\tc ## U\n"
1923 "# define UINT16_C(c)\tc ## U";
1926 /* Some versions of glibc have a version of bits/string2.h that
1927 produces "value computed is not used" warnings from strncpy; fix
1928 this definition by using __builtin_strncpy instead as in newer
1931 hackname = glibc_strncpy;
1932 files = bits/string2.h, '*/bits
/string2.h
';
1933 bypass = "__builtin_strncpy";
1935 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1936 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1938 # define strncpy(dest, src, n) \
1939 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1940 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1941 ? (char *) memcpy (dest, src, n) \\
1942 : strncpy (dest, src, n)) \\
1943 : strncpy (dest, src, n)))
1948 /* glibc's tgmath.h relies on an expression that is not an integer
1949 constant expression being treated as it was by GCC
4.4 and
1952 hackname
= glibc_tgmath
;
1954 select
= '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1955 bypass
= "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1957 c_fix_arg
= "(__builtin_classify_type ((type) 0) == 8 || "
1958 "(__builtin_classify_type ((type) 0) == 9 && "
1959 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1960 test_text
= "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1964 * Fix these files to use the types we think they should for
1965 * ptrdiff_t
, size_t
, and wchar_t.
1967 * This defines the types in terms of macros predefined by our
'cpp'.
1968 * This is supposedly necessary for glibc
's handling of these types.
1969 * It's probably not necessary for anyone else
, but it doesn
't hurt.
1972 hackname = gnu_types;
1973 files = "sys/types.h";
1975 files = "sys/stdtypes.h";
1979 bypass = '_GCC_(PTRDIFF|
SIZE|WCHAR
)_T
';
1980 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1982 /* The Solaris 10 headers already define these types correctly. */
1983 mach = '*-*-solaris2.1
[0-9]*';
1986 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1987 "typedef uint_t size_t; /* uint_t */\n"
1988 "typedef ushort_t wchar_t; /* ushort_t */";
1992 * Fix HP & Sony's use of
"../machine/xxx.h"
1993 * to refer to
: <machine
/xxx.h
>
1996 hackname
= hp_inline
;
1997 files
= sys
/spinlock.h
;
1998 files
= machine
/machparam.h
;
1999 select
= "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2002 c_fix_arg
= "%1<machine/%2.h>";
2004 c_fix_arg
= "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2007 test_text
= ' # include "../machine/mumble.h"';
2011 * Check
for (...
) in C
++ code in HP
/UX sys
/file.h.
2014 hackname
= hp_sysfile
;
2016 select
= "HPUX_SOURCE";
2019 c_fix_arg
= "(struct file *, ...)";
2020 c_fix_arg
= '\(\.\.\.\)';
2022 test_text
= "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2026 * Un
-Hide a series of five FP defines from post
-1999 compliance GCC
:
2027 * FP_NORMAL
, FP_ZERO
, FP_INFINITE
, FP_SUBNORMAL and FP_NAN
2030 hackname
= hppa_hpux_fp_macros
;
2031 mach
= "hppa*-hp-hpux11*";
2033 select
= "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2034 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2035 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2036 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2037 "#[ \t]*define[ \t]*FP_NAN.*\n";
2039 c_fix_arg
= <<- _EOFix_
2040 #endif
/* _INCLUDE_HPUX_SOURCE
*/
2042 #if
defined(_INCLUDE_HPUX_SOURCE
) || \
2043 (defined(__STDC_VERSION__
) && (__STDC_VERSION__
>= 199901L))
2046 #ifdef _INCLUDE_HPUX_SOURCE
2051 "# define FP_NORMAL 0\n"
2052 "# define FP_ZERO 1\n"
2053 "# define FP_INFINITE 2\n"
2054 "# define FP_SUBNORMAL 3\n"
2055 "# define FP_NAN 4\n";
2059 * Delete C
++ double
pow (double
, int
) inline function from HP
-UX
10 & 11
2060 * math.h to prevent clash with define in c_std
/bits
/std_cmath.h.
2063 hackname
= hpux10_cpp_pow_inline
;
2064 files
= fixinc
-test
-limits.h
, math.h
;
2065 select
= <<- END_POW_INLINE
2066 ^#
+ifdef
+__cplusplus
2068 +inline
+double
+pow\
(double
+__d
,int
+__expon\
) +\
{
2069 [ ]+return
+pow\
(__d
,\
(double\
)__expon\
);
2080 "# ifdef __cplusplus\n"
2082 " inline double pow(double __d,int __expon) {\n"
2083 "\t return pow(__d,(double)__expon);\n"
2085 ' extern "C"' " {\n"
2091 hackname
= hpux11_cpp_pow_inline
;
2093 select
= " +inline double pow\\(double d,int expon\\) \\{\n"
2094 " +return pow\\(d, \\(double\\)expon\\);\n"
2100 " inline double pow(double d,int expon) {\n"
2101 " return pow(d, (double)expon);\n"
2106 * Fix hpux
10.X missing ctype declarations
1
2109 hackname
= hpux10_ctype_declarations1
;
2111 select
= "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2112 bypass
= "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2114 c_fix_arg
= "#ifdef _PROTOTYPES\n"
2115 "extern int __tolower(int);\n"
2116 "extern int __toupper(int);\n"
2117 "#else /* NOT _PROTOTYPES */\n"
2118 "extern int __tolower();\n"
2119 "extern int __toupper();\n"
2120 "#endif /* _PROTOTYPES */\n\n"
2123 test_text
= "# define _toupper(__c) __toupper(__c)\n";
2127 * Fix hpux
10.X missing ctype declarations
2
2130 hackname
= hpux10_ctype_declarations2
;
2132 select
= "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2133 bypass
= "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2135 c_fix_arg
= "%0\n\n"
2136 "#ifdef _PROTOTYPES\n"
2137 " extern int _isalnum(int);\n"
2138 " extern int _isalpha(int);\n"
2139 " extern int _iscntrl(int);\n"
2140 " extern int _isdigit(int);\n"
2141 " extern int _isgraph(int);\n"
2142 " extern int _islower(int);\n"
2143 " extern int _isprint(int);\n"
2144 " extern int _ispunct(int);\n"
2145 " extern int _isspace(int);\n"
2146 " extern int _isupper(int);\n"
2147 " extern int _isxdigit(int);\n"
2148 "# else /* not _PROTOTYPES */\n"
2149 " extern int _isalnum();\n"
2150 " extern int _isalpha();\n"
2151 " extern int _iscntrl();\n"
2152 " extern int _isdigit();\n"
2153 " extern int _isgraph();\n"
2154 " extern int _islower();\n"
2155 " extern int _isprint();\n"
2156 " extern int _ispunct();\n"
2157 " extern int _isspace();\n"
2158 " extern int _isupper();\n"
2159 " extern int _isxdigit();\n"
2160 "#endif /* _PROTOTYPES */\n";
2162 test_text
= "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2163 " extern unsigned int *__SB_masks;\n";
2167 * Fix hpux
10.X missing stdio declarations
2170 hackname
= hpux10_stdio_declarations
;
2172 select
= "^#[ \t]*define _iob[ \t]*__iob";
2173 bypass
= "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2175 c_fix_arg
= "%0\n\n"
2176 "# if defined(__STDC__) || defined(__cplusplus)\n"
2177 " extern int snprintf(char *, size_t, const char *, ...);\n"
2178 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2179 "# else /* not __STDC__) || __cplusplus */\n"
2180 " extern int snprintf();\n"
2181 " extern int vsnprintf();\n"
2182 "# endif /* __STDC__) || __cplusplus */\n";
2184 test_text
= "# define _iob __iob\n";
2188 * The HP
-UX stddef.h is replaced by gcc
's. It doesn't include sys
/stdsyms.h.
2189 * As a result
, we need to include sys
/stdsyms.h in alloca.h.
2192 hackname
= hppa_hpux11_alloca
;
2193 mach
= "hppa*-*-hpux11*";
2195 select
= "#ifndef _STDDEF_INCLUDED";
2197 c_fix_arg
= "#ifndef _SYS_STDSYMS_INCLUDED\n"
2198 "# include <sys/stdsyms.h>\n"
2199 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2202 test_text
= "#ifndef _STDDEF_INCLUDED";
2206 * Make sure hpux defines abs in header.
2209 hackname
= hpux11_abs
;
2210 mach
= "*-hp-hpux11*";
2212 select
= "ifndef _MATH_INCLUDED";
2214 c_fix_arg
= "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2215 test_text
= "#ifndef _MATH_INCLUDED";
2219 * Fix hpux11 __LWP_RWLOCK_VALID define
2222 hackname
= hpux11_lwp_rwlock_valid
;
2223 mach
= "*-hp-hpux11*";
2224 files
= sys
/pthread.h
;
2225 select
= "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2227 c_fix_arg
= "#define __LWP_RWLOCK_VALID -29551";
2228 test_text
= "#define __LWP_RWLOCK_VALID 0x8c91";
2235 hackname
= hpux11_extern_sendfile
;
2236 mach
= "*-hp-hpux11.[12]*";
2237 files
= sys
/socket.h
;
2238 select
= "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2240 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2241 test_text
= " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2242 " const struct iovec *, int));\n";
2249 hackname
= hpux11_extern_sendpath
;
2250 mach
= "*-hp-hpux11.[12]*";
2251 files
= sys
/socket.h
;
2252 select
= "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2254 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2255 test_text
= " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2256 " const struct iovec *, int));\n";
2260 * Keep HP
-UX
11 from stomping on C
++ math namespace
2261 * with defines for fabsf.
2264 hackname
= hpux11_fabsf
;
2265 mach
= "*-hp-hpux11*";
2267 select
= "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2270 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
2274 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2279 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2280 * in pthread.h need to be constant expressions to be standard complient.
2281 * As a result
, we need to remove the void
* casts in the initializers
2282 * (see hpux11_pthread_const
) and to change the
__(M|C|RW
)POINTER defines
2283 * to use the long type.
2286 hackname
= hpux11_pthread_pointer
;
2287 mach
= "*-hp-hpux11.[0-3]*";
2288 files
= sys
/pthread.h
;
2289 select
= "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2292 c_fix_arg
= "long\t%2%3";
2293 test_text
= "#define __MPOINTER\t\tvoid\t *m_ptr";
2297 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2300 hackname
= hpux11_pthread_const
;
2301 mach
= "*-hp-hpux11.[0-3]*";
2302 files
= sys
/pthread.h
;
2303 select
= "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2307 test_text
= "#define __POINTER_SET\t\t((void *) 1LL)";
2311 * Prevent HP
-UX
11 from defining __size_t and preventing size_t from
2312 * being defined by having it define _hpux_size_t instead.
2315 hackname
= hpux11_size_t
;
2316 mach
= "*-hp-hpux11*";
2317 select
= "__size_t";
2320 c_fix_arg
= "_hpux_size_t";
2323 "#define __size_t size_t\n"
2324 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2328 * Fix hpux
11.00 broken snprintf declaration
2329 * (third argument is char
*, needs to be const char
* to prevent
2330 * spurious warnings with
-Wwrite
-strings or in C
++).
2333 hackname
= hpux11_snprintf
;
2335 select
= '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2336 ' *(char *\*, *\.\.\.\);)';
2338 c_fix_arg
= '%1 const %3';
2340 test_text
= "extern int snprintf(char *, size_t, char *, ...);\n"
2341 "extern int snprintf(char *, __size_t, char *, ...);\n"
2342 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2346 * Fix hpux
11.00 broken vsnprintf declaration
2349 hackname
= hpux11_vsnprintf
;
2351 select
= '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2352 'const char \*,) __va__list\);';
2354 c_fix_arg
= "%1 __va_list);";
2356 test_text
= 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2361 * Fix missing const in hpux vsscanf declaration
2364 hackname
= hpux_vsscanf
;
2367 select
= '(extern int vsscanf\()char';
2369 c_fix_arg
= "%1const char";
2371 test_text
= 'extern int vsscanf(char *, const char *, __va_list);';
2375 * get rid of bogus inline definitions in HP
-UX
8.0
2378 hackname
= hpux8_bogus_inlines
;
2381 bypass
= "__GNUG__";
2382 sed
= "s@inline int abs(int [a-z][a-z]*) {.*}"
2383 "@extern \"C\" int abs(int);@";
2384 sed
= "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2385 sed
= "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2386 sed
= "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2387 test_text
= "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2388 "inline double sqr(double v) { return v**0.5; }";
2395 hackname
= hpux_c99_intptr
;
2396 mach
= "*-hp-hpux11.3*";
2397 files
= stdint
-hpux11.h
, stdint.h
;
2398 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2399 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2400 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2401 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2402 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2403 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2404 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2405 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2406 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2407 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2408 sed
= "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2409 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2410 test_text
= "#define PTRDIFF_MAX INT32_MAX\n"
2411 "#define PTRDIFF_MIN INT32_MIN\n"
2412 "#define INTPTR_MAX INT32_MAX\n"
2413 "#define INTPTR_MIN INT32_MIN\n"
2414 "#define UINTPTR_MAX UINT32_MAX\n"
2415 "#define SIZE_MAX UINT32_MAX\n";
2419 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2422 hackname
= hpux_c99_inttypes
;
2423 mach
= "*-hp-hpux11.[23]*";
2425 files
= stdint
-hpux11.h
, stdint.h
;
2426 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2427 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2428 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2429 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2430 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2431 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2432 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2433 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2434 test_text
= "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2435 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2436 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2437 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2441 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2444 hackname
= hpux_c99_inttypes2
;
2445 mach
= "*-hp-hpux11.2*";
2446 files
= stdint
-hpux11.h
, stdint.h
;
2447 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2448 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2449 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2450 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2451 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2452 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2453 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2454 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2455 test_text
= "# define INT8_C(__c) ((signed char)(__c))\n"
2456 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2457 "# define INT16_C(__c) ((short)(__c))\n"
2458 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2462 * Fix hpux broken ctype macros
2465 hackname
= hpux_ctype_macros
;
2467 select
= '((: |\()__SB_masks \? )'
2468 '(__SB_masks\[__(alnum|c)\] & _IS)';
2470 c_fix_arg
= "%1(int)%3";
2472 test_text
= ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2473 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2480 hackname
= hpux_extern_errno
;
2481 mach
= "*-hp-hpux10.*";
2482 mach
= "*-hp-hpux11.[0-2]*";
2484 select
= "^[ \t]*extern int errno;$";
2486 c_fix_arg
= "#ifdef __cplusplus\n"
2490 "#ifdef __cplusplus\n"
2493 test_text
= " extern int errno;\n";
2497 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2500 hackname
= hpux_htonl
;
2501 files
= netinet
/in.h
;
2502 select
= "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2504 " \\* Macros for number representation conversion\\.\n"
2508 c_fix_arg
= "#if 1\n%1";
2510 test_text
= "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2512 " * Macros for number representation conversion.\n"
2515 "#define ntohl(x) (x)\n"
2516 "#define ntohs(x) (x)\n"
2517 "#define htonl(x) (x)\n"
2518 "#define htons(x) (x)\n"
2520 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2524 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2527 hackname
= hpux_imaginary_i
;
2528 mach
= "ia64-hp-hpux11.*";
2530 select
= "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2532 c_fix_arg
= "#define _Complex_I (__extension__ 1.0iF)";
2533 test_text
= "#define _Complex_I (0.f+_Imaginary_I)\n";
2537 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2540 hackname
= hpux_inttype_int8_t
;
2541 mach
= "*-hp-hpux1[01].*";
2542 files
= sys
/_inttypes.h
;
2543 select
= "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2545 c_fix_arg
= "typedef signed char int%18_t;";
2546 test_text
= "typedef char int_least8_t;\n"
2547 "typedef char int8_t;\n";
2554 hackname
= hpux_long_double
;
2555 mach
= "*-*-hpux10*";
2556 mach
= "*-*-hpux11.[012]*";
2558 select
= "extern[ \t]long_double[ \t]strtold";
2559 bypass
= "long_double_t";
2560 sed
= "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2561 sed
= "s/long_double/long double/g";
2563 test_text
= "# ifndef _LONG_DOUBLE\n"
2564 "# define _LONG_DOUBLE\n"
2565 " typedef struct {\n"
2566 " unsigned int word1, word2, word3, word4;\n"
2568 "# endif /* _LONG_DOUBLE */\n"
2569 "extern long_double strtold(const char *, char **);\n";
2573 * We cannot use the above rule on
11.31 because it removes the strtold
2574 * definition. ia64 is OK with no hack
, PA needs some help.
2577 hackname
= hpux_long_double_2
;
2578 mach
= "hppa*-*-hpux11.3*";
2580 select
= "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2581 "defined\\(_PROTOTYPES\\) \\|\\| "
2582 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2584 c_fix_arg
= "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2586 test_text
= "# if !defined(__ia64) || "
2587 "!defined(_PROTOTYPES) || "
2588 "defined(_LONG_DOUBLE_STRUCT)\n";
2592 * Add missing braces to pthread initializer defines.
2595 hackname
= hpux_pthread_initializers
;
2596 mach
= "*-hp-hpux11.[0-3]*";
2597 files
= sys
/pthread.h
;
2598 sed
= "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2599 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2600 sed
= "s@^[ \t]*1,[ \t]*\\\\"
2602 sed
= "/^[ \t]*0$/d";
2603 sed
= "s@__PTHREAD_MUTEX_VALID, 0"
2604 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2605 sed
= "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2606 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2607 sed
= "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2608 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2609 sed
= "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2610 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2611 sed
= "s@^[ \t]*0, 0[ \t]*\\\\"
2612 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2613 sed
= "s@__PTHREAD_COND_VALID, 0"
2614 "@{ __PTHREAD_COND_VALID, 0 }@";
2615 sed
= "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2616 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2617 sed
= "s@__PTHREAD_RWLOCK_VALID, 0"
2618 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2619 sed
= "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2620 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2621 sed
= "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2622 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2623 test_text
= "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2624 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2625 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2626 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2627 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2628 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2629 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2634 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2635 * type and mpinfou is only defined when _KERNEL is set.
2638 hackname
= hpux_spu_info
;
2639 mach
= "*-hp-hpux*";
2641 * It is tempting to omit the first
"files" entry. Do not.
2642 * The testing machinery will take the first
"files" entry as the name
2643 * of a test file to play with. It would be a nuisance to have a directory
2644 * with the name
"*".
2646 files
= "ia64/sys/getppdp.h";
2647 files
= "*/sys/getppdp.h";
2648 select
= "^.*extern.*spu_info.*";
2651 c_fix_arg
= "#ifdef _KERNEL\n%0\n#endif";
2653 test_text
= "extern union mpinfou spu_info[];";
2657 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2660 hackname
= hpux_stdint_least_fast
;
2661 mach
= "*-hp-hpux11.2*";
2662 files
= stdint
-hpux11.h
, stdint.h
;
2664 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2666 c
-fix
-arg
= "# define UINT_%164_MAX __UINT64_MAX__";
2667 test
-text
= "# define UINT_FAST64_MAX ULLONG_MAX\n"
2668 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2672 * Add noreturn attribute to longjmp declarations in hpux
<setjmp.h
>
2675 hackname
= hpux_longjmp
;
2676 mach
= "*-hp-hpux*";
2678 select
= "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2681 c_fix_arg
= "%0 __attribute__ ((__noreturn__))";
2683 test_text
= 'extern void longjmp __((jmp_buf, int));';
2687 * Fix hpux10.20
<sys
/time.h
> to avoid invalid forward decl
2690 hackname
= hpux_systime
;
2692 select
= "^extern struct sigevent;";
2695 c_fix_arg
= "struct sigevent;";
2697 test_text
= 'extern struct sigevent;';
2701 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2704 hackname
= huge_val_hex
;
2705 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2706 select
= "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2707 bypass
= "__builtin_huge_val";
2710 c_fix_arg
= "#define HUGE_VAL (__builtin_huge_val())\n";
2712 test_text
= "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2716 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2719 hackname
= huge_valf_hex
;
2720 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2721 select
= "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2722 bypass
= "__builtin_huge_valf";
2725 c_fix_arg
= "#define HUGE_VALF (__builtin_huge_valf())\n";
2727 test_text
= "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2731 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2734 hackname
= huge_vall_hex
;
2735 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2736 select
= "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2737 bypass
= "__builtin_huge_vall";
2740 c_fix_arg
= "#define HUGE_VALL (__builtin_huge_vall())\n";
2742 test_text
= "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2746 * Fix return type of abort and free
2749 hackname
= int_abort_free_and_exit
;
2751 select
= "int[ \t]+(abort|free|exit)[ \t]*\\(";
2752 bypass
= "_CLASSIC_ANSI_TYPES";
2755 c_fix_arg
= "void\t%1(";
2757 test_text
= "extern int abort(int);\n"
2758 "extern int free(void*);\n"
2759 "extern int exit(void*);";
2763 * Fix various macros used to define ioctl numbers.
2764 * The traditional syntax was
:
2766 * #define
_IO(n
, x
) (('n'<<8)+x
)
2767 * #define TIOCFOO
_IO(T
, 1)
2769 * but this does not work with the C standard
, which disallows macro
2770 * expansion inside strings. We have to rewrite it thus
:
2772 * #define
_IO(n
, x
) ((n
<<8)+x
)
2773 * #define TIOCFOO
_IO('T', 1)
2775 * The select expressions match too much
, but the c_fix code is cautious.
2777 * _IO might be
: _IO DESIO BSD43__IO with W
, R
, WR
, C
, ... suffixes.
2780 hackname
= io_quotes_def
;
2781 select
= "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2782 c_fix
= char_macro_def
;
2785 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2786 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2787 "#define _IO(x,y) ('x'<<8|y)";
2789 "#define XX_IO(x) ('x'<<8|256)";
2793 * Fix the usage of the ioctl macro numbers.
2796 hackname
= io_quotes_use
;
2797 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2799 c_fix
= char_macro_use
;
2801 test_text
= "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2802 "#define TIOCFOO \\\\\n"
2803 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2807 * Check for missing
';' in struct
2810 hackname
= ip_missing_semi
;
2811 files
= netinet
/ip.h
;
2813 sed
= "/^struct/,/^};/s/}$/};/";
2819 "}; /* mumbled struct */\n";
2823 * Non
-traditional
"const" declaration in Irix
's limits.h.
2826 hackname = irix_limits_const;
2827 files = fixinc-test-limits.h, limits.h;
2828 select = "^extern const ";
2830 c_fix_arg = "extern __const ";
2831 test_text = "extern const char limit; /* test limits */";
2835 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2836 * taking char
*. However
, GCC uses void
* for va_list
, so
2837 * calling vfprintf with a va_list fails in C
++.
*/
2839 hackname
= irix_stdio_va_list
;
2842 select
= '/\* va_list \*/ char \*';
2844 c_fix_arg
= "__gnuc_va_list";
2846 "extern int printf( const char *, /* va_list */ char * );";
2850 * These files in Sun OS
4.x and ARM
/RISCiX and BSD4.3
2851 * use
/ * * / to concatenate tokens.
2854 hackname
= kandr_concat
;
2855 files
= "sparc/asm_linkage.h";
2856 files
= "sun*/asm_linkage.h";
2857 files
= "arm/as_support.h";
2858 files
= "arm/mc_type.h";
2859 files
= "arm/xcb.h";
2860 files
= "dev/chardefmac.h";
2861 files
= "dev/ps_irq.h";
2862 files
= "dev/screen.h";
2863 files
= "dev/scsi.h";
2864 files
= "sys/tty.h";
2865 files
= "Xm.acorn/XmP.h";
2866 files
= bsd43
/bsd43_.h
;
2870 test_text
= "#define __CONCAT__(a,b) a/**/b";
2874 * The
/usr
/include
/sys
/ucontext.h on ia64
-*linux
-gnu systems defines
2875 * an _SC_GR0_OFFSET macro using an idiom that isn
't a compile time
2876 * constant on recent versions of g++.
2879 hackname = linux_ia64_ucontext;
2880 files = "sys/ucontext.h";
2881 mach = "ia64-*-linux*";
2882 select = '\
(\
(\
(char \
*\
) &\
(\
(struct sigcontext \
*\
) 0\
)'
2883 '->sc_gr\
[0\
]\
) - \
(char \
*\
) 0\
)';
2885 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2886 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2887 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2891 * Remove header file warning from sys/time.h. Autoconf's
2892 * AC_HEADER_TIME recommends to include both sys
/time.h and time.h
2893 * which causes warning on LynxOS. Remove the warning.
2896 hackname
= lynxos_no_warning_in_sys_time_h
;
2898 select
= "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2901 test_text
= "#warning Using <time.h> instead of <sys/time.h>";
2905 * Add missing declaration for putenv.
2908 hackname
= lynxos_missing_putenv
;
2909 mach
= '*-*-lynxos*';
2911 bypass
= 'putenv[ \t]*\\(';
2912 select
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2915 "extern int putenv _AP((char *));";
2916 c_fix_arg
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2917 test_text
= "extern char *getenv _AP((const char *));";
2921 * Fix BSD machine
/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2923 * On NetBSD
, machine is a symbolic link to an architecture specific
2924 * directory name
, so we can
't match a specific file name here.
2927 hackname = machine_ansi_h_va_list;
2928 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2929 bypass = '__builtin_va_list
';
2932 c_fix_arg = "%1__builtin_va_list";
2933 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2935 test_text = " # define _BSD_VA_LIST_\tchar**";
2939 * Fix non-ansi machine name defines
2942 hackname = machine_name;
2943 c_test = machine_name;
2944 c_fix = machine_name;
2946 test_text = "/* MACH_DIFF: */\n"
2947 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2948 "\n/* no uniform test, so be careful :-) */";
2952 * Some math.h files define struct exception (it's in the System V
2953 * Interface Definition
), which conflicts with the class exception defined
2954 * in the C
++ file std
/stdexcept.h. We redefine it to __math_exception.
2955 * This is not a great fix
, but I haven
't been able to think of anything
2959 hackname = math_exception;
2961 select = "struct exception";
2963 * This should be bypassed on __cplusplus, but some supposedly C++
2964 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2965 * exception either. So currently we bypass only for glibc
, based on a
2966 * comment in the fixed glibc header. Ick.
2968 bypass
= 'We have a problem when using C\+\+|for C\+\+, '
2969 '_[a-z0-9A-Z_]+_exception; for C, exception';
2970 /* The Solaris
10 headers already get this right.
*/
2971 mach
= '*-*-solaris2.1[0-9]*';
2975 c_fix_arg
= "#ifdef __cplusplus\n"
2976 "#define exception __math_exception\n"
2979 c_fix_arg
= "#ifdef __cplusplus\n"
2980 "#undef exception\n"
2983 test_text
= "typedef struct exception t_math_exception;";
2987 * This looks pretty broken to me. ``dbl_max_def
'' will contain
2988 * "define DBL_MAX " at the start
, when what we really want is just
2989 * the value portion. Can
't figure out how to write a test case
2990 * for this either :-(
2993 hackname = math_huge_val_from_dbl_max;
2997 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2998 * in math.h, this fix applies.
3000 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3001 bypass = "define[ \t]+DBL_MAX";
3005 * See if we have a definition for DBL_MAX in float.h.
3006 * If we do, we will replace the one in math.h with that one.
3009 "\tdbl_max_def=`egrep 'define
[ \t]+DBL_MAX
[ \t]+.
*' float.h "
3010 "| sed 's
/.
*DBL_MAX
[ \t]*//' 2>/dev/null`\n\n"
3012 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3013 "\tthen sed -e '/define
[ \t]*HUGE_VAL
[ \t]*DBL_MAX
/"
3014 "s@DBL_MAX@
'\"$dbl_max_def@\"\n"
3019 "`echo '#define DBL_MAX
\t3.1415e+9 /* really big
*/' >> float.h`\n"
3020 "#define HUGE_VAL DBL_MAX";
3027 hackname = nested_auth_des;
3029 select = '(/\
*.
*rpc
/auth_des\.h
>.*)
/\
*';
3031 c_fix_arg = "%1*/ /*";
3032 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3036 * Some versions of NetBSD don't expect the C99 inline semantics.
3039 hackname
= netbsd_c99_inline_1
;
3040 mach
= "*-*-netbsd*";
3042 select
= "extern __inline int";
3045 c_fix_arg
= "extern\n"
3046 "#ifdef __GNUC_STDC_INLINE__\n"
3047 "__attribute__((__gnu_inline__))\n"
3051 test_text
= "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3055 * netbsd_c99_inline_2
3058 hackname
= netbsd_c99_inline_2
;
3059 mach
= "*-*-netbsd*";
3061 select
= "#define _SIGINLINE extern __inline";
3064 c_fix_arg
= <<- _EOArg_
3065 #ifdef __GNUC_STDC_INLINE__
3066 #define _SIGINLINE extern
__attribute__((__gnu_inline__
)) __inline
3072 test_text
= "#define _SIGINLINE extern __inline";
3076 * NetBSD has a semicolon after the ending
'}' for some extern
"C".
3079 hackname
= netbsd_extra_semicolon
;
3080 mach
= "*-*-netbsd*";
3081 files
= sys
/cdefs.h
;
3082 select
= "#define[ \t]*__END_DECLS[ \t]*};";
3085 c_fix_arg
= "#define __END_DECLS }";
3087 test_text
= "#define __END_DECLS };";
3091 * newlib
's stdint.h has several failures to conform to C99. The fix
3092 * for these removed a comment that can be matched to identify unfixed
3096 hackname = newlib_stdint_1;
3097 files = stdint-newlib.h, stdint.h;
3098 select = "@todo - Add support for wint_t types";
3099 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3100 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3101 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3102 sed = "s@#define INT_LEAST32_MIN.*@"
3103 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3104 sed = "s@#define INT_LEAST32_MAX.*@"
3105 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3106 sed = "s@#define UINT_LEAST32_MAX.*@"
3107 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3108 sed = 's@#define INT_FAST\
([0-9]*\
)_MIN.
*@
'
3109 '#define INT_FAST\
1_MIN (-INT_FAST\
1_MAX
- 1)@
';
3110 sed = 's@#define INT_FAST\
([0-9]*\
)_MAX.
*@
'
3111 '#define INT_FAST\
1_MAX __INT_FAST\
1_MAX__@
';
3112 sed = 's@#define UINT_FAST\
([0-9]*\
)_MAX.
*@
'
3113 '#define UINT_FAST\
1_MAX __UINT_FAST\
1_MAX__@
';
3114 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3115 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3116 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3117 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3118 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3119 test_text = "/* @todo - Add support for wint_t types. */\n"
3120 "#define INT32_MIN (-2147483647-1)\n"
3121 "#define INT32_MAX 2147483647\n"
3122 "#define UINT32_MAX 4294967295U\n"
3123 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3124 "#define INT_LEAST32_MAX 2147483647\n"
3125 "#define UINT_LEAST32_MAX 4294967295U\n"
3126 "#define INT_FAST8_MIN INT8_MIN\n"
3127 "#define INT_FAST8_MAX INT8_MAX\n"
3128 "#define UINT_FAST8_MAX UINT8_MAX\n"
3129 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3130 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3131 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3132 "#define UINT8_C(x) x##U\n"
3133 "#define UINT16_C(x) x##U";
3140 hackname = newlib_stdint_2;
3141 files = stdint-newlib.h, stdint.h;
3142 select = "@todo - Add support for wint_t types";
3144 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3145 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3146 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3147 "#define WCHAR_MAX __WCHAR_MAX__\n"
3148 "#define WCHAR_MIN __WCHAR_MIN__\n"
3149 "#define WINT_MAX __WINT_MAX__\n"
3150 "#define WINT_MIN __WINT_MIN__\n\n"
3152 c_fix_arg = '/\
*\
* Macros for minimum
-width integer constant expressions \
*/';
3153 test_text = "/* @todo - Add support for wint_t types. */\n"
3154 "/** Macros for minimum-width integer constant expressions */";
3158 * NeXT 3.2 adds const prefix to some math functions.
3159 * These conflict with the built-in functions.
3162 hackname = next_math_prefix;
3163 files = ansi/math.h;
3164 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3167 c_fix_arg = "extern double %1(";
3168 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3170 test_text = "extern\tdouble\t__const__\tmumble();";
3174 * NeXT 3.2 uses the word "template" as a parameter for some
3175 * functions. GCC reports an invalid use of a reserved key word
3176 * with the built-in functions.
3179 hackname = next_template;
3181 select = "[ \t]template\\)";
3185 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3186 test_text = "extern mumble( char * template); /* fix */";
3190 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3191 * function prototypes. That conflicts with the built-in functions.
3194 hackname = next_volitile;
3195 files = ansi/stdlib.h;
3196 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3199 c_fix_arg = "extern void %1(";
3200 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3202 test_text = "extern\tvolatile\tvoid\tabort();";
3206 * NeXT 2.0 defines 'int
wait(union wait*)
', which conflicts with Posix.1.
3207 * Note that version 3 of the NeXT system has wait.h in a different directory,
3208 * so that this code won't do anything. But wait.h in version
3 has a
3209 * conditional
, so it doesn
't need this fix. So everything is okay.
3212 hackname = next_wait_union;
3215 select = 'wait\
(union wait
';
3217 c_fix_arg = "wait(void";
3218 test_text = "extern pid_d wait(union wait*);";
3222 * a missing semi-colon at the end of the nodeent structure definition.
3225 hackname = nodeent_syntax;
3226 files = netdnet/dnetdb.h;
3227 select = "char[ \t]*\\*na_addr[ \t]*$";
3230 test_text = "char *na_addr\t";
3234 * Fix OpenBSD's NULL definition.
3237 hackname
= openbsd_null_definition
;
3238 mach
= "*-*-openbsd*";
3239 files
= locale.h
, stddef.h
, stdio.h
, string.h
,
3240 time.h
, unistd.h
, wchar.h
, sys
/param.h
;
3241 select
= "__GNUG__";
3243 c_fix_arg
= "#ifndef NULL\n"
3244 "#ifdef __cplusplus\n"
3246 "#define NULL\t__null\n"
3247 "#else\t /* ! __GNUG__ */\n"
3248 "#define NULL\t0L\n"
3249 "#endif\t /* __GNUG__ */\n"
3250 "#else\t /* ! __cplusplus */\n"
3251 "#define NULL\t((void *)0)\n"
3252 "#endif\t /* __cplusplus */\n"
3253 "#endif\t /* !NULL */";
3255 c_fix_arg
= "^#ifndef[ \t]*NULL\n"
3256 "^#ifdef[ \t]*__GNUG__\n"
3257 "^#define[ \t]*NULL[ \t]*__null\n"
3259 "^#define[ \t]*NULL[ \t]*0L\n"
3265 "#define NULL __null\n"
3273 * obstack.h used casts as lvalues.
3275 * We need to change postincrements of casted
pointers (which are
3276 * then dereferenced and assigned into
) of the form
3278 * *((TYPE*)PTRVAR
)++ = (VALUE
)
3280 * into expressions like
3282 * ((*((TYPE*)PTRVAR
) = (VALUE
)), (PTRVAR
+= sizeof (TYPE)))
3284 * which is correct for the cases used in obstack.h since PTRVAR is
3285 * of type char
* and the value of the expression is not used.
3288 hackname
= obstack_lvalue_cast
;
3290 select
= '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3292 c_fix_arg
= "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3293 test_text
= "*((void **) (h)->next_free)++ = (aptr)";
3297 * Fix OpenBSD
's va_start define.
3300 hackname = openbsd_va_start;
3301 mach = "*-*-openbsd*";
3303 select = '__builtin_stdarg_start
';
3305 c_fix_arg = __builtin_va_start;
3307 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3311 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3312 * defining regex.h related types. This causes libg++ build and usage
3313 * failures. Fixing this correctly requires checking and modifying 3 files.
3316 hackname = osf_namespace_a;
3317 files = reg_types.h;
3318 files = sys/lc_core.h;
3319 test = " -r reg_types.h";
3320 test = " -r sys/lc_core.h";
3321 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3322 test = " -z \"`grep __regex_t regex.h`\"";
3326 c_fix_arg = "reg(ex|off|match)_t";
3328 test_text = "`touch sys/lc_core.h`"
3329 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3330 "extern regex_t re;\n"
3331 "extern regoff_t ro;\n"
3332 "extern regmatch_t rm;\n";
3336 hackname = osf_namespace_c;
3338 test = " -r reg_types.h";
3339 test = " -r sys/lc_core.h";
3340 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3341 test = " -z \"`grep __regex_t regex.h`\"";
3343 select = "#include <reg_types\.h>.*";
3346 "typedef __regex_t\tregex_t;\n"
3347 "typedef __regoff_t\tregoff_t;\n"
3348 "typedef __regmatch_t\tregmatch_t;";
3350 test_text = "#include <reg_types.h>";
3354 * On broken glibc-2.3.3 systems an array of incomplete structures is
3355 * passed to __sigsetjmp. Fix that to take a pointer instead.
3358 hackname = pthread_incomplete_struct_argument;
3360 select = "struct __jmp_buf_tag";
3362 c_fix_arg = "%1 *%2%3";
3363 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3364 "(__env)\\[1\\](.*)$";
3365 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3370 * Fix return type of fread and fwrite on sysV68
3373 hackname = read_ret_type;
3375 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3377 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3378 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3380 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3384 * Fix casts as lvalues in glibc's
<rpc
/xdr.h
>.
3387 hackname
= rpc_xdr_lvalue_cast_a
;
3389 select
= "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3391 c_fix_arg
= "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3392 test_text
= "#define IXDR_GET_LONG(buf) \\\\\n"
3393 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3397 * rpc_xdr_lvalue_cast_b
3400 hackname
= rpc_xdr_lvalue_cast_b
;
3402 select
= "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3404 c_fix_arg
= "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3405 test_text
= "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3406 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3410 * function
class(double x
) conflicts with C
++ keyword on rs
/6000
3413 hackname
= rs6000_double
;
3415 select
= '[^a-zA-Z_]class\(';
3418 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
3419 c_fix_arg
= '^.*[^a-zA-Z_]class\(.*';
3421 test_text
= "extern int class();";
3425 * Wrong fchmod prototype on RS
/6000.
3428 hackname
= rs6000_fchmod
;
3430 select
= 'fchmod\(char \*';
3432 c_fix_arg
= "fchmod(int";
3433 test_text
= "extern int fchmod(char *, mode_t);";
3437 * parameters conflict with C
++ new on rs
/6000
3440 hackname
= rs6000_param
;
3444 select
= 'rename\(const char \*old, const char \*new\)';
3446 c_fix_arg
= 'rename(const char *_old, const char *_new)';
3448 test_text
= 'extern int rename(const char *old, const char *new);';
3452 * Solaris
10+ <sys
/feature_tests.h
> defines _RESTRICT_KYWD as restrict
3453 * for C99. This is wrong for C
++, which needs many C99 features
, but
3454 * only supports __restrict.
3457 hackname
= solaris___restrict
;
3458 files
= sys
/feature_tests.h
;
3459 select
= "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3460 mach
= "*-*-solaris2*";
3462 c_fix_arg
= "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3463 "#else\n%0\n#endif";
3464 test_text
= "#define _RESTRICT_KYWD restrict";
3468 * Solaris
10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3469 * themselves
, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3470 * and imaginary definitions which are not supported by GCC.
3473 hackname
= solaris_complex
;
3474 mach
= "*-*-solaris2.*";
3476 select
= "#define[ \t]_Complex_I[ \t]_Complex_I";
3477 sed
= "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3478 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3479 sed
= "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3480 sed
= "/#define[ \t]imaginary[ \t]_Imaginary/d";
3481 sed
= "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3482 test_text
= "#define _Complex_I _Complex_I\n"
3483 "#define complex _Complex\n"
3484 "#define _Imaginary_I _Imaginary_I\n"
3485 "#define imaginary _Imaginary\n"
3487 "#define I _Imaginary_I";
3491 * Solaris
10+ <complex.h
> is wrapped in #ifndef __cplusplus. Wrap in
3492 * extern
"C" instead so libstdc
++ can use it.
3495 hackname
= solaris_complex_cxx
;
3496 mach
= "*-*-solaris2.*";
3498 sed
= "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3499 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3500 sed
= "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3501 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3502 test_text
= "#if !defined(__cplusplus)\n"
3503 "#endif /* !defined(__cplusplus) */";
3507 * g
++ rejects functions declared with both C and C
++ linkage.
3510 hackname
= solaris_cxx_linkage
;
3511 mach
= '*-*-solaris2*';
3512 files
= "iso/stdlib_iso.h";
3513 select
= "(#if __cplusplus >= 199711L)\n"
3514 "(extern \"C\\+\\+\" \\{\n)"
3515 "(.*(bsearch|qsort).*)";
3517 c_fix_arg
= "%1 && !__GNUG__\n%2%3";
3520 "#if __cplusplus >= 199711L\n"
3521 "extern \"C++\" {\n"
3522 " void *bsearch(const void *, const void *, size_t, size_t,";
3526 * Solaris
<iso
/stdio_iso.h
> doesn
't declare getc for C++ with
3527 * _STRICT_STDC, but uses it.
3530 hackname = solaris_getc_strict_stdc;
3531 mach = "*-*-solaris2*";
3532 files = "iso/stdio_iso.h";
3533 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3535 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3538 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3542 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3545 hackname = solaris_gets_c11;
3546 mach = "*-*-solaris2*";
3547 files = "iso/stdio_iso.h";
3548 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3551 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3552 "%1 __attribute__((__deprecated__));\n"
3555 test_text = "extern char *gets(char *);";
3559 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C
++14.
3562 hackname
= solaris_gets_cxx14
;
3563 mach
= "*-*-solaris2*";
3564 files
= "iso/stdio_iso.h";
3565 select
= <<- _EOSelect_
3566 (#if __STDC_VERSION__
< 201112L)
3567 (extern char \
*gets\
(char \
*\
) __ATTR_DEPRECATED
;)
3570 c_fix_arg
= "%1 && __cplusplus < 201402L\n%2";
3572 test_text
= <<- _EOText_
3573 #if __STDC_VERSION__
< 201112L
3574 extern char
*gets(char *) __ATTR_DEPRECATED
;
3579 * Sun Solaris
2 has a version of sys
/int_const.h that defines
3580 * UINT8_C and UINT16_C to unsigned constants.
3583 hackname
= solaris_int_const
;
3584 files
= sys
/int_const.h
;
3585 mach
= '*-*-solaris2*';
3587 c_fix_arg
= "#define\tUINT8_C(c)\t(c)\n"
3589 "#define\tUINT16_C(c)\t(c)";
3590 select
= "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3592 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3594 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3596 "#define UINT16_C(c) __CONCAT__(c,u)";
3600 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3601 * UINT8_MAX and UINT16_MAX to unsigned constants.
3604 hackname
= solaris_int_limits_1
;
3605 files
= sys
/int_limits.h
;
3606 mach
= '*-*-solaris2*';
3608 c_fix_arg
= "#define\tUINT8_MAX\t(255)\n"
3609 "#define\tUINT16_MAX\t(65535)";
3610 select
= "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3611 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3613 "#define UINT8_MAX (255U)\n"
3614 "#define UINT16_MAX (65535U)";
3618 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3619 * INT_FAST16 limits to wrong values for sys
/int_types.h.
3622 hackname
= solaris_int_limits_2
;
3623 files
= sys
/int_limits.h
;
3624 mach
= '*-*-solaris2*';
3626 c_fix_arg
= "#define\t%1_FAST16_%2 %132_%2";
3627 select
= "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3629 "#define INT_FAST16_MAX INT16_MAX\n"
3630 "#define UINT_FAST16_MAX UINT16_MAX\n"
3631 "#define INT_FAST16_MIN INT16_MIN";
3635 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3636 * SIZE_MAX as unsigned long.
3639 hackname
= solaris_int_limits_3
;
3640 files
= sys
/int_limits.h
;
3641 mach
= '*-*-solaris2*';
3643 c_fix_arg
= "#define\tSIZE_MAX\t4294967295U";
3644 select
= "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3646 "#define SIZE_MAX 4294967295UL";
3650 * Sun Solaris
10 defines several C99 math macros in terms of
3651 * builtins specific to the Studio compiler
, in particular not
3652 * compatible with the GNU compiler.
3655 hackname
= solaris_math_1
;
3656 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3657 bypass
= "__GNUC__";
3658 files
= iso
/math_c99.h
;
3660 c_fix_arg
= "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3661 c_fix_arg
= "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3663 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3665 "#define HUGE_VAL __builtin_huge_val\n"
3666 "#undef HUGE_VALF\n"
3667 "#define HUGE_VALF __builtin_huge_valf\n"
3668 "#undef HUGE_VALL\n"
3669 "#define HUGE_VALL __builtin_huge_vall";
3673 * On Solaris
11, if you do
isinf(NaN
) you
'll get a floating point
3674 * exception. Provide an alternative using GCC's builtin.
3677 hackname
= solaris_math_10
;
3678 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3679 files
= iso
/math_c99.h
;
3681 c_fix_arg
= "#define\tisinf(x) __builtin_isinf(x)";
3682 c_fix_arg
= "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3683 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3685 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3686 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3687 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3688 "\\(-INFINITY\\);[ \t]*\\}\\)";
3690 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3692 "#define isinf(x) __extension__( \\\\\n"
3693 " { __typeof(x) __x_i = (x); \\\\\n"
3694 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3695 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3699 * Solaris math INFINITY
3702 hackname
= solaris_math_2
;
3703 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3704 bypass
= "__GNUC__";
3705 files
= iso
/math_c99.h
;
3707 c_fix_arg
= "#define\tINFINITY\t(__builtin_inff())";
3708 c_fix_arg
= "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3710 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3712 "#define INFINITY __builtin_infinity";
3719 hackname
= solaris_math_3
;
3720 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3721 bypass
= "__GNUC__";
3722 files
= iso
/math_c99.h
;
3724 c_fix_arg
= "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3725 c_fix_arg
= "^#define[ \t]+NAN[ \t]+__builtin_nan";
3727 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3729 "#define NAN __builtin_nan";
3733 * Solaris math fpclassify
3736 hackname
= solaris_math_4
;
3737 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3738 bypass
= "__GNUC__";
3739 files
= iso
/math_c99.h
;
3741 c_fix_arg
= "#define\tfpclassify(x) \\\n"
3742 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3743 "FP_SUBNORMAL, FP_ZERO, (x))";
3744 c_fix_arg
= "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3746 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3747 "#undef fpclassify\n"
3748 "#define fpclassify(x) __builtin_fpclassify(x)";
3752 * Solaris math signbit
3755 hackname
= solaris_math_8
;
3756 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3757 bypass
= "__GNUC__";
3758 files
= iso
/math_c99.h
;
3760 c_fix_arg
= "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3761 "\t\t\t ? __builtin_signbitf(x) \\\n"
3762 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3763 "\t\t\t ? __builtin_signbitl(x) \\\n"
3764 "\t\t\t : __builtin_signbit(x))";
3765 c_fix_arg
= "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3766 test_text
= <<- _EOText_
3767 #ident
"@(#)math_c99.h 1.9 04/11/01 SMI"
3769 #define
signbit(x
) __builtin_signbit(x
)
3774 * Solaris math comparison macros
3777 hackname
= solaris_math_9
;
3778 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3779 bypass
= "__GNUC__";
3780 files
= iso
/math_c99.h
;
3782 c_fix_arg
= "#define\t%1(x, y)%2__builtin_%1(x, y)";
3783 c_fix_arg
= "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3784 "__builtin_[a-z]+\\(y\\)\\)";
3786 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3787 "#undef isgreater\n"
3788 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3789 "#undef isgreaterequal\n"
3790 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3792 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3793 "#undef islessequal\n"
3794 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3795 "#undef islessgreater\n"
3796 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3797 "#undef isunordered\n"
3798 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3802 * Newer Solaris
10/11 GCC signbit implementations cause strict
-aliasing
3806 hackname
= solaris_math_11
;
3807 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3808 files
= iso
/math_c99.h
;
3810 c_fix_arg
= << _EOArg_
3812 #define
signbit(x
) (sizeof(x
) == sizeof(float
) \
3813 ?
__builtin_signbitf(x
) \
3814 : sizeof(x
) == sizeof(long double
) \
3815 ?
__builtin_signbitl(x
) \
3816 : __builtin_signbit(x
))
3818 c_fix_arg
= << _EOArg_
3820 #if defined\
(__sparc\
)
3821 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3822 [ ]+\
{[ ]*__typeof\
(x\
)[ ]*__x_s
[ ]*=[ ]*\
(x\
);[ ]*\\
3823 [ ]+\
(int\
)[ ]*\
(\
*\
(unsigned
[ ]*\
*\
)[ ]*\
&__x_s
[ ]*>>[ ]*31\
);[ ]*\
}\
)
3824 #elif defined\
(__i386\
) \|\| defined\
(__amd64\
)
3825 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3826 [ ]+\
{ __typeof\
(x\
) __x_s
= \
(x\
); \\
3827 [ ]+\
(sizeof \
(__x_s\
) == sizeof \
(float\
) \? \\
3828 [ ]+\
(int\
) \
(\
*\
(unsigned \
*\
) \
&__x_s
>> 31\
) : \\
3829 [ ]+sizeof \
(__x_s\
) == sizeof \
(double\
) \? \\
3830 [ ]+\
(int\
) \
(\
(\
(unsigned \
*\
) \
&__x_s\
)\
[1\
] >> 31\
) : \\
3831 [ ]+\
(int\
) \
(\
(\
(unsigned short \
*\
) \
&__x_s\
)\
[4\
] >> 15\
)\
); \
}\
)
3834 test_text
= << _EOText_
3835 /* @
(#
)math_c99.h
1.14 13/03/27 */
3837 #if
defined(__sparc
)
3838 #define
signbit(x
) __extension__( \\
3839 { __typeof(x
) __x_s
= (x
); \\
3840 (int
) (*(unsigned *) &__x_s
>> 31); })
3841 #elif
defined(__i386
) ||
defined(__amd64
)
3842 #define
signbit(x
) __extension__( \\
3843 { __typeof(x
) __x_s
= (x
); \\
3844 (sizeof (__x_s
) == sizeof (float
) ?
\\
3845 (int
) (*(unsigned *) &__x_s
>> 31) : \\
3846 sizeof (__x_s
) == sizeof (double
) ?
\\
3847 (int
) (((unsigned *)
&__x_s
)[1] >> 31) : \\
3848 (int
) (((unsigned short *)
&__x_s
)[4] >> 15)); })
3854 * Some versions of Solaris
10+ <math.h
> #undef libstdc
++-internal macros.
3857 hackname
= solaris_math_12
;
3859 mach
= '*-*-solaris2*';
3860 select
= '#undef.*_GLIBCXX_USE_C99_MATH';
3861 sed
= "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3862 test_text
= << _EOText_
3863 #if __cplusplus
>= 201103L
3864 #undef _GLIBCXX_USE_C99_MATH
3865 #undef _GLIBCXX_USE_C99_MATH_TR1
3871 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3872 * structure. As such
, it need two levels of brackets
, but only
3873 * contains one. Wrap the macro definition in an extra layer.
3876 hackname
= solaris_once_init_1
;
3877 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3879 mach
= '*-*-solaris*';
3881 c_fix_arg
= "%1{%2}%3";
3882 c_fix_arg
= "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3884 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3885 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3889 * Solaris
10+ <spawn.h
> uses char
*const argv
[_RESTRICT_KYWD
] in the
3890 * posix_spawn declarations
, which doesn
't work with C++.
3893 hackname = solaris_posix_spawn_restrict;
3895 mach = '*-*-solaris2
*';
3897 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3898 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3900 "char *const argv[_RESTRICT_KYWD],\n"
3901 "char *const envp[_RESTRICT_KYWD]);";
3905 * The pow overloads with int were removed in C++ 2011 DR 550.
3908 hackname = solaris_pow_int_overload;
3909 mach = '*-*-solaris2
*';
3910 files = "iso/math_iso.h";
3911 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3912 " *\\{[^{}]*\n[^{}]*\\}";
3914 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3917 " inline long double pow(long double __X, int __Y) { return\n"
3918 " __powl(__X, (long double) (__Y)); }";
3922 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3923 * fields of the pthread_rwlock_t structure, which are of type
3924 * upad64_t, which itself is typedef'd to int64_t
, but with __STDC__
3925 * defined (e.g. by
-ansi
) it is a union. So change the initializer
3929 hackname
= solaris_rwlock_init_1
;
3930 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3932 mach
= '*-*-solaris*';
3934 c_fix_arg
= "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3937 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3939 c_fix_arg
= "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3940 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3943 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3944 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3948 * Before Solaris
10, <stdio.h
> lacks declarations of std
::__filbuf and
3949 * std
::__flsbuf
, but
<iso
/stdio_iso.h
> uses them.
3952 hackname
= solaris_std___filbuf
;
3954 mach
= '*-*-solaris2*';
3955 bypass
= "using std::__filbuf";
3956 select
= "(using std::perror;\n)(#endif)";
3958 c_fix_arg
= "%1#ifndef _LP64\n"
3959 "using std::__filbuf;\n"
3960 "using std::__flsbuf;\n"
3963 test_text
= "using std::perror;\n"
3968 * Solaris
<stdio.h
> shouldn
't use std::gets for C++14.
3971 hackname = solaris_std_gets_cxx14;
3972 mach = "*-*-solaris2*";
3974 select = "using std::gets;";
3977 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
3979 test_text = "using std::gets;";
3983 * Sun Solaris 8 has what appears to be some gross workaround for
3984 * some old version of their c++ compiler. G++ doesn't want it
3985 * either
, but doesn
't want to be tied to SunPRO version numbers.
3988 hackname = solaris_stdio_tag;
3989 files = stdio_tag.h;
3991 select = '__cplusplus
< 54321L';
3992 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3993 "!defined(__GNUC__)" so we no longer need to fix it. */
3994 bypass = '__GNUC__
';
3995 sed = 's
/defined(__cplusplus
) && (__cplusplus
< 54321L)/0/';
3997 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4001 * Solaris <stdlib.h> shouldn't use _Noreturn
, breaks with C
++.
4004 hackname
= solaris_stdlib_noreturn
;
4005 mach
= "*-*-solaris2*";
4006 files
= "iso/stdlib_c99.h";
4007 select
= "(extern) _Noreturn (void quick_exit\\(int\\));";
4010 c_fix_arg
= "%1 %2 __attribute__((__noreturn__));";
4012 test_text
= "extern _Noreturn void quick_exit(int);";
4016 * a missing semi
-colon at the end of the statsswtch structure definition.
4019 hackname
= statsswtch
;
4020 files
= rpcsvc
/rstat.h
;
4021 select
= "boottime$";
4023 c_fix_arg
= "boottime;";
4024 test_text
= "struct statswtch {\n int boottime\n};";
4028 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4029 * On
4BSD
-derived systems
, stdio.h defers to machine
/ansi.h
; that
's
4033 hackname = stdio_stdarg_h;
4035 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4037 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4038 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4040 mach = '*-*-solaris2.1
[0-9]*';
4045 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4051 * Don't use or define the name va_list in stdio.h. This is for
4052 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4053 * of __gnuc_va_list
, __DJ_va_list
, or _G_va_list is taken to
4054 * indicate that the header knows what it
's doing -- under SUSv2,
4055 * stdio.h is required to define va_list, and we shouldn't break
4059 hackname
= stdio_va_list
;
4061 bypass
= '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4063 * On Solaris
10, the definition in
4064 * <stdio.h
> is guarded appropriately by the _XPG4 feature macro
;
4065 * there is therefore no need for this fix there.
4067 mach
= '*-*-solaris2.1[0-9]*';
4071 * Use __gnuc_va_list in arg types in place of va_list.
4072 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4073 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4074 * trailing parentheses and semicolon save all other systems from this.
4075 * Define __not_va_list__ (something harmless and unused)
4076 * instead of va_list.
4077 * Don't claim to have defined va_list.
4079 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4080 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4081 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4082 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4083 "s@ va_list@ __not_va_list__@\n"
4084 "s@\\*va_list@*__not_va_list__@\n"
4085 "s@ __va_list)@ __gnuc_va_list)@\n"
4086 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4087 "@typedef \\1 __not_va_list__;@\n"
4088 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4089 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4090 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4091 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4092 "s@VA_LIST@DUMMY_VA_LIST@\n"
4093 "s@_Va_LIST@_VA_LIST@";
4094 test_text
= "extern void mumble( va_list);";
4098 * Fix headers that use va_list from stdio.h to use the updated
4099 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4100 * dealt with elsewhere. The presence of __gnuc_va_list
,
4101 * __DJ_va_list
, or _G_va_list is taken to indicate that the header
4102 * knows what it
's doing.
4105 hackname = stdio_va_list_clients;
4113 files = curses_colr/curses.h;
4114 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list
';
4115 /* Don't fix
, if we use va_list from stdarg.h
, or if the use is
4116 otherwise protected.
*/
4117 bypass
= 'include <stdarg\.h>|#ifdef va_start';
4120 * Use __gnuc_va_list in arg types in place of va_list.
4121 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4122 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4123 * trailing parentheses and semicolon save all other systems from this.
4124 * Define __not_va_list__ (something harmless and unused)
4125 * instead of va_list.
4126 * Don't claim to have defined va_list.
4128 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4129 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4130 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4131 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4132 "s@ va_list@ __not_va_list__@\n"
4133 "s@\\*va_list@*__not_va_list__@\n"
4134 "s@ __va_list)@ __gnuc_va_list)@\n"
4135 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4136 "@typedef \\1 __not_va_list__;@\n"
4137 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4138 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4139 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4140 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4141 "s@VA_LIST@DUMMY_VA_LIST@\n"
4142 "s@_Va_LIST@_VA_LIST@";
4143 test_text
= "extern void mumble( va_list);";
4147 * "!__STDC__" or
"__STDC__==0" or
"__STDC__!=1" or
"__STDC__-0==0"
4148 * is
"!defined( __STRICT_ANSI__ )"
4151 hackname
= strict_ansi_not
;
4152 select
= "^([ \t]*#[ \t]*if.*)"
4154 "|__STDC__[ \t]*==[ \t]*0"
4155 "|__STDC__[ \t]*!=[ \t]*1"
4156 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4157 /* Tru64 UNIX V4.0F
/V5.1
<standards.h
> supports GCC usage of __STDC__.
*/
4158 bypass
= 'GNU and MIPS C compilers define __STDC__ differently';
4159 /* GNU gmp.h uses
"__STDC__ != 1" only if __SCO_VERSION__
, which
4160 is not defined by GCC
, so it is safe.
*/
4161 bypass
= '__SCO_VERSION__.*__STDC__ != 1';
4162 c_test
= stdc_0_in_system_headers
;
4165 c_fix_arg
= "%1 !defined(__STRICT_ANSI__)";
4167 test_text
= "#if !__STDC__ \n"
4168 "#if __STDC__ == 0\n"
4169 "#if __STDC__ != 1\n"
4170 "#if __STDC__ - 0 == 0"
4171 "/* not std C */\nint foo;\n"
4172 "\n#end-end-end-end-if :-)";
4177 * is
"!defined( __STRICT_ANSI__ )" on continued #if
-s
4180 hackname
= strict_ansi_not_ctd
;
4181 files
= math.h
, limits.h
, stdio.h
, signal.h
,
4182 stdlib.h
, sys
/signal.h
, time.h
;
4184 * Starting at the beginning of a line
, skip white space and
4185 * a leading
"(" or
"&&" or
"||". One of those must be found.
4186 * Then
, zero
, one or more copies of a
"defined(_FOO_BAR_) &&"
4187 * expression. If these are nested
, then they must accumulate
4188 * because we won
't match any closing parentheses. Finally,
4189 * after skipping over all that, we must then match our suspect
4190 * phrase: "__STDC__-0==0" with or without white space.
4192 select = "^([ \t]*" '(\
(|
&&|\|\|
)'
4193 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4195 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4196 c_test = stdc_0_in_system_headers;
4199 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4201 test_text = "#if 1 && \\\\\n"
4202 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4203 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4204 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4209 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4210 * is "defined( __STRICT_ANSI__ )"
4213 hackname = strict_ansi_only;
4214 select = "^([ \t]*#[ \t]*if.*)"
4215 "(__STDC__[ \t]*!=[ \t]*0"
4216 "|__STDC__[ \t]*==[ \t]*1"
4217 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4218 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4219 c_test = stdc_0_in_system_headers;
4222 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4224 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4228 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4229 * in prototype without previous definition.
4232 hackname = struct_file;
4234 select = '^.
*xdrstdio_create.
*struct __file_s
';
4236 c_fix_arg = "struct __file_s;\n%0";
4237 test_text = "extern void xdrstdio_create( struct __file_s* );";
4241 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4242 * in prototype without previous definition.
4244 * Don't fix OpenBSD
, which uses struct sockaddr_in prototyping the same
4245 * function
, and does define it.
4248 hackname
= struct_sockaddr
;
4250 select
= "^.*authdes_create.*struct sockaddr[^_]";
4251 bypass
= "<sys/socket\.h>";
4252 bypass
= "struct sockaddr;\n";
4254 c_fix_arg
= "struct sockaddr;\n%0";
4255 test_text
= "extern AUTH* authdes_create( struct sockaddr* );";
4259 * Apply fix this to all OSs since this problem seems to effect
4260 * more than just SunOS.
4263 hackname
= sun_auth_proto
;
4268 bypass
= "__cplusplus";
4270 * Select those files containing
'(*name)()'.
4272 select
= '\(\*[a-z][a-z_]*\)\(\)';
4275 c_fix_arg
= "#ifdef __cplusplus\n%1(...);%2\n"
4276 "#else\n%1();%2\n#endif";
4277 c_fix_arg
= '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4281 " int (*name)(); /* C++ bad */\n"
4286 * Fix bogus #ifdef on SunOS
4.1.
4289 hackname
= sun_bogus_ifdef
;
4290 files
= "hsfs/hsfs_spec.h";
4291 files
= "hsfs/iso_spec.h";
4292 select
= '#ifdef(.*\|\|.*)';
4294 c_fix_arg
= "#if%1";
4296 test_text
= "#ifdef __i386__ || __vax__ || __sun4c__";
4300 * Fix the CAT macro in SunOS memvar.h.
4303 hackname
= sun_catmacro
;
4304 files
= pixrect
/memvar.h
;
4305 select
= "^#define[ \t]+CAT\\(a,b\\).*";
4310 "# define CAT(a,b) a##b\n"
4311 "#else\n%0\n#endif";
4314 "#define CAT(a,b)\ta/**/b";
4318 * Fix return type of free and
{c
,m
,re
}alloc in
<malloc.h
> on SunOS
4.1.
4319 * Also fix return type of
{m
,re
}alloc in
<malloc.h
> on sysV68
4322 hackname
= sun_malloc
;
4324 bypass
= "_CLASSIC_ANSI_TYPES";
4326 sed
= "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4327 sed
= "s/int[ \t][ \t]*free/void\tfree/g";
4328 sed
= "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4329 sed
= "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4330 sed
= "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4333 "typedef char *\tmalloc_t;\n"
4335 "char*\tmalloc();\n"
4336 "char*\tcalloc();\n"
4337 "char*\trealloc();";
4341 * Check for yet more missing
';' in
struct (in SunOS
4.0.x
)
4344 hackname
= sun_rusers_semi
;
4345 files
= rpcsvc
/rusers.h
;
4347 sed
= "/^struct/,/^};/s/_cnt$/_cnt;/";
4348 test_text
= "struct mumble\n int _cnt\n};";
4352 * signal.h on SunOS defines signal
using (),
4353 * which causes trouble when compiling with g
++ -pedantic.
4356 hackname
= sun_signal
;
4357 files
= sys
/signal.h
;
4359 select
= "^void\t" '\(\*signal\(\)\)\(\);.*';
4363 "#ifdef __cplusplus\n"
4364 "void\t(*signal(...))(...);\n"
4365 "#else\n%0\n#endif";
4367 test_text
= "void\t(*signal())();";
4371 * Correct the return type for strlen in strings.h in SunOS
4.
4374 hackname
= sunos_strlen
;
4376 select
= "int[ \t]*strlen\\(\\);(.*)";
4378 c_fix_arg
= "__SIZE_TYPE__ strlen();%1";
4379 test_text
= " int\tstrlen(); /* string length */";
4383 * Linux kernel
's vt.h breaks C++
4386 hackname = suse_linux_vt_cxx;
4389 select = "^[ \t]*unsigned int new;";
4391 c_fix_arg = "unsigned int newev;";
4393 test_text = " unsigned int new; /* New console (if changing) */";
4397 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4398 * that is visible to any ANSI compiler using this include. Simply
4399 * delete the lines that #define some string functions to internal forms.
4402 hackname = svr4_disable_opt;
4404 select = '#define.
*__std_hdr_
';
4405 sed = '/#define.
*__std_hdr_
/d
';
4406 test_text = "#define strlen __std_hdr_strlen\n";
4410 * Fix broken decl of getcwd present on some svr4 systems.
4413 hackname = svr4_getcwd;
4416 files = prototypes.h;
4417 select = 'getcwd\
(char \
*, int\
)';
4420 c_fix_arg = "getcwd(char *, size_t)";
4422 test_text = "extern char* getcwd(char *, int);";
4426 * Fix broken decl of profil present on some svr4 systems.
4429 hackname = svr4_profil;
4434 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
4436 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
4439 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
4443 * Correct types for signal handler constants like SIG_DFL; they might be
4444 * void (*) (), and should be void (*) (int). C++ doesn't like the
4448 hackname
= svr4_sighandler_type
;
4449 files
= sys
/signal.h
;
4450 select
= 'void *\(\*\)\(\)';
4452 c_fix_arg
= "void (*)(int)";
4453 test_text
= "#define SIG_DFL (void(*)())0\n"
4454 "#define SIG_IGN (void (*)())0\n";
4458 * Some SysV r4 systems
, including Sequent
's DYNIX/ptx, use the local
4459 * function 'getrnge
' in <regexp.h> before they declare it. For these
4460 * systems add a 'static int
' declaration of 'getrnge
' into <regexp.h>
4463 * 'getrnge
' traditionally manipulates a file-scope global called 'size
',
4464 * so put the declaration right after the declaration of 'size
'.
4466 * Don't do this if there is already a `static void getrnge
' declaration
4467 * present, since this would cause a redeclaration error. Solaris 2.x has
4468 * such a declaration.
4471 hackname = svr4_undeclared_getrnge;
4474 bypass = "static void getrnge";
4477 "static int getrnge ();";
4478 c_fix_arg = "^static int[ \t]+size;";
4479 test_text = "static int size;\n"
4480 "/* stuff which calls getrnge() */\n"
4481 "static getrnge()\n"
4486 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4487 * in string.h on sysV68
4488 * Correct the return type for strlen in string.h on Lynx.
4489 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4490 * Add missing const for strdup on OSF/1 V3.0.
4491 * On sysV88 layout is slightly different.
4494 hackname = sysv68_string;
4497 bypass = "_CLASSIC_ANSI_TYPES";
4499 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4500 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4501 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4503 sed = "/^extern char$/N";
4504 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4506 sed = "/^extern int$/N";
4507 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4509 sed = "/^\tstrncmp(),$/N";
4510 sed = 's
/^\
(' "\t" 'strncmp()\
),\n\
(' "\t" 'strlen(),\
)$
/'
4511 '\
1;' "\\\nextern unsigned int\\\n\\2/";
4514 "extern int strlen();\n"
4516 "extern int ffs(long);\n"
4529 "\tstrlen(), strspn();";
4533 * Fix return type of calloc, malloc, realloc, bsearch and exit
4536 hackname = sysz_stdlib_for_sun;
4538 bypass = "_CLASSIC_ANSI_TYPES";
4540 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4542 c_fix_arg = "void *\t%1(";
4545 "extern char*\tcalloc(size_t);\n"
4546 "extern char*\tmalloc(size_t);\n"
4547 "extern char*\trealloc(void*,size_t);\n"
4548 "extern char*\tbsearch(void*,size_t,size_t);\n";
4552 * __thread is now a keyword.
4555 hackname = thread_keyword;
4556 files = "pthread.h";
4557 files = bits/sigthread.h, '*/bits
/sigthread.h
';
4558 select = "([* ])__thread([,)])";
4560 c_fix_arg = "%1__thr%2";
4563 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4564 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4565 "extern int pthread_cancel (pthread_t __thread);";
4569 * if the #if says _cplusplus, not the double underscore __cplusplus
4573 hackname = tinfo_cplusplus;
4575 select = "[ \t]_cplusplus";
4578 c_fix_arg = " __cplusplus";
4579 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4583 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4586 hackname = ultrix_const;
4588 select = 'perror\
( char \
*';
4591 c_fix_arg = "%1 const %3 *__";
4592 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4593 "[ \t]+(char|void) \\*__";
4596 "extern void perror( char *__s );\n"
4597 "extern int fputs( char *__s, FILE *);\n"
4598 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4599 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4600 "extern int scanf( char *__format, ...);\n";
4604 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4607 hackname = ultrix_const2;
4610 select = '\
*fopen\
( char \
*';
4612 c_fix_arg = "%1( const char *%3, const char *";
4613 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4614 "[ \t]*char[ \t]*\\*([^,]*),"
4615 "[ \t]*char[ \t]*\\*[ \t]*";
4618 "extern FILE *fopen( char *__filename, char *__type );\n"
4619 "extern int sscanf( char *__s, char *__format, ...);\n"
4620 "extern FILE *popen(char *, char *);\n"
4621 "extern char *tempnam(char*,char*);\n";
4625 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4628 hackname = va_i960_macro;
4629 files = arch/i960/archI960.h;
4630 select = "__(vsiz|vali|vpad|alignof__)";
4633 c_fix_arg = "__vx%1";
4636 "extern int __vsiz vsiz;\n"
4637 "extern int __vali vali;\n"
4638 "extern int __vpad vpad;\n"
4639 "#define __alignof__(x) ...";
4643 * On VMS, add missing braces around sigset_t constants.
4646 hackname = vms_add_missing_braces;
4647 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4649 files = "rtldef/signal.h";
4652 c_fix_arg = '%1 {%2} ';
4654 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4655 "{0x00000000, 0x00000000},\n"
4656 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4660 * On VMS, some DEC-C builtins are directly used.
4663 hackname = vms_decc_builtin;
4664 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4666 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4668 sed = "s@__MEMSET@memset@";
4669 sed = "s@__MEMMOVE@memmove@";
4670 sed = "s@__MEMCPY@memcpy@";
4671 sed = "s@__STRLEN@strlen@";
4672 sed = "s@__STRCPY@strcpy@";
4674 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4678 * Define __CAN_USE_EXTERN_PREFIX on vms.
4681 hackname = vms_define_can_use_extern_prefix;
4682 files = "rtldef/decc$types.h";
4683 select = "#[ \t]*else\n"
4684 "#[ \t]*if defined\\(__DECCXX\\)\n"
4685 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4690 "# elif defined (__GNUC__)\n"
4691 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4693 test_text = "# else\n"
4694 "# if defined(__DECCXX)\n"
4695 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4701 * On VMS, disable the use of dec-c string builtins
4704 hackname = vms_disable_decc_string_builtins;
4705 select = "#if !defined\\(__VAX\\)\n";
4707 files = "rtldef/string.h";
4710 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4712 test_text = "#if !defined(__VAX)\n";
4716 * On VMS, fix incompatible redeclaration of hostalias.
4719 hackname = vms_do_not_redeclare_hostalias;
4720 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4721 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4723 files = "rtldef/resolv.h";
4729 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4730 "__char_ptr32 hostalias (const char *);\n";
4734 * On VMS, forward declare structure before referencing them in prototypes.
4737 hackname = vms_forward_declare_struct;
4738 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4739 "#ifdef __cplusplus\n";
4741 files = rtldef/if.h;
4745 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4747 test_text = "/* forward decls for C++ */\n"
4748 "#ifdef __cplusplus\n"
4754 * On VMS, do not declare getopt and al if pointers are 64 bit.
4757 hackname = vms_no_64bit_getopt;
4758 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4759 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4761 files = rtldef/stdio.h, rtldef/unistd.h;
4764 c_fix_arg = <<- _EOArg_
4765 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4770 test_text = "int getopt (int, char * const [], const char *);";
4774 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4775 * which is not yet fully supported by gcc.
4778 hackname = vms_use_fast_setjmp;
4779 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4781 files = rtldef/setjmp.h;
4784 c_fix_arg = "%0 defined (__GNUC__) ||";
4786 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4790 * On VMS, use pragma extern_model instead of VAX-C keywords.
4793 hackname = vms_use_pragma_extern_model;
4794 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4795 "# pragma extern_model __save\n";
4799 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4800 "# pragma extern_model __save\n";
4802 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4803 "# pragma extern_model __save\n"
4804 "# pragma extern_model strict_refdef\n"
4805 " extern struct x zz$yy;\n"
4806 "# pragma extern_model __restore\n"
4811 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4812 * conflict while building gcc. Likewise for <builtins.h>
4815 hackname = vms_use_quoted_include;
4816 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4818 files = rtldef/wait.h, starlet_c/pthread.h;
4821 c_fix_arg = '%1<sys
/%2.h
>';
4823 test_text = "# include <resource.h>";
4827 * AIX and Interix headers define NULL to be cast to a void pointer,
4828 * which is illegal in ANSI C++.
4831 hackname = void_null;
4832 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4833 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4834 /* avoid changing C++ friendly NULL */
4835 bypass = __cplusplus;
4837 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4839 c_fix_arg = <<- _EOFix_
4844 #else /* ! __GNUG__ */
4846 #endif /* __GNUG__ */
4847 #else /* ! __cplusplus */
4848 #define NULL ((void *)0)
4849 #endif /* __cplusplus */
4852 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4856 * Make VxWorks header which is almost gcc ready fully gcc ready.
4859 hackname = vxworks_gcc_problem;
4860 files = types/vxTypesBase.h;
4861 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4863 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4866 sed = "/[ \t]size_t/i\\\n"
4867 "#ifndef _GCC_SIZE_T\\\n"
4868 "#define _GCC_SIZE_T\n";
4870 sed = "/[ \t]size_t/a\\\n"
4873 sed = "/[ \t]ptrdiff_t/i\\\n"
4874 "#ifndef _GCC_PTRDIFF_T\\\n"
4875 "#define _GCC_PTRDIFF_T\n";
4877 sed = "/[ \t]ptrdiff_t/a\\\n"
4880 sed = "/[ \t]wchar_t/i\\\n"
4881 "#ifndef _GCC_WCHAR_T\\\n"
4882 "#define _GCC_WCHAR_T\n";
4884 sed = "/[ \t]wchar_t/a\\\n"
4888 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4889 "typedef unsigned int size_t;\n"
4890 "typedef long ptrdiff_t;\n"
4891 "typedef unsigned short wchar_t;\n"
4892 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4896 * Wrap VxWorks ioctl to keep everything pretty
4899 hackname = vxworks_ioctl_macro;
4901 mach = "*-*-vxworks*";
4905 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4906 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4908 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4912 * Wrap VxWorks mkdir to be posix compliant
4915 hackname = vxworks_mkdir_macro;
4917 mach = "*-*-vxworks*";
4921 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4922 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4923 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4924 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4927 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4931 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4934 hackname = vxworks_needs_vxtypes;
4936 select = "uint_t([ \t]+_clocks_per_sec)";
4938 c_fix_arg = "unsigned int%1";
4939 test_text = "uint_t\t_clocks_per_sec;";
4943 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4946 hackname = vxworks_needs_vxworks;
4948 test = " -r types/vxTypesOld.h";
4949 test = " -n \"`egrep '#include
' $file`\"";
4950 test = " -n \"`egrep ULONG $file`\"";
4951 select = "#[ \t]define[ \t]+__INCstath";
4953 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4954 "#include <types/vxTypesOld.h>\n";
4956 test_text = "`touch types/vxTypesOld.h`"
4957 "#include </dev/null> /* ULONG */\n"
4958 "# define\t__INCstath <sys/stat.h>";
4962 * Make it so VxWorks does not include gcc/regs.h accidentally
4965 hackname = vxworks_regs;
4966 mach = "*-*-vxworks*";
4968 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4970 c_fix_arg = "#include <arch/../regs.h>";
4972 test_text = "#include <regs.h>\n";
4976 * Another bad dependency in VxWorks 5.2 <time.h>.
4979 hackname = vxworks_time;
4981 test = " -r vxWorks.h";
4983 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4987 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4988 "#ifdef __cplusplus\n"
4989 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4991 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4993 "#define __gcc_VOIDFUNCPTR_defined\n"
4995 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4997 test_text = "`touch vxWorks.h`"
4998 "#define VOIDFUNCPTR (void(*)())";
5002 * This hack makes write const-correct on VxWorks
5005 hackname = vxworks_write_const;
5007 mach = "*-*-vxworks*";
5010 c_fix_arg = "extern int write (int, const char*, size_t);";
5011 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5013 "[\t ]*char[\t ]*\\*[\t ]*,"
5014 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5016 test_text = "extern int write ( int , char * , size_t ) ;";
5020 * This hack ensures the include_next in the fixed unistd.h actually
5021 * finds the system's unistd.h and not the fixed unistd.h again.
5024 hackname
= vxworks_iolib_include_unistd
;
5026 mach
= "*-*-vxworks*";
5027 select
= "#include \"unistd.h\"";
5030 c_fix_arg
= "#include <unistd.h>";
5032 test_text
= "#include \"unistd.h\"";
5036 * There are several name conflicts with C
++ reserved words in X11 header
5037 * files. These are fixed in some versions
, so don
't do the fixes if
5038 * we find __cplusplus in the file. These were found on the RS/6000.
5041 hackname = x11_class;
5042 files = X11/ShellP.h;
5043 bypass = __cplusplus;
5044 select = "^([ \t]*char \\*)class;(.*)";
5046 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5047 "#else\n%1class;%2\n#endif";
5055 * class in Xm/BaseClassI.h
5058 hackname = x11_class_usage;
5059 files = Xm/BaseClassI.h;
5060 bypass = "__cplusplus";
5062 select = " class\\)";
5064 c_fix_arg = " c_class)";
5066 test_text = "extern mumble (int class);\n";
5070 * new in Xm/Traversal.h
5074 files = Xm/Traversal.h;
5075 bypass = __cplusplus;
5077 sed = "/Widget\told, new;/i\\\n"
5078 "#ifdef __cplusplus\\\n"
5079 "\\\tWidget\told, c_new;\\\n"
5082 sed = "/Widget\told, new;/a\\\n"
5085 sed = "s/Widget new,/Widget c_new,/g";
5088 " Widget\told, new;\n"
5089 "};\nextern Wedged( Widget new, Widget old );";
5093 * Incorrect sprintf declaration in X11/Xmu.h
5096 hackname = x11_sprintf;
5098 files = X11/Xmu/Xmu.h;
5099 select = "^extern char \\*\tsprintf\\(\\);$";
5102 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5104 test_text = "extern char *\tsprintf();";