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 /* regs.h depends on CPU_FAMILY being properly defined, which
430 is done by vxCpu.h. */
431 #include <types/vxCpu.h>
432 /* regs.h includes a CPU_FAMILY-specific header that requires
433 vxTypesOld.h to already have been included. Those headers
434 contain proper _ASMLANGUAGE guards around their typedefs,
435 but vxTypesOld.h itself does not. So we avoid including
436 vxTypesOld.h from assembly. */
438 #include <types/vxTypesOld.h>
440 #include_next <arch/../regs.h>
446 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
449 hackname = AAB_vxworks_unistd;
451 mach = "*-*-vxworks*";
453 replace = <<- _EndOfHeader_
456 #include_next <unistd.h>
459 #define STDIN_FILENO 0
461 #ifndef STDOUT_FILENO
462 #define STDOUT_FILENO 1
464 #ifndef STDERR_FILENO
465 #define STDERR_FILENO 2
467 #endif /* _UNISTD_H */
472 * assert.h on AIX 7 redefines static_assert as _Static_assert without
476 hackname = aix_assert;
479 select = "#define[ \t]static_assert[ \t]_Static_assert";
481 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
482 test_text = "#define static_assert _Static_assert";
486 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
487 * which only is provided by AIX xlc C99.
490 hackname = aix_complex;
493 select = "#define[ \t]_Complex_I[ \t]__I";
495 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
496 test_text = "#define _Complex_I __I\n";
500 * On AIX some headers are not properly guarded by 'extern
"C"'.
503 hackname = aix_externc;
509 files = sys/localedef.h;
511 bypass = "extern \"C\"";
513 c_fix_arg = "#ifdef __cplusplus\n"
516 c_fix_arg = "#ifdef __cplusplus\n"
519 test_text = "extern int __n_pthreads;\n";
523 * On AIX sys/socket.h assumes C++.
526 hackname = aix_externcpp1;
528 files = "sys/socket.h";
529 select = "#ifdef __cplusplus";
531 c_fix_arg = "#ifdef __cplusplus\n"
533 test_text = "#ifdef __cplusplus";
538 hackname = aix_externcpp2;
540 files = "sys/socket.h";
541 select = "#else /\\* __cplusplus \\*/";
543 c_fix_arg = "} /* extern \"C++\" */\n"
544 "#else /* __cplusplus */";
545 test_text = "#else /* __cplusplus */";
550 * malloc.h on AIX6 uses XLC++ specific builtin syntax
553 hackname = aix_malloc;
556 select = "#ifdef __cplusplus";
558 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
559 test_text = "#ifdef __cplusplus";
563 * net/if_arp.h defines a variable fc_softc instead of adding a
564 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
567 hackname = aix_net_if_arp;
569 files = "net/if_arp.h";
570 select = "^struct fc_softc \\{";
572 c_fix_arg = "typedef struct _fc_softc {";
573 test_text = "struct fc_softc {\n int a;\n};";
577 * Fix AIX definition of NULL for G++.
582 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
583 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
585 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
587 c_fix_arg = <<- _EOFix_
592 #else /* ! __GNUG__ */
594 #endif /* __GNUG__ */
595 #else /* ! __cplusplus */
596 #define NULL ((void *)0)
597 #endif /* __cplusplus */
600 test_text = "# define\tNULL \t(0L) /* typed NULL */";
604 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
605 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
609 hackname = aix_once_init_1;
612 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
615 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
617 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
622 hackname = aix_once_init_2;
625 select = "[ \t]0 \\\\\n"
628 c_fix_arg = " 0 \\\n"
630 test_text = " 0 \\\\\n"
635 hackname = aix_mutex_initializer_1;
638 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
641 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
643 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
648 hackname = aix_cond_initializer_1;
651 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
654 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
656 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
661 hackname = aix_rwlock_initializer_1;
664 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
667 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
669 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
674 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
675 * which violates a requirement of ISO C.
678 hackname = aix_pthread;
680 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
683 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
684 "{...init stuff...}";
688 * AIX stdint.h fixes.
691 hackname = aix_stdint_1;
693 files = stdint-aix.h, stdint.h;
694 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
695 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
697 c_fix_arg = "#define UINT8_MAX (255)\n"
698 "#define UINT16_MAX (65535)";
699 test_text = "#define UINT8_MAX (255U)\n"
700 "#define UINT16_MAX (65535U)";
707 hackname = aix_stdint_2;
709 files = stdint-aix.h, stdint.h;
710 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
711 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
712 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
714 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
715 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
716 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
718 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
719 "#define INTPTR_MAX 9223372036854775807L\n"
720 "#define UINTPTR_MAX 18446744073709551615UL\n"
722 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
723 "#define INTPTR_MAX 2147483647L\n"
724 "#define UINTPTR_MAX 4294967295UL";
725 test_text = "#define INTPTR_MIN INT64_MIN\n"
726 "#define INTPTR_MAX INT64_MAX\n"
727 "#define UINTPTR_MAX UINT64_MAX\n"
729 "#define INTPTR_MIN INT32_MIN\n"
730 "#define INTPTR_MAX INT32_MAX\n"
731 "#define UINTPTR_MAX UINT32_MAX";
738 hackname = aix_stdint_3;
740 files = stdint-aix.h, stdint.h;
741 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
742 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
744 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
745 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
747 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
748 "#define PTRDIFF_MAX 9223372036854775807L\n"
750 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
751 "#define PTRDIFF_MAX 2147483647L";
752 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
753 "#define PTRDIFF_MAX INT64_MAX\n"
755 "#define PTRDIFF_MIN INT32_MIN\n"
756 "#define PTRDIFF_MAX INT32_MAX";
763 hackname = aix_stdint_4;
765 files = stdint-aix.h, stdint.h;
766 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
768 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
770 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
772 "#define SIZE_MAX 4294967295UL";
773 test_text = "#define SIZE_MAX UINT64_MAX\n"
775 "#define SIZE_MAX UINT32_MAX";
782 hackname = aix_stdint_5;
784 files = stdint-aix.h, stdint.h;
785 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
786 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
788 c_fix_arg = "#define UINT8_C(c) c\n"
789 "#define UINT16_C(c) c";
790 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
791 "#define UINT16_C(c) __CONCAT__(c,U)";
795 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
796 produces wrong code with G++.
799 hackname = aix_stdio_inline;
802 select = "#ifdef __cplusplus\\\n"
806 c_fix_arg = "#ifdef __cplusplus\n"
809 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
811 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
815 * stdlib.h on AIX uses #define on malloc and friends.
818 hackname = aix_stdlib_malloc;
821 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
823 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
824 test_text = "#define malloc __linux_malloc";
828 hackname = aix_stdlib_realloc;
831 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
833 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
834 test_text = "#define realloc __linux_realloc";
838 hackname = aix_stdlib_calloc;
841 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
843 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
844 test_text = "#define calloc __linux_calloc";
848 hackname = aix_stdlib_valloc;
851 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
853 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
854 test_text = "#define valloc __linux_valloc";
858 hackname = aix_stdlib_vec_malloc;
861 select = "#define[ \t]+malloc[ \t]+vec_malloc";
863 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
864 test_text = "#define malloc vec_malloc";
868 hackname = aix_stdlib_vec_calloc;
871 select = "#define[ \t]+calloc[ \t]+vec_calloc";
873 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
874 test_text = "#define calloc vec_calloc";
878 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
881 hackname = aix_strtof_const;
884 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
886 c_fix_arg = "%1(const char *, char **);";
887 test_text = "extern float strtof(char *, char **);";
891 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
892 * in an otherwise harmless (and #ifed out) macro definition
895 hackname = aix_sysmachine;
897 files = sys/machine.h;
901 test_text = "#define FOO \\\n"
902 " bar \\ \n baz \\ \n bat";
906 * sys/wait.h on AIX 5.2 defines macros that have both signed and
907 * unsigned types in conditional expressions.
910 hackname = aix_syswait_2;
913 select = '\? (\
(\
(\
(\
(unsigned
[^
)]*\
)[^
)]*\
) >> [^
)]*\
) \
& 0xff\
) : -1)';
915 c_fix_arg = "? (int)%1";
916 test_text = "#define WSTOPSIG(__x) "
917 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
921 * sys/signal.h on some versions of AIX uses volatile in the typedef of
922 * sig_atomic_t, which causes gcc to generate a warning about duplicate
923 * volatile when a sig_atomic_t variable is declared volatile, as
924 * required by ANSI C.
927 hackname = aix_volatile;
929 files = sys/signal.h;
930 select = "typedef volatile int sig_atomic_t";
932 c_fix_arg = "typedef int sig_atomic_t";
933 test_text = "typedef volatile int sig_atomic_t;";
937 * AIX unistd.h defines a static function with an empty parameter list.
940 hackname = aix_unistd;
944 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
946 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
947 test_text = " static int getdtablesize()";
951 * Fix __assert declaration in assert.h on Alpha OSF/1.
954 hackname = alpha___assert;
956 select = '__assert\
(char \
*, char \
*, int\
)';
958 c_fix_arg = "__assert(const char *, const char *, int)";
959 test_text = 'extern void
__assert(char
*, char
*, int
);';
963 * Fix assert macro in assert.h on Alpha OSF/1.
964 * The superfluous int cast breaks C++.
967 hackname = alpha_assert;
969 select = "(#[ \t]*" 'define assert\
(EX\
).*)\
(\
(int\
) \
(EX\
)\
)';
971 c_fix_arg = "%1(EX)";
972 test_text = '#define
assert(EX
) (((int
) (EX
)) ?
(void
)0 '
973 ': __assert(#EX
, __FILE__
, __LINE__
))';
977 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
980 hackname = alpha_getopt;
983 select = 'getopt\
(int
, char \
*\
[\
], *char \
*\
)';
985 c_fix_arg = "getopt(int, char *const[], const char *)";
986 test_text = 'extern int
getopt(int
, char
*[], char *)
;';
990 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
993 hackname = alpha_if_semicolon;
995 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
997 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
998 test_text = ' struct sockaddr vmif_paddr
/* protocol address
*/';
1002 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1005 hackname = alpha_parens;
1007 select = '#ifndef\
(__mips64\
)';
1009 c_fix_arg = "#ifndef __mips64";
1010 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1014 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1018 hackname = alpha_sbrk;
1020 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1022 c_fix_arg = "void *sbrk(";
1023 test_text = "extern char* sbrk(ptrdiff_t increment);";
1027 * For C++, avoid any typedef or macro definition of bool,
1028 * and use the built in type instead.
1029 * HP/UX 10.20 also has it in curses_colr/curses.h.
1032 hackname = avoid_bool_define;
1034 files = curses_colr/curses.h;
1038 select = "#[ \t]*define[ \t]+bool[ \t]";
1039 bypass = "__cplusplus";
1042 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1043 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1045 test_text = "# define bool\t char \n";
1052 hackname = avoid_bool_type;
1054 files = curses_colr/curses.h;
1058 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1059 bypass = "__cplusplus";
1062 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1064 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1068 * For C++, avoid any typedef definition of wchar_t,
1069 * and use the built in type instead.
1070 * Don't do this for headers that are smart enough to do the right
1071 * thing (recent
[n
]curses.h and Xlib.h
).
1072 * Don
't do it for <linux/nls.h> which is never used from C++ anyway,
1073 * and will be broken by the edit.
1077 hackname = avoid_wchar_t_type;
1079 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1080 bypass = "__cplusplus";
1081 bypass = "_LINUX_NLS_H";
1082 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1085 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1087 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1091 * Fix `typedef struct term;' on hppa1.1
-hp
-hpux9.
1094 hackname
= bad_struct_term
;
1096 select
= "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1098 c_fix_arg
= "struct term;";
1100 test_text
= 'typedef struct term;';
1104 * Fix one other error in this file
:
1105 * a mismatched quote not inside a C comment.
1108 hackname
= badquote
;
1109 files
= sundev
/vuid_event.h
;
1112 c_fix_arg
= "does not";
1114 test_text
= "/* doesn't have matched single quotes */";
1118 * check for broken assert.h that needs stdio.h
1121 hackname
= broken_assert_stdio
;
1124 bypass
= "include.*stdio\\.h";
1126 c_fix_arg
= "#include <stdio.h>\n";
1127 test_text
= "extern FILE* stderr;";
1131 * check for broken assert.h that needs stdlib.h
1134 hackname
= broken_assert_stdlib
;
1136 select
= 'exit *\(|abort *\(';
1137 bypass
= "include.*stdlib\\.h";
1139 c_fix_arg
= "#ifdef __cplusplus\n"
1140 "#include <stdlib.h>\n"
1142 test_text
= "extern void exit ( int );";
1146 * Remove `extern double cabs
' declarations from math.h.
1147 * This conflicts with C99. Discovered on AIX.
1148 * Darwin hides its broken cabs in architecture-specific subdirs.
1151 hackname = broken_cabs;
1152 files = math.h, "architecture/*/math.h";
1153 select = "^extern[ \t]+double[ \t]+cabs";
1155 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1156 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1158 test_text = "#ifdef __STDC__\n"
1159 "extern double cabs(struct dbl_hypot);\n"
1161 "extern double cabs();\n"
1163 "extern double cabs ( _Complex z );";
1167 * Fixup Darwin's broken check for __builtin_nanf.
1170 hackname
= broken_nan
;
1172 * It is tempting to omit the first
"files" entry. Do not.
1173 * The testing machinery will take the first
"files" entry as the name
1174 * of a test file to play with. It would be a nuisance to have a directory
1175 * with the name
"*".
1177 files
= "architecture/ppc/math.h";
1178 files
= "architecture/*/math.h";
1179 select
= '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1182 c_fix_arg
= "#if 1";
1183 test_text
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1187 * Various systems derived from BSD4.4 contain a macro definition
1188 * for vfscanf that interacts badly with requirements of builtin
-attrs.def.
1189 * Known to be fixed in FreeBSD
5 system headers.
1192 hackname
= bsd_stdio_attrs_conflict
;
1194 mach
= "*-*-*darwin*";
1196 select
= "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1198 c_fix_arg
= '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1199 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1200 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1201 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1202 test_text
= '#define vfscanf __svfscanf';
1206 * Fix various macros used to define ioctl numbers.
1207 * The traditional syntax was
:
1209 * #define
_CTRL(n
, x
) (('n'<<8)+x
)
1210 * #define TCTRLCFOO
_CTRL(T
, 1)
1212 * but this does not work with the C standard
, which disallows macro
1213 * expansion inside strings. We have to rewrite it thus
:
1215 * #define
_CTRL(n
, x
) ((n
<<8)+x
)
1216 * #define TCTRLCFOO
_CTRL('T', 1)
1218 * The select expressions match too much
, but the c_fix code is cautious.
1220 * CTRL might be
: CTRL _CTRL ISCTRL BSD43_CTRL ...
1223 hackname
= ctrl_quotes_def
;
1224 select
= "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1225 c_fix
= char_macro_def
;
1229 * This is two tests in order to ensure that the
"CTRL(c)" can
1230 * be selected in isolation from the multi
-arg format
1232 test_text
= "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1233 test_text
= "#define _CTRL(c) ('c'&037)";
1237 * Fix various macros used to define ioctl numbers.
1240 hackname
= ctrl_quotes_use
;
1241 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1242 c_fix
= char_macro_use
;
1244 test_text
= "#define TCTRLFOO BSD43_CTRL(T, 1)";
1248 * sys
/mman.h on HP
/UX is not C
++ ready
,
1249 * even though NO_IMPLICIT_EXTERN_C is defined on HP
/UX.
1251 * rpc
/types.h on OSF1
/2.0 is not C
++ ready
,
1252 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1254 * The problem is the declaration of malloc.
1257 hackname
= cxx_unready
;
1259 files
= rpc
/types.h
;
1260 select
= '[^#]+malloc.*;'; /* Catch any form of declaration
1261 not within a macro.
*/
1262 bypass
= '"C"|__BEGIN_DECLS';
1265 c_fix_arg
= "#ifdef __cplusplus\n"
1268 c_fix_arg
= "#ifdef __cplusplus\n"
1271 test_text
= "extern void* malloc( size_t );";
1275 * macOS
10.12 <AvailabilityInternal.h
> uses
__attribute__((availability
))
1279 hackname
= darwin_availabilityinternal
;
1280 mach
= "*-*-darwin*";
1281 files
= AvailabilityInternal.h
;
1282 select
= "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1284 c_fix_arg
= <<- _EOFix_
1285 #if
defined(__has_attribute
)
1286 #if
__has_attribute(availability
)
1296 test_text
= "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1297 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1301 * For the AAB_darwin7_9_long_double_funcs fix to be useful
,
1302 * you have to not use
"" includes.
1305 hackname
= darwin_9_long_double_funcs_2
;
1306 mach
= "*-*-darwin7.9*";
1308 select
= '#include[ \t]+\"';
1310 c_fix_arg
= "%1<%2.h>";
1312 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1314 test_text
= '#include "architecture/ppc/math.h"';
1318 * On darwin8 and earlier
, mach
-o
/swap.h isn
't properly guarded
1319 * by 'extern
"C"'. On darwin7 some mach/ headers aren't properly guarded.
1322 hackname
= darwin_externc
;
1323 mach
= "*-*-darwin*";
1324 files
= mach
-o
/swap.h
;
1325 files
= mach
/mach_time.h
;
1326 files
= mach
/mach_traps.h
;
1327 files
= mach
/message.h
;
1329 files
= mach
/semaphore.h
;
1330 bypass
= "extern \"C\"";
1331 bypass
= "__BEGIN_DECLS";
1333 c_fix_arg
= "#ifdef __cplusplus\n"
1336 c_fix_arg
= "#ifdef __cplusplus\n"
1339 test_text
= "extern void swap_fat_header();\n";
1343 * AvailabilityMacros.h on Darwin breaks with GCC
4.0, because of
1344 * bad __GNUC__ tests.
1347 hackname
= darwin_gcc4_breakage
;
1348 mach
= "*-*-darwin*";
1349 files
= AvailabilityMacros.h
;
1350 select
= "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1352 c_fix_arg
= "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1353 test_text
= "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1354 "(__GNUC_MINOR__ >= 1)\n";
1358 * Before Mac OS X
10.8 <i386
/setjmp.h
> doesn
't mark longjump noreturn.
1361 hackname = darwin_longjmp_noreturn;
1362 mach = "*-*-darwin*";
1363 files = "i386/setjmp.h";
1365 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1367 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1369 test_text = "void siglongjmp(sigjmp_buf, int);";
1373 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1376 hackname = darwin_os_trace_1;
1377 mach = "*-*-darwin*";
1379 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1382 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1386 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1387 * extension without guard.
1390 hackname = darwin_os_trace_2;
1391 mach = "*-*-darwin*";
1393 select = "typedef.*\\^os_trace_payload_t.*";
1395 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1396 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1400 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1401 * os_trace_payload_t typedef, too.
1404 hackname = darwin_os_trace_3;
1405 mach = "*-*-darwin*";
1407 select = <<- _EOSelect_
1411 _os_trace.*os_trace_payload_t payload);
1414 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1415 test_text = <<- _EOText_
1416 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1417 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1419 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1421 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1422 OS_EXPORT OS_NOTHROW
1424 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1429 * __private_extern__ doesn't exist in FSF GCC. Even if it did
,
1430 * why would you ever put it in a system header file?
1433 hackname
= darwin_private_extern
;
1434 mach
= "*-*-darwin*";
1435 files
= mach
-o
/dyld.h
;
1436 select
= "__private_extern__ [a-z_]+ _dyld_";
1438 c_fix_arg
= "extern";
1439 c_fix_arg
= "__private_extern__";
1440 test_text
= "__private_extern__ int _dyld_func_lookup(\n"
1441 "const char *dyld_func_name,\n"
1442 "unsigned long *address);\n";
1446 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1447 * unsigned constants.
1450 hackname
= darwin_stdint_1
;
1451 mach
= "*-*-darwin*";
1452 files
= stdint
-darwin.h
, stdint.h
;
1454 c_fix_arg
= "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1455 select
= "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1456 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1457 test_text
= "#define UINT8_C(v) (v ## U)\n"
1458 "#define UINT16_C(v) (v ## U)";
1462 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1466 hackname
= darwin_stdint_2
;
1467 mach
= "*-*-darwin*";
1468 files
= stdint
-darwin.h
, stdint.h
;
1470 c_fix_arg
= "#if __WORDSIZE == 64\n"
1471 "#define INTPTR_MAX 9223372036854775807L\n"
1472 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1474 "#define INTPTR_MAX 2147483647L\n"
1475 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1477 select
= "#if __WORDSIZE == 64\n"
1478 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1479 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1481 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1482 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1484 test_text
= "#if __WORDSIZE == 64\n"
1485 "#define INTPTR_MIN INT64_MIN\n"
1486 "#define INTPTR_MAX INT64_MAX\n"
1488 "#define INTPTR_MIN INT32_MIN\n"
1489 "#define INTPTR_MAX INT32_MAX\n"
1494 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1497 hackname
= darwin_stdint_3
;
1498 mach
= "*-*-darwin*";
1499 files
= stdint
-darwin.h
, stdint.h
;
1501 c_fix_arg
= "#if __WORDSIZE == 64\n"
1502 "#define UINTPTR_MAX 18446744073709551615UL\n"
1504 "#define UINTPTR_MAX 4294967295UL\n"
1506 select
= "#if __WORDSIZE == 64\n"
1507 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1509 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1511 test_text
= "#if __WORDSIZE == 64\n"
1512 "#define UINTPTR_MAX UINT64_MAX\n"
1514 "#define UINTPTR_MAX UINT32_MAX\n"
1519 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1522 hackname
= darwin_stdint_4
;
1523 mach
= "*-*-darwin*";
1524 files
= stdint
-darwin.h
, stdint.h
;
1526 c_fix_arg
= "#if __WORDSIZE == 64\n"
1527 "#define SIZE_MAX 18446744073709551615UL\n"
1529 "#define SIZE_MAX 4294967295UL\n"
1531 select
= "#if __WORDSIZE == 64\n"
1532 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1534 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1536 test_text
= "#if __WORDSIZE == 64\n"
1537 "#define SIZE_MAX UINT64_MAX\n"
1539 "#define SIZE_MAX UINT32_MAX\n"
1544 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_
{MIN,MAX}
1545 * with a wrong type.
1548 hackname
= darwin_stdint_5
;
1549 mach
= "*-*-darwin*";
1550 files
= stdint
-darwin.h
, stdint.h
;
1552 c_fix_arg
= "#if __WORDSIZE == 64\n"
1553 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1554 "#define INTMAX_MAX 9223372036854775807L\n"
1555 "#define UINTMAX_MAX 18446744073709551615UL\n"
1557 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1558 "#define INTMAX_MAX 9223372036854775807LL\n"
1559 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1561 select
= "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1562 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1564 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1565 test_text
= "#define INTMAX_MIN INT64_MIN\n"
1566 "#define INTMAX_MAX INT64_MAX\n"
1568 "#define UINTMAX_MAX UINT64_MAX";
1572 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_C
1573 * with a wrong type.
1576 hackname
= darwin_stdint_6
;
1577 mach
= "*-*-darwin*";
1578 files
= stdint
-darwin.h
, stdint.h
;
1580 c_fix_arg
= "#if __WORDSIZE == 64\n"
1581 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1582 "#define PTRDIFF_MAX 9223372036854775807L\n"
1584 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1585 "#define PTRDIFF_MAX 2147483647\n"
1587 select
= "#if __WORDSIZE == 64\n"
1588 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1589 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1591 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1592 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1594 test_text
= "#if __WORDSIZE == 64\n"
1595 "#define PTRDIFF_MIN INT64_MIN\n"
1596 "#define PTRDIFF_MAX INT64_MAX\n"
1598 "#define PTRDIFF_MIN INT32_MIN\n"
1599 "#define PTRDIFF_MAX INT32_MAX\n"
1604 * Darwin headers have a stdint.h that defines
{U
,}INTMAX_C
1605 * with a wrong type.
1608 hackname
= darwin_stdint_7
;
1609 mach
= "*-*-darwin*";
1610 files
= stdint
-darwin.h
, stdint.h
;
1612 c_fix_arg
= "#if __WORDSIZE == 64\n"
1613 "#define INTMAX_C(v) (v ## L)\n"
1614 "#define UINTMAX_C(v) (v ## UL)\n"
1616 "#define INTMAX_C(v) (v ## LL)\n"
1617 "#define UINTMAX_C(v) (v ## ULL)\n"
1619 select
= "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1620 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1621 test_text
= "#define INTMAX_C(v) (v ## LL)\n"
1622 "#define UINTMAX_C(v) (v ## ULL)";
1626 * Fix
<c_asm.h
> on Digital UNIX V4.0
:
1627 * It contains a prototype for a
DEC C internal
asm() function
,
1628 * clashing with gcc
's asm keyword. So protect this with __DECC.
1631 hackname = dec_intern_asm;
1633 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1634 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1638 " ... asm stuff ...\n"
1639 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1643 * Fix typo in <wchar.h> on DJGPP 2.03.
1646 hackname = djgpp_wchar_h;
1648 select = "__DJ_wint_t";
1649 bypass = "sys/djtypes.h";
1651 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1652 c_fix_arg = "#include <stddef.h>";
1653 test_text = "#include <stddef.h>\n"
1654 "extern __DJ_wint_t x;\n";
1658 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1661 hackname = ecd_cursor;
1662 files = "sunwindow/win_lock.h";
1663 files = "sunwindow/win_cursor.h";
1664 select = 'ecd\.cursor
';
1666 c_fix_arg = 'ecd_cursor
';
1668 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1672 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1673 * that fails when compiling for SSE-less 32-bit x86.
1676 hackname = feraiseexcept_nosse_divbyzero;
1677 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1678 files = bits/fenv.h, '*/bits
/fenv.h
';
1679 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1680 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1681 bypass = "\"fdivp .*; fwait\"";
1684 c_fix_arg = <<- _EOText_
1685 # ifdef __SSE_MATH__
1688 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1689 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1693 test_text = <<- _EOText_
1694 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1699 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1700 * that fails when compiling for SSE-less 32-bit x86.
1703 hackname = feraiseexcept_nosse_invalid;
1704 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1705 files = bits/fenv.h, '*/bits
/fenv.h
';
1706 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1707 ": \"x\" \\(__f\\)\\);$";
1708 bypass = "\"fdiv .*; fwait\"";
1711 c_fix_arg = <<- _EOText_
1712 # ifdef __SSE_MATH__
1715 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1716 %1 : "=t" (__f) : "0" (__f));
1720 test_text = <<- _EOText_
1721 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1726 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1727 * neither the existence of GCC 3 nor its exact feature set yet break
1728 * (by design?) when __GNUC__ is set beyond 2.
1731 hackname = freebsd_gcc3_breakage;
1732 mach = "*-*-freebsd*";
1733 files = sys/cdefs.h;
1734 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7$
';
1735 bypass = '__GNUC__
[ \t]*([>=]=[ \t]*[3-9]|
>[ \t]*2)';
1737 c_fix_arg = '%0 || __GNUC__
>= 3';
1738 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7';
1742 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1743 * neither the existence of GCC 4 nor its exact feature set yet break
1744 * (by design?) when __GNUC__ is set beyond 3.
1747 hackname = freebsd_gcc4_breakage;
1748 mach = "*-*-freebsd*";
1749 files = sys/cdefs.h;
1750 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 \|\| __GNUC__
== 3$
';
1752 c_fix_arg = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
>= 3';
1753 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
== 3';
1757 * Some versions of glibc don't expect the C99 inline semantics.
1760 hackname
= glibc_c99_inline_1
;
1761 files
= features.h
, '*/features.h';
1762 select
= "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1764 c_fix_arg
= "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1766 #if
__GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1767 && !defined __OPTIMIZE_SIZE__
&& !defined __NO_INLINE__
1768 # define __USE_EXTERN_INLINES
1
1774 * Similar
, but a version that didn
't have __NO_INLINE__
1777 hackname = glibc_c99_inline_1a;
1778 files = features.h, '*/features.h
';
1779 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1780 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1782 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1784 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1785 # define __USE_EXTERN_INLINES 1
1791 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1792 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1793 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1796 hackname = glibc_c99_inline_2;
1797 files = sys/stat.h, '*/sys
/stat.h
';
1798 select = "extern __inline__ int";
1799 sed = "s/extern int \\(stat\\)/"
1800 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1801 "__inline__ int \\1/";
1802 sed = "s/extern int \\([lf]stat\\)/"
1803 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1804 "__inline__ int \\1/";
1805 sed = "s/extern int \\(mknod\\)/"
1806 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1807 "__inline__ int \\1/";
1808 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1809 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1810 "__inline__ int __REDIRECT\\1 (\\2/";
1811 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1812 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1813 "__inline__ int __REDIRECT\\1 (\\2/";
1814 sed = "s/^extern __inline__ int/"
1815 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1818 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1819 extern __inline__ int
1820 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1826 * glibc_c99_inline_3
1829 hackname = glibc_c99_inline_3;
1830 files = bits/string2.h, '*/bits
/string2.h
';
1831 select = "extern __inline";
1832 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1834 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1835 c_fix_arg = "^# ifdef __cplusplus$";
1838 # define __STRING_INLINE inline
1840 # define __STRING_INLINE extern __inline
1846 * glibc_c99_inline_4
1849 hackname = glibc_c99_inline_4;
1850 files = sys/sysmacros.h, '*/sys
/sysmacros.h
', wchar.h, '*/wchar.h
',
1851 pthread.h, '*/pthread.h
';
1852 bypass = "__extern_inline|__gnu_inline__";
1853 select = "(^| )extern __inline";
1855 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1857 __extension__ extern __inline unsigned int
1858 extern __inline unsigned int
1862 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1863 * so we replace them with versions that correspond to the
1867 hackname = glibc_mutex_init;
1869 select = '\
{ *\
{ *0, *\
} *\
}';
1870 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1871 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1872 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1873 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1874 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1875 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1876 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1877 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1878 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1879 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1880 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1881 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1882 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1883 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1884 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1885 "N;s/^[ \t]*#[ \t]*"
1886 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1887 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1889 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1892 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1894 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
1895 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1896 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1897 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1899 test_text = <<- _EOText_
1900 #define PTHREAD_MUTEX_INITIALIZER \\
1903 # if __WORDSIZE == 64
1904 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1905 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1906 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1907 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1908 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1909 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1911 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1912 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1913 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1914 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1915 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1916 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1919 # define PTHREAD_RWLOCK_INITIALIZER \\
1922 # if __WORDSIZE == 64
1923 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1924 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1925 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1927 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1928 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1931 #define PTHREAD_COND_INITIALIZER { { 0, } }
1935 /* glibc versions before 2.5 have a version of stdint.h that defines
1936 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1937 versions with stdint.h based on those glibc versions. */
1939 hackname = glibc_stdint;
1941 select = "GNU C Library";
1943 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1944 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1945 test_text = "/* This file is part of the GNU C Library. */\n"
1946 "# define UINT8_C(c)\tc ## U\n"
1947 "# define UINT16_C(c)\tc ## U";
1950 /* Some versions of glibc have a version of bits/string2.h that
1951 produces "value computed is not used" warnings from strncpy; fix
1952 this definition by using __builtin_strncpy instead as in newer
1955 hackname = glibc_strncpy;
1956 files = bits/string2.h, '*/bits
/string2.h
';
1957 bypass = "__builtin_strncpy";
1959 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1960 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1962 # define strncpy(dest, src, n) \
1963 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
1964 ? (strlen (src) + 1 >= ((size_t) (n)) \\
1965 ? (char *) memcpy (dest, src, n) \\
1966 : strncpy (dest, src, n)) \\
1967 : strncpy (dest, src, n)))
1972 /* glibc's tgmath.h relies on an expression that is not an integer
1973 constant expression being treated as it was by GCC
4.4 and
1976 hackname
= glibc_tgmath
;
1978 select
= '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1979 bypass
= "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1981 c_fix_arg
= "(__builtin_classify_type ((type) 0) == 8 || "
1982 "(__builtin_classify_type ((type) 0) == 9 && "
1983 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1984 test_text
= "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1988 * Fix these files to use the types we think they should for
1989 * ptrdiff_t
, size_t
, and wchar_t.
1991 * This defines the types in terms of macros predefined by our
'cpp'.
1992 * This is supposedly necessary for glibc
's handling of these types.
1993 * It's probably not necessary for anyone else
, but it doesn
't hurt.
1996 hackname = gnu_types;
1997 files = "sys/types.h";
1999 files = "sys/stdtypes.h";
2003 bypass = '_GCC_(PTRDIFF|
SIZE|WCHAR
)_T
';
2004 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2006 /* The Solaris 10 headers already define these types correctly. */
2007 mach = '*-*-solaris2.1
[0-9]*';
2010 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2011 "typedef uint_t size_t; /* uint_t */\n"
2012 "typedef ushort_t wchar_t; /* ushort_t */";
2016 * Fix HP & Sony's use of
"../machine/xxx.h"
2017 * to refer to
: <machine
/xxx.h
>
2020 hackname
= hp_inline
;
2021 files
= sys
/spinlock.h
;
2022 files
= machine
/machparam.h
;
2023 select
= "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2026 c_fix_arg
= "%1<machine/%2.h>";
2028 c_fix_arg
= "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2031 test_text
= ' # include "../machine/mumble.h"';
2035 * Check
for (...
) in C
++ code in HP
/UX sys
/file.h.
2038 hackname
= hp_sysfile
;
2040 select
= "HPUX_SOURCE";
2043 c_fix_arg
= "(struct file *, ...)";
2044 c_fix_arg
= '\(\.\.\.\)';
2046 test_text
= "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2050 * Un
-Hide a series of five FP defines from post
-1999 compliance GCC
:
2051 * FP_NORMAL
, FP_ZERO
, FP_INFINITE
, FP_SUBNORMAL and FP_NAN
2054 hackname
= hppa_hpux_fp_macros
;
2055 mach
= "hppa*-hp-hpux11*";
2057 select
= "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2058 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2059 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2060 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2061 "#[ \t]*define[ \t]*FP_NAN.*\n";
2063 c_fix_arg
= <<- _EOFix_
2064 #endif
/* _INCLUDE_HPUX_SOURCE
*/
2066 #if
defined(_INCLUDE_HPUX_SOURCE
) || \
2067 (defined(__STDC_VERSION__
) && (__STDC_VERSION__
>= 199901L))
2070 #ifdef _INCLUDE_HPUX_SOURCE
2075 "# define FP_NORMAL 0\n"
2076 "# define FP_ZERO 1\n"
2077 "# define FP_INFINITE 2\n"
2078 "# define FP_SUBNORMAL 3\n"
2079 "# define FP_NAN 4\n";
2083 * Delete C
++ double
pow (double
, int
) inline function from HP
-UX
10 & 11
2084 * math.h to prevent clash with define in c_std
/bits
/std_cmath.h.
2087 hackname
= hpux10_cpp_pow_inline
;
2088 files
= fixinc
-test
-limits.h
, math.h
;
2089 select
= <<- END_POW_INLINE
2090 ^#
+ifdef
+__cplusplus
2092 +inline
+double
+pow\
(double
+__d
,int
+__expon\
) +\
{
2093 [ ]+return
+pow\
(__d
,\
(double\
)__expon\
);
2104 "# ifdef __cplusplus\n"
2106 " inline double pow(double __d,int __expon) {\n"
2107 "\t return pow(__d,(double)__expon);\n"
2109 ' extern "C"' " {\n"
2115 hackname
= hpux11_cpp_pow_inline
;
2117 select
= " +inline double pow\\(double d,int expon\\) \\{\n"
2118 " +return pow\\(d, \\(double\\)expon\\);\n"
2124 " inline double pow(double d,int expon) {\n"
2125 " return pow(d, (double)expon);\n"
2130 * Fix hpux
10.X missing ctype declarations
1
2133 hackname
= hpux10_ctype_declarations1
;
2135 select
= "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2136 bypass
= "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2138 c_fix_arg
= "#ifdef _PROTOTYPES\n"
2139 "extern int __tolower(int);\n"
2140 "extern int __toupper(int);\n"
2141 "#else /* NOT _PROTOTYPES */\n"
2142 "extern int __tolower();\n"
2143 "extern int __toupper();\n"
2144 "#endif /* _PROTOTYPES */\n\n"
2147 test_text
= "# define _toupper(__c) __toupper(__c)\n";
2151 * Fix hpux
10.X missing ctype declarations
2
2154 hackname
= hpux10_ctype_declarations2
;
2156 select
= "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2157 bypass
= "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2159 c_fix_arg
= "%0\n\n"
2160 "#ifdef _PROTOTYPES\n"
2161 " extern int _isalnum(int);\n"
2162 " extern int _isalpha(int);\n"
2163 " extern int _iscntrl(int);\n"
2164 " extern int _isdigit(int);\n"
2165 " extern int _isgraph(int);\n"
2166 " extern int _islower(int);\n"
2167 " extern int _isprint(int);\n"
2168 " extern int _ispunct(int);\n"
2169 " extern int _isspace(int);\n"
2170 " extern int _isupper(int);\n"
2171 " extern int _isxdigit(int);\n"
2172 "# else /* not _PROTOTYPES */\n"
2173 " extern int _isalnum();\n"
2174 " extern int _isalpha();\n"
2175 " extern int _iscntrl();\n"
2176 " extern int _isdigit();\n"
2177 " extern int _isgraph();\n"
2178 " extern int _islower();\n"
2179 " extern int _isprint();\n"
2180 " extern int _ispunct();\n"
2181 " extern int _isspace();\n"
2182 " extern int _isupper();\n"
2183 " extern int _isxdigit();\n"
2184 "#endif /* _PROTOTYPES */\n";
2186 test_text
= "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2187 " extern unsigned int *__SB_masks;\n";
2191 * Fix hpux
10.X missing stdio declarations
2194 hackname
= hpux10_stdio_declarations
;
2196 select
= "^#[ \t]*define _iob[ \t]*__iob";
2197 bypass
= "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2199 c_fix_arg
= "%0\n\n"
2200 "# if defined(__STDC__) || defined(__cplusplus)\n"
2201 " extern int snprintf(char *, size_t, const char *, ...);\n"
2202 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2203 "# else /* not __STDC__) || __cplusplus */\n"
2204 " extern int snprintf();\n"
2205 " extern int vsnprintf();\n"
2206 "# endif /* __STDC__) || __cplusplus */\n";
2208 test_text
= "# define _iob __iob\n";
2212 * The HP
-UX stddef.h is replaced by gcc
's. It doesn't include sys
/stdsyms.h.
2213 * As a result
, we need to include sys
/stdsyms.h in alloca.h.
2216 hackname
= hppa_hpux11_alloca
;
2217 mach
= "hppa*-*-hpux11*";
2219 select
= "#ifndef _STDDEF_INCLUDED";
2221 c_fix_arg
= "#ifndef _SYS_STDSYMS_INCLUDED\n"
2222 "# include <sys/stdsyms.h>\n"
2223 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2226 test_text
= "#ifndef _STDDEF_INCLUDED";
2230 * Make sure hpux defines abs in header.
2233 hackname
= hpux11_abs
;
2234 mach
= "*-hp-hpux11*";
2236 select
= "ifndef _MATH_INCLUDED";
2238 c_fix_arg
= "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2239 test_text
= "#ifndef _MATH_INCLUDED";
2243 * Fix hpux11 __LWP_RWLOCK_VALID define
2246 hackname
= hpux11_lwp_rwlock_valid
;
2247 mach
= "*-hp-hpux11*";
2248 files
= sys
/pthread.h
;
2249 select
= "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2251 c_fix_arg
= "#define __LWP_RWLOCK_VALID -29551";
2252 test_text
= "#define __LWP_RWLOCK_VALID 0x8c91";
2259 hackname
= hpux11_extern_sendfile
;
2260 mach
= "*-hp-hpux11.[12]*";
2261 files
= sys
/socket.h
;
2262 select
= "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2264 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2265 test_text
= " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2266 " const struct iovec *, int));\n";
2273 hackname
= hpux11_extern_sendpath
;
2274 mach
= "*-hp-hpux11.[12]*";
2275 files
= sys
/socket.h
;
2276 select
= "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2278 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2279 test_text
= " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2280 " const struct iovec *, int));\n";
2284 * Keep HP
-UX
11 from stomping on C
++ math namespace
2285 * with defines for fabsf.
2288 hackname
= hpux11_fabsf
;
2289 mach
= "*-hp-hpux11*";
2291 select
= "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2294 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
2298 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2303 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2304 * in pthread.h need to be constant expressions to be standard complient.
2305 * As a result
, we need to remove the void
* casts in the initializers
2306 * (see hpux11_pthread_const
) and to change the
__(M|C|RW
)POINTER defines
2307 * to use the long type.
2310 hackname
= hpux11_pthread_pointer
;
2311 mach
= "*-hp-hpux11.[0-3]*";
2312 files
= sys
/pthread.h
;
2313 select
= "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2316 c_fix_arg
= "long\t%2%3";
2317 test_text
= "#define __MPOINTER\t\tvoid\t *m_ptr";
2321 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2324 hackname
= hpux11_pthread_const
;
2325 mach
= "*-hp-hpux11.[0-3]*";
2326 files
= sys
/pthread.h
;
2327 select
= "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2331 test_text
= "#define __POINTER_SET\t\t((void *) 1LL)";
2335 * Prevent HP
-UX
11 from defining __size_t and preventing size_t from
2336 * being defined by having it define _hpux_size_t instead.
2339 hackname
= hpux11_size_t
;
2340 mach
= "*-hp-hpux11*";
2341 select
= "__size_t";
2344 c_fix_arg
= "_hpux_size_t";
2347 "#define __size_t size_t\n"
2348 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2352 * Fix hpux
11.00 broken snprintf declaration
2353 * (third argument is char
*, needs to be const char
* to prevent
2354 * spurious warnings with
-Wwrite
-strings or in C
++).
2357 hackname
= hpux11_snprintf
;
2359 select
= '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2360 ' *(char *\*, *\.\.\.\);)';
2362 c_fix_arg
= '%1 const %3';
2364 test_text
= "extern int snprintf(char *, size_t, char *, ...);\n"
2365 "extern int snprintf(char *, __size_t, char *, ...);\n"
2366 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2370 * Fix hpux
11.00 broken vsnprintf declaration
2373 hackname
= hpux11_vsnprintf
;
2375 select
= '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2376 'const char \*,) __va__list\);';
2378 c_fix_arg
= "%1 __va_list);";
2380 test_text
= 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2385 * Fix missing const in hpux vsscanf declaration
2388 hackname
= hpux_vsscanf
;
2391 select
= '(extern int vsscanf\()char';
2393 c_fix_arg
= "%1const char";
2395 test_text
= 'extern int vsscanf(char *, const char *, __va_list);';
2399 * get rid of bogus inline definitions in HP
-UX
8.0
2402 hackname
= hpux8_bogus_inlines
;
2405 bypass
= "__GNUG__";
2406 sed
= "s@inline int abs(int [a-z][a-z]*) {.*}"
2407 "@extern \"C\" int abs(int);@";
2408 sed
= "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2409 sed
= "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2410 sed
= "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2411 test_text
= "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2412 "inline double sqr(double v) { return v**0.5; }";
2419 hackname
= hpux_c99_intptr
;
2420 mach
= "*-hp-hpux11.3*";
2421 files
= stdint
-hpux11.h
, stdint.h
;
2422 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2423 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2424 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2425 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2426 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2427 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2428 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2429 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2430 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2431 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2432 sed
= "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2433 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2434 test_text
= "#define PTRDIFF_MAX INT32_MAX\n"
2435 "#define PTRDIFF_MIN INT32_MIN\n"
2436 "#define INTPTR_MAX INT32_MAX\n"
2437 "#define INTPTR_MIN INT32_MIN\n"
2438 "#define UINTPTR_MAX UINT32_MAX\n"
2439 "#define SIZE_MAX UINT32_MAX\n";
2443 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2446 hackname
= hpux_c99_inttypes
;
2447 mach
= "*-hp-hpux11.[23]*";
2449 files
= stdint
-hpux11.h
, stdint.h
;
2450 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2451 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2452 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2453 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2454 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2455 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2456 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2457 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2458 test_text
= "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2459 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2460 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2461 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2465 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2468 hackname
= hpux_c99_inttypes2
;
2469 mach
= "*-hp-hpux11.2*";
2470 files
= stdint
-hpux11.h
, stdint.h
;
2471 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2472 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2473 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2474 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2475 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2476 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2477 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2478 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2479 test_text
= "# define INT8_C(__c) ((signed char)(__c))\n"
2480 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2481 "# define INT16_C(__c) ((short)(__c))\n"
2482 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2486 * Fix hpux broken ctype macros
2489 hackname
= hpux_ctype_macros
;
2491 select
= '((: |\()__SB_masks \? )'
2492 '(__SB_masks\[__(alnum|c)\] & _IS)';
2494 c_fix_arg
= "%1(int)%3";
2496 test_text
= ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2497 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2504 hackname
= hpux_extern_errno
;
2505 mach
= "*-hp-hpux10.*";
2506 mach
= "*-hp-hpux11.[0-2]*";
2508 select
= "^[ \t]*extern int errno;$";
2510 c_fix_arg
= "#ifdef __cplusplus\n"
2514 "#ifdef __cplusplus\n"
2517 test_text
= " extern int errno;\n";
2521 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2524 hackname
= hpux_htonl
;
2525 files
= netinet
/in.h
;
2526 select
= "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2528 " \\* Macros for number representation conversion\\.\n"
2532 c_fix_arg
= "#if 1\n%1";
2534 test_text
= "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2536 " * Macros for number representation conversion.\n"
2539 "#define ntohl(x) (x)\n"
2540 "#define ntohs(x) (x)\n"
2541 "#define htonl(x) (x)\n"
2542 "#define htons(x) (x)\n"
2544 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2548 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2551 hackname
= hpux_imaginary_i
;
2552 mach
= "ia64-hp-hpux11.*";
2554 select
= "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2556 c_fix_arg
= "#define _Complex_I (__extension__ 1.0iF)";
2557 test_text
= "#define _Complex_I (0.f+_Imaginary_I)\n";
2561 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2564 hackname
= hpux_inttype_int8_t
;
2565 mach
= "*-hp-hpux1[01].*";
2566 files
= sys
/_inttypes.h
;
2567 select
= "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2569 c_fix_arg
= "typedef signed char int%18_t;";
2570 test_text
= "typedef char int_least8_t;\n"
2571 "typedef char int8_t;\n";
2578 hackname
= hpux_long_double
;
2579 mach
= "*-*-hpux10*";
2580 mach
= "*-*-hpux11.[012]*";
2582 select
= "extern[ \t]long_double[ \t]strtold";
2583 bypass
= "long_double_t";
2584 sed
= "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2585 sed
= "s/long_double/long double/g";
2587 test_text
= "# ifndef _LONG_DOUBLE\n"
2588 "# define _LONG_DOUBLE\n"
2589 " typedef struct {\n"
2590 " unsigned int word1, word2, word3, word4;\n"
2592 "# endif /* _LONG_DOUBLE */\n"
2593 "extern long_double strtold(const char *, char **);\n";
2597 * We cannot use the above rule on
11.31 because it removes the strtold
2598 * definition. ia64 is OK with no hack
, PA needs some help.
2601 hackname
= hpux_long_double_2
;
2602 mach
= "hppa*-*-hpux11.3*";
2604 select
= "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2605 "defined\\(_PROTOTYPES\\) \\|\\| "
2606 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2608 c_fix_arg
= "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2610 test_text
= "# if !defined(__ia64) || "
2611 "!defined(_PROTOTYPES) || "
2612 "defined(_LONG_DOUBLE_STRUCT)\n";
2616 * Add missing braces to pthread initializer defines.
2619 hackname
= hpux_pthread_initializers
;
2620 mach
= "*-hp-hpux11.[0-3]*";
2621 files
= sys
/pthread.h
;
2622 sed
= "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2623 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2624 sed
= "s@^[ \t]*1,[ \t]*\\\\"
2626 sed
= "/^[ \t]*0$/d";
2627 sed
= "s@__PTHREAD_MUTEX_VALID, 0"
2628 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2629 sed
= "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2630 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2631 sed
= "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2632 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2633 sed
= "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2634 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2635 sed
= "s@^[ \t]*0, 0[ \t]*\\\\"
2636 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2637 sed
= "s@__PTHREAD_COND_VALID, 0"
2638 "@{ __PTHREAD_COND_VALID, 0 }@";
2639 sed
= "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2640 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2641 sed
= "s@__PTHREAD_RWLOCK_VALID, 0"
2642 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2643 sed
= "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2644 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2645 sed
= "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2646 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2647 test_text
= "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2648 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2649 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2650 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2651 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2652 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2653 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2658 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2659 * type and mpinfou is only defined when _KERNEL is set.
2662 hackname
= hpux_spu_info
;
2663 mach
= "*-hp-hpux*";
2665 * It is tempting to omit the first
"files" entry. Do not.
2666 * The testing machinery will take the first
"files" entry as the name
2667 * of a test file to play with. It would be a nuisance to have a directory
2668 * with the name
"*".
2670 files
= "ia64/sys/getppdp.h";
2671 files
= "*/sys/getppdp.h";
2672 select
= "^.*extern.*spu_info.*";
2675 c_fix_arg
= "#ifdef _KERNEL\n%0\n#endif";
2677 test_text
= "extern union mpinfou spu_info[];";
2681 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2684 hackname
= hpux_stdint_least_fast
;
2685 mach
= "*-hp-hpux11.2*";
2686 files
= stdint
-hpux11.h
, stdint.h
;
2688 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2690 c
-fix
-arg
= "# define UINT_%164_MAX __UINT64_MAX__";
2691 test
-text
= "# define UINT_FAST64_MAX ULLONG_MAX\n"
2692 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2696 * Add noreturn attribute to longjmp declarations in hpux
<setjmp.h
>
2699 hackname
= hpux_longjmp
;
2700 mach
= "*-hp-hpux*";
2702 select
= "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2705 c_fix_arg
= "%0 __attribute__ ((__noreturn__))";
2707 test_text
= 'extern void longjmp __((jmp_buf, int));';
2711 * Fix hpux10.20
<sys
/time.h
> to avoid invalid forward decl
2714 hackname
= hpux_systime
;
2716 select
= "^extern struct sigevent;";
2719 c_fix_arg
= "struct sigevent;";
2721 test_text
= 'extern struct sigevent;';
2725 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2728 hackname
= huge_val_hex
;
2729 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2730 select
= "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2731 bypass
= "__builtin_huge_val";
2734 c_fix_arg
= "#define HUGE_VAL (__builtin_huge_val())\n";
2736 test_text
= "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2740 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2743 hackname
= huge_valf_hex
;
2744 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2745 select
= "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2746 bypass
= "__builtin_huge_valf";
2749 c_fix_arg
= "#define HUGE_VALF (__builtin_huge_valf())\n";
2751 test_text
= "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2755 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2758 hackname
= huge_vall_hex
;
2759 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2760 select
= "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2761 bypass
= "__builtin_huge_vall";
2764 c_fix_arg
= "#define HUGE_VALL (__builtin_huge_vall())\n";
2766 test_text
= "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2770 * Fix return type of abort and free
2773 hackname
= int_abort_free_and_exit
;
2775 select
= "int[ \t]+(abort|free|exit)[ \t]*\\(";
2776 bypass
= "_CLASSIC_ANSI_TYPES";
2779 c_fix_arg
= "void\t%1(";
2781 test_text
= "extern int abort(int);\n"
2782 "extern int free(void*);\n"
2783 "extern int exit(void*);";
2787 * Fix various macros used to define ioctl numbers.
2788 * The traditional syntax was
:
2790 * #define
_IO(n
, x
) (('n'<<8)+x
)
2791 * #define TIOCFOO
_IO(T
, 1)
2793 * but this does not work with the C standard
, which disallows macro
2794 * expansion inside strings. We have to rewrite it thus
:
2796 * #define
_IO(n
, x
) ((n
<<8)+x
)
2797 * #define TIOCFOO
_IO('T', 1)
2799 * The select expressions match too much
, but the c_fix code is cautious.
2801 * _IO might be
: _IO DESIO BSD43__IO with W
, R
, WR
, C
, ... suffixes.
2804 hackname
= io_quotes_def
;
2805 select
= "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2806 c_fix
= char_macro_def
;
2809 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2810 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2811 "#define _IO(x,y) ('x'<<8|y)";
2813 "#define XX_IO(x) ('x'<<8|256)";
2817 * Fix the usage of the ioctl macro numbers.
2820 hackname
= io_quotes_use
;
2821 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2823 c_fix
= char_macro_use
;
2825 test_text
= "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2826 "#define TIOCFOO \\\\\n"
2827 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2831 * Check for missing
';' in struct
2834 hackname
= ip_missing_semi
;
2835 files
= netinet
/ip.h
;
2837 sed
= "/^struct/,/^};/s/}$/};/";
2843 "}; /* mumbled struct */\n";
2847 * Non
-traditional
"const" declaration in Irix
's limits.h.
2850 hackname = irix_limits_const;
2851 files = fixinc-test-limits.h, limits.h;
2852 select = "^extern const ";
2854 c_fix_arg = "extern __const ";
2855 test_text = "extern const char limit; /* test limits */";
2859 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2860 * taking char
*. However
, GCC uses void
* for va_list
, so
2861 * calling vfprintf with a va_list fails in C
++.
*/
2863 hackname
= irix_stdio_va_list
;
2866 select
= '/\* va_list \*/ char \*';
2868 c_fix_arg
= "__gnuc_va_list";
2870 "extern int printf( const char *, /* va_list */ char * );";
2874 * These files in Sun OS
4.x and ARM
/RISCiX and BSD4.3
2875 * use
/ * * / to concatenate tokens.
2878 hackname
= kandr_concat
;
2879 files
= "sparc/asm_linkage.h";
2880 files
= "sun*/asm_linkage.h";
2881 files
= "arm/as_support.h";
2882 files
= "arm/mc_type.h";
2883 files
= "arm/xcb.h";
2884 files
= "dev/chardefmac.h";
2885 files
= "dev/ps_irq.h";
2886 files
= "dev/screen.h";
2887 files
= "dev/scsi.h";
2888 files
= "sys/tty.h";
2889 files
= "Xm.acorn/XmP.h";
2890 files
= bsd43
/bsd43_.h
;
2894 test_text
= "#define __CONCAT__(a,b) a/**/b";
2898 * The
/usr
/include
/sys
/ucontext.h on ia64
-*linux
-gnu systems defines
2899 * an _SC_GR0_OFFSET macro using an idiom that isn
't a compile time
2900 * constant on recent versions of g++.
2903 hackname = linux_ia64_ucontext;
2904 files = "sys/ucontext.h";
2905 mach = "ia64-*-linux*";
2906 select = '\
(\
(\
(char \
*\
) &\
(\
(struct sigcontext \
*\
) 0\
)'
2907 '->sc_gr\
[0\
]\
) - \
(char \
*\
) 0\
)';
2909 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2910 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2911 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2915 * Remove header file warning from sys/time.h. Autoconf's
2916 * AC_HEADER_TIME recommends to include both sys
/time.h and time.h
2917 * which causes warning on LynxOS. Remove the warning.
2920 hackname
= lynxos_no_warning_in_sys_time_h
;
2922 select
= "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2925 test_text
= "#warning Using <time.h> instead of <sys/time.h>";
2929 * Add missing declaration for putenv.
2932 hackname
= lynxos_missing_putenv
;
2933 mach
= '*-*-lynxos*';
2935 bypass
= 'putenv[ \t]*\\(';
2936 select
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2939 "extern int putenv _AP((char *));";
2940 c_fix_arg
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2941 test_text
= "extern char *getenv _AP((const char *));";
2945 * Fix BSD machine
/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2947 * On NetBSD
, machine is a symbolic link to an architecture specific
2948 * directory name
, so we can
't match a specific file name here.
2951 hackname = machine_ansi_h_va_list;
2952 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
2953 bypass = '__builtin_va_list
';
2956 c_fix_arg = "%1__builtin_va_list";
2957 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2959 test_text = " # define _BSD_VA_LIST_\tchar**";
2963 * Fix non-ansi machine name defines
2966 hackname = machine_name;
2967 c_test = machine_name;
2968 c_fix = machine_name;
2970 test_text = "/* MACH_DIFF: */\n"
2971 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2972 "\n/* no uniform test, so be careful :-) */";
2976 * Some math.h files define struct exception (it's in the System V
2977 * Interface Definition
), which conflicts with the class exception defined
2978 * in the C
++ file std
/stdexcept.h. We redefine it to __math_exception.
2979 * This is not a great fix
, but I haven
't been able to think of anything
2983 hackname = math_exception;
2985 select = "struct exception";
2987 * This should be bypassed on __cplusplus, but some supposedly C++
2988 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2989 * exception either. So currently we bypass only for glibc
, based on a
2990 * comment in the fixed glibc header. Ick.
2992 bypass
= 'We have a problem when using C\+\+|for C\+\+, '
2993 '_[a-z0-9A-Z_]+_exception; for C, exception';
2994 /* The Solaris
10 headers already get this right.
*/
2995 mach
= '*-*-solaris2.1[0-9]*';
2999 c_fix_arg
= "#ifdef __cplusplus\n"
3000 "#define exception __math_exception\n"
3003 c_fix_arg
= "#ifdef __cplusplus\n"
3004 "#undef exception\n"
3007 test_text
= "typedef struct exception t_math_exception;";
3011 * This looks pretty broken to me. ``dbl_max_def
'' will contain
3012 * "define DBL_MAX " at the start
, when what we really want is just
3013 * the value portion. Can
't figure out how to write a test case
3014 * for this either :-(
3017 hackname = math_huge_val_from_dbl_max;
3021 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3022 * in math.h, this fix applies.
3024 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3025 bypass = "define[ \t]+DBL_MAX";
3029 * See if we have a definition for DBL_MAX in float.h.
3030 * If we do, we will replace the one in math.h with that one.
3033 "\tdbl_max_def=`egrep 'define
[ \t]+DBL_MAX
[ \t]+.
*' float.h "
3034 "| sed 's
/.
*DBL_MAX
[ \t]*//' 2>/dev/null`\n\n"
3036 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3037 "\tthen sed -e '/define
[ \t]*HUGE_VAL
[ \t]*DBL_MAX
/"
3038 "s@DBL_MAX@
'\"$dbl_max_def@\"\n"
3043 "`echo '#define DBL_MAX
\t3.1415e+9 /* really big
*/' >> float.h`\n"
3044 "#define HUGE_VAL DBL_MAX";
3051 hackname = nested_auth_des;
3053 select = '(/\
*.
*rpc
/auth_des\.h
>.*)
/\
*';
3055 c_fix_arg = "%1*/ /*";
3056 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3060 * Some versions of NetBSD don't expect the C99 inline semantics.
3063 hackname
= netbsd_c99_inline_1
;
3064 mach
= "*-*-netbsd*";
3066 select
= "extern __inline int";
3069 c_fix_arg
= "extern\n"
3070 "#ifdef __GNUC_STDC_INLINE__\n"
3071 "__attribute__((__gnu_inline__))\n"
3075 test_text
= "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3079 * netbsd_c99_inline_2
3082 hackname
= netbsd_c99_inline_2
;
3083 mach
= "*-*-netbsd*";
3085 select
= "#define _SIGINLINE extern __inline";
3088 c_fix_arg
= <<- _EOArg_
3089 #ifdef __GNUC_STDC_INLINE__
3090 #define _SIGINLINE extern
__attribute__((__gnu_inline__
)) __inline
3096 test_text
= "#define _SIGINLINE extern __inline";
3100 * NetBSD has a semicolon after the ending
'}' for some extern
"C".
3103 hackname
= netbsd_extra_semicolon
;
3104 mach
= "*-*-netbsd*";
3105 files
= sys
/cdefs.h
;
3106 select
= "#define[ \t]*__END_DECLS[ \t]*};";
3109 c_fix_arg
= "#define __END_DECLS }";
3111 test_text
= "#define __END_DECLS };";
3115 * newlib
's stdint.h has several failures to conform to C99. The fix
3116 * for these removed a comment that can be matched to identify unfixed
3120 hackname = newlib_stdint_1;
3121 files = stdint-newlib.h, stdint.h;
3122 select = "@todo - Add support for wint_t types";
3123 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3124 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3125 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3126 sed = "s@#define INT_LEAST32_MIN.*@"
3127 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3128 sed = "s@#define INT_LEAST32_MAX.*@"
3129 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3130 sed = "s@#define UINT_LEAST32_MAX.*@"
3131 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3132 sed = 's@#define INT_FAST\
([0-9]*\
)_MIN.
*@
'
3133 '#define INT_FAST\
1_MIN (-INT_FAST\
1_MAX
- 1)@
';
3134 sed = 's@#define INT_FAST\
([0-9]*\
)_MAX.
*@
'
3135 '#define INT_FAST\
1_MAX __INT_FAST\
1_MAX__@
';
3136 sed = 's@#define UINT_FAST\
([0-9]*\
)_MAX.
*@
'
3137 '#define UINT_FAST\
1_MAX __UINT_FAST\
1_MAX__@
';
3138 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3139 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3140 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3141 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3142 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3143 test_text = "/* @todo - Add support for wint_t types. */\n"
3144 "#define INT32_MIN (-2147483647-1)\n"
3145 "#define INT32_MAX 2147483647\n"
3146 "#define UINT32_MAX 4294967295U\n"
3147 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3148 "#define INT_LEAST32_MAX 2147483647\n"
3149 "#define UINT_LEAST32_MAX 4294967295U\n"
3150 "#define INT_FAST8_MIN INT8_MIN\n"
3151 "#define INT_FAST8_MAX INT8_MAX\n"
3152 "#define UINT_FAST8_MAX UINT8_MAX\n"
3153 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3154 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3155 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3156 "#define UINT8_C(x) x##U\n"
3157 "#define UINT16_C(x) x##U";
3164 hackname = newlib_stdint_2;
3165 files = stdint-newlib.h, stdint.h;
3166 select = "@todo - Add support for wint_t types";
3168 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3169 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3170 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3171 "#define WCHAR_MAX __WCHAR_MAX__\n"
3172 "#define WCHAR_MIN __WCHAR_MIN__\n"
3173 "#define WINT_MAX __WINT_MAX__\n"
3174 "#define WINT_MIN __WINT_MIN__\n\n"
3176 c_fix_arg = '/\
*\
* Macros for minimum
-width integer constant expressions \
*/';
3177 test_text = "/* @todo - Add support for wint_t types. */\n"
3178 "/** Macros for minimum-width integer constant expressions */";
3182 * NeXT 3.2 adds const prefix to some math functions.
3183 * These conflict with the built-in functions.
3186 hackname = next_math_prefix;
3187 files = ansi/math.h;
3188 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3191 c_fix_arg = "extern double %1(";
3192 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3194 test_text = "extern\tdouble\t__const__\tmumble();";
3198 * NeXT 3.2 uses the word "template" as a parameter for some
3199 * functions. GCC reports an invalid use of a reserved key word
3200 * with the built-in functions.
3203 hackname = next_template;
3205 select = "[ \t]template\\)";
3209 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3210 test_text = "extern mumble( char * template); /* fix */";
3214 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3215 * function prototypes. That conflicts with the built-in functions.
3218 hackname = next_volitile;
3219 files = ansi/stdlib.h;
3220 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3223 c_fix_arg = "extern void %1(";
3224 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3226 test_text = "extern\tvolatile\tvoid\tabort();";
3230 * NeXT 2.0 defines 'int
wait(union wait*)
', which conflicts with Posix.1.
3231 * Note that version 3 of the NeXT system has wait.h in a different directory,
3232 * so that this code won't do anything. But wait.h in version
3 has a
3233 * conditional
, so it doesn
't need this fix. So everything is okay.
3236 hackname = next_wait_union;
3239 select = 'wait\
(union wait
';
3241 c_fix_arg = "wait(void";
3242 test_text = "extern pid_d wait(union wait*);";
3246 * a missing semi-colon at the end of the nodeent structure definition.
3249 hackname = nodeent_syntax;
3250 files = netdnet/dnetdb.h;
3251 select = "char[ \t]*\\*na_addr[ \t]*$";
3254 test_text = "char *na_addr\t";
3258 * Fix OpenBSD's NULL definition.
3261 hackname
= openbsd_null_definition
;
3262 mach
= "*-*-openbsd*";
3263 files
= locale.h
, stddef.h
, stdio.h
, string.h
,
3264 time.h
, unistd.h
, wchar.h
, sys
/param.h
;
3265 select
= "__GNUG__";
3267 c_fix_arg
= "#ifndef NULL\n"
3268 "#ifdef __cplusplus\n"
3270 "#define NULL\t__null\n"
3271 "#else\t /* ! __GNUG__ */\n"
3272 "#define NULL\t0L\n"
3273 "#endif\t /* __GNUG__ */\n"
3274 "#else\t /* ! __cplusplus */\n"
3275 "#define NULL\t((void *)0)\n"
3276 "#endif\t /* __cplusplus */\n"
3277 "#endif\t /* !NULL */";
3279 c_fix_arg
= "^#ifndef[ \t]*NULL\n"
3280 "^#ifdef[ \t]*__GNUG__\n"
3281 "^#define[ \t]*NULL[ \t]*__null\n"
3283 "^#define[ \t]*NULL[ \t]*0L\n"
3289 "#define NULL __null\n"
3297 * obstack.h used casts as lvalues.
3299 * We need to change postincrements of casted
pointers (which are
3300 * then dereferenced and assigned into
) of the form
3302 * *((TYPE*)PTRVAR
)++ = (VALUE
)
3304 * into expressions like
3306 * ((*((TYPE*)PTRVAR
) = (VALUE
)), (PTRVAR
+= sizeof (TYPE)))
3308 * which is correct for the cases used in obstack.h since PTRVAR is
3309 * of type char
* and the value of the expression is not used.
3312 hackname
= obstack_lvalue_cast
;
3314 select
= '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3316 c_fix_arg
= "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3317 test_text
= "*((void **) (h)->next_free)++ = (aptr)";
3321 * Fix OpenBSD
's va_start define.
3324 hackname = openbsd_va_start;
3325 mach = "*-*-openbsd*";
3327 select = '__builtin_stdarg_start
';
3329 c_fix_arg = __builtin_va_start;
3331 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3335 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3336 * defining regex.h related types. This causes libg++ build and usage
3337 * failures. Fixing this correctly requires checking and modifying 3 files.
3340 hackname = osf_namespace_a;
3341 files = reg_types.h;
3342 files = sys/lc_core.h;
3343 test = " -r reg_types.h";
3344 test = " -r sys/lc_core.h";
3345 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3346 test = " -z \"`grep __regex_t regex.h`\"";
3350 c_fix_arg = "reg(ex|off|match)_t";
3352 test_text = "`touch sys/lc_core.h`"
3353 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3354 "extern regex_t re;\n"
3355 "extern regoff_t ro;\n"
3356 "extern regmatch_t rm;\n";
3360 hackname = osf_namespace_c;
3362 test = " -r reg_types.h";
3363 test = " -r sys/lc_core.h";
3364 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3365 test = " -z \"`grep __regex_t regex.h`\"";
3367 select = "#include <reg_types\.h>.*";
3370 "typedef __regex_t\tregex_t;\n"
3371 "typedef __regoff_t\tregoff_t;\n"
3372 "typedef __regmatch_t\tregmatch_t;";
3374 test_text = "#include <reg_types.h>";
3378 * On broken glibc-2.3.3 systems an array of incomplete structures is
3379 * passed to __sigsetjmp. Fix that to take a pointer instead.
3382 hackname = pthread_incomplete_struct_argument;
3384 select = "struct __jmp_buf_tag";
3386 c_fix_arg = "%1 *%2%3";
3387 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3388 "(__env)\\[1\\](.*)$";
3389 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3394 * Fix return type of fread and fwrite on sysV68
3397 hackname = read_ret_type;
3399 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3401 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3402 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3404 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3408 * Fix casts as lvalues in glibc's
<rpc
/xdr.h
>.
3411 hackname
= rpc_xdr_lvalue_cast_a
;
3413 select
= "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3415 c_fix_arg
= "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3416 test_text
= "#define IXDR_GET_LONG(buf) \\\\\n"
3417 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3421 * rpc_xdr_lvalue_cast_b
3424 hackname
= rpc_xdr_lvalue_cast_b
;
3426 select
= "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3428 c_fix_arg
= "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3429 test_text
= "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3430 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3434 * function
class(double x
) conflicts with C
++ keyword on rs
/6000
3437 hackname
= rs6000_double
;
3439 select
= '[^a-zA-Z_]class\(';
3442 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
3443 c_fix_arg
= '^.*[^a-zA-Z_]class\(.*';
3445 test_text
= "extern int class();";
3449 * Wrong fchmod prototype on RS
/6000.
3452 hackname
= rs6000_fchmod
;
3454 select
= 'fchmod\(char \*';
3456 c_fix_arg
= "fchmod(int";
3457 test_text
= "extern int fchmod(char *, mode_t);";
3461 * parameters conflict with C
++ new on rs
/6000
3464 hackname
= rs6000_param
;
3468 select
= 'rename\(const char \*old, const char \*new\)';
3470 c_fix_arg
= 'rename(const char *_old, const char *_new)';
3472 test_text
= 'extern int rename(const char *old, const char *new);';
3476 * Solaris
10+ <sys
/feature_tests.h
> defines _RESTRICT_KYWD as restrict
3477 * for C99. This is wrong for C
++, which needs many C99 features
, but
3478 * only supports __restrict.
3481 hackname
= solaris___restrict
;
3482 files
= sys
/feature_tests.h
;
3483 select
= "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3484 mach
= "*-*-solaris2*";
3486 c_fix_arg
= "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3487 "#else\n%0\n#endif";
3488 test_text
= "#define _RESTRICT_KYWD restrict";
3492 * Solaris
10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3493 * themselves
, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3494 * and imaginary definitions which are not supported by GCC.
3497 hackname
= solaris_complex
;
3498 mach
= "*-*-solaris2.*";
3500 select
= "#define[ \t]_Complex_I[ \t]_Complex_I";
3501 sed
= "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3502 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3503 sed
= "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3504 sed
= "/#define[ \t]imaginary[ \t]_Imaginary/d";
3505 sed
= "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3506 test_text
= "#define _Complex_I _Complex_I\n"
3507 "#define complex _Complex\n"
3508 "#define _Imaginary_I _Imaginary_I\n"
3509 "#define imaginary _Imaginary\n"
3511 "#define I _Imaginary_I";
3515 * Solaris
10+ <complex.h
> is wrapped in #ifndef __cplusplus. Wrap in
3516 * extern
"C" instead so libstdc
++ can use it.
3519 hackname
= solaris_complex_cxx
;
3520 mach
= "*-*-solaris2.*";
3522 sed
= "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3523 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3524 sed
= "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3525 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3526 test_text
= "#if !defined(__cplusplus)\n"
3527 "#endif /* !defined(__cplusplus) */";
3531 * g
++ rejects functions declared with both C and C
++ linkage.
3534 hackname
= solaris_cxx_linkage
;
3535 mach
= '*-*-solaris2*';
3536 files
= "iso/stdlib_iso.h";
3537 select
= "(#if __cplusplus >= 199711L)\n"
3538 "(extern \"C\\+\\+\" \\{\n)"
3539 "(.*(bsearch|qsort).*)";
3541 c_fix_arg
= "%1 && !__GNUG__\n%2%3";
3544 "#if __cplusplus >= 199711L\n"
3545 "extern \"C++\" {\n"
3546 " void *bsearch(const void *, const void *, size_t, size_t,";
3550 * Solaris
<iso
/stdio_iso.h
> doesn
't declare getc for C++ with
3551 * _STRICT_STDC, but uses it.
3554 hackname = solaris_getc_strict_stdc;
3555 mach = "*-*-solaris2*";
3556 files = "iso/stdio_iso.h";
3557 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3559 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3562 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3566 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3569 hackname = solaris_gets_c11;
3570 mach = "*-*-solaris2*";
3571 files = "iso/stdio_iso.h";
3572 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3575 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3576 "%1 __attribute__((__deprecated__));\n"
3579 test_text = "extern char *gets(char *);";
3583 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C
++14.
3586 hackname
= solaris_gets_cxx14
;
3587 mach
= "*-*-solaris2*";
3588 files
= "iso/stdio_iso.h";
3589 select
= <<- _EOSelect_
3590 (#if __STDC_VERSION__
< 201112L)
3591 (extern char \
*gets\
(char \
*\
) __ATTR_DEPRECATED
;)
3594 c_fix_arg
= "%1 && __cplusplus < 201402L\n%2";
3596 test_text
= <<- _EOText_
3597 #if __STDC_VERSION__
< 201112L
3598 extern char
*gets(char *) __ATTR_DEPRECATED
;
3603 * Sun Solaris
2 has a version of sys
/int_const.h that defines
3604 * UINT8_C and UINT16_C to unsigned constants.
3607 hackname
= solaris_int_const
;
3608 files
= sys
/int_const.h
;
3609 mach
= '*-*-solaris2*';
3611 c_fix_arg
= "#define\tUINT8_C(c)\t(c)\n"
3613 "#define\tUINT16_C(c)\t(c)";
3614 select
= "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3616 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3618 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3620 "#define UINT16_C(c) __CONCAT__(c,u)";
3624 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3625 * UINT8_MAX and UINT16_MAX to unsigned constants.
3628 hackname
= solaris_int_limits_1
;
3629 files
= sys
/int_limits.h
;
3630 mach
= '*-*-solaris2*';
3632 c_fix_arg
= "#define\tUINT8_MAX\t(255)\n"
3633 "#define\tUINT16_MAX\t(65535)";
3634 select
= "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3635 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3637 "#define UINT8_MAX (255U)\n"
3638 "#define UINT16_MAX (65535U)";
3642 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3643 * INT_FAST16 limits to wrong values for sys
/int_types.h.
3646 hackname
= solaris_int_limits_2
;
3647 files
= sys
/int_limits.h
;
3648 mach
= '*-*-solaris2*';
3650 c_fix_arg
= "#define\t%1_FAST16_%2 %132_%2";
3651 select
= "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3653 "#define INT_FAST16_MAX INT16_MAX\n"
3654 "#define UINT_FAST16_MAX UINT16_MAX\n"
3655 "#define INT_FAST16_MIN INT16_MIN";
3659 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3660 * SIZE_MAX as unsigned long.
3663 hackname
= solaris_int_limits_3
;
3664 files
= sys
/int_limits.h
;
3665 mach
= '*-*-solaris2*';
3667 c_fix_arg
= "#define\tSIZE_MAX\t4294967295U";
3668 select
= "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3670 "#define SIZE_MAX 4294967295UL";
3674 * Sun Solaris
10 defines several C99 math macros in terms of
3675 * builtins specific to the Studio compiler
, in particular not
3676 * compatible with the GNU compiler.
3679 hackname
= solaris_math_1
;
3680 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3681 bypass
= "__GNUC__";
3682 files
= iso
/math_c99.h
;
3684 c_fix_arg
= "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3685 c_fix_arg
= "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3687 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3689 "#define HUGE_VAL __builtin_huge_val\n"
3690 "#undef HUGE_VALF\n"
3691 "#define HUGE_VALF __builtin_huge_valf\n"
3692 "#undef HUGE_VALL\n"
3693 "#define HUGE_VALL __builtin_huge_vall";
3697 * On Solaris
11, if you do
isinf(NaN
) you
'll get a floating point
3698 * exception. Provide an alternative using GCC's builtin.
3701 hackname
= solaris_math_10
;
3702 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3703 files
= iso
/math_c99.h
;
3705 c_fix_arg
= "#define\tisinf(x) __builtin_isinf(x)";
3706 c_fix_arg
= "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3707 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3709 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3710 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3711 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3712 "\\(-INFINITY\\);[ \t]*\\}\\)";
3714 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3716 "#define isinf(x) __extension__( \\\\\n"
3717 " { __typeof(x) __x_i = (x); \\\\\n"
3718 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3719 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3723 * Solaris math INFINITY
3726 hackname
= solaris_math_2
;
3727 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3728 bypass
= "__GNUC__";
3729 files
= iso
/math_c99.h
;
3731 c_fix_arg
= "#define\tINFINITY\t(__builtin_inff())";
3732 c_fix_arg
= "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3734 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3736 "#define INFINITY __builtin_infinity";
3743 hackname
= solaris_math_3
;
3744 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3745 bypass
= "__GNUC__";
3746 files
= iso
/math_c99.h
;
3748 c_fix_arg
= "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3749 c_fix_arg
= "^#define[ \t]+NAN[ \t]+__builtin_nan";
3751 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3753 "#define NAN __builtin_nan";
3757 * Solaris math fpclassify
3760 hackname
= solaris_math_4
;
3761 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3762 bypass
= "__GNUC__";
3763 files
= iso
/math_c99.h
;
3765 c_fix_arg
= "#define\tfpclassify(x) \\\n"
3766 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3767 "FP_SUBNORMAL, FP_ZERO, (x))";
3768 c_fix_arg
= "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3770 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3771 "#undef fpclassify\n"
3772 "#define fpclassify(x) __builtin_fpclassify(x)";
3776 * Solaris math signbit
3779 hackname
= solaris_math_8
;
3780 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3781 bypass
= "__GNUC__";
3782 files
= iso
/math_c99.h
;
3784 c_fix_arg
= "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3785 "\t\t\t ? __builtin_signbitf(x) \\\n"
3786 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3787 "\t\t\t ? __builtin_signbitl(x) \\\n"
3788 "\t\t\t : __builtin_signbit(x))";
3789 c_fix_arg
= "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3790 test_text
= <<- _EOText_
3791 #ident
"@(#)math_c99.h 1.9 04/11/01 SMI"
3793 #define
signbit(x
) __builtin_signbit(x
)
3798 * Solaris math comparison macros
3801 hackname
= solaris_math_9
;
3802 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3803 bypass
= "__GNUC__";
3804 files
= iso
/math_c99.h
;
3806 c_fix_arg
= "#define\t%1(x, y)%2__builtin_%1(x, y)";
3807 c_fix_arg
= "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3808 "__builtin_[a-z]+\\(y\\)\\)";
3810 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3811 "#undef isgreater\n"
3812 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3813 "#undef isgreaterequal\n"
3814 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3816 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3817 "#undef islessequal\n"
3818 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3819 "#undef islessgreater\n"
3820 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3821 "#undef isunordered\n"
3822 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3826 * Newer Solaris
10/11 GCC signbit implementations cause strict
-aliasing
3830 hackname
= solaris_math_11
;
3831 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3832 files
= iso
/math_c99.h
;
3834 c_fix_arg
= << _EOArg_
3836 #define
signbit(x
) (sizeof(x
) == sizeof(float
) \
3837 ?
__builtin_signbitf(x
) \
3838 : sizeof(x
) == sizeof(long double
) \
3839 ?
__builtin_signbitl(x
) \
3840 : __builtin_signbit(x
))
3842 c_fix_arg
= << _EOArg_
3844 #if defined\
(__sparc\
)
3845 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3846 [ ]+\
{[ ]*__typeof\
(x\
)[ ]*__x_s
[ ]*=[ ]*\
(x\
);[ ]*\\
3847 [ ]+\
(int\
)[ ]*\
(\
*\
(unsigned
[ ]*\
*\
)[ ]*\
&__x_s
[ ]*>>[ ]*31\
);[ ]*\
}\
)
3848 #elif defined\
(__i386\
) \|\| defined\
(__amd64\
)
3849 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3850 [ ]+\
{ __typeof\
(x\
) __x_s
= \
(x\
); \\
3851 [ ]+\
(sizeof \
(__x_s\
) == sizeof \
(float\
) \? \\
3852 [ ]+\
(int\
) \
(\
*\
(unsigned \
*\
) \
&__x_s
>> 31\
) : \\
3853 [ ]+sizeof \
(__x_s\
) == sizeof \
(double\
) \? \\
3854 [ ]+\
(int\
) \
(\
(\
(unsigned \
*\
) \
&__x_s\
)\
[1\
] >> 31\
) : \\
3855 [ ]+\
(int\
) \
(\
(\
(unsigned short \
*\
) \
&__x_s\
)\
[4\
] >> 15\
)\
); \
}\
)
3858 test_text
= << _EOText_
3859 /* @
(#
)math_c99.h
1.14 13/03/27 */
3861 #if
defined(__sparc
)
3862 #define
signbit(x
) __extension__( \\
3863 { __typeof(x
) __x_s
= (x
); \\
3864 (int
) (*(unsigned *) &__x_s
>> 31); })
3865 #elif
defined(__i386
) ||
defined(__amd64
)
3866 #define
signbit(x
) __extension__( \\
3867 { __typeof(x
) __x_s
= (x
); \\
3868 (sizeof (__x_s
) == sizeof (float
) ?
\\
3869 (int
) (*(unsigned *) &__x_s
>> 31) : \\
3870 sizeof (__x_s
) == sizeof (double
) ?
\\
3871 (int
) (((unsigned *)
&__x_s
)[1] >> 31) : \\
3872 (int
) (((unsigned short *)
&__x_s
)[4] >> 15)); })
3878 * Some versions of Solaris
10+ <math.h
> #undef libstdc
++-internal macros.
3881 hackname
= solaris_math_12
;
3883 mach
= '*-*-solaris2*';
3884 select
= '#undef.*_GLIBCXX_USE_C99_MATH';
3885 sed
= "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3886 test_text
= << _EOText_
3887 #if __cplusplus
>= 201103L
3888 #undef _GLIBCXX_USE_C99_MATH
3889 #undef _GLIBCXX_USE_C99_MATH_TR1
3895 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3896 * structure. As such
, it need two levels of brackets
, but only
3897 * contains one. Wrap the macro definition in an extra layer.
3900 hackname
= solaris_once_init_1
;
3901 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3903 mach
= '*-*-solaris*';
3905 c_fix_arg
= "%1{%2}%3";
3906 c_fix_arg
= "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3908 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3909 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3913 * Solaris
10+ <spawn.h
> uses char
*const argv
[_RESTRICT_KYWD
] in the
3914 * posix_spawn declarations
, which doesn
't work with C++.
3917 hackname = solaris_posix_spawn_restrict;
3919 mach = '*-*-solaris2
*';
3921 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3922 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3924 "char *const argv[_RESTRICT_KYWD],\n"
3925 "char *const envp[_RESTRICT_KYWD]);";
3929 * The pow overloads with int were removed in C++ 2011 DR 550.
3932 hackname = solaris_pow_int_overload;
3933 mach = '*-*-solaris2
*';
3934 files = "iso/math_iso.h";
3935 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3936 " *\\{[^{}]*\n[^{}]*\\}";
3938 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3941 " inline long double pow(long double __X, int __Y) { return\n"
3942 " __powl(__X, (long double) (__Y)); }";
3946 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3947 * fields of the pthread_rwlock_t structure, which are of type
3948 * upad64_t, which itself is typedef'd to int64_t
, but with __STDC__
3949 * defined (e.g. by
-ansi
) it is a union. So change the initializer
3953 hackname
= solaris_rwlock_init_1
;
3954 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3956 mach
= '*-*-solaris*';
3958 c_fix_arg
= "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3961 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3963 c_fix_arg
= "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3964 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3967 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3968 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3972 * Before Solaris
10, <stdio.h
> lacks declarations of std
::__filbuf and
3973 * std
::__flsbuf
, but
<iso
/stdio_iso.h
> uses them.
3976 hackname
= solaris_std___filbuf
;
3978 mach
= '*-*-solaris2*';
3979 bypass
= "using std::__filbuf";
3980 select
= "(using std::perror;\n)(#endif)";
3982 c_fix_arg
= "%1#ifndef _LP64\n"
3983 "using std::__filbuf;\n"
3984 "using std::__flsbuf;\n"
3987 test_text
= "using std::perror;\n"
3992 * Solaris
<stdio.h
> shouldn
't use std::gets for C++14.
3995 hackname = solaris_std_gets_cxx14;
3996 mach = "*-*-solaris2*";
3998 select = "using std::gets;";
4001 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4003 test_text = "using std::gets;";
4007 * Sun Solaris 8 has what appears to be some gross workaround for
4008 * some old version of their c++ compiler. G++ doesn't want it
4009 * either
, but doesn
't want to be tied to SunPRO version numbers.
4012 hackname = solaris_stdio_tag;
4013 files = stdio_tag.h;
4015 select = '__cplusplus
< 54321L';
4016 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4017 "!defined(__GNUC__)" so we no longer need to fix it. */
4018 bypass = '__GNUC__
';
4019 sed = 's
/defined(__cplusplus
) && (__cplusplus
< 54321L)/0/';
4021 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4025 * Solaris <stdlib.h> shouldn't use _Noreturn
, breaks with C
++.
4028 hackname
= solaris_stdlib_noreturn
;
4029 mach
= "*-*-solaris2*";
4030 files
= "iso/stdlib_c99.h";
4031 select
= "(extern) _Noreturn (void quick_exit\\(int\\));";
4034 c_fix_arg
= "%1 %2 __attribute__((__noreturn__));";
4036 test_text
= "extern _Noreturn void quick_exit(int);";
4040 * a missing semi
-colon at the end of the statsswtch structure definition.
4043 hackname
= statsswtch
;
4044 files
= rpcsvc
/rstat.h
;
4045 select
= "boottime$";
4047 c_fix_arg
= "boottime;";
4048 test_text
= "struct statswtch {\n int boottime\n};";
4052 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4053 * On
4BSD
-derived systems
, stdio.h defers to machine
/ansi.h
; that
's
4057 hackname = stdio_stdarg_h;
4059 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4061 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4062 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4064 mach = '*-*-solaris2.1
[0-9]*';
4069 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4075 * Don't use or define the name va_list in stdio.h. This is for
4076 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4077 * of __gnuc_va_list
, __DJ_va_list
, or _G_va_list is taken to
4078 * indicate that the header knows what it
's doing -- under SUSv2,
4079 * stdio.h is required to define va_list, and we shouldn't break
4083 hackname
= stdio_va_list
;
4085 bypass
= '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4087 * On Solaris
10, the definition in
4088 * <stdio.h
> is guarded appropriately by the _XPG4 feature macro
;
4089 * there is therefore no need for this fix there.
4091 mach
= '*-*-solaris2.1[0-9]*';
4095 * Use __gnuc_va_list in arg types in place of va_list.
4096 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4097 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4098 * trailing parentheses and semicolon save all other systems from this.
4099 * Define __not_va_list__ (something harmless and unused)
4100 * instead of va_list.
4101 * Don't claim to have defined va_list.
4103 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4104 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4105 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4106 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4107 "s@ va_list@ __not_va_list__@\n"
4108 "s@\\*va_list@*__not_va_list__@\n"
4109 "s@ __va_list)@ __gnuc_va_list)@\n"
4110 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4111 "@typedef \\1 __not_va_list__;@\n"
4112 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4113 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4114 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4115 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4116 "s@VA_LIST@DUMMY_VA_LIST@\n"
4117 "s@_Va_LIST@_VA_LIST@";
4118 test_text
= "extern void mumble( va_list);";
4122 * Fix headers that use va_list from stdio.h to use the updated
4123 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4124 * dealt with elsewhere. The presence of __gnuc_va_list
,
4125 * __DJ_va_list
, or _G_va_list is taken to indicate that the header
4126 * knows what it
's doing.
4129 hackname = stdio_va_list_clients;
4137 files = curses_colr/curses.h;
4138 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list
';
4139 /* Don't fix
, if we use va_list from stdarg.h
, or if the use is
4140 otherwise protected.
*/
4141 bypass
= 'include <stdarg\.h>|#ifdef va_start';
4144 * Use __gnuc_va_list in arg types in place of va_list.
4145 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4146 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4147 * trailing parentheses and semicolon save all other systems from this.
4148 * Define __not_va_list__ (something harmless and unused)
4149 * instead of va_list.
4150 * Don't claim to have defined va_list.
4152 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4153 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4154 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4155 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4156 "s@ va_list@ __not_va_list__@\n"
4157 "s@\\*va_list@*__not_va_list__@\n"
4158 "s@ __va_list)@ __gnuc_va_list)@\n"
4159 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4160 "@typedef \\1 __not_va_list__;@\n"
4161 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4162 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4163 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4164 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4165 "s@VA_LIST@DUMMY_VA_LIST@\n"
4166 "s@_Va_LIST@_VA_LIST@";
4167 test_text
= "extern void mumble( va_list);";
4171 * "!__STDC__" or
"__STDC__==0" or
"__STDC__!=1" or
"__STDC__-0==0"
4172 * is
"!defined( __STRICT_ANSI__ )"
4175 hackname
= strict_ansi_not
;
4176 select
= "^([ \t]*#[ \t]*if.*)"
4178 "|__STDC__[ \t]*==[ \t]*0"
4179 "|__STDC__[ \t]*!=[ \t]*1"
4180 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4181 /* Tru64 UNIX V4.0F
/V5.1
<standards.h
> supports GCC usage of __STDC__.
*/
4182 bypass
= 'GNU and MIPS C compilers define __STDC__ differently';
4183 /* GNU gmp.h uses
"__STDC__ != 1" only if __SCO_VERSION__
, which
4184 is not defined by GCC
, so it is safe.
*/
4185 bypass
= '__SCO_VERSION__.*__STDC__ != 1';
4186 c_test
= stdc_0_in_system_headers
;
4189 c_fix_arg
= "%1 !defined(__STRICT_ANSI__)";
4191 test_text
= "#if !__STDC__ \n"
4192 "#if __STDC__ == 0\n"
4193 "#if __STDC__ != 1\n"
4194 "#if __STDC__ - 0 == 0"
4195 "/* not std C */\nint foo;\n"
4196 "\n#end-end-end-end-if :-)";
4201 * is
"!defined( __STRICT_ANSI__ )" on continued #if
-s
4204 hackname
= strict_ansi_not_ctd
;
4205 files
= math.h
, limits.h
, stdio.h
, signal.h
,
4206 stdlib.h
, sys
/signal.h
, time.h
;
4208 * Starting at the beginning of a line
, skip white space and
4209 * a leading
"(" or
"&&" or
"||". One of those must be found.
4210 * Then
, zero
, one or more copies of a
"defined(_FOO_BAR_) &&"
4211 * expression. If these are nested
, then they must accumulate
4212 * because we won
't match any closing parentheses. Finally,
4213 * after skipping over all that, we must then match our suspect
4214 * phrase: "__STDC__-0==0" with or without white space.
4216 select = "^([ \t]*" '(\
(|
&&|\|\|
)'
4217 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4219 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4220 c_test = stdc_0_in_system_headers;
4223 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4225 test_text = "#if 1 && \\\\\n"
4226 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4227 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4228 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4233 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4234 * is "defined( __STRICT_ANSI__ )"
4237 hackname = strict_ansi_only;
4238 select = "^([ \t]*#[ \t]*if.*)"
4239 "(__STDC__[ \t]*!=[ \t]*0"
4240 "|__STDC__[ \t]*==[ \t]*1"
4241 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4242 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4243 c_test = stdc_0_in_system_headers;
4246 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4248 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4252 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4253 * in prototype without previous definition.
4256 hackname = struct_file;
4258 select = '^.
*xdrstdio_create.
*struct __file_s
';
4260 c_fix_arg = "struct __file_s;\n%0";
4261 test_text = "extern void xdrstdio_create( struct __file_s* );";
4265 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4266 * in prototype without previous definition.
4268 * Don't fix OpenBSD
, which uses struct sockaddr_in prototyping the same
4269 * function
, and does define it.
4272 hackname
= struct_sockaddr
;
4274 select
= "^.*authdes_create.*struct sockaddr[^_]";
4275 bypass
= "<sys/socket\.h>";
4276 bypass
= "struct sockaddr;\n";
4278 c_fix_arg
= "struct sockaddr;\n%0";
4279 test_text
= "extern AUTH* authdes_create( struct sockaddr* );";
4283 * Apply fix this to all OSs since this problem seems to effect
4284 * more than just SunOS.
4287 hackname
= sun_auth_proto
;
4292 bypass
= "__cplusplus";
4294 * Select those files containing
'(*name)()'.
4296 select
= '\(\*[a-z][a-z_]*\)\(\)';
4299 c_fix_arg
= "#ifdef __cplusplus\n%1(...);%2\n"
4300 "#else\n%1();%2\n#endif";
4301 c_fix_arg
= '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4305 " int (*name)(); /* C++ bad */\n"
4310 * Fix bogus #ifdef on SunOS
4.1.
4313 hackname
= sun_bogus_ifdef
;
4314 files
= "hsfs/hsfs_spec.h";
4315 files
= "hsfs/iso_spec.h";
4316 select
= '#ifdef(.*\|\|.*)';
4318 c_fix_arg
= "#if%1";
4320 test_text
= "#ifdef __i386__ || __vax__ || __sun4c__";
4324 * Fix the CAT macro in SunOS memvar.h.
4327 hackname
= sun_catmacro
;
4328 files
= pixrect
/memvar.h
;
4329 select
= "^#define[ \t]+CAT\\(a,b\\).*";
4334 "# define CAT(a,b) a##b\n"
4335 "#else\n%0\n#endif";
4338 "#define CAT(a,b)\ta/**/b";
4342 * Fix return type of free and
{c
,m
,re
}alloc in
<malloc.h
> on SunOS
4.1.
4343 * Also fix return type of
{m
,re
}alloc in
<malloc.h
> on sysV68
4346 hackname
= sun_malloc
;
4348 bypass
= "_CLASSIC_ANSI_TYPES";
4350 sed
= "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4351 sed
= "s/int[ \t][ \t]*free/void\tfree/g";
4352 sed
= "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4353 sed
= "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4354 sed
= "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4357 "typedef char *\tmalloc_t;\n"
4359 "char*\tmalloc();\n"
4360 "char*\tcalloc();\n"
4361 "char*\trealloc();";
4365 * Check for yet more missing
';' in
struct (in SunOS
4.0.x
)
4368 hackname
= sun_rusers_semi
;
4369 files
= rpcsvc
/rusers.h
;
4371 sed
= "/^struct/,/^};/s/_cnt$/_cnt;/";
4372 test_text
= "struct mumble\n int _cnt\n};";
4376 * signal.h on SunOS defines signal
using (),
4377 * which causes trouble when compiling with g
++ -pedantic.
4380 hackname
= sun_signal
;
4381 files
= sys
/signal.h
;
4383 select
= "^void\t" '\(\*signal\(\)\)\(\);.*';
4387 "#ifdef __cplusplus\n"
4388 "void\t(*signal(...))(...);\n"
4389 "#else\n%0\n#endif";
4391 test_text
= "void\t(*signal())();";
4395 * Correct the return type for strlen in strings.h in SunOS
4.
4398 hackname
= sunos_strlen
;
4400 select
= "int[ \t]*strlen\\(\\);(.*)";
4402 c_fix_arg
= "__SIZE_TYPE__ strlen();%1";
4403 test_text
= " int\tstrlen(); /* string length */";
4407 * Linux kernel
's vt.h breaks C++
4410 hackname = suse_linux_vt_cxx;
4413 select = "^[ \t]*unsigned int new;";
4415 c_fix_arg = "unsigned int newev;";
4417 test_text = " unsigned int new; /* New console (if changing) */";
4421 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4422 * that is visible to any ANSI compiler using this include. Simply
4423 * delete the lines that #define some string functions to internal forms.
4426 hackname = svr4_disable_opt;
4428 select = '#define.
*__std_hdr_
';
4429 sed = '/#define.
*__std_hdr_
/d
';
4430 test_text = "#define strlen __std_hdr_strlen\n";
4434 * Fix broken decl of getcwd present on some svr4 systems.
4437 hackname = svr4_getcwd;
4440 files = prototypes.h;
4441 select = 'getcwd\
(char \
*, int\
)';
4444 c_fix_arg = "getcwd(char *, size_t)";
4446 test_text = "extern char* getcwd(char *, int);";
4450 * Fix broken decl of profil present on some svr4 systems.
4453 hackname = svr4_profil;
4458 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
4460 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
4463 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
4467 * Correct types for signal handler constants like SIG_DFL; they might be
4468 * void (*) (), and should be void (*) (int). C++ doesn't like the
4472 hackname
= svr4_sighandler_type
;
4473 files
= sys
/signal.h
;
4474 select
= 'void *\(\*\)\(\)';
4476 c_fix_arg
= "void (*)(int)";
4477 test_text
= "#define SIG_DFL (void(*)())0\n"
4478 "#define SIG_IGN (void (*)())0\n";
4482 * Some SysV r4 systems
, including Sequent
's DYNIX/ptx, use the local
4483 * function 'getrnge
' in <regexp.h> before they declare it. For these
4484 * systems add a 'static int
' declaration of 'getrnge
' into <regexp.h>
4487 * 'getrnge
' traditionally manipulates a file-scope global called 'size
',
4488 * so put the declaration right after the declaration of 'size
'.
4490 * Don't do this if there is already a `static void getrnge
' declaration
4491 * present, since this would cause a redeclaration error. Solaris 2.x has
4492 * such a declaration.
4495 hackname = svr4_undeclared_getrnge;
4498 bypass = "static void getrnge";
4501 "static int getrnge ();";
4502 c_fix_arg = "^static int[ \t]+size;";
4503 test_text = "static int size;\n"
4504 "/* stuff which calls getrnge() */\n"
4505 "static getrnge()\n"
4510 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4511 * in string.h on sysV68
4512 * Correct the return type for strlen in string.h on Lynx.
4513 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4514 * Add missing const for strdup on OSF/1 V3.0.
4515 * On sysV88 layout is slightly different.
4518 hackname = sysv68_string;
4521 bypass = "_CLASSIC_ANSI_TYPES";
4523 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4524 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4525 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4527 sed = "/^extern char$/N";
4528 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4530 sed = "/^extern int$/N";
4531 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4533 sed = "/^\tstrncmp(),$/N";
4534 sed = 's
/^\
(' "\t" 'strncmp()\
),\n\
(' "\t" 'strlen(),\
)$
/'
4535 '\
1;' "\\\nextern unsigned int\\\n\\2/";
4538 "extern int strlen();\n"
4540 "extern int ffs(long);\n"
4553 "\tstrlen(), strspn();";
4557 * Fix return type of calloc, malloc, realloc, bsearch and exit
4560 hackname = sysz_stdlib_for_sun;
4562 bypass = "_CLASSIC_ANSI_TYPES";
4564 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4566 c_fix_arg = "void *\t%1(";
4569 "extern char*\tcalloc(size_t);\n"
4570 "extern char*\tmalloc(size_t);\n"
4571 "extern char*\trealloc(void*,size_t);\n"
4572 "extern char*\tbsearch(void*,size_t,size_t);\n";
4576 * __thread is now a keyword.
4579 hackname = thread_keyword;
4580 files = "pthread.h";
4581 files = bits/sigthread.h, '*/bits
/sigthread.h
';
4582 select = "([* ])__thread([,)])";
4584 c_fix_arg = "%1__thr%2";
4587 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4588 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4589 "extern int pthread_cancel (pthread_t __thread);";
4593 * if the #if says _cplusplus, not the double underscore __cplusplus
4597 hackname = tinfo_cplusplus;
4599 select = "[ \t]_cplusplus";
4602 c_fix_arg = " __cplusplus";
4603 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4607 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4610 hackname = ultrix_const;
4612 select = 'perror\
( char \
*';
4615 c_fix_arg = "%1 const %3 *__";
4616 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4617 "[ \t]+(char|void) \\*__";
4620 "extern void perror( char *__s );\n"
4621 "extern int fputs( char *__s, FILE *);\n"
4622 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4623 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4624 "extern int scanf( char *__format, ...);\n";
4628 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4631 hackname = ultrix_const2;
4634 select = '\
*fopen\
( char \
*';
4636 c_fix_arg = "%1( const char *%3, const char *";
4637 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4638 "[ \t]*char[ \t]*\\*([^,]*),"
4639 "[ \t]*char[ \t]*\\*[ \t]*";
4642 "extern FILE *fopen( char *__filename, char *__type );\n"
4643 "extern int sscanf( char *__s, char *__format, ...);\n"
4644 "extern FILE *popen(char *, char *);\n"
4645 "extern char *tempnam(char*,char*);\n";
4649 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4652 hackname = va_i960_macro;
4653 files = arch/i960/archI960.h;
4654 select = "__(vsiz|vali|vpad|alignof__)";
4657 c_fix_arg = "__vx%1";
4660 "extern int __vsiz vsiz;\n"
4661 "extern int __vali vali;\n"
4662 "extern int __vpad vpad;\n"
4663 "#define __alignof__(x) ...";
4667 * On VMS, add missing braces around sigset_t constants.
4670 hackname = vms_add_missing_braces;
4671 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4673 files = "rtldef/signal.h";
4676 c_fix_arg = '%1 {%2} ';
4678 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4679 "{0x00000000, 0x00000000},\n"
4680 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4684 * On VMS, some DEC-C builtins are directly used.
4687 hackname = vms_decc_builtin;
4688 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4690 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4692 sed = "s@__MEMSET@memset@";
4693 sed = "s@__MEMMOVE@memmove@";
4694 sed = "s@__MEMCPY@memcpy@";
4695 sed = "s@__STRLEN@strlen@";
4696 sed = "s@__STRCPY@strcpy@";
4698 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4702 * Define __CAN_USE_EXTERN_PREFIX on vms.
4705 hackname = vms_define_can_use_extern_prefix;
4706 files = "rtldef/decc$types.h";
4707 select = "#[ \t]*else\n"
4708 "#[ \t]*if defined\\(__DECCXX\\)\n"
4709 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4714 "# elif defined (__GNUC__)\n"
4715 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4717 test_text = "# else\n"
4718 "# if defined(__DECCXX)\n"
4719 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4725 * On VMS, disable the use of dec-c string builtins
4728 hackname = vms_disable_decc_string_builtins;
4729 select = "#if !defined\\(__VAX\\)\n";
4731 files = "rtldef/string.h";
4734 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4736 test_text = "#if !defined(__VAX)\n";
4740 * On VMS, fix incompatible redeclaration of hostalias.
4743 hackname = vms_do_not_redeclare_hostalias;
4744 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4745 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4747 files = "rtldef/resolv.h";
4753 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4754 "__char_ptr32 hostalias (const char *);\n";
4758 * On VMS, forward declare structure before referencing them in prototypes.
4761 hackname = vms_forward_declare_struct;
4762 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4763 "#ifdef __cplusplus\n";
4765 files = rtldef/if.h;
4769 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4771 test_text = "/* forward decls for C++ */\n"
4772 "#ifdef __cplusplus\n"
4778 * On VMS, do not declare getopt and al if pointers are 64 bit.
4781 hackname = vms_no_64bit_getopt;
4782 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4783 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4785 files = rtldef/stdio.h, rtldef/unistd.h;
4788 c_fix_arg = <<- _EOArg_
4789 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4794 test_text = "int getopt (int, char * const [], const char *);";
4798 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4799 * which is not yet fully supported by gcc.
4802 hackname = vms_use_fast_setjmp;
4803 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4805 files = rtldef/setjmp.h;
4808 c_fix_arg = "%0 defined (__GNUC__) ||";
4810 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4814 * On VMS, use pragma extern_model instead of VAX-C keywords.
4817 hackname = vms_use_pragma_extern_model;
4818 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4819 "# pragma extern_model __save\n";
4823 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4824 "# pragma extern_model __save\n";
4826 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4827 "# pragma extern_model __save\n"
4828 "# pragma extern_model strict_refdef\n"
4829 " extern struct x zz$yy;\n"
4830 "# pragma extern_model __restore\n"
4835 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4836 * conflict while building gcc. Likewise for <builtins.h>
4839 hackname = vms_use_quoted_include;
4840 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4842 files = rtldef/wait.h, starlet_c/pthread.h;
4845 c_fix_arg = '%1<sys
/%2.h
>';
4847 test_text = "# include <resource.h>";
4851 * AIX and Interix headers define NULL to be cast to a void pointer,
4852 * which is illegal in ANSI C++.
4855 hackname = void_null;
4856 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4857 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4858 /* avoid changing C++ friendly NULL */
4859 bypass = __cplusplus;
4861 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4863 c_fix_arg = <<- _EOFix_
4868 #else /* ! __GNUG__ */
4870 #endif /* __GNUG__ */
4871 #else /* ! __cplusplus */
4872 #define NULL ((void *)0)
4873 #endif /* __cplusplus */
4876 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4880 * Make VxWorks header which is almost gcc ready fully gcc ready.
4883 hackname = vxworks_gcc_problem;
4884 files = types/vxTypesBase.h;
4885 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4887 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4890 sed = "/[ \t]size_t/i\\\n"
4891 "#ifndef _GCC_SIZE_T\\\n"
4892 "#define _GCC_SIZE_T\n";
4894 sed = "/[ \t]size_t/a\\\n"
4897 sed = "/[ \t]ptrdiff_t/i\\\n"
4898 "#ifndef _GCC_PTRDIFF_T\\\n"
4899 "#define _GCC_PTRDIFF_T\n";
4901 sed = "/[ \t]ptrdiff_t/a\\\n"
4904 sed = "/[ \t]wchar_t/i\\\n"
4905 "#ifndef _GCC_WCHAR_T\\\n"
4906 "#define _GCC_WCHAR_T\n";
4908 sed = "/[ \t]wchar_t/a\\\n"
4912 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4913 "typedef unsigned int size_t;\n"
4914 "typedef long ptrdiff_t;\n"
4915 "typedef unsigned short wchar_t;\n"
4916 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4920 * Wrap VxWorks ioctl to keep everything pretty
4923 hackname = vxworks_ioctl_macro;
4925 mach = "*-*-vxworks*";
4929 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
4930 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4932 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4936 * Wrap VxWorks mkdir to be posix compliant
4939 hackname = vxworks_mkdir_macro;
4941 mach = "*-*-vxworks*";
4945 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4946 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4947 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4948 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4951 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4955 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4958 hackname = vxworks_needs_vxtypes;
4960 select = "uint_t([ \t]+_clocks_per_sec)";
4962 c_fix_arg = "unsigned int%1";
4963 test_text = "uint_t\t_clocks_per_sec;";
4967 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4970 hackname = vxworks_needs_vxworks;
4972 test = " -r types/vxTypesOld.h";
4973 test = " -n \"`egrep '#include
' $file`\"";
4974 test = " -n \"`egrep ULONG $file`\"";
4975 select = "#[ \t]define[ \t]+__INCstath";
4977 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4978 "#include <types/vxTypesOld.h>\n";
4980 test_text = "`touch types/vxTypesOld.h`"
4981 "#include </dev/null> /* ULONG */\n"
4982 "# define\t__INCstath <sys/stat.h>";
4986 * Make it so VxWorks does not include gcc/regs.h accidentally
4989 hackname = vxworks_regs;
4990 mach = "*-*-vxworks*";
4992 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4994 c_fix_arg = "#include <arch/../regs.h>";
4996 test_text = "#include <regs.h>\n";
5000 * Another bad dependency in VxWorks 5.2 <time.h>.
5003 hackname = vxworks_time;
5005 test = " -r vxWorks.h";
5007 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5011 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5012 "#ifdef __cplusplus\n"
5013 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5015 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5017 "#define __gcc_VOIDFUNCPTR_defined\n"
5019 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5021 test_text = "`touch vxWorks.h`"
5022 "#define VOIDFUNCPTR (void(*)())";
5026 * This hack makes write const-correct on VxWorks
5029 hackname = vxworks_write_const;
5031 mach = "*-*-vxworks*";
5034 c_fix_arg = "extern int write (int, const char*, size_t);";
5035 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5037 "[\t ]*char[\t ]*\\*[\t ]*,"
5038 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5040 test_text = "extern int write ( int , char * , size_t ) ;";
5044 * This hack ensures the include_next in the fixed unistd.h actually
5045 * finds the system's unistd.h and not the fixed unistd.h again.
5048 hackname
= vxworks_iolib_include_unistd
;
5050 mach
= "*-*-vxworks*";
5051 select
= "#include \"unistd.h\"";
5054 c_fix_arg
= "#include <unistd.h>";
5056 test_text
= "#include \"unistd.h\"";
5060 * There are several name conflicts with C
++ reserved words in X11 header
5061 * files. These are fixed in some versions
, so don
't do the fixes if
5062 * we find __cplusplus in the file. These were found on the RS/6000.
5065 hackname = x11_class;
5066 files = X11/ShellP.h;
5067 bypass = __cplusplus;
5068 select = "^([ \t]*char \\*)class;(.*)";
5070 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5071 "#else\n%1class;%2\n#endif";
5079 * class in Xm/BaseClassI.h
5082 hackname = x11_class_usage;
5083 files = Xm/BaseClassI.h;
5084 bypass = "__cplusplus";
5086 select = " class\\)";
5088 c_fix_arg = " c_class)";
5090 test_text = "extern mumble (int class);\n";
5094 * new in Xm/Traversal.h
5098 files = Xm/Traversal.h;
5099 bypass = __cplusplus;
5101 sed = "/Widget\told, new;/i\\\n"
5102 "#ifdef __cplusplus\\\n"
5103 "\\\tWidget\told, c_new;\\\n"
5106 sed = "/Widget\told, new;/a\\\n"
5109 sed = "s/Widget new,/Widget c_new,/g";
5112 " Widget\told, new;\n"
5113 "};\nextern Wedged( Widget new, Widget old );";
5117 * Incorrect sprintf declaration in X11/Xmu.h
5120 hackname = x11_sprintf;
5122 files = X11/Xmu/Xmu.h;
5123 select = "^extern char \\*\tsprintf\\(\\);$";
5126 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5128 test_text = "extern char *\tsprintf();";