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 * SDKs for
10.13 and
10.14 omit the definitions for API_AVAILABLE where
199 * __attribute__((availability
)) is not supported.
202 hackname
= darwin_api_availability
;
203 mach
= "*-*-darwin*";
204 files
= os
/availability.h
;
205 bypass
= "__IPHONE_OS_VERSION_MIN_REQUIRED";
207 " *#define __API_AVAILABLE.*\n"
208 " *#define __API_DEPRECATED.*\n"
209 " *#define __API_DEPRECATED_WITH_REPLACEMENT.*\n"
210 " *#define __API_UNAVAILABLE.*\n";
213 " #define API_AVAILABLE(...)\n"
214 " #define API_DEPRECATED(...)\n"
215 " #define API_DEPRECATED_WITH_REPLACEMENT(...)\n"
216 " #define API_UNAVAILABLE(...)\n";
218 "#define __API_AVAILABLE(...)\n"
219 "#define __API_DEPRECATED(...)\n"
220 "#define __API_DEPRECATED_WITH_REPLACEMENT(...)\n"
221 "#define __API_UNAVAILABLE(...)\n";
225 * This fixes __FD_ZERO bug for linux
2.x.
y (x
<= 2 && y
<= some n
)
228 hackname
= AAB_fd_zero_asm_posix_types_h
;
229 files
= asm
/posix_types.h
;
230 mach
= 'i[34567]86-*-linux*';
233 bypass
= 'posix_types_64';
236 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper
, not
237 * the start
, so that if #include_next gets another instance of
238 * the wrapper
, this will follow the #include_next chain until
239 * we arrive at the real
<asm
/posix_types.h
>.
241 replace
= <<- _EndOfHeader_
242 /* This file fixes a bug in the __FD_ZERO macro
243 for older versions of the Linux kernel.
*/
244 #ifndef _POSIX_TYPES_H_WRAPPER
245 #include
<features.h
>
246 #include_next
<asm
/posix_types.h
>
248 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
250 #define
__FD_ZERO(fdsetp
) \
253 __asm__
__volatile__("cld ; rep ; stosl" \
254 : "=&c" (__d0
), "=&D" (__d1
) \
255 : "a" (0), "0" (__FDSET_LONGS
), \
256 "1" ((__kernel_fd_set *)
(fdsetp
)) :"memory"); \
260 #define _POSIX_TYPES_H_WRAPPER
261 #endif
/* _POSIX_TYPES_H_WRAPPER
*/
266 * This fixes __FD_ZERO bug for glibc
-1.x
269 hackname
= AAB_fd_zero_gnu_types_h
;
271 mach
= 'i[34567]86-*-linux*';
274 * Define _TYPES_H_WRAPPER at the end of the wrapper
, not
275 * the start
, so that if #include_next gets another instance of
276 * the wrapper
, this will follow the #include_next chain until
277 * we arrive at the real
<gnu
/types.h
>.
279 replace
= <<- _EndOfHeader_
280 /* This file fixes a bug in the __FD_ZERO macro present in glibc
1.x.
*/
281 #ifndef _TYPES_H_WRAPPER
282 #include
<features.h
>
283 #include_next
<gnu
/types.h
>
285 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
287 # define
__FD_ZERO(fdsetp
) \
290 __asm__
__volatile__("cld ; rep ; stosl" \
291 : "=&c" (__d0
), "=&D" (__d1
) \
292 : "a" (0), "0" (__FDSET_LONGS
), \
293 "1" ((__fd_set *)
(fdsetp
)) :"memory"); \
297 #define _TYPES_H_WRAPPER
298 #endif
/* _TYPES_H_WRAPPER
*/
303 * This fixes __FD_ZERO bug for glibc
-2.0.x
306 hackname
= AAB_fd_zero_selectbits_h
;
307 files
= selectbits.h
;
308 mach
= 'i[34567]86-*-linux*';
311 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper
, not
312 * the start
, so that if #include_next gets another instance of
313 * the wrapper
, this will follow the #include_next chain until
314 * we arrive at the real
<selectbits.h
>.
316 replace
= <<- _EndOfHeader_
317 /* This file fixes a bug in the __FD_ZERO macro present in glibc
2.0.x.
*/
318 #ifndef _SELECTBITS_H_WRAPPER
319 #include
<features.h
>
320 #include_next
<selectbits.h
>
322 #if
defined(__FD_ZERO
) && defined(__GLIBC__
) \\
323 && defined(__GLIBC_MINOR__
) && __GLIBC__
== 2 \\
324 && __GLIBC_MINOR__
== 0
326 #define
__FD_ZERO(fdsetp
) \\
329 __asm__
__volatile__ ("cld; rep; stosl" \\
330 : "=&c" (__d0
), "=&D" (__d1
) \\
331 : "a" (0), "0" (sizeof (__fd_set
) \\
332 / sizeof (__fd_mask
)), \\
333 "1" ((__fd_mask *)
(fdsetp
)) \\
338 #define _SELECTBITS_H_WRAPPER
339 #endif
/* _SELECTBITS_H_WRAPPER
*/
344 * Solaris
<sys
/varargs.h
> is a
DDK (aka kernel
-land
) header providing
345 * the same interface as
<stdarg.h
>. No idea why they couldn
't have just
346 * used the standard header.
349 hackname = AAB_solaris_sys_varargs_h;
350 files = "sys/varargs.h";
351 mach = '*-*-solaris
*';
352 replace = <<- _EndOfHeader_
362 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
363 * declaration on Sun OS
4.x. We must only fix this on Sun OS
4.x
, because
364 * many other systems have similar text but correct versions of the file.
365 * To ensure only Sun
's is fixed, we grep for a likely unique string.
366 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
369 hackname = AAB_sun_memcpy;
371 select = "/\\*\t@\\(#\\)"
372 "(head/memory.h\t50.1\t "
373 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
375 replace = <<- _EndOfHeader_
376 /* This file was generated by fixincludes */
381 extern void *memccpy();
382 extern void *memchr();
383 extern void *memcpy();
384 extern void *memset();
386 extern char *memccpy();
387 extern char *memchr();
388 extern char *memcpy();
389 extern char *memset();
390 #endif /* __STDC__ */
394 #endif /* __memory_h__ */
399 * Fix assert.h on VxWorks:
402 hackname = AAB_vxworks_assert;
404 mach = "*-*-vxworks*";
406 replace = <<- _EndOfHeader_
418 #if defined(__STDC__) || defined(__cplusplus)
419 extern void __assert (const char*);
421 extern void __assert ();
425 #define assert(ign) ((void)0)
428 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
429 #define ASSERT_STRINGIFY_HELPER(str) #str
431 #define assert(test) ((void) \
432 ((test) ? ((void)0) : \
433 __assert("Assertion failed: " #test ", file " \
434 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
445 * Add needed include to regs.h (NOT the gcc header) on VxWorks
449 hackname = AAB_vxworks_regs_vxtypes;
451 mach = "*-*-vxworks*";
453 replace = <<- _EndOfHeader_
456 /* regs.h depends on CPU_FAMILY being properly defined, which
457 is done by vxCpu.h. */
458 #include <types/vxCpu.h>
459 /* regs.h includes a CPU_FAMILY-specific header that requires
460 vxTypesOld.h to already have been included. Those headers
461 contain proper _ASMLANGUAGE guards around their typedefs,
462 but vxTypesOld.h itself does not. So we avoid including
463 vxTypesOld.h from assembly. */
465 #include <types/vxTypesOld.h>
467 #include_next <arch/../regs.h>
473 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
476 hackname = AAB_vxworks_unistd;
478 mach = "*-*-vxworks*";
480 replace = <<- _EndOfHeader_
483 #include_next <unistd.h>
486 #define STDIN_FILENO 0
488 #ifndef STDOUT_FILENO
489 #define STDOUT_FILENO 1
491 #ifndef STDERR_FILENO
492 #define STDERR_FILENO 2
494 #endif /* _UNISTD_H */
499 * assert.h on AIX 7 redefines static_assert as _Static_assert without
503 hackname = aix_assert;
506 select = "#define[ \t]static_assert[ \t]_Static_assert";
508 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
509 test_text = "#define static_assert _Static_assert";
513 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
514 * which only is provided by AIX xlc C99.
517 hackname = aix_complex;
520 select = "#define[ \t]_Complex_I[ \t]__I";
522 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
523 test_text = "#define _Complex_I __I\n";
527 * On AIX some headers are not properly guarded by 'extern
"C"'.
530 hackname = aix_externc;
536 files = sys/localedef.h;
538 bypass = "extern \"C\"";
540 c_fix_arg = "#ifdef __cplusplus\n"
543 c_fix_arg = "#ifdef __cplusplus\n"
546 test_text = "extern int __n_pthreads;\n";
550 * On AIX sys/socket.h assumes C++.
553 hackname = aix_externcpp1;
555 files = "sys/socket.h";
556 select = "#ifndef _KERNEL\n"
557 "#ifdef __cplusplus";
559 c_fix_arg = "#ifndef _KERNEL\n"
560 "#ifdef __cplusplus\n"
562 test_text = "#ifndef _KERNEL\n"
563 "#ifdef __cplusplus";
567 hackname = aix_externcpp2;
569 files = "sys/socket.h";
570 select = "#endif /\\* COMPAT_43 \\*/\n"
571 "#else /\\* __cplusplus \\*/";
573 c_fix_arg = "#endif /* COMPAT_43 */\n"
574 "} /* extern \"C++\" */\n"
575 "#else /* __cplusplus */";
576 test_text = "#endif /* COMPAT_43 */\n"
577 "#else /* __cplusplus */";
581 * inttypes.h STDC_FORMAT_MACROS
584 hackname = aix_inttypes;
586 files = "sys/inttypes.h";
587 select = "#if !defined\\(__cplusplus\\) \\|\\| defined\\(__STDC_FORMAT_MACROS\\)";
590 test_text = "#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)";
594 * malloc.h on AIX6 uses XLC++ specific builtin syntax
597 hackname = aix_malloc;
600 select = "#ifdef __cplusplus\n"
602 "[ \t]extern \"builtin\" char \\*__alloca \\(size_t\\);";
604 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
606 "\textern \"builtin\" char *__alloca (size_t);";
607 test_text = "#ifdef __cplusplus\n"
609 "\textern \"builtin\" char *__alloca (size_t);";
613 * net/if_arp.h defines a variable fc_softc instead of adding a
614 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
617 hackname = aix_net_if_arp;
619 files = "net/if_arp.h";
620 select = "^struct fc_softc \\{";
622 c_fix_arg = "typedef struct _fc_softc {";
623 test_text = "struct fc_softc {\n int a;\n};";
627 * Fix AIX definition of NULL for G++.
632 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
633 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
635 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
637 c_fix_arg = <<- _EOFix_
642 #else /* ! __GNUG__ */
644 #endif /* __GNUG__ */
645 #else /* ! __cplusplus */
646 #define NULL ((void *)0)
647 #endif /* __cplusplus */
650 test_text = "# define\tNULL \t(0L) /* typed NULL */";
654 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
655 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
659 hackname = aix_once_init_1;
662 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
665 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
667 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
672 hackname = aix_once_init_2;
675 select = "[ \t]0 \\\\\n"
678 c_fix_arg = " 0 \\\n"
680 test_text = " 0 \\\\\n"
685 hackname = aix_mutex_initializer_1;
688 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
691 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
693 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
698 hackname = aix_cond_initializer_1;
701 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
704 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
706 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
711 hackname = aix_rwlock_initializer_1;
714 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
717 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
719 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
724 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
725 * which violates a requirement of ISO C.
728 hackname = aix_pthread;
730 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
733 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
734 "{...init stuff...}";
738 * AIX stdint.h fixes.
741 hackname = aix_stdint_1;
743 files = stdint-aix.h, stdint.h;
744 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
745 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
747 c_fix_arg = "#define UINT8_MAX (255)\n"
748 "#define UINT16_MAX (65535)";
749 test_text = "#define UINT8_MAX (255U)\n"
750 "#define UINT16_MAX (65535U)";
757 hackname = aix_stdint_2;
759 files = stdint-aix.h, stdint.h;
760 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
761 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
762 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
764 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
765 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
766 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
768 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
769 "#define INTPTR_MAX 9223372036854775807L\n"
770 "#define UINTPTR_MAX 18446744073709551615UL\n"
772 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
773 "#define INTPTR_MAX 2147483647L\n"
774 "#define UINTPTR_MAX 4294967295UL";
775 test_text = "#define INTPTR_MIN INT64_MIN\n"
776 "#define INTPTR_MAX INT64_MAX\n"
777 "#define UINTPTR_MAX UINT64_MAX\n"
779 "#define INTPTR_MIN INT32_MIN\n"
780 "#define INTPTR_MAX INT32_MAX\n"
781 "#define UINTPTR_MAX UINT32_MAX";
788 hackname = aix_stdint_3;
790 files = stdint-aix.h, stdint.h;
791 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
792 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
794 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
795 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
797 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
798 "#define PTRDIFF_MAX 9223372036854775807L\n"
800 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
801 "#define PTRDIFF_MAX 2147483647L";
802 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
803 "#define PTRDIFF_MAX INT64_MAX\n"
805 "#define PTRDIFF_MIN INT32_MIN\n"
806 "#define PTRDIFF_MAX INT32_MAX";
813 hackname = aix_stdint_4;
815 files = stdint-aix.h, stdint.h;
816 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
818 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
820 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
822 "#define SIZE_MAX 4294967295UL";
823 test_text = "#define SIZE_MAX UINT64_MAX\n"
825 "#define SIZE_MAX UINT32_MAX";
832 hackname = aix_stdint_5;
834 files = stdint-aix.h, stdint.h;
835 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
836 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
838 c_fix_arg = "#define UINT8_C(c) c\n"
839 "#define UINT16_C(c) c";
840 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
841 "#define UINT16_C(c) __CONCAT__(c,U)";
845 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
846 produces wrong code with G++.
849 hackname = aix_stdio_inline;
852 select = "#ifdef __cplusplus\\\n"
856 c_fix_arg = "#ifdef __cplusplus\n"
859 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
861 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
865 * stdlib.h on AIX uses #define on malloc and friends.
868 hackname = aix_stdlib_malloc;
871 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
873 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
874 test_text = "#define malloc __linux_malloc";
878 hackname = aix_stdlib_realloc;
881 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
883 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
884 test_text = "#define realloc __linux_realloc";
888 hackname = aix_stdlib_calloc;
891 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
893 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
894 test_text = "#define calloc __linux_calloc";
898 hackname = aix_stdlib_valloc;
901 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
903 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
904 test_text = "#define valloc __linux_valloc";
908 hackname = aix_stdlib_vec_malloc;
911 select = "#define[ \t]+malloc[ \t]+vec_malloc";
913 c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
914 test_text = "#define malloc vec_malloc";
918 hackname = aix_stdlib_vec_calloc;
921 select = "#define[ \t]+calloc[ \t]+vec_calloc";
923 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
924 test_text = "#define calloc vec_calloc";
928 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
931 hackname = aix_strtof_const;
934 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
936 c_fix_arg = "%1(const char *, char **);";
937 test_text = "extern float strtof(char *, char **);";
941 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
942 * in an otherwise harmless (and #ifed out) macro definition
945 hackname = aix_sysmachine;
947 files = sys/machine.h;
951 test_text = "#define FOO \\\n"
952 " bar \\ \n baz \\ \n bat";
956 * sys/wait.h on AIX 5.2 defines macros that have both signed and
957 * unsigned types in conditional expressions.
960 hackname = aix_syswait_2;
963 select = '\? (\
(\
(\
(\
(unsigned
[^
)]*\
)[^
)]*\
) >> [^
)]*\
) \
& 0xff\
) : -1)';
965 c_fix_arg = "? (int)%1";
966 test_text = "#define WSTOPSIG(__x) "
967 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
971 * sys/signal.h on some versions of AIX uses volatile in the typedef of
972 * sig_atomic_t, which causes gcc to generate a warning about duplicate
973 * volatile when a sig_atomic_t variable is declared volatile, as
974 * required by ANSI C.
977 hackname = aix_volatile;
979 files = sys/signal.h;
980 select = "typedef volatile int sig_atomic_t";
982 c_fix_arg = "typedef int sig_atomic_t";
983 test_text = "typedef volatile int sig_atomic_t;";
987 * AIX unistd.h defines a static function with an empty parameter list.
990 hackname = aix_unistd;
994 select = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
996 c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
997 test_text = " static int getdtablesize()";
1001 * Fix __assert declaration in assert.h on Alpha OSF/1.
1004 hackname = alpha___assert;
1006 select = '__assert\
(char \
*, char \
*, int\
)';
1008 c_fix_arg = "__assert(const char *, const char *, int)";
1009 test_text = 'extern void
__assert(char
*, char
*, int
);';
1013 * Fix assert macro in assert.h on Alpha OSF/1.
1014 * The superfluous int cast breaks C++.
1017 hackname = alpha_assert;
1019 select = "(#[ \t]*" 'define assert\
(EX\
).*)\
(\
(int\
) \
(EX\
)\
)';
1021 c_fix_arg = "%1(EX)";
1022 test_text = '#define
assert(EX
) (((int
) (EX
)) ?
(void
)0 '
1023 ': __assert(#EX
, __FILE__
, __LINE__
))';
1027 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1030 hackname = alpha_getopt;
1033 select = 'getopt\
(int
, char \
*\
[\
], *char \
*\
)';
1035 c_fix_arg = "getopt(int, char *const[], const char *)";
1036 test_text = 'extern int
getopt(int
, char
*[], char *)
;';
1040 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
1043 hackname = alpha_if_semicolon;
1045 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
1047 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
1048 test_text = ' struct sockaddr vmif_paddr
/* protocol address
*/';
1052 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1055 hackname = alpha_parens;
1057 select = '#ifndef\
(__mips64\
)';
1059 c_fix_arg = "#ifndef __mips64";
1060 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1064 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1068 hackname = alpha_sbrk;
1070 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1072 c_fix_arg = "void *sbrk(";
1073 test_text = "extern char* sbrk(ptrdiff_t increment);";
1077 * For C++, avoid any typedef or macro definition of bool,
1078 * and use the built in type instead.
1079 * HP/UX 10.20 also has it in curses_colr/curses.h.
1082 hackname = avoid_bool_define;
1084 files = curses_colr/curses.h;
1088 select = "#[ \t]*define[ \t]+bool[ \t]";
1089 bypass = "__cplusplus";
1092 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1093 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1095 test_text = "# define bool\t char \n";
1102 hackname = avoid_bool_type;
1104 files = curses_colr/curses.h;
1108 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1109 bypass = "__cplusplus";
1112 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1114 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1118 * For C++, avoid any typedef definition of wchar_t,
1119 * and use the built in type instead.
1120 * Don't do this for headers that are smart enough to do the right
1121 * thing (recent
[n
]curses.h and Xlib.h
).
1122 * Don
't do it for <linux/nls.h> which is never used from C++ anyway,
1123 * and will be broken by the edit.
1127 hackname = avoid_wchar_t_type;
1129 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1130 bypass = "__cplusplus";
1131 bypass = "_LINUX_NLS_H";
1132 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1135 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1137 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1141 * Fix `typedef struct term;' on hppa1.1
-hp
-hpux9.
1144 hackname
= bad_struct_term
;
1146 select
= "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1148 c_fix_arg
= "struct term;";
1150 test_text
= 'typedef struct term;';
1154 * Fix one other error in this file
:
1155 * a mismatched quote not inside a C comment.
1158 hackname
= badquote
;
1159 files
= sundev
/vuid_event.h
;
1162 c_fix_arg
= "does not";
1164 test_text
= "/* doesn't have matched single quotes */";
1168 * check for broken assert.h that needs stdio.h
1171 hackname
= broken_assert_stdio
;
1174 bypass
= "include.*stdio\\.h";
1176 c_fix_arg
= "#include <stdio.h>\n";
1177 test_text
= "extern FILE* stderr;";
1181 * check for broken assert.h that needs stdlib.h
1184 hackname
= broken_assert_stdlib
;
1186 select
= 'exit *\(|abort *\(';
1187 bypass
= "include.*stdlib\\.h";
1189 c_fix_arg
= "#ifdef __cplusplus\n"
1190 "#include <stdlib.h>\n"
1192 test_text
= "extern void exit ( int );";
1196 * Remove `extern double cabs
' declarations from math.h.
1197 * This conflicts with C99. Discovered on AIX.
1198 * Darwin hides its broken cabs in architecture-specific subdirs.
1201 hackname = broken_cabs;
1202 files = math.h, "architecture/*/math.h";
1203 select = "^extern[ \t]+double[ \t]+cabs";
1205 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1206 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1208 test_text = "#ifdef __STDC__\n"
1209 "extern double cabs(struct dbl_hypot);\n"
1211 "extern double cabs();\n"
1213 "extern double cabs ( _Complex z );";
1217 * Fixup Darwin's broken check for __builtin_nanf.
1220 hackname
= broken_nan
;
1222 * It is tempting to omit the first
"files" entry. Do not.
1223 * The testing machinery will take the first
"files" entry as the name
1224 * of a test file to play with. It would be a nuisance to have a directory
1225 * with the name
"*".
1227 files
= "architecture/ppc/math.h";
1228 files
= "architecture/*/math.h";
1229 select
= '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1232 c_fix_arg
= "#if 1";
1233 test_text
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1237 * Various systems derived from BSD4.4 contain a macro definition
1238 * for vfscanf that interacts badly with requirements of builtin
-attrs.def.
1239 * Known to be fixed in FreeBSD
5 system headers.
1242 hackname
= bsd_stdio_attrs_conflict
;
1244 mach
= "*-*-*darwin*";
1246 select
= "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1248 c_fix_arg
= '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1249 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1250 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1251 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1252 test_text
= '#define vfscanf __svfscanf';
1256 * Fix various macros used to define ioctl numbers.
1257 * The traditional syntax was
:
1259 * #define
_CTRL(n
, x
) (('n'<<8)+x
)
1260 * #define TCTRLCFOO
_CTRL(T
, 1)
1262 * but this does not work with the C standard
, which disallows macro
1263 * expansion inside strings. We have to rewrite it thus
:
1265 * #define
_CTRL(n
, x
) ((n
<<8)+x
)
1266 * #define TCTRLCFOO
_CTRL('T', 1)
1268 * The select expressions match too much
, but the c_fix code is cautious.
1270 * CTRL might be
: CTRL _CTRL ISCTRL BSD43_CTRL ...
1273 hackname
= ctrl_quotes_def
;
1274 select
= "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1275 c_fix
= char_macro_def
;
1279 * This is two tests in order to ensure that the
"CTRL(c)" can
1280 * be selected in isolation from the multi
-arg format
1282 test_text
= "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1283 test_text
= "#define _CTRL(c) ('c'&037)";
1287 * Fix various macros used to define ioctl numbers.
1290 hackname
= ctrl_quotes_use
;
1291 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1292 c_fix
= char_macro_use
;
1294 test_text
= "#define TCTRLFOO BSD43_CTRL(T, 1)";
1298 * sys
/mman.h on HP
/UX is not C
++ ready
,
1299 * even though NO_IMPLICIT_EXTERN_C is defined on HP
/UX.
1301 * rpc
/types.h on OSF1
/2.0 is not C
++ ready
,
1302 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1304 * The problem is the declaration of malloc.
1307 hackname
= cxx_unready
;
1309 files
= rpc
/types.h
;
1310 select
= '[^#]+malloc.*;'; /* Catch any form of declaration
1311 not within a macro.
*/
1312 bypass
= '"C"|__BEGIN_DECLS';
1315 c_fix_arg
= "#ifdef __cplusplus\n"
1318 c_fix_arg
= "#ifdef __cplusplus\n"
1321 test_text
= "extern void* malloc( size_t );";
1325 * macOS
10.12 <AvailabilityInternal.h
> uses
__attribute__((availability
))
1329 hackname
= darwin_availabilityinternal
;
1330 mach
= "*-*-darwin*";
1331 files
= AvailabilityInternal.h
;
1332 select
= "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1334 c_fix_arg
= <<- _EOFix_
1335 #if
defined(__has_attribute
)
1336 #if
__has_attribute(availability
)
1346 test_text
= "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1347 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1351 * For the AAB_darwin7_9_long_double_funcs
fix (and later fixes for long long
)
1352 * to be useful
, the main math.h must use
<> and not
"" includes.
1355 hackname
= darwin_9_long_double_funcs_2
;
1356 mach
= "*-*-darwin*";
1358 select
= '#include[ \t]+\"';
1360 c_fix_arg
= "%1<%2.h>";
1362 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1364 test_text
= '#include <architecture/ppc/math.h>';
1368 * On darwin8 and earlier
, mach
-o
/swap.h isn
't properly guarded
1369 * by 'extern
"C"'. On darwin7 some mach/ headers aren't properly guarded.
1372 hackname
= darwin_externc
;
1373 mach
= "*-*-darwin*";
1374 files
= mach
-o
/swap.h
;
1375 files
= mach
/mach_time.h
;
1376 files
= mach
/mach_traps.h
;
1377 files
= mach
/message.h
;
1379 files
= mach
/semaphore.h
;
1380 bypass
= "extern \"C\"";
1381 bypass
= "__BEGIN_DECLS";
1383 c_fix_arg
= "#ifdef __cplusplus\n"
1386 c_fix_arg
= "#ifdef __cplusplus\n"
1389 test_text
= "extern void swap_fat_header();\n";
1393 * AvailabilityMacros.h on Darwin breaks with GCC
4.0, because of
1394 * bad __GNUC__ tests.
1397 hackname
= darwin_gcc4_breakage
;
1398 mach
= "*-*-darwin*";
1399 files
= AvailabilityMacros.h
;
1400 select
= "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1402 c_fix_arg
= "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1403 test_text
= "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1404 "(__GNUC_MINOR__ >= 1)\n";
1408 * math.h hides the long long functions that are available on the system for
1409 * 10.5 and
10.6 SDKs
, we expect to use them in G
++ without specifying a value
1410 * for __STDC_VERSION__
, or switching __STRICT_ANSI__ off.
1413 hackname
= darwin_ll_funcs_avail
;
1414 mach
= "*-*-darwin*";
1415 files
= architecture
/ppc
/math.h
, architecture
/i386
/math.h
;
1416 select
= "#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^1]*199901L[^_]*"
1417 "__STRICT_ANSI__[^_]*__GNUC__[^\)]*";
1418 sed
= "s/#if[^_]*__STDC_VERSION__[^_]*__STDC_VERSION__[^_]*199901L[^_]*"
1419 "__STRICT_ANSI__[^_]*__GNUC__[^\\)]*\)/#if\ !\(__DARWIN_NO_LONG_LONG\)/";
1420 test_text
= "#if\ !(__DARWIN_NO_LONG_LONG)";
1424 * Before Mac OS X
10.8 <i386
/setjmp.h
> doesn
't mark longjump noreturn.
1427 hackname = darwin_longjmp_noreturn;
1428 mach = "*-*-darwin*";
1429 files = "i386/setjmp.h";
1431 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1433 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1435 test_text = "void siglongjmp(sigjmp_buf, int);";
1439 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1442 hackname = darwin_os_trace_1;
1443 mach = "*-*-darwin*";
1445 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1448 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1452 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1453 * extension without guard.
1456 hackname = darwin_os_trace_2;
1457 mach = "*-*-darwin*";
1459 select = "typedef.*\\^os_trace_payload_t.*";
1461 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1462 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1466 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1467 * os_trace_payload_t typedef, too.
1470 hackname = darwin_os_trace_3;
1471 mach = "*-*-darwin*";
1473 select = <<- _EOSelect_
1477 _os_trace.*os_trace_payload_t payload);
1480 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1481 test_text = <<- _EOText_
1482 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1483 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1485 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1487 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1488 OS_EXPORT OS_NOTHROW
1490 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1495 * In macOS 10.10 <os/base.h>, doesn't have __has_extension guarded.
1498 hackname
= darwin_os_base_1
;
1499 mach
= "*-*-darwin*";
1501 select
= <<- OS_BASE_1_SEL
1502 #define __has_attribute.
*
1506 c_fix_arg
= <<- OS_BASE_1_FIX
1508 #ifndef __has_extension
1509 #define
__has_extension(x
) 0
1512 test_text
= <<- OS_BASE_1_TEST
1513 #define
__has_attribute(x
) 0
1521 * In macOS
10.10 <dispatch
/object.h
>, has unguarded block syntax.
1524 hackname
= darwin_dispatch_object_1
;
1525 mach
= "*-*-darwin*";
1526 files
= dispatch
/object.h
;
1527 select
= "typedef void.*\\^dispatch_block_t.*";
1529 c_fix_arg
= "#if __BLOCKS__\n%0\n#endif";
1530 test_text
= <<- DISPATCH_OBJECT_1_TEST
1531 typedef
void (^dispatch_block_t
)(void
);
1534 DISPATCH_OBJECT_1_TEST
;
1538 * __private_extern__ doesn
't exist in FSF GCC. Even if it did,
1539 * why would you ever put it in a system header file?
1542 hackname = darwin_private_extern;
1543 mach = "*-*-darwin*";
1544 files = mach-o/dyld.h;
1545 select = "__private_extern__ [a-z_]+ _dyld_";
1547 c_fix_arg = "extern";
1548 c_fix_arg = "__private_extern__";
1549 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1550 "const char *dyld_func_name,\n"
1551 "unsigned long *address);\n";
1555 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1556 * unsigned constants.
1559 hackname = darwin_stdint_1;
1560 mach = "*-*-darwin*";
1561 files = stdint-darwin.h, stdint.h;
1563 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1564 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1565 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1566 test_text = "#define UINT8_C(v) (v ## U)\n"
1567 "#define UINT16_C(v) (v ## U)";
1571 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1575 hackname = darwin_stdint_2;
1576 mach = "*-*-darwin*";
1577 files = stdint-darwin.h, stdint.h;
1579 c_fix_arg = "#if __WORDSIZE == 64\n"
1580 "#define INTPTR_MAX 9223372036854775807L\n"
1581 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1583 "#define INTPTR_MAX 2147483647L\n"
1584 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1586 select = "#if __WORDSIZE == 64\n"
1587 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1588 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1590 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1591 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1593 test_text = "#if __WORDSIZE == 64\n"
1594 "#define INTPTR_MIN INT64_MIN\n"
1595 "#define INTPTR_MAX INT64_MAX\n"
1597 "#define INTPTR_MIN INT32_MIN\n"
1598 "#define INTPTR_MAX INT32_MAX\n"
1603 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1606 hackname = darwin_stdint_3;
1607 mach = "*-*-darwin*";
1608 files = stdint-darwin.h, stdint.h;
1610 c_fix_arg = "#if __WORDSIZE == 64\n"
1611 "#define UINTPTR_MAX 18446744073709551615UL\n"
1613 "#define UINTPTR_MAX 4294967295UL\n"
1615 select = "#if __WORDSIZE == 64\n"
1616 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1618 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1620 test_text = "#if __WORDSIZE == 64\n"
1621 "#define UINTPTR_MAX UINT64_MAX\n"
1623 "#define UINTPTR_MAX UINT32_MAX\n"
1628 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1631 hackname = darwin_stdint_4;
1632 mach = "*-*-darwin*";
1633 files = stdint-darwin.h, stdint.h;
1635 c_fix_arg = "#if __WORDSIZE == 64\n"
1636 "#define SIZE_MAX 18446744073709551615UL\n"
1638 "#define SIZE_MAX 4294967295UL\n"
1640 select = "#if __WORDSIZE == 64\n"
1641 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1643 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1645 test_text = "#if __WORDSIZE == 64\n"
1646 "#define SIZE_MAX UINT64_MAX\n"
1648 "#define SIZE_MAX UINT32_MAX\n"
1653 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1654 * with a wrong type.
1657 hackname = darwin_stdint_5;
1658 mach = "*-*-darwin*";
1659 files = stdint-darwin.h, stdint.h;
1661 c_fix_arg = "#if __WORDSIZE == 64\n"
1662 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1663 "#define INTMAX_MAX 9223372036854775807L\n"
1664 "#define UINTMAX_MAX 18446744073709551615UL\n"
1666 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1667 "#define INTMAX_MAX 9223372036854775807LL\n"
1668 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1670 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1671 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1673 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1674 test_text = "#define INTMAX_MIN INT64_MIN\n"
1675 "#define INTMAX_MAX INT64_MAX\n"
1677 "#define UINTMAX_MAX UINT64_MAX";
1681 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1682 * with a wrong type.
1685 hackname = darwin_stdint_6;
1686 mach = "*-*-darwin*";
1687 files = stdint-darwin.h, stdint.h;
1689 c_fix_arg = "#if __WORDSIZE == 64\n"
1690 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1691 "#define PTRDIFF_MAX 9223372036854775807L\n"
1693 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1694 "#define PTRDIFF_MAX 2147483647\n"
1696 select = "#if __WORDSIZE == 64\n"
1697 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1698 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1700 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1701 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1703 test_text = "#if __WORDSIZE == 64\n"
1704 "#define PTRDIFF_MIN INT64_MIN\n"
1705 "#define PTRDIFF_MAX INT64_MAX\n"
1707 "#define PTRDIFF_MIN INT32_MIN\n"
1708 "#define PTRDIFF_MAX INT32_MAX\n"
1713 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1714 * with a wrong type.
1717 hackname = darwin_stdint_7;
1718 mach = "*-*-darwin*";
1719 files = stdint-darwin.h, stdint.h;
1721 c_fix_arg = "#if __WORDSIZE == 64\n"
1722 "#define INTMAX_C(v) (v ## L)\n"
1723 "#define UINTMAX_C(v) (v ## UL)\n"
1725 "#define INTMAX_C(v) (v ## LL)\n"
1726 "#define UINTMAX_C(v) (v ## ULL)\n"
1728 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1729 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1730 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1731 "#define UINTMAX_C(v) (v ## ULL)";
1734 /* The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
1735 C11 _Atomic keyword (exposing it to C++ code). The work-around here follows
1736 the header in declaring the entity volatile when _Atomic is not available.
1739 hackname = darwin_ucred__Atomic;
1740 mach = "*-*-darwin*";
1741 files = sys/ucred.h;
1744 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1745 "# define _Atomic volatile\n"
1747 c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
1750 test_text = ""; /* Don't provide this for wrap fixes.
*/
1754 * Fix
<c_asm.h
> on Digital UNIX V4.0
:
1755 * It contains a prototype for a
DEC C internal
asm() function
,
1756 * clashing with gcc
's asm keyword. So protect this with __DECC.
1759 hackname = dec_intern_asm;
1761 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1762 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1766 " ... asm stuff ...\n"
1767 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1771 * Fix typo in <wchar.h> on DJGPP 2.03.
1774 hackname = djgpp_wchar_h;
1776 select = "__DJ_wint_t";
1777 bypass = "sys/djtypes.h";
1779 c_fix_arg = "%0\n#include <sys/djtypes.h>";
1780 c_fix_arg = "#include <stddef.h>";
1781 test_text = "#include <stddef.h>\n"
1782 "extern __DJ_wint_t x;\n";
1786 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1789 hackname = ecd_cursor;
1790 files = "sunwindow/win_lock.h";
1791 files = "sunwindow/win_cursor.h";
1792 select = 'ecd\.cursor
';
1794 c_fix_arg = 'ecd_cursor
';
1796 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1800 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1801 * that fails when compiling for SSE-less 32-bit x86.
1804 hackname = feraiseexcept_nosse_divbyzero;
1805 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1806 files = bits/fenv.h, '*/bits
/fenv.h
';
1807 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1808 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1809 bypass = "\"fdivp .*; fwait\"";
1812 c_fix_arg = <<- _EOText_
1813 # ifdef __SSE_MATH__
1816 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1817 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1821 test_text = <<- _EOText_
1822 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1827 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1828 * that fails when compiling for SSE-less 32-bit x86.
1831 hackname = feraiseexcept_nosse_invalid;
1832 mach = 'i
[34567]86-*-linux
*', 'x86
*-linux
*', 'amd64
-*-linux
*';
1833 files = bits/fenv.h, '*/bits
/fenv.h
';
1834 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1835 ": \"x\" \\(__f\\)\\);$";
1836 bypass = "\"fdiv .*; fwait\"";
1839 c_fix_arg = <<- _EOText_
1840 # ifdef __SSE_MATH__
1843 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1844 %1 : "=t" (__f) : "0" (__f));
1848 test_text = <<- _EOText_
1849 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1854 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1855 * neither the existence of GCC 3 nor its exact feature set yet break
1856 * (by design?) when __GNUC__ is set beyond 2.
1859 hackname = freebsd_gcc3_breakage;
1860 mach = "*-*-freebsd*";
1861 files = sys/cdefs.h;
1862 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7$
';
1863 bypass = '__GNUC__
[ \t]*([>=]=[ \t]*[3-9]|
>[ \t]*2)';
1865 c_fix_arg = '%0 || __GNUC__
>= 3';
1866 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7';
1870 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1871 * neither the existence of GCC 4 nor its exact feature set yet break
1872 * (by design?) when __GNUC__ is set beyond 3.
1875 hackname = freebsd_gcc4_breakage;
1876 mach = "*-*-freebsd*";
1877 files = sys/cdefs.h;
1878 select = '^#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 \|\| __GNUC__
== 3$
';
1880 c_fix_arg = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
>= 3';
1881 test_text = '#if __GNUC__
== 2 && __GNUC_MINOR__
>= 7 || __GNUC__
== 3';
1885 * Some versions of glibc don't expect the C99 inline semantics.
1888 hackname
= glibc_c99_inline_1
;
1889 files
= features.h
, '*/features.h';
1890 select
= "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1892 c_fix_arg
= "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1894 #if
__GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1895 && !defined __OPTIMIZE_SIZE__
&& !defined __NO_INLINE__
1896 # define __USE_EXTERN_INLINES
1
1902 * Similar
, but a version that didn
't have __NO_INLINE__
1905 hackname = glibc_c99_inline_1a;
1906 files = features.h, '*/features.h
';
1907 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1908 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1910 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1912 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1913 # define __USE_EXTERN_INLINES 1
1919 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1920 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1921 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1924 hackname = glibc_c99_inline_2;
1925 files = sys/stat.h, '*/sys
/stat.h
';
1926 select = "extern __inline__ int";
1927 sed = "s/extern int \\(stat\\)/"
1928 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1929 "__inline__ int \\1/";
1930 sed = "s/extern int \\([lf]stat\\)/"
1931 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1932 "__inline__ int \\1/";
1933 sed = "s/extern int \\(mknod\\)/"
1934 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1935 "__inline__ int \\1/";
1936 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1937 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1938 "__inline__ int __REDIRECT\\1 (\\2/";
1939 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1940 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1941 "__inline__ int __REDIRECT\\1 (\\2/";
1942 sed = "s/^extern __inline__ int/"
1943 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1946 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1947 extern __inline__ int
1948 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1954 * glibc_c99_inline_3
1957 hackname = glibc_c99_inline_3;
1958 files = bits/string2.h, '*/bits
/string2.h
';
1959 select = "extern __inline";
1960 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1962 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1963 c_fix_arg = "^# ifdef __cplusplus$";
1966 # define __STRING_INLINE inline
1968 # define __STRING_INLINE extern __inline
1974 * glibc_c99_inline_4
1977 hackname = glibc_c99_inline_4;
1978 files = sys/sysmacros.h, '*/sys
/sysmacros.h
', wchar.h, '*/wchar.h
',
1979 pthread.h, '*/pthread.h
';
1980 bypass = "__extern_inline|__gnu_inline__";
1981 select = "(^| )extern __inline";
1983 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1985 __extension__ extern __inline unsigned int
1986 extern __inline unsigned int
1990 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1991 * so we replace them with versions that correspond to the
1995 hackname = glibc_mutex_init;
1997 select = '\
{ *\
{ *0, *\
} *\
}';
1998 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1999 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
2000 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2001 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
2002 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2003 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
2004 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
2005 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
2006 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2007 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
2008 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2009 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
2010 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
2011 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
2012 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
2013 "N;s/^[ \t]*#[ \t]*"
2014 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
2015 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
2017 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
2020 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
2022 sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
2023 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
2024 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
2025 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
2027 test_text = <<- _EOText_
2028 #define PTHREAD_MUTEX_INITIALIZER \\
2031 # if __WORDSIZE == 64
2032 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2033 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2034 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2035 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2036 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2037 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2039 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
2040 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
2041 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
2042 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
2043 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
2044 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
2047 # define PTHREAD_RWLOCK_INITIALIZER \\
2050 # if __WORDSIZE == 64
2051 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2052 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
2053 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2055 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
2056 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
2059 #define PTHREAD_COND_INITIALIZER { { 0, } }
2063 /* glibc versions before 2.5 have a version of stdint.h that defines
2064 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
2065 versions with stdint.h based on those glibc versions. */
2067 hackname = glibc_stdint;
2069 select = "GNU C Library";
2071 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
2072 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
2073 test_text = "/* This file is part of the GNU C Library. */\n"
2074 "# define UINT8_C(c)\tc ## U\n"
2075 "# define UINT16_C(c)\tc ## U";
2078 /* Some versions of glibc have a version of bits/string2.h that
2079 produces "value computed is not used" warnings from strncpy; fix
2080 this definition by using __builtin_strncpy instead as in newer
2083 hackname = glibc_strncpy;
2084 files = bits/string2.h, '*/bits
/string2.h
';
2085 bypass = "__builtin_strncpy";
2087 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
2088 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
2090 # define strncpy(dest, src, n) \
2091 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
2092 ? (strlen (src) + 1 >= ((size_t) (n)) \\
2093 ? (char *) memcpy (dest, src, n) \\
2094 : strncpy (dest, src, n)) \\
2095 : strncpy (dest, src, n)))
2100 /* glibc's tgmath.h relies on an expression that is not an integer
2101 constant expression being treated as it was by GCC
4.4 and
2104 hackname
= glibc_tgmath
;
2106 select
= '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
2107 bypass
= "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
2109 c_fix_arg
= "(__builtin_classify_type ((type) 0) == 8 || "
2110 "(__builtin_classify_type ((type) 0) == 9 && "
2111 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
2112 test_text
= "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
2116 * Fix these files to use the types we think they should for
2117 * ptrdiff_t
, size_t
, and wchar_t.
2119 * This defines the types in terms of macros predefined by our
'cpp'.
2120 * This is supposedly necessary for glibc
's handling of these types.
2121 * It's probably not necessary for anyone else
, but it doesn
't hurt.
2124 hackname = gnu_types;
2125 files = "sys/types.h";
2127 files = "sys/stdtypes.h";
2131 bypass = '_GCC_(PTRDIFF|
SIZE|WCHAR
)_T
';
2132 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
2134 /* The Solaris 10 headers already define these types correctly. */
2135 mach = '*-*-solaris2.1
[0-9]*';
2138 test_text = "typedef long int ptrdiff_t; /* long int */\n"
2139 "typedef uint_t size_t; /* uint_t */\n"
2140 "typedef ushort_t wchar_t; /* ushort_t */";
2144 * Fix HP & Sony's use of
"../machine/xxx.h"
2145 * to refer to
: <machine
/xxx.h
>
2148 hackname
= hp_inline
;
2149 files
= sys
/spinlock.h
;
2150 files
= machine
/machparam.h
;
2151 select
= "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
2154 c_fix_arg
= "%1<machine/%2.h>";
2156 c_fix_arg
= "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
2159 test_text
= ' # include "../machine/mumble.h"';
2163 * Check
for (...
) in C
++ code in HP
/UX sys
/file.h.
2166 hackname
= hp_sysfile
;
2168 select
= "HPUX_SOURCE";
2171 c_fix_arg
= "(struct file *, ...)";
2172 c_fix_arg
= '\(\.\.\.\)';
2174 test_text
= "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
2178 * Un
-Hide a series of five FP defines from post
-1999 compliance GCC
:
2179 * FP_NORMAL
, FP_ZERO
, FP_INFINITE
, FP_SUBNORMAL and FP_NAN
2182 hackname
= hppa_hpux_fp_macros
;
2183 mach
= "hppa*-hp-hpux11*";
2185 select
= "#[ \t]*define[ \t]*FP_NORMAL.*\n"
2186 "#[ \t]*define[ \t]*FP_ZERO.*\n"
2187 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
2188 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
2189 "#[ \t]*define[ \t]*FP_NAN.*\n";
2191 c_fix_arg
= <<- _EOFix_
2192 #endif
/* _INCLUDE_HPUX_SOURCE
*/
2194 #if
defined(_INCLUDE_HPUX_SOURCE
) || \
2195 (defined(__STDC_VERSION__
) && (__STDC_VERSION__
>= 199901L))
2198 #ifdef _INCLUDE_HPUX_SOURCE
2203 "# define FP_NORMAL 0\n"
2204 "# define FP_ZERO 1\n"
2205 "# define FP_INFINITE 2\n"
2206 "# define FP_SUBNORMAL 3\n"
2207 "# define FP_NAN 4\n";
2211 * Delete C
++ double
pow (double
, int
) inline function from HP
-UX
10 & 11
2212 * math.h to prevent clash with define in c_std
/bits
/std_cmath.h.
2215 hackname
= hpux10_cpp_pow_inline
;
2216 files
= fixinc
-test
-limits.h
, math.h
;
2217 select
= <<- END_POW_INLINE
2218 ^#
+ifdef
+__cplusplus
2220 +inline
+double
+pow\
(double
+__d
,int
+__expon\
) +\
{
2221 [ ]+return
+pow\
(__d
,\
(double\
)__expon\
);
2232 "# ifdef __cplusplus\n"
2234 " inline double pow(double __d,int __expon) {\n"
2235 "\t return pow(__d,(double)__expon);\n"
2237 ' extern "C"' " {\n"
2243 hackname
= hpux11_cpp_pow_inline
;
2245 select
= " +inline double pow\\(double d,int expon\\) \\{\n"
2246 " +return pow\\(d, \\(double\\)expon\\);\n"
2252 " inline double pow(double d,int expon) {\n"
2253 " return pow(d, (double)expon);\n"
2258 * Fix hpux
10.X missing ctype declarations
1
2261 hackname
= hpux10_ctype_declarations1
;
2263 select
= "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
2264 bypass
= "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
2266 c_fix_arg
= "#ifdef _PROTOTYPES\n"
2267 "extern int __tolower(int);\n"
2268 "extern int __toupper(int);\n"
2269 "#else /* NOT _PROTOTYPES */\n"
2270 "extern int __tolower();\n"
2271 "extern int __toupper();\n"
2272 "#endif /* _PROTOTYPES */\n\n"
2275 test_text
= "# define _toupper(__c) __toupper(__c)\n";
2279 * Fix hpux
10.X missing ctype declarations
2
2282 hackname
= hpux10_ctype_declarations2
;
2284 select
= "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
2285 bypass
= "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
2287 c_fix_arg
= "%0\n\n"
2288 "#ifdef _PROTOTYPES\n"
2289 " extern int _isalnum(int);\n"
2290 " extern int _isalpha(int);\n"
2291 " extern int _iscntrl(int);\n"
2292 " extern int _isdigit(int);\n"
2293 " extern int _isgraph(int);\n"
2294 " extern int _islower(int);\n"
2295 " extern int _isprint(int);\n"
2296 " extern int _ispunct(int);\n"
2297 " extern int _isspace(int);\n"
2298 " extern int _isupper(int);\n"
2299 " extern int _isxdigit(int);\n"
2300 "# else /* not _PROTOTYPES */\n"
2301 " extern int _isalnum();\n"
2302 " extern int _isalpha();\n"
2303 " extern int _iscntrl();\n"
2304 " extern int _isdigit();\n"
2305 " extern int _isgraph();\n"
2306 " extern int _islower();\n"
2307 " extern int _isprint();\n"
2308 " extern int _ispunct();\n"
2309 " extern int _isspace();\n"
2310 " extern int _isupper();\n"
2311 " extern int _isxdigit();\n"
2312 "#endif /* _PROTOTYPES */\n";
2314 test_text
= "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
2315 " extern unsigned int *__SB_masks;\n";
2319 * Fix hpux
10.X missing stdio declarations
2322 hackname
= hpux10_stdio_declarations
;
2324 select
= "^#[ \t]*define _iob[ \t]*__iob";
2325 bypass
= "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2327 c_fix_arg
= "%0\n\n"
2328 "# if defined(__STDC__) || defined(__cplusplus)\n"
2329 " extern int snprintf(char *, size_t, const char *, ...);\n"
2330 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2331 "# else /* not __STDC__) || __cplusplus */\n"
2332 " extern int snprintf();\n"
2333 " extern int vsnprintf();\n"
2334 "# endif /* __STDC__) || __cplusplus */\n";
2336 test_text
= "# define _iob __iob\n";
2340 * The HP
-UX stddef.h is replaced by gcc
's. It doesn't include sys
/stdsyms.h.
2341 * As a result
, we need to include sys
/stdsyms.h in alloca.h.
2344 hackname
= hppa_hpux11_alloca
;
2345 mach
= "hppa*-*-hpux11*";
2347 select
= "#ifndef _STDDEF_INCLUDED";
2349 c_fix_arg
= "#ifndef _SYS_STDSYMS_INCLUDED\n"
2350 "# include <sys/stdsyms.h>\n"
2351 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2354 test_text
= "#ifndef _STDDEF_INCLUDED";
2358 * Make sure hpux defines abs in header.
2361 hackname
= hpux11_abs
;
2362 mach
= "*-hp-hpux11*";
2364 select
= "ifndef _MATH_INCLUDED";
2366 c_fix_arg
= "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2367 test_text
= "#ifndef _MATH_INCLUDED";
2371 * Fix hpux11 __LWP_RWLOCK_VALID define
2374 hackname
= hpux11_lwp_rwlock_valid
;
2375 mach
= "*-hp-hpux11*";
2376 files
= sys
/pthread.h
;
2377 select
= "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2379 c_fix_arg
= "#define __LWP_RWLOCK_VALID -29551";
2380 test_text
= "#define __LWP_RWLOCK_VALID 0x8c91";
2387 hackname
= hpux11_extern_sendfile
;
2388 mach
= "*-hp-hpux11.[12]*";
2389 files
= sys
/socket.h
;
2390 select
= "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2392 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2393 test_text
= " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2394 " const struct iovec *, int));\n";
2401 hackname
= hpux11_extern_sendpath
;
2402 mach
= "*-hp-hpux11.[12]*";
2403 files
= sys
/socket.h
;
2404 select
= "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2406 c_fix_arg
= "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2407 test_text
= " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2408 " const struct iovec *, int));\n";
2412 * Keep HP
-UX
11 from stomping on C
++ math namespace
2413 * with defines for fabsf.
2416 hackname
= hpux11_fabsf
;
2417 mach
= "*-hp-hpux11*";
2419 select
= "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2422 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
2426 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2431 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
2432 * in pthread.h need to be constant expressions to be standard complient.
2433 * As a result
, we need to remove the void
* casts in the initializers
2434 * (see hpux11_pthread_const
) and to change the
__(M|C|RW
)POINTER defines
2435 * to use the long type.
2438 hackname
= hpux11_pthread_pointer
;
2439 mach
= "*-hp-hpux11.[0-3]*";
2440 files
= sys
/pthread.h
;
2441 select
= "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2444 c_fix_arg
= "long\t%2%3";
2445 test_text
= "#define __MPOINTER\t\tvoid\t *m_ptr";
2449 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
2452 hackname
= hpux11_pthread_const
;
2453 mach
= "*-hp-hpux11.[0-3]*";
2454 files
= sys
/pthread.h
;
2455 select
= "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
2459 test_text
= "#define __POINTER_SET\t\t((void *) 1LL)";
2463 * Prevent HP
-UX
11 from defining __size_t and preventing size_t from
2464 * being defined by having it define _hpux_size_t instead.
2467 hackname
= hpux11_size_t
;
2468 mach
= "*-hp-hpux11*";
2469 select
= "__size_t";
2472 c_fix_arg
= "_hpux_size_t";
2475 "#define __size_t size_t\n"
2476 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2480 * Fix hpux
11.00 broken snprintf declaration
2481 * (third argument is char
*, needs to be const char
* to prevent
2482 * spurious warnings with
-Wwrite
-strings or in C
++).
2485 hackname
= hpux11_snprintf
;
2487 select
= '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2488 ' *(char *\*, *\.\.\.\);)';
2490 c_fix_arg
= '%1 const %3';
2492 test_text
= "extern int snprintf(char *, size_t, char *, ...);\n"
2493 "extern int snprintf(char *, __size_t, char *, ...);\n"
2494 "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2498 * Fix hpux
11.00 broken vsnprintf declaration
2501 hackname
= hpux11_vsnprintf
;
2503 select
= '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2504 'const char \*,) __va__list\);';
2506 c_fix_arg
= "%1 __va_list);";
2508 test_text
= 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2513 * Fix missing const in hpux vsscanf declaration
2516 hackname
= hpux_vsscanf
;
2519 select
= '(extern int vsscanf\()char';
2521 c_fix_arg
= "%1const char";
2523 test_text
= 'extern int vsscanf(char *, const char *, __va_list);';
2527 * get rid of bogus inline definitions in HP
-UX
8.0
2530 hackname
= hpux8_bogus_inlines
;
2533 bypass
= "__GNUG__";
2534 sed
= "s@inline int abs(int [a-z][a-z]*) {.*}"
2535 "@extern \"C\" int abs(int);@";
2536 sed
= "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2537 sed
= "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2538 sed
= "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2539 test_text
= "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2540 "inline double sqr(double v) { return v**0.5; }";
2547 hackname
= hpux_c99_intptr
;
2548 mach
= "*-hp-hpux11.3*";
2549 files
= stdint
-hpux11.h
, stdint.h
;
2550 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2551 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2552 sed
= "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2553 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2554 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2555 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2556 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2557 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2558 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2559 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2560 sed
= "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2561 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2562 test_text
= "#define PTRDIFF_MAX INT32_MAX\n"
2563 "#define PTRDIFF_MIN INT32_MIN\n"
2564 "#define INTPTR_MAX INT32_MAX\n"
2565 "#define INTPTR_MIN INT32_MIN\n"
2566 "#define UINTPTR_MAX UINT32_MAX\n"
2567 "#define SIZE_MAX UINT32_MAX\n";
2571 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2574 hackname
= hpux_c99_inttypes
;
2575 mach
= "*-hp-hpux11.[23]*";
2577 files
= stdint
-hpux11.h
, stdint.h
;
2578 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2579 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2580 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2581 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2582 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2583 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2584 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2585 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2586 test_text
= "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2587 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2588 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2589 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2593 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2596 hackname
= hpux_c99_inttypes2
;
2597 mach
= "*-hp-hpux11.2*";
2598 files
= stdint
-hpux11.h
, stdint.h
;
2599 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2600 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2601 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2602 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2603 sed
= "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2604 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2605 sed
= "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2606 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2607 test_text
= "# define INT8_C(__c) ((signed char)(__c))\n"
2608 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2609 "# define INT16_C(__c) ((short)(__c))\n"
2610 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2614 * Fix broken and missing defines in inttypes.h
2617 hackname
= hpux_c99_inttypes3
;
2618 mach
= "hppa*-hp-hpux11*";
2620 select
= "#define[ \t]INTPTR_MAX[ \t]*\n"
2621 "#define[ \t]UINTPTR_MAX[ \t]*\n";
2623 c_fix_arg
= "#undef SIZE_MAX\n"
2624 "#define SIZE_MAX __SIZE_MAX__\n"
2625 "#ifdef __INTPTR_MAX__\n"
2626 "# undef INTPTR_MAX\n"
2627 "# define INTPTR_MAX __INTPTR_MAX__\n"
2628 "# undef INTPTR_MIN\n"
2629 "# define INTPTR_MIN (-INTPTR_MAX - 1)\n"
2631 "#ifdef __UINTPTR_MAX__\n"
2632 "# undef UINTPTR_MAX\n"
2633 "# define UINTPTR_MAX __UINTPTR_MAX__\n"
2635 test_text
= "#define INTPTR_MAX\n"
2636 "#define UINTPTR_MAX\n";
2640 * Fix missing SCNuMAX defines in inttypes.h
2643 hackname
= hpux_c99_inttypes4
;
2644 mach
= "hppa*-hp-hpux11.[01]*";
2646 sed
= "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx64/a\\\n"
2647 "#define SCNuMAX \t SCNu64\n";
2648 sed
= "/^[ \t]*#[ \t]*define[ \t]*SCNxMAX[ \t]*SCNx32/a\\\n"
2649 "#define SCNuMAX \t SCNu32\n";
2650 test_text
= "#define SCNxMAX SCNx64\n"
2651 "#define SCNxMAX SCNx32\n";
2655 * Fix hpux broken ctype macros
2658 hackname
= hpux_ctype_macros
;
2660 select
= '((: |\()__SB_masks \? )'
2661 '(__SB_masks\[__(alnum|c)\] & _IS)';
2663 c_fix_arg
= "%1(int)%3";
2665 test_text
= ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2666 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2673 hackname
= hpux_extern_errno
;
2674 mach
= "*-hp-hpux10.*";
2675 mach
= "*-hp-hpux11.[0-2]*";
2677 select
= "^[ \t]*extern int errno;$";
2679 c_fix_arg
= "#ifdef __cplusplus\n"
2683 "#ifdef __cplusplus\n"
2686 test_text
= " extern int errno;\n";
2690 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2693 hackname
= hpux_htonl
;
2694 files
= netinet
/in.h
;
2695 select
= "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2697 " \\* Macros for number representation conversion\\.\n"
2701 c_fix_arg
= "#if 1\n%1";
2703 test_text
= "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2705 " * Macros for number representation conversion.\n"
2708 "#define ntohl(x) (x)\n"
2709 "#define ntohs(x) (x)\n"
2710 "#define htonl(x) (x)\n"
2711 "#define htons(x) (x)\n"
2713 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2717 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2720 hackname
= hpux_imaginary_i
;
2721 mach
= "ia64-hp-hpux11.*";
2723 select
= "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2725 c_fix_arg
= "#define _Complex_I (__extension__ 1.0iF)";
2726 test_text
= "#define _Complex_I (0.f+_Imaginary_I)\n";
2730 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2733 hackname
= hpux_inttype_int8_t
;
2734 mach
= "*-hp-hpux1[01].*";
2735 files
= sys
/_inttypes.h
;
2736 select
= "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2738 c_fix_arg
= "typedef signed char int%18_t;";
2739 test_text
= "typedef char int_least8_t;\n"
2740 "typedef char int8_t;\n";
2747 hackname
= hpux_long_double
;
2748 mach
= "*-*-hpux10*";
2749 mach
= "*-*-hpux11.[012]*";
2751 select
= "extern[ \t]long_double[ \t]strtold";
2752 bypass
= "long_double_t";
2753 sed
= "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2754 sed
= "s/long_double/long double/g";
2756 test_text
= "# ifndef _LONG_DOUBLE\n"
2757 "# define _LONG_DOUBLE\n"
2758 " typedef struct {\n"
2759 " unsigned int word1, word2, word3, word4;\n"
2761 "# endif /* _LONG_DOUBLE */\n"
2762 "extern long_double strtold(const char *, char **);\n";
2766 * We cannot use the above rule on
11.31 because it removes the strtold
2767 * definition. ia64 is OK with no hack
, PA needs some help.
2770 hackname
= hpux_long_double_2
;
2771 mach
= "hppa*-*-hpux11.3*";
2773 select
= "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2774 "defined\\(_PROTOTYPES\\) \\|\\| "
2775 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2777 c_fix_arg
= "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2779 test_text
= "# if !defined(__ia64) || "
2780 "!defined(_PROTOTYPES) || "
2781 "defined(_LONG_DOUBLE_STRUCT)\n";
2785 * Add missing braces to pthread initializer defines.
2788 hackname
= hpux_pthread_initializers
;
2789 mach
= "*-hp-hpux11.[0-3]*";
2790 files
= sys
/pthread.h
;
2791 sed
= "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2792 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2793 sed
= "s@^[ \t]*1,[ \t]*\\\\"
2795 sed
= "/^[ \t]*0$/d";
2796 sed
= "s@__PTHREAD_MUTEX_VALID, 0"
2797 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2798 sed
= "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2799 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2800 sed
= "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2801 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2802 sed
= "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2803 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2804 sed
= "s@^[ \t]*0, 0[ \t]*\\\\"
2805 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2806 sed
= "s@__PTHREAD_COND_VALID, 0"
2807 "@{ __PTHREAD_COND_VALID, 0 }@";
2808 sed
= "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2809 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2810 sed
= "s@__PTHREAD_RWLOCK_VALID, 0"
2811 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2812 sed
= "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2813 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2814 sed
= "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2815 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2816 test_text
= "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
2817 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2818 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2819 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2820 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2821 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2822 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2827 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2828 * type and mpinfou is only defined when _KERNEL is set.
2831 hackname
= hpux_spu_info
;
2832 mach
= "*-hp-hpux*";
2834 * It is tempting to omit the first
"files" entry. Do not.
2835 * The testing machinery will take the first
"files" entry as the name
2836 * of a test file to play with. It would be a nuisance to have a directory
2837 * with the name
"*".
2839 files
= "ia64/sys/getppdp.h";
2840 files
= "*/sys/getppdp.h";
2841 select
= "^.*extern.*spu_info.*";
2844 c_fix_arg
= "#ifdef _KERNEL\n%0\n#endif";
2846 test_text
= "extern union mpinfou spu_info[];";
2850 * These hacks are need in inttypes.h on
11.23 and in stdint.h on
11.31.
2853 hackname
= hpux_stdint_least_fast
;
2854 mach
= "*-hp-hpux11.2*";
2855 files
= stdint
-hpux11.h
, stdint.h
;
2857 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2859 c
-fix
-arg
= "# define UINT_%164_MAX __UINT64_MAX__";
2860 test
-text
= "# define UINT_FAST64_MAX ULLONG_MAX\n"
2861 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2865 * Add noreturn attribute to longjmp declarations in hpux
<setjmp.h
>
2868 hackname
= hpux_longjmp
;
2869 mach
= "*-hp-hpux*";
2871 select
= "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2874 c_fix_arg
= "%0 __attribute__ ((__noreturn__))";
2876 test_text
= 'extern void longjmp __((jmp_buf, int));';
2880 * Fix hpux10.20
<sys
/time.h
> to avoid invalid forward decl
2883 hackname
= hpux_systime
;
2885 select
= "^extern struct sigevent;";
2888 c_fix_arg
= "struct sigevent;";
2890 test_text
= 'extern struct sigevent;';
2894 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2897 hackname
= huge_val_hex
;
2898 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2899 select
= "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2900 bypass
= "__builtin_huge_val";
2903 c_fix_arg
= "#define HUGE_VAL (__builtin_huge_val())\n";
2905 test_text
= "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2909 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2912 hackname
= huge_valf_hex
;
2913 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2914 select
= "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2915 bypass
= "__builtin_huge_valf";
2918 c_fix_arg
= "#define HUGE_VALF (__builtin_huge_valf())\n";
2920 test_text
= "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2924 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2927 hackname
= huge_vall_hex
;
2928 files
= bits
/huge_val.h
, '*/bits/huge_val.h';
2929 select
= "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2930 bypass
= "__builtin_huge_vall";
2933 c_fix_arg
= "#define HUGE_VALL (__builtin_huge_vall())\n";
2935 test_text
= "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2939 * Fix return type of abort and free
2942 hackname
= int_abort_free_and_exit
;
2944 select
= "int[ \t]+(abort|free|exit)[ \t]*\\(";
2945 bypass
= "_CLASSIC_ANSI_TYPES";
2948 c_fix_arg
= "void\t%1(";
2950 test_text
= "extern int abort(int);\n"
2951 "extern int free(void*);\n"
2952 "extern int exit(void*);";
2956 * Fix various macros used to define ioctl numbers.
2957 * The traditional syntax was
:
2959 * #define
_IO(n
, x
) (('n'<<8)+x
)
2960 * #define TIOCFOO
_IO(T
, 1)
2962 * but this does not work with the C standard
, which disallows macro
2963 * expansion inside strings. We have to rewrite it thus
:
2965 * #define
_IO(n
, x
) ((n
<<8)+x
)
2966 * #define TIOCFOO
_IO('T', 1)
2968 * The select expressions match too much
, but the c_fix code is cautious.
2970 * _IO might be
: _IO DESIO BSD43__IO with W
, R
, WR
, C
, ... suffixes.
2973 hackname
= io_quotes_def
;
2974 select
= "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2975 c_fix
= char_macro_def
;
2978 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2979 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2980 "#define _IO(x,y) ('x'<<8|y)";
2982 "#define XX_IO(x) ('x'<<8|256)";
2986 * Fix the usage of the ioctl macro numbers.
2989 hackname
= io_quotes_use
;
2990 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2992 c_fix
= char_macro_use
;
2994 test_text
= "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2995 "#define TIOCFOO \\\\\n"
2996 "BSD43__IOWR(T, 1) /* Some are multi-line */";
3000 * Check for missing
';' in struct
3003 hackname
= ip_missing_semi
;
3004 files
= netinet
/ip.h
;
3006 sed
= "/^struct/,/^};/s/}$/};/";
3012 "}; /* mumbled struct */\n";
3016 * Non
-traditional
"const" declaration in Irix
's limits.h.
3019 hackname = irix_limits_const;
3020 files = fixinc-test-limits.h, limits.h;
3021 select = "^extern const ";
3023 c_fix_arg = "extern __const ";
3024 test_text = "extern const char limit; /* test limits */";
3028 * IRIX 5.x's stdio.h declares some functions that take a va_list as
3029 * taking char
*. However
, GCC uses void
* for va_list
, so
3030 * calling vfprintf with a va_list fails in C
++.
*/
3032 hackname
= irix_stdio_va_list
;
3035 select
= '/\* va_list \*/ char \*';
3037 c_fix_arg
= "__gnuc_va_list";
3039 "extern int printf( const char *, /* va_list */ char * );";
3043 * These files in Sun OS
4.x and ARM
/RISCiX and BSD4.3
3044 * use
/ * * / to concatenate tokens.
3047 hackname
= kandr_concat
;
3048 files
= "sparc/asm_linkage.h";
3049 files
= "sun*/asm_linkage.h";
3050 files
= "arm/as_support.h";
3051 files
= "arm/mc_type.h";
3052 files
= "arm/xcb.h";
3053 files
= "dev/chardefmac.h";
3054 files
= "dev/ps_irq.h";
3055 files
= "dev/screen.h";
3056 files
= "dev/scsi.h";
3057 files
= "sys/tty.h";
3058 files
= "Xm.acorn/XmP.h";
3059 files
= bsd43
/bsd43_.h
;
3063 test_text
= "#define __CONCAT__(a,b) a/**/b";
3067 * The
/usr
/include
/sys
/ucontext.h on ia64
-*linux
-gnu systems defines
3068 * an _SC_GR0_OFFSET macro using an idiom that isn
't a compile time
3069 * constant on recent versions of g++.
3072 hackname = linux_ia64_ucontext;
3073 files = "sys/ucontext.h";
3074 mach = "ia64-*-linux*";
3075 select = '\
(\
(\
(char \
*\
) &\
(\
(struct sigcontext \
*\
) 0\
)'
3076 '->sc_gr\
[0\
]\
) - \
(char \
*\
) 0\
)';
3078 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
3079 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
3080 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
3084 * Remove header file warning from sys/time.h. Autoconf's
3085 * AC_HEADER_TIME recommends to include both sys
/time.h and time.h
3086 * which causes warning on LynxOS. Remove the warning.
3089 hackname
= lynxos_no_warning_in_sys_time_h
;
3091 select
= "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
3094 test_text
= "#warning Using <time.h> instead of <sys/time.h>";
3098 * Add missing declaration for putenv.
3101 hackname
= lynxos_missing_putenv
;
3102 mach
= '*-*-lynxos*';
3104 bypass
= 'putenv[ \t]*\\(';
3105 select
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3108 "extern int putenv _AP((char *));";
3109 c_fix_arg
= "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
3110 test_text
= "extern char *getenv _AP((const char *));";
3114 * Fix BSD machine
/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
3116 * On NetBSD
, machine is a symbolic link to an architecture specific
3117 * directory name
, so we can
't match a specific file name here.
3120 hackname = machine_ansi_h_va_list;
3121 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
3122 bypass = '__builtin_va_list
';
3125 c_fix_arg = "%1__builtin_va_list";
3126 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
3128 test_text = " # define _BSD_VA_LIST_\tchar**";
3132 * Fix non-ansi machine name defines
3135 hackname = machine_name;
3136 c_test = machine_name;
3137 c_fix = machine_name;
3139 test_text = "/* MACH_DIFF: */\n"
3140 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
3141 "\n/* no uniform test, so be careful :-) */";
3145 * Some math.h files define struct exception (it's in the System V
3146 * Interface Definition
), which conflicts with the class exception defined
3147 * in the C
++ file std
/stdexcept.h. We redefine it to __math_exception.
3148 * This is not a great fix
, but I haven
't been able to think of anything
3152 hackname = math_exception;
3154 select = "struct exception";
3156 * This should be bypassed on __cplusplus, but some supposedly C++
3157 * aware headers, such as Solaris 8 and 9, don't wrap their struct
3158 * exception either. So currently we bypass only for glibc
, based on a
3159 * comment in the fixed glibc header. Ick.
3161 bypass
= 'We have a problem when using C\+\+|for C\+\+, '
3162 '_[a-z0-9A-Z_]+_exception; for C, exception';
3163 /* The Solaris
10 headers already get this right.
*/
3164 mach
= '*-*-solaris2.1[0-9]*';
3168 c_fix_arg
= "#ifdef __cplusplus\n"
3169 "#define exception __math_exception\n"
3172 c_fix_arg
= "#ifdef __cplusplus\n"
3173 "#undef exception\n"
3176 test_text
= "typedef struct exception t_math_exception;";
3180 * This looks pretty broken to me. ``dbl_max_def
'' will contain
3181 * "define DBL_MAX " at the start
, when what we really want is just
3182 * the value portion. Can
't figure out how to write a test case
3183 * for this either :-(
3186 hackname = math_huge_val_from_dbl_max;
3190 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
3191 * in math.h, this fix applies.
3193 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
3194 bypass = "define[ \t]+DBL_MAX";
3198 * See if we have a definition for DBL_MAX in float.h.
3199 * If we do, we will replace the one in math.h with that one.
3202 "\tdbl_max_def=`egrep 'define
[ \t]+DBL_MAX
[ \t]+.
*' float.h "
3203 "| sed 's
/.
*DBL_MAX
[ \t]*//' 2>/dev/null`\n\n"
3205 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
3206 "\tthen sed -e '/define
[ \t]*HUGE_VAL
[ \t]*DBL_MAX
/"
3207 "s@DBL_MAX@
'\"$dbl_max_def@\"\n"
3212 "`echo '#define DBL_MAX
\t3.1415e+9 /* really big
*/' >> float.h`\n"
3213 "#define HUGE_VAL DBL_MAX";
3220 hackname = nested_auth_des;
3222 select = '(/\
*.
*rpc
/auth_des\.h
>.*)
/\
*';
3224 c_fix_arg = "%1*/ /*";
3225 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
3229 * Some versions of NetBSD don't expect the C99 inline semantics.
3232 hackname
= netbsd_c99_inline_1
;
3233 mach
= "*-*-netbsd*";
3235 select
= "extern __inline int";
3238 c_fix_arg
= "extern\n"
3239 "#ifdef __GNUC_STDC_INLINE__\n"
3240 "__attribute__((__gnu_inline__))\n"
3244 test_text
= "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
3248 * netbsd_c99_inline_2
3251 hackname
= netbsd_c99_inline_2
;
3252 mach
= "*-*-netbsd*";
3254 select
= "#define _SIGINLINE extern __inline";
3257 c_fix_arg
= <<- _EOArg_
3258 #ifdef __GNUC_STDC_INLINE__
3259 #define _SIGINLINE extern
__attribute__((__gnu_inline__
)) __inline
3265 test_text
= "#define _SIGINLINE extern __inline";
3269 * NetBSD has a semicolon after the ending
'}' for some extern
"C".
3272 hackname
= netbsd_extra_semicolon
;
3273 mach
= "*-*-netbsd*";
3274 files
= sys
/cdefs.h
;
3275 select
= "#define[ \t]*__END_DECLS[ \t]*};";
3278 c_fix_arg
= "#define __END_DECLS }";
3280 test_text
= "#define __END_DECLS };";
3284 * newlib
's stdint.h has several failures to conform to C99. The fix
3285 * for these removed a comment that can be matched to identify unfixed
3289 hackname = newlib_stdint_1;
3290 files = stdint-newlib.h, stdint.h;
3291 select = "@todo - Add support for wint_t types";
3292 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3293 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3294 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3295 sed = "s@#define INT_LEAST32_MIN.*@"
3296 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3297 sed = "s@#define INT_LEAST32_MAX.*@"
3298 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3299 sed = "s@#define UINT_LEAST32_MAX.*@"
3300 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3301 sed = 's@#define INT_FAST\
([0-9]*\
)_MIN.
*@
'
3302 '#define INT_FAST\
1_MIN (-INT_FAST\
1_MAX
- 1)@
';
3303 sed = 's@#define INT_FAST\
([0-9]*\
)_MAX.
*@
'
3304 '#define INT_FAST\
1_MAX __INT_FAST\
1_MAX__@
';
3305 sed = 's@#define UINT_FAST\
([0-9]*\
)_MAX.
*@
'
3306 '#define UINT_FAST\
1_MAX __UINT_FAST\
1_MAX__@
';
3307 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3308 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3309 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3310 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3311 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3312 test_text = "/* @todo - Add support for wint_t types. */\n"
3313 "#define INT32_MIN (-2147483647-1)\n"
3314 "#define INT32_MAX 2147483647\n"
3315 "#define UINT32_MAX 4294967295U\n"
3316 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3317 "#define INT_LEAST32_MAX 2147483647\n"
3318 "#define UINT_LEAST32_MAX 4294967295U\n"
3319 "#define INT_FAST8_MIN INT8_MIN\n"
3320 "#define INT_FAST8_MAX INT8_MAX\n"
3321 "#define UINT_FAST8_MAX UINT8_MAX\n"
3322 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3323 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3324 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3325 "#define UINT8_C(x) x##U\n"
3326 "#define UINT16_C(x) x##U";
3333 hackname = newlib_stdint_2;
3334 files = stdint-newlib.h, stdint.h;
3335 select = "@todo - Add support for wint_t types";
3337 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
3338 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3339 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3340 "#define WCHAR_MAX __WCHAR_MAX__\n"
3341 "#define WCHAR_MIN __WCHAR_MIN__\n"
3342 "#define WINT_MAX __WINT_MAX__\n"
3343 "#define WINT_MIN __WINT_MIN__\n\n"
3345 c_fix_arg = '/\
*\
* Macros for minimum
-width integer constant expressions \
*/';
3346 test_text = "/* @todo - Add support for wint_t types. */\n"
3347 "/** Macros for minimum-width integer constant expressions */";
3351 * NeXT 3.2 adds const prefix to some math functions.
3352 * These conflict with the built-in functions.
3355 hackname = next_math_prefix;
3356 files = ansi/math.h;
3357 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
3360 c_fix_arg = "extern double %1(";
3361 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3363 test_text = "extern\tdouble\t__const__\tmumble();";
3367 * NeXT 3.2 uses the word "template" as a parameter for some
3368 * functions. GCC reports an invalid use of a reserved key word
3369 * with the built-in functions.
3372 hackname = next_template;
3374 select = "[ \t]template\\)";
3378 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
3379 test_text = "extern mumble( char * template); /* fix */";
3383 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3384 * function prototypes. That conflicts with the built-in functions.
3387 hackname = next_volitile;
3388 files = ansi/stdlib.h;
3389 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
3392 c_fix_arg = "extern void %1(";
3393 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3395 test_text = "extern\tvolatile\tvoid\tabort();";
3399 * NeXT 2.0 defines 'int
wait(union wait*)
', which conflicts with Posix.1.
3400 * Note that version 3 of the NeXT system has wait.h in a different directory,
3401 * so that this code won't do anything. But wait.h in version
3 has a
3402 * conditional
, so it doesn
't need this fix. So everything is okay.
3405 hackname = next_wait_union;
3408 select = 'wait\
(union wait
';
3410 c_fix_arg = "wait(void";
3411 test_text = "extern pid_d wait(union wait*);";
3415 * a missing semi-colon at the end of the nodeent structure definition.
3418 hackname = nodeent_syntax;
3419 files = netdnet/dnetdb.h;
3420 select = "char[ \t]*\\*na_addr[ \t]*$";
3423 test_text = "char *na_addr\t";
3427 * Fix OpenBSD's NULL definition.
3430 hackname
= openbsd_null_definition
;
3431 mach
= "*-*-openbsd*";
3432 files
= locale.h
, stddef.h
, stdio.h
, string.h
,
3433 time.h
, unistd.h
, wchar.h
, sys
/param.h
;
3434 select
= "__GNUG__";
3436 c_fix_arg
= "#ifndef NULL\n"
3437 "#ifdef __cplusplus\n"
3439 "#define NULL\t__null\n"
3440 "#else\t /* ! __GNUG__ */\n"
3441 "#define NULL\t0L\n"
3442 "#endif\t /* __GNUG__ */\n"
3443 "#else\t /* ! __cplusplus */\n"
3444 "#define NULL\t((void *)0)\n"
3445 "#endif\t /* __cplusplus */\n"
3446 "#endif\t /* !NULL */";
3448 c_fix_arg
= "^#ifndef[ \t]*NULL\n"
3449 "^#ifdef[ \t]*__GNUG__\n"
3450 "^#define[ \t]*NULL[ \t]*__null\n"
3452 "^#define[ \t]*NULL[ \t]*0L\n"
3458 "#define NULL __null\n"
3466 * obstack.h used casts as lvalues.
3468 * We need to change postincrements of casted
pointers (which are
3469 * then dereferenced and assigned into
) of the form
3471 * *((TYPE*)PTRVAR
)++ = (VALUE
)
3473 * into expressions like
3475 * ((*((TYPE*)PTRVAR
) = (VALUE
)), (PTRVAR
+= sizeof (TYPE)))
3477 * which is correct for the cases used in obstack.h since PTRVAR is
3478 * of type char
* and the value of the expression is not used.
3481 hackname
= obstack_lvalue_cast
;
3483 select
= '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3485 c_fix_arg
= "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3486 test_text
= "*((void **) (h)->next_free)++ = (aptr)";
3490 * Fix OpenBSD
's va_start define.
3493 hackname = openbsd_va_start;
3494 mach = "*-*-openbsd*";
3496 select = '__builtin_stdarg_start
';
3498 c_fix_arg = __builtin_va_start;
3500 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3504 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3505 * defining regex.h related types. This causes libg++ build and usage
3506 * failures. Fixing this correctly requires checking and modifying 3 files.
3509 hackname = osf_namespace_a;
3510 files = reg_types.h;
3511 files = sys/lc_core.h;
3512 test = " -r reg_types.h";
3513 test = " -r sys/lc_core.h";
3514 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3515 test = " -z \"`grep __regex_t regex.h`\"";
3519 c_fix_arg = "reg(ex|off|match)_t";
3521 test_text = "`touch sys/lc_core.h`"
3522 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3523 "extern regex_t re;\n"
3524 "extern regoff_t ro;\n"
3525 "extern regmatch_t rm;\n";
3529 hackname = osf_namespace_c;
3531 test = " -r reg_types.h";
3532 test = " -r sys/lc_core.h";
3533 test = " -n \"`grep '} regex_t
;' reg_types.h`\"";
3534 test = " -z \"`grep __regex_t regex.h`\"";
3536 select = "#include <reg_types\.h>.*";
3539 "typedef __regex_t\tregex_t;\n"
3540 "typedef __regoff_t\tregoff_t;\n"
3541 "typedef __regmatch_t\tregmatch_t;";
3543 test_text = "#include <reg_types.h>";
3547 * On broken glibc-2.3.3 systems an array of incomplete structures is
3548 * passed to __sigsetjmp. Fix that to take a pointer instead.
3551 hackname = pthread_incomplete_struct_argument;
3553 select = "struct __jmp_buf_tag";
3555 c_fix_arg = "%1 *%2%3";
3556 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3557 "(__env)\\[1\\](.*)$";
3558 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3563 * Fix return type of fread and fwrite on sysV68
3566 hackname = read_ret_type;
3568 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3570 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3571 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3573 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3577 * Fix casts as lvalues in glibc's
<rpc
/xdr.h
>.
3580 hackname
= rpc_xdr_lvalue_cast_a
;
3582 select
= "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3584 c_fix_arg
= "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3585 test_text
= "#define IXDR_GET_LONG(buf) \\\\\n"
3586 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3590 * rpc_xdr_lvalue_cast_b
3593 hackname
= rpc_xdr_lvalue_cast_b
;
3595 select
= "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3597 c_fix_arg
= "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3598 test_text
= "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3599 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3603 * function
class(double x
) conflicts with C
++ keyword on rs
/6000
3606 hackname
= rs6000_double
;
3608 select
= '[^a-zA-Z_]class\(';
3611 c_fix_arg
= "#ifndef __cplusplus\n%0\n#endif";
3612 c_fix_arg
= '^.*[^a-zA-Z_]class\(.*';
3614 test_text
= "extern int class();";
3618 * Wrong fchmod prototype on RS
/6000.
3621 hackname
= rs6000_fchmod
;
3623 select
= 'fchmod\(char \*';
3625 c_fix_arg
= "fchmod(int";
3626 test_text
= "extern int fchmod(char *, mode_t);";
3630 * parameters conflict with C
++ new on rs
/6000
3633 hackname
= rs6000_param
;
3637 select
= 'rename\(const char \*old, const char \*new\)';
3639 c_fix_arg
= 'rename(const char *_old, const char *_new)';
3641 test_text
= 'extern int rename(const char *old, const char *new);';
3645 * Solaris
10+ <sys
/feature_tests.h
> defines _RESTRICT_KYWD as restrict
3646 * for C99. This is wrong for C
++, which needs many C99 features
, but
3647 * only supports __restrict.
3650 hackname
= solaris___restrict
;
3651 files
= sys
/feature_tests.h
;
3652 select
= "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3653 mach
= "*-*-solaris2*";
3655 c_fix_arg
= "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3656 "#else\n%0\n#endif";
3657 test_text
= "#define _RESTRICT_KYWD restrict";
3661 * Solaris
10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3662 * themselves
, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3663 * and imaginary definitions which are not supported by GCC.
3666 hackname
= solaris_complex
;
3667 mach
= "*-*-solaris2.*";
3669 select
= "#define[ \t]_Complex_I[ \t]_Complex_I";
3670 sed
= "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3671 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3672 sed
= "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3673 sed
= "/#define[ \t]imaginary[ \t]_Imaginary/d";
3674 sed
= "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3675 test_text
= "#define _Complex_I _Complex_I\n"
3676 "#define complex _Complex\n"
3677 "#define _Imaginary_I _Imaginary_I\n"
3678 "#define imaginary _Imaginary\n"
3680 "#define I _Imaginary_I";
3684 * Solaris
10+ <complex.h
> is wrapped in #ifndef __cplusplus. Wrap in
3685 * extern
"C" instead so libstdc
++ can use it.
3688 hackname
= solaris_complex_cxx
;
3689 mach
= "*-*-solaris2.*";
3691 sed
= "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3692 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3693 sed
= "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3694 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3695 test_text
= "#if !defined(__cplusplus)\n"
3696 "#endif /* !defined(__cplusplus) */";
3700 * g
++ rejects functions declared with both C and C
++ linkage.
3703 hackname
= solaris_cxx_linkage
;
3704 mach
= '*-*-solaris2*';
3705 files
= "iso/stdlib_iso.h";
3706 select
= "(#if __cplusplus >= 199711L)\n"
3707 "(extern \"C\\+\\+\" \\{\n)"
3708 "(.*(bsearch|qsort).*)";
3710 c_fix_arg
= "%1 && !__GNUG__\n%2%3";
3713 "#if __cplusplus >= 199711L\n"
3714 "extern \"C++\" {\n"
3715 " void *bsearch(const void *, const void *, size_t, size_t,";
3719 * Solaris
<iso
/stdio_iso.h
> doesn
't declare getc for C++ with
3720 * _STRICT_STDC, but uses it.
3723 hackname = solaris_getc_strict_stdc;
3724 mach = "*-*-solaris2*";
3725 files = "iso/stdio_iso.h";
3726 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3728 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3731 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3735 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3738 hackname = solaris_gets_c11;
3739 mach = "*-*-solaris2*";
3740 files = "iso/stdio_iso.h";
3741 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3744 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3745 "%1 __attribute__((__deprecated__));\n"
3748 test_text = "extern char *gets(char *);";
3752 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C
++14.
3755 hackname
= solaris_gets_cxx14
;
3756 mach
= "*-*-solaris2*";
3757 files
= "iso/stdio_iso.h";
3758 select
= <<- _EOSelect_
3759 (#if __STDC_VERSION__
< 201112L)
3760 (extern char \
*gets\
(char \
*\
) __ATTR_DEPRECATED
;)
3763 c_fix_arg
= "%1 && __cplusplus < 201402L\n%2";
3765 test_text
= <<- _EOText_
3766 #if __STDC_VERSION__
< 201112L
3767 extern char
*gets(char *) __ATTR_DEPRECATED
;
3772 * Sun Solaris
2 has a version of sys
/int_const.h that defines
3773 * UINT8_C and UINT16_C to unsigned constants.
3776 hackname
= solaris_int_const
;
3777 files
= sys
/int_const.h
;
3778 mach
= '*-*-solaris2*';
3780 c_fix_arg
= "#define\tUINT8_C(c)\t(c)\n"
3782 "#define\tUINT16_C(c)\t(c)";
3783 select
= "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3785 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3787 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3789 "#define UINT16_C(c) __CONCAT__(c,u)";
3793 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3794 * UINT8_MAX and UINT16_MAX to unsigned constants.
3797 hackname
= solaris_int_limits_1
;
3798 files
= sys
/int_limits.h
;
3799 mach
= '*-*-solaris2*';
3801 c_fix_arg
= "#define\tUINT8_MAX\t(255)\n"
3802 "#define\tUINT16_MAX\t(65535)";
3803 select
= "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3804 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3806 "#define UINT8_MAX (255U)\n"
3807 "#define UINT16_MAX (65535U)";
3811 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3812 * INT_FAST16 limits to wrong values for sys
/int_types.h.
3815 hackname
= solaris_int_limits_2
;
3816 files
= sys
/int_limits.h
;
3817 mach
= '*-*-solaris2*';
3819 c_fix_arg
= "#define\t%1_FAST16_%2 %132_%2";
3820 select
= "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3822 "#define INT_FAST16_MAX INT16_MAX\n"
3823 "#define UINT_FAST16_MAX UINT16_MAX\n"
3824 "#define INT_FAST16_MIN INT16_MIN";
3828 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3829 * SIZE_MAX as unsigned long.
3832 hackname
= solaris_int_limits_3
;
3833 files
= sys
/int_limits.h
;
3834 mach
= '*-*-solaris2*';
3836 c_fix_arg
= "#define\tSIZE_MAX\t4294967295U";
3837 select
= "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3839 "#define SIZE_MAX 4294967295UL";
3843 * Sun Solaris
10 defines several C99 math macros in terms of
3844 * builtins specific to the Studio compiler
, in particular not
3845 * compatible with the GNU compiler.
3848 hackname
= solaris_math_1
;
3849 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3850 bypass
= "__GNUC__";
3851 files
= iso
/math_c99.h
;
3853 c_fix_arg
= "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3854 c_fix_arg
= "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3856 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3858 "#define HUGE_VAL __builtin_huge_val\n"
3859 "#undef HUGE_VALF\n"
3860 "#define HUGE_VALF __builtin_huge_valf\n"
3861 "#undef HUGE_VALL\n"
3862 "#define HUGE_VALL __builtin_huge_vall";
3866 * On Solaris
11, if you do
isinf(NaN
) you
'll get a floating point
3867 * exception. Provide an alternative using GCC's builtin.
3870 hackname
= solaris_math_10
;
3871 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3872 files
= iso
/math_c99.h
;
3874 c_fix_arg
= "#define\tisinf(x) __builtin_isinf(x)";
3875 c_fix_arg
= "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3876 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3878 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3879 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3880 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3881 "\\(-INFINITY\\);[ \t]*\\}\\)";
3883 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3885 "#define isinf(x) __extension__( \\\\\n"
3886 " { __typeof(x) __x_i = (x); \\\\\n"
3887 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3888 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3892 * Solaris math INFINITY
3895 hackname
= solaris_math_2
;
3896 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3897 bypass
= "__GNUC__";
3898 files
= iso
/math_c99.h
;
3900 c_fix_arg
= "#define\tINFINITY\t(__builtin_inff())";
3901 c_fix_arg
= "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3903 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3905 "#define INFINITY __builtin_infinity";
3912 hackname
= solaris_math_3
;
3913 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3914 bypass
= "__GNUC__";
3915 files
= iso
/math_c99.h
;
3917 c_fix_arg
= "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3918 c_fix_arg
= "^#define[ \t]+NAN[ \t]+__builtin_nan";
3920 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3922 "#define NAN __builtin_nan";
3926 * Solaris math fpclassify
3929 hackname
= solaris_math_4
;
3930 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3931 bypass
= "__GNUC__";
3932 files
= iso
/math_c99.h
;
3934 c_fix_arg
= "#define\tfpclassify(x) \\\n"
3935 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3936 "FP_SUBNORMAL, FP_ZERO, (x))";
3937 c_fix_arg
= "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3939 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3940 "#undef fpclassify\n"
3941 "#define fpclassify(x) __builtin_fpclassify(x)";
3945 * Solaris math signbit
3948 hackname
= solaris_math_8
;
3949 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3950 bypass
= "__GNUC__";
3951 files
= iso
/math_c99.h
;
3953 c_fix_arg
= "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3954 "\t\t\t ? __builtin_signbitf(x) \\\n"
3955 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3956 "\t\t\t ? __builtin_signbitl(x) \\\n"
3957 "\t\t\t : __builtin_signbit(x))";
3958 c_fix_arg
= "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3959 test_text
= <<- _EOText_
3960 #ident
"@(#)math_c99.h 1.9 04/11/01 SMI"
3962 #define
signbit(x
) __builtin_signbit(x
)
3967 * Solaris math comparison macros
3970 hackname
= solaris_math_9
;
3971 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3972 bypass
= "__GNUC__";
3973 files
= iso
/math_c99.h
;
3975 c_fix_arg
= "#define\t%1(x, y)%2__builtin_%1(x, y)";
3976 c_fix_arg
= "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3977 "__builtin_[a-z]+\\(y\\)\\)";
3979 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3980 "#undef isgreater\n"
3981 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3982 "#undef isgreaterequal\n"
3983 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3985 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3986 "#undef islessequal\n"
3987 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3988 "#undef islessgreater\n"
3989 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3990 "#undef isunordered\n"
3991 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3995 * Newer Solaris
10/11 GCC signbit implementations cause strict
-aliasing
3999 hackname
= solaris_math_11
;
4000 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
4001 files
= iso
/math_c99.h
;
4003 c_fix_arg
= << _EOArg_
4005 #define
signbit(x
) (sizeof(x
) == sizeof(float
) \
4006 ?
__builtin_signbitf(x
) \
4007 : sizeof(x
) == sizeof(long double
) \
4008 ?
__builtin_signbitl(x
) \
4009 : __builtin_signbit(x
))
4011 c_fix_arg
= << _EOArg_
4013 #if defined\
(__sparc\
)
4014 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
4015 [ ]+\
{[ ]*__typeof\
(x\
)[ ]*__x_s
[ ]*=[ ]*\
(x\
);[ ]*\\
4016 [ ]+\
(int\
)[ ]*\
(\
*\
(unsigned
[ ]*\
*\
)[ ]*\
&__x_s
[ ]*>>[ ]*31\
);[ ]*\
}\
)
4017 #elif defined\
(__i386\
) \|\| defined\
(__amd64\
)
4018 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
4019 [ ]+\
{ __typeof\
(x\
) __x_s
= \
(x\
); \\
4020 [ ]+\
(sizeof \
(__x_s\
) == sizeof \
(float\
) \? \\
4021 [ ]+\
(int\
) \
(\
*\
(unsigned \
*\
) \
&__x_s
>> 31\
) : \\
4022 [ ]+sizeof \
(__x_s\
) == sizeof \
(double\
) \? \\
4023 [ ]+\
(int\
) \
(\
(\
(unsigned \
*\
) \
&__x_s\
)\
[1\
] >> 31\
) : \\
4024 [ ]+\
(int\
) \
(\
(\
(unsigned short \
*\
) \
&__x_s\
)\
[4\
] >> 15\
)\
); \
}\
)
4027 test_text
= << _EOText_
4028 /* @
(#
)math_c99.h
1.14 13/03/27 */
4030 #if
defined(__sparc
)
4031 #define
signbit(x
) __extension__( \\
4032 { __typeof(x
) __x_s
= (x
); \\
4033 (int
) (*(unsigned *) &__x_s
>> 31); })
4034 #elif
defined(__i386
) ||
defined(__amd64
)
4035 #define
signbit(x
) __extension__( \\
4036 { __typeof(x
) __x_s
= (x
); \\
4037 (sizeof (__x_s
) == sizeof (float
) ?
\\
4038 (int
) (*(unsigned *) &__x_s
>> 31) : \\
4039 sizeof (__x_s
) == sizeof (double
) ?
\\
4040 (int
) (((unsigned *)
&__x_s
)[1] >> 31) : \\
4041 (int
) (((unsigned short *)
&__x_s
)[4] >> 15)); })
4047 * Some versions of Solaris
10+ <math.h
> #undef libstdc
++-internal macros.
4050 hackname
= solaris_math_12
;
4052 mach
= '*-*-solaris2*';
4053 select
= '#undef.*_GLIBCXX_USE_C99_MATH';
4054 sed
= "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
4055 test_text
= << _EOText_
4056 #if __cplusplus
>= 201103L
4057 #undef _GLIBCXX_USE_C99_MATH
4058 #undef _GLIBCXX_USE_C99_MATH_TR1
4064 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
4065 * structure. As such
, it need two levels of brackets
, but only
4066 * contains one. Wrap the macro definition in an extra layer.
4069 hackname
= solaris_once_init_1
;
4070 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4072 mach
= '*-*-solaris*';
4074 c_fix_arg
= "%1{%2}%3";
4075 c_fix_arg
= "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
4077 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
4078 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
4082 * Solaris
10+ <spawn.h
> uses char
*const argv
[_RESTRICT_KYWD
] in the
4083 * posix_spawn declarations
, which doesn
't work with C++.
4086 hackname = solaris_posix_spawn_restrict;
4088 mach = '*-*-solaris2
*';
4090 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
4091 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
4093 "char *const argv[_RESTRICT_KYWD],\n"
4094 "char *const envp[_RESTRICT_KYWD]);";
4098 * The pow overloads with int were removed in C++ 2011 DR 550.
4101 hackname = solaris_pow_int_overload;
4102 mach = '*-*-solaris2
*';
4103 files = "iso/math_iso.h";
4104 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
4105 " *\\{[^{}]*\n[^{}]*\\}";
4107 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
4110 " inline long double pow(long double __X, int __Y) { return\n"
4111 " __powl(__X, (long double) (__Y)); }";
4115 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
4116 * fields of the pthread_rwlock_t structure, which are of type
4117 * upad64_t, which itself is typedef'd to int64_t
, but with __STDC__
4118 * defined (e.g. by
-ansi
) it is a union. So change the initializer
4122 hackname
= solaris_rwlock_init_1
;
4123 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
4125 mach
= '*-*-solaris*';
4127 c_fix_arg
= "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
4130 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
4132 c_fix_arg
= "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
4133 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
4136 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
4137 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
4141 * Before Solaris
10, <stdio.h
> lacks declarations of std
::__filbuf and
4142 * std
::__flsbuf
, but
<iso
/stdio_iso.h
> uses them.
4145 hackname
= solaris_std___filbuf
;
4147 mach
= '*-*-solaris2*';
4148 bypass
= "using std::__filbuf";
4149 select
= "(using std::perror;\n)(#endif)";
4151 c_fix_arg
= "%1#ifndef _LP64\n"
4152 "using std::__filbuf;\n"
4153 "using std::__flsbuf;\n"
4156 test_text
= "using std::perror;\n"
4161 * Solaris
<stdio.h
> shouldn
't use std::gets for C++14.
4164 hackname = solaris_std_gets_cxx14;
4165 mach = "*-*-solaris2*";
4167 select = "using std::gets;";
4170 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
4172 test_text = "using std::gets;";
4176 * Sun Solaris 8 has what appears to be some gross workaround for
4177 * some old version of their c++ compiler. G++ doesn't want it
4178 * either
, but doesn
't want to be tied to SunPRO version numbers.
4181 hackname = solaris_stdio_tag;
4182 files = stdio_tag.h;
4184 select = '__cplusplus
< 54321L';
4185 /* In Solaris 10, the code in stdio_tag.h is conditionalized on
4186 "!defined(__GNUC__)" so we no longer need to fix it. */
4187 bypass = '__GNUC__
';
4188 sed = 's
/defined(__cplusplus
) && (__cplusplus
< 54321L)/0/';
4190 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
4194 * Solaris <stdlib.h> shouldn't use _Noreturn
, breaks with C
++.
4197 hackname
= solaris_stdlib_noreturn
;
4198 mach
= "*-*-solaris2*";
4199 files
= "iso/stdlib_c99.h";
4200 select
= "(extern) _Noreturn (void quick_exit\\(int\\));";
4203 c_fix_arg
= "%1 %2 __attribute__((__noreturn__));";
4205 test_text
= "extern _Noreturn void quick_exit(int);";
4209 * a missing semi
-colon at the end of the statsswtch structure definition.
4212 hackname
= statsswtch
;
4213 files
= rpcsvc
/rstat.h
;
4214 select
= "boottime$";
4216 c_fix_arg
= "boottime;";
4217 test_text
= "struct statswtch {\n int boottime\n};";
4221 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
4222 * On
4BSD
-derived systems
, stdio.h defers to machine
/ansi.h
; that
's
4226 hackname = stdio_stdarg_h;
4228 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
4230 * On Solaris 10, this fix is unncessary; <stdio.h> includes
4231 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
4233 mach = '*-*-solaris2.1
[0-9]*';
4238 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
4244 * Don't use or define the name va_list in stdio.h. This is for
4245 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
4246 * of __gnuc_va_list
, __DJ_va_list
, or _G_va_list is taken to
4247 * indicate that the header knows what it
's doing -- under SUSv2,
4248 * stdio.h is required to define va_list, and we shouldn't break
4252 hackname
= stdio_va_list
;
4254 bypass
= '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
4256 * On Solaris
10, the definition in
4257 * <stdio.h
> is guarded appropriately by the _XPG4 feature macro
;
4258 * there is therefore no need for this fix there.
4260 mach
= '*-*-solaris2.1[0-9]*';
4264 * Use __gnuc_va_list in arg types in place of va_list.
4265 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4266 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4267 * trailing parentheses and semicolon save all other systems from this.
4268 * Define __not_va_list__ (something harmless and unused)
4269 * instead of va_list.
4270 * Don't claim to have defined va_list.
4272 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4273 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4274 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4275 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4276 "s@ va_list@ __not_va_list__@\n"
4277 "s@\\*va_list@*__not_va_list__@\n"
4278 "s@ __va_list)@ __gnuc_va_list)@\n"
4279 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4280 "@typedef \\1 __not_va_list__;@\n"
4281 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4282 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4283 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4284 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4285 "s@VA_LIST@DUMMY_VA_LIST@\n"
4286 "s@_Va_LIST@_VA_LIST@";
4287 test_text
= "extern void mumble( va_list);";
4291 * Fix headers that use va_list from stdio.h to use the updated
4292 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
4293 * dealt with elsewhere. The presence of __gnuc_va_list
,
4294 * __DJ_va_list
, or _G_va_list is taken to indicate that the header
4295 * knows what it
's doing.
4298 hackname = stdio_va_list_clients;
4306 files = curses_colr/curses.h;
4307 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list
';
4308 /* Don't fix
, if we use va_list from stdarg.h
, or if the use is
4309 otherwise protected.
*/
4310 bypass
= 'include <stdarg\.h>|#ifdef va_start';
4313 * Use __gnuc_va_list in arg types in place of va_list.
4314 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
4315 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
4316 * trailing parentheses and semicolon save all other systems from this.
4317 * Define __not_va_list__ (something harmless and unused)
4318 * instead of va_list.
4319 * Don't claim to have defined va_list.
4321 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
4322 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
4323 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
4324 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
4325 "s@ va_list@ __not_va_list__@\n"
4326 "s@\\*va_list@*__not_va_list__@\n"
4327 "s@ __va_list)@ __gnuc_va_list)@\n"
4328 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
4329 "@typedef \\1 __not_va_list__;@\n"
4330 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
4331 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
4332 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
4333 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4334 "s@VA_LIST@DUMMY_VA_LIST@\n"
4335 "s@_Va_LIST@_VA_LIST@";
4336 test_text
= "extern void mumble( va_list);";
4340 * "!__STDC__" or
"__STDC__==0" or
"__STDC__!=1" or
"__STDC__-0==0"
4341 * is
"!defined( __STRICT_ANSI__ )"
4344 hackname
= strict_ansi_not
;
4345 select
= "^([ \t]*#[ \t]*if.*)"
4347 "|__STDC__[ \t]*==[ \t]*0"
4348 "|__STDC__[ \t]*!=[ \t]*1"
4349 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4350 /* Tru64 UNIX V4.0F
/V5.1
<standards.h
> supports GCC usage of __STDC__.
*/
4351 bypass
= 'GNU and MIPS C compilers define __STDC__ differently';
4352 /* GNU gmp.h uses
"__STDC__ != 1" only if __SCO_VERSION__
, which
4353 is not defined by GCC
, so it is safe.
*/
4354 bypass
= '__SCO_VERSION__.*__STDC__ != 1';
4355 c_test
= stdc_0_in_system_headers
;
4358 c_fix_arg
= "%1 !defined(__STRICT_ANSI__)";
4360 test_text
= "#if !__STDC__ \n"
4361 "#if __STDC__ == 0\n"
4362 "#if __STDC__ != 1\n"
4363 "#if __STDC__ - 0 == 0"
4364 "/* not std C */\nint foo;\n"
4365 "\n#end-end-end-end-if :-)";
4370 * is
"!defined( __STRICT_ANSI__ )" on continued #if
-s
4373 hackname
= strict_ansi_not_ctd
;
4374 files
= math.h
, limits.h
, stdio.h
, signal.h
,
4375 stdlib.h
, sys
/signal.h
, time.h
;
4377 * Starting at the beginning of a line
, skip white space and
4378 * a leading
"(" or
"&&" or
"||". One of those must be found.
4379 * Then
, zero
, one or more copies of a
"defined(_FOO_BAR_) &&"
4380 * expression. If these are nested
, then they must accumulate
4381 * because we won
't match any closing parentheses. Finally,
4382 * after skipping over all that, we must then match our suspect
4383 * phrase: "__STDC__-0==0" with or without white space.
4385 select = "^([ \t]*" '(\
(|
&&|\|\|
)'
4386 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4388 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4389 c_test = stdc_0_in_system_headers;
4392 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4394 test_text = "#if 1 && \\\\\n"
4395 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4396 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4397 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4402 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4403 * is "defined( __STRICT_ANSI__ )"
4406 hackname = strict_ansi_only;
4407 select = "^([ \t]*#[ \t]*if.*)"
4408 "(__STDC__[ \t]*!=[ \t]*0"
4409 "|__STDC__[ \t]*==[ \t]*1"
4410 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4411 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4412 c_test = stdc_0_in_system_headers;
4415 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4417 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4421 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4422 * in prototype without previous definition.
4425 hackname = struct_file;
4427 select = '^.
*xdrstdio_create.
*struct __file_s
';
4429 c_fix_arg = "struct __file_s;\n%0";
4430 test_text = "extern void xdrstdio_create( struct __file_s* );";
4434 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4435 * in prototype without previous definition.
4437 * Don't fix OpenBSD
, which uses struct sockaddr_in prototyping the same
4438 * function
, and does define it.
4441 hackname
= struct_sockaddr
;
4443 select
= "^.*authdes_create.*struct sockaddr[^_]";
4444 bypass
= "<sys/socket\.h>";
4445 bypass
= "struct sockaddr;\n";
4447 c_fix_arg
= "struct sockaddr;\n%0";
4448 test_text
= "extern AUTH* authdes_create( struct sockaddr* );";
4452 * Apply fix this to all OSs since this problem seems to effect
4453 * more than just SunOS.
4456 hackname
= sun_auth_proto
;
4461 bypass
= "__cplusplus";
4463 * Select those files containing
'(*name)()'.
4465 select
= '\(\*[a-z][a-z_]*\)\(\)';
4468 c_fix_arg
= "#ifdef __cplusplus\n%1(...);%2\n"
4469 "#else\n%1();%2\n#endif";
4470 c_fix_arg
= '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4474 " int (*name)(); /* C++ bad */\n"
4479 * Fix bogus #ifdef on SunOS
4.1.
4482 hackname
= sun_bogus_ifdef
;
4483 files
= "hsfs/hsfs_spec.h";
4484 files
= "hsfs/iso_spec.h";
4485 select
= '#ifdef(.*\|\|.*)';
4487 c_fix_arg
= "#if%1";
4489 test_text
= "#ifdef __i386__ || __vax__ || __sun4c__";
4493 * Fix the CAT macro in SunOS memvar.h.
4496 hackname
= sun_catmacro
;
4497 files
= pixrect
/memvar.h
;
4498 select
= "^#define[ \t]+CAT\\(a,b\\).*";
4503 "# define CAT(a,b) a##b\n"
4504 "#else\n%0\n#endif";
4507 "#define CAT(a,b)\ta/**/b";
4511 * Fix return type of free and
{c
,m
,re
}alloc in
<malloc.h
> on SunOS
4.1.
4512 * Also fix return type of
{m
,re
}alloc in
<malloc.h
> on sysV68
4515 hackname
= sun_malloc
;
4517 bypass
= "_CLASSIC_ANSI_TYPES";
4519 sed
= "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4520 sed
= "s/int[ \t][ \t]*free/void\tfree/g";
4521 sed
= "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4522 sed
= "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4523 sed
= "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4526 "typedef char *\tmalloc_t;\n"
4528 "char*\tmalloc();\n"
4529 "char*\tcalloc();\n"
4530 "char*\trealloc();";
4534 * Check for yet more missing
';' in
struct (in SunOS
4.0.x
)
4537 hackname
= sun_rusers_semi
;
4538 files
= rpcsvc
/rusers.h
;
4540 sed
= "/^struct/,/^};/s/_cnt$/_cnt;/";
4541 test_text
= "struct mumble\n int _cnt\n};";
4545 * signal.h on SunOS defines signal
using (),
4546 * which causes trouble when compiling with g
++ -pedantic.
4549 hackname
= sun_signal
;
4550 files
= sys
/signal.h
;
4552 select
= "^void\t" '\(\*signal\(\)\)\(\);.*';
4556 "#ifdef __cplusplus\n"
4557 "void\t(*signal(...))(...);\n"
4558 "#else\n%0\n#endif";
4560 test_text
= "void\t(*signal())();";
4564 * Correct the return type for strlen in strings.h in SunOS
4.
4567 hackname
= sunos_strlen
;
4569 select
= "int[ \t]*strlen\\(\\);(.*)";
4571 c_fix_arg
= "__SIZE_TYPE__ strlen();%1";
4572 test_text
= " int\tstrlen(); /* string length */";
4576 * Linux kernel
's vt.h breaks C++
4579 hackname = suse_linux_vt_cxx;
4582 select = "^[ \t]*unsigned int new;";
4584 c_fix_arg = "unsigned int newev;";
4586 test_text = " unsigned int new; /* New console (if changing) */";
4590 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4591 * that is visible to any ANSI compiler using this include. Simply
4592 * delete the lines that #define some string functions to internal forms.
4595 hackname = svr4_disable_opt;
4597 select = '#define.
*__std_hdr_
';
4598 sed = '/#define.
*__std_hdr_
/d
';
4599 test_text = "#define strlen __std_hdr_strlen\n";
4603 * Fix broken decl of getcwd present on some svr4 systems.
4606 hackname = svr4_getcwd;
4609 files = prototypes.h;
4610 select = 'getcwd\
(char \
*, int\
)';
4613 c_fix_arg = "getcwd(char *, size_t)";
4615 test_text = "extern char* getcwd(char *, int);";
4619 * Fix broken decl of profil present on some svr4 systems.
4622 hackname = svr4_profil;
4627 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
4629 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
4632 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
4636 * Correct types for signal handler constants like SIG_DFL; they might be
4637 * void (*) (), and should be void (*) (int). C++ doesn't like the
4641 hackname
= svr4_sighandler_type
;
4642 files
= sys
/signal.h
;
4643 select
= 'void *\(\*\)\(\)';
4645 c_fix_arg
= "void (*)(int)";
4646 test_text
= "#define SIG_DFL (void(*)())0\n"
4647 "#define SIG_IGN (void (*)())0\n";
4651 * Some SysV r4 systems
, including Sequent
's DYNIX/ptx, use the local
4652 * function 'getrnge
' in <regexp.h> before they declare it. For these
4653 * systems add a 'static int
' declaration of 'getrnge
' into <regexp.h>
4656 * 'getrnge
' traditionally manipulates a file-scope global called 'size
',
4657 * so put the declaration right after the declaration of 'size
'.
4659 * Don't do this if there is already a `static void getrnge
' declaration
4660 * present, since this would cause a redeclaration error. Solaris 2.x has
4661 * such a declaration.
4664 hackname = svr4_undeclared_getrnge;
4667 bypass = "static void getrnge";
4670 "static int getrnge ();";
4671 c_fix_arg = "^static int[ \t]+size;";
4672 test_text = "static int size;\n"
4673 "/* stuff which calls getrnge() */\n"
4674 "static getrnge()\n"
4679 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4680 * in string.h on sysV68
4681 * Correct the return type for strlen in string.h on Lynx.
4682 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4683 * Add missing const for strdup on OSF/1 V3.0.
4684 * On sysV88 layout is slightly different.
4687 hackname = sysv68_string;
4690 bypass = "_CLASSIC_ANSI_TYPES";
4692 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4693 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4694 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4696 sed = "/^extern char$/N";
4697 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4699 sed = "/^extern int$/N";
4700 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4702 sed = "/^\tstrncmp(),$/N";
4703 sed = 's
/^\
(' "\t" 'strncmp()\
),\n\
(' "\t" 'strlen(),\
)$
/'
4704 '\
1;' "\\\nextern unsigned int\\\n\\2/";
4707 "extern int strlen();\n"
4709 "extern int ffs(long);\n"
4722 "\tstrlen(), strspn();";
4726 * Fix return type of calloc, malloc, realloc, bsearch and exit
4729 hackname = sysz_stdlib_for_sun;
4731 bypass = "_CLASSIC_ANSI_TYPES";
4733 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4735 c_fix_arg = "void *\t%1(";
4738 "extern char*\tcalloc(size_t);\n"
4739 "extern char*\tmalloc(size_t);\n"
4740 "extern char*\trealloc(void*,size_t);\n"
4741 "extern char*\tbsearch(void*,size_t,size_t);\n";
4745 * __thread is now a keyword.
4748 hackname = thread_keyword;
4749 files = "pthread.h";
4750 files = bits/sigthread.h, '*/bits
/sigthread.h
';
4751 select = "([* ])__thread([,)])";
4753 c_fix_arg = "%1__thr%2";
4756 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4757 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4758 "extern int pthread_cancel (pthread_t __thread);";
4762 * if the #if says _cplusplus, not the double underscore __cplusplus
4766 hackname = tinfo_cplusplus;
4768 select = "[ \t]_cplusplus";
4771 c_fix_arg = " __cplusplus";
4772 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4776 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4779 hackname = ultrix_const;
4781 select = 'perror\
( char \
*';
4784 c_fix_arg = "%1 const %3 *__";
4785 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4786 "[ \t]+(char|void) \\*__";
4789 "extern void perror( char *__s );\n"
4790 "extern int fputs( char *__s, FILE *);\n"
4791 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4792 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4793 "extern int scanf( char *__format, ...);\n";
4797 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4800 hackname = ultrix_const2;
4803 select = '\
*fopen\
( char \
*';
4805 c_fix_arg = "%1( const char *%3, const char *";
4806 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4807 "[ \t]*char[ \t]*\\*([^,]*),"
4808 "[ \t]*char[ \t]*\\*[ \t]*";
4811 "extern FILE *fopen( char *__filename, char *__type );\n"
4812 "extern int sscanf( char *__s, char *__format, ...);\n"
4813 "extern FILE *popen(char *, char *);\n"
4814 "extern char *tempnam(char*,char*);\n";
4818 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4821 hackname = va_i960_macro;
4822 files = arch/i960/archI960.h;
4823 select = "__(vsiz|vali|vpad|alignof__)";
4826 c_fix_arg = "__vx%1";
4829 "extern int __vsiz vsiz;\n"
4830 "extern int __vali vali;\n"
4831 "extern int __vpad vpad;\n"
4832 "#define __alignof__(x) ...";
4836 * On VMS, add missing braces around sigset_t constants.
4839 hackname = vms_add_missing_braces;
4840 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4842 files = "rtldef/signal.h";
4845 c_fix_arg = '%1 {%2} ';
4847 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4848 "{0x00000000, 0x00000000},\n"
4849 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4853 * On VMS, some DEC-C builtins are directly used.
4856 hackname = vms_decc_builtin;
4857 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4859 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4861 sed = "s@__MEMSET@memset@";
4862 sed = "s@__MEMMOVE@memmove@";
4863 sed = "s@__MEMCPY@memcpy@";
4864 sed = "s@__STRLEN@strlen@";
4865 sed = "s@__STRCPY@strcpy@";
4867 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4871 * Define __CAN_USE_EXTERN_PREFIX on vms.
4874 hackname = vms_define_can_use_extern_prefix;
4875 files = "rtldef/decc$types.h";
4876 select = "#[ \t]*else\n"
4877 "#[ \t]*if defined\\(__DECCXX\\)\n"
4878 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4883 "# elif defined (__GNUC__)\n"
4884 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4886 test_text = "# else\n"
4887 "# if defined(__DECCXX)\n"
4888 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4894 * On VMS, disable the use of dec-c string builtins
4897 hackname = vms_disable_decc_string_builtins;
4898 select = "#if !defined\\(__VAX\\)\n";
4900 files = "rtldef/string.h";
4903 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4905 test_text = "#if !defined(__VAX)\n";
4909 * On VMS, fix incompatible redeclaration of hostalias.
4912 hackname = vms_do_not_redeclare_hostalias;
4913 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4914 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4916 files = "rtldef/resolv.h";
4922 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4923 "__char_ptr32 hostalias (const char *);\n";
4927 * On VMS, forward declare structure before referencing them in prototypes.
4930 hackname = vms_forward_declare_struct;
4931 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4932 "#ifdef __cplusplus\n";
4934 files = rtldef/if.h;
4938 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4940 test_text = "/* forward decls for C++ */\n"
4941 "#ifdef __cplusplus\n"
4947 * On VMS, do not declare getopt and al if pointers are 64 bit.
4950 hackname = vms_no_64bit_getopt;
4951 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4952 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4954 files = rtldef/stdio.h, rtldef/unistd.h;
4957 c_fix_arg = <<- _EOArg_
4958 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4963 test_text = "int getopt (int, char * const [], const char *);";
4967 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4968 * which is not yet fully supported by gcc.
4971 hackname = vms_use_fast_setjmp;
4972 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4974 files = rtldef/setjmp.h;
4977 c_fix_arg = "%0 defined (__GNUC__) ||";
4979 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4983 * On VMS, use pragma extern_model instead of VAX-C keywords.
4986 hackname = vms_use_pragma_extern_model;
4987 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4988 "# pragma extern_model __save\n";
4992 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4993 "# pragma extern_model __save\n";
4995 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4996 "# pragma extern_model __save\n"
4997 "# pragma extern_model strict_refdef\n"
4998 " extern struct x zz$yy;\n"
4999 "# pragma extern_model __restore\n"
5004 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
5005 * conflict while building gcc. Likewise for <builtins.h>
5008 hackname = vms_use_quoted_include;
5009 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
5011 files = rtldef/wait.h, starlet_c/pthread.h;
5014 c_fix_arg = '%1<sys
/%2.h
>';
5016 test_text = "# include <resource.h>";
5020 * AIX and Interix headers define NULL to be cast to a void pointer,
5021 * which is illegal in ANSI C++.
5024 hackname = void_null;
5025 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
5026 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
5027 /* avoid changing C++ friendly NULL */
5028 bypass = __cplusplus;
5030 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
5032 c_fix_arg = <<- _EOFix_
5037 #else /* ! __GNUG__ */
5039 #endif /* __GNUG__ */
5040 #else /* ! __cplusplus */
5041 #define NULL ((void *)0)
5042 #endif /* __cplusplus */
5045 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
5049 * Make VxWorks header which is almost gcc ready fully gcc ready.
5052 hackname = vxworks_gcc_problem;
5053 files = types/vxTypesBase.h;
5054 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
5056 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
5059 sed = "/[ \t]size_t/i\\\n"
5060 "#ifndef _GCC_SIZE_T\\\n"
5061 "#define _GCC_SIZE_T\n";
5063 sed = "/[ \t]size_t/a\\\n"
5066 sed = "/[ \t]ptrdiff_t/i\\\n"
5067 "#ifndef _GCC_PTRDIFF_T\\\n"
5068 "#define _GCC_PTRDIFF_T\n";
5070 sed = "/[ \t]ptrdiff_t/a\\\n"
5073 sed = "/[ \t]wchar_t/i\\\n"
5074 "#ifndef _GCC_WCHAR_T\\\n"
5075 "#define _GCC_WCHAR_T\n";
5077 sed = "/[ \t]wchar_t/a\\\n"
5081 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
5082 "typedef unsigned int size_t;\n"
5083 "typedef long ptrdiff_t;\n"
5084 "typedef unsigned short wchar_t;\n"
5085 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
5089 * Wrap VxWorks ioctl to keep everything pretty
5092 hackname = vxworks_ioctl_macro;
5094 mach = "*-*-vxworks*";
5098 "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
5099 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
5101 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
5105 * Wrap VxWorks mkdir to be posix compliant
5108 hackname = vxworks_mkdir_macro;
5110 mach = "*-*-vxworks*";
5114 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
5115 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
5116 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
5117 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
5120 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
5124 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
5127 hackname = vxworks_needs_vxtypes;
5129 select = "uint_t([ \t]+_clocks_per_sec)";
5131 c_fix_arg = "unsigned int%1";
5132 test_text = "uint_t\t_clocks_per_sec;";
5136 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
5139 hackname = vxworks_needs_vxworks;
5141 test = " -r types/vxTypesOld.h";
5142 test = " -n \"`egrep '#include
' $file`\"";
5143 test = " -n \"`egrep ULONG $file`\"";
5144 select = "#[ \t]define[ \t]+__INCstath";
5146 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
5147 "#include <types/vxTypesOld.h>\n";
5149 test_text = "`touch types/vxTypesOld.h`"
5150 "#include </dev/null> /* ULONG */\n"
5151 "# define\t__INCstath <sys/stat.h>";
5155 * Make it so VxWorks does not include gcc/regs.h accidentally
5158 hackname = vxworks_regs;
5159 mach = "*-*-vxworks*";
5161 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
5163 c_fix_arg = "#include <arch/../regs.h>";
5165 test_text = "#include <regs.h>\n";
5169 * Another bad dependency in VxWorks 5.2 <time.h>.
5172 hackname = vxworks_time;
5174 test = " -r vxWorks.h";
5176 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
5180 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
5181 "#ifdef __cplusplus\n"
5182 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
5184 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
5186 "#define __gcc_VOIDFUNCPTR_defined\n"
5188 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
5190 test_text = "`touch vxWorks.h`"
5191 "#define VOIDFUNCPTR (void(*)())";
5195 * This hack makes write const-correct on VxWorks
5198 hackname = vxworks_write_const;
5200 mach = "*-*-vxworks*";
5203 c_fix_arg = "extern int write (int, const char*, size_t);";
5204 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
5206 "[\t ]*char[\t ]*\\*[\t ]*,"
5207 "[\t ]*size_t[\t ]*\\)[\t ]*;";
5209 test_text = "extern int write ( int , char * , size_t ) ;";
5213 * This hack ensures the include_next in the fixed unistd.h actually
5214 * finds the system's unistd.h and not the fixed unistd.h again.
5217 hackname
= vxworks_iolib_include_unistd
;
5219 mach
= "*-*-vxworks*";
5220 select
= "#include \"unistd.h\"";
5223 c_fix_arg
= "#include <unistd.h>";
5225 test_text
= "#include \"unistd.h\"";
5229 * There are several name conflicts with C
++ reserved words in X11 header
5230 * files. These are fixed in some versions
, so don
't do the fixes if
5231 * we find __cplusplus in the file. These were found on the RS/6000.
5234 hackname = x11_class;
5235 files = X11/ShellP.h;
5236 bypass = __cplusplus;
5237 select = "^([ \t]*char \\*)class;(.*)";
5239 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
5240 "#else\n%1class;%2\n#endif";
5248 * class in Xm/BaseClassI.h
5251 hackname = x11_class_usage;
5252 files = Xm/BaseClassI.h;
5253 bypass = "__cplusplus";
5255 select = " class\\)";
5257 c_fix_arg = " c_class)";
5259 test_text = "extern mumble (int class);\n";
5263 * new in Xm/Traversal.h
5267 files = Xm/Traversal.h;
5268 bypass = __cplusplus;
5270 sed = "/Widget\told, new;/i\\\n"
5271 "#ifdef __cplusplus\\\n"
5272 "\\\tWidget\told, c_new;\\\n"
5275 sed = "/Widget\told, new;/a\\\n"
5278 sed = "s/Widget new,/Widget c_new,/g";
5281 " Widget\told, new;\n"
5282 "};\nextern Wedged( Widget new, Widget old );";
5286 * Incorrect sprintf declaration in X11/Xmu.h
5289 hackname = x11_sprintf;
5291 files = X11/Xmu/Xmu.h;
5292 select = "^extern char \\*\tsprintf\\(\\);$";
5295 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
5297 test_text = "extern char *\tsprintf();";