3 autogen definitions fixincl
;
5 /* Define all the fixes we know about for repairing damaged headers.
6 Please see the README before adding or changing entries in this file.
8 This is the sort command
:
10 blocksort output
=inclhack.sorted \
12 trailer
='^/\*EOF\*[/]' \
14 key
=$
'hackname[ \t]*=[ \t]*(.*);'
16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes
: */
23 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g
++
25 * because cstdio udefs everything from stdio.h
, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g
++ and
-D_LARGE_FILES
31 hackname
= AAB_aix_stdio
;
33 select
= "define fopen fopen64";
35 test
-text
= ''; /* no way to test
*/
41 c_fix_arg
= <<- _EOArg_
43 #if defined __GNUG__
&& defined _LARGE_FILES
&& defined __cplusplus
44 #define __need__aix_stdio_h_fix
45 #ifdef __need__aix_stdio_h_fix
52 /* Alias the symbols using asm
*/
54 extern int
fgetpos(FILE
*, fpos64_t *)
__asm__("fgetpos64");
55 extern FILE
*fopen(const char
*, const char *)
__asm__("fopen64");
56 extern FILE
*freopen(const char
*, const char
*, FILE *)
__asm__("freopen64");
57 extern int
fseeko(FILE
*, off64_t
, int
) __asm__("fseeko64");
58 extern int
fsetpos(FILE
*, const fpos64_t *)
__asm__("fsetpos64");
59 extern off64_t
ftello(FILE *)
__asm__("ftello64");
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g
++ and
-D_LARGE_FILES
73 hackname
= AAB_aix_fcntl
;
75 select
= "define open[ \t]open64";
77 test
-text
= ''; /* no way to test
*/
83 c_fix_arg
= <<- _EOArg_
85 #if defined __GNUG__
&& defined _LARGE_FILES
&& defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
91 /* Alias the symbols using asm
*/
93 extern int
open(const char
*, int
, ...
) __asm__("open64");
94 extern int
creat(const char
*, mode_t
) __asm__("creat64");
95 #
if (_XOPEN_SOURCE
>= 700)
96 extern int
openat(int
, const char
*, int
, ...
) __asm__("open64at");
106 * On Mac OS
10.3.9, the
'long double' functions are available in
107 * libSystem
, but are not prototyped in math.h.
110 hackname
= AAB_darwin7_9_long_double_funcs
;
111 mach
= "*-*-darwin7.9*";
112 files
= architecture
/ppc
/math.h
;
114 replace
= <<- _EndOfHeader_
115 /* This file prototypes the long double functions available on Mac OS
119 # define __APPLE_CC__
1345
120 # include_next
<architecture
/ppc
/math.h
>
122 # define __APPLE_CC__
1
123 # ifndef __LIBMLDBL_COMPAT
124 # ifdef __LONG_DOUBLE_128__
125 # define
__LIBMLDBL_COMPAT(sym
) __asm("_" #sym
"$LDBL128")
127 # define
__LIBMLDBL_COMPAT(sym
)
128 # endif
/* __LONG_DOUBLE_128__
*/
129 # endif
/* __LIBMLDBL_COMPAT
*/
133 extern long double
acosl( long double
) __LIBMLDBL_COMPAT(acosl
);
134 extern long double
asinl( long double
) __LIBMLDBL_COMPAT(asinl
);
135 extern long double
atanl( long double
) __LIBMLDBL_COMPAT(atanl
);
136 extern long double
atan2l( long double
, long double
) __LIBMLDBL_COMPAT(atan2l
);
137 extern long double
cosl( long double
) __LIBMLDBL_COMPAT(cosl
);
138 extern long double
sinl( long double
) __LIBMLDBL_COMPAT(sinl
);
139 extern long double
tanl( long double
) __LIBMLDBL_COMPAT(tanl
);
140 extern long double
acoshl( long double
) __LIBMLDBL_COMPAT(acoshl
);
141 extern long double
asinhl( long double
) __LIBMLDBL_COMPAT(asinhl
);
142 extern long double
atanhl( long double
) __LIBMLDBL_COMPAT(atanhl
);
143 extern long double
coshl( long double
) __LIBMLDBL_COMPAT(coshl
);
144 extern long double
sinhl( long double
) __LIBMLDBL_COMPAT(sinhl
);
145 extern long double
tanhl( long double
) __LIBMLDBL_COMPAT(tanhl
);
146 extern long double
expl( long double
) __LIBMLDBL_COMPAT(expl
);
147 extern long double
exp2l( long double
) __LIBMLDBL_COMPAT(exp2l
);
148 extern long double
expm1l( long double
) __LIBMLDBL_COMPAT(expm1l
);
149 extern long double
logl( long double
) __LIBMLDBL_COMPAT(logl
);
150 extern long double
log10l( long double
) __LIBMLDBL_COMPAT(log10l
);
151 extern long double
log2l( long double
) __LIBMLDBL_COMPAT(log2l
);
152 extern long double
log1pl( long double
) __LIBMLDBL_COMPAT(log1pl
);
153 extern long double
logbl( long double
) __LIBMLDBL_COMPAT(logbl
);
154 extern long double
modfl( long double
, long double
* ) __LIBMLDBL_COMPAT(modfl
);
155 extern long double
ldexpl( long double
, int
) __LIBMLDBL_COMPAT(ldexpl
);
156 extern long double
frexpl( long double
, int
* ) __LIBMLDBL_COMPAT(frexpl
);
157 extern int
ilogbl( long double
) __LIBMLDBL_COMPAT(ilogbl
);
158 extern long double
scalbnl( long double
, int
) __LIBMLDBL_COMPAT(scalbnl
);
159 extern long double
scalblnl( long double
, long int
) __LIBMLDBL_COMPAT(scalblnl
);
160 extern long double
fabsl( long double
) __LIBMLDBL_COMPAT(fabsl
);
161 extern long double
cbrtl( long double
) __LIBMLDBL_COMPAT(cbrtl
);
162 extern long double
hypotl( long double
, long double
) __LIBMLDBL_COMPAT(hypotl
);
163 extern long double
powl( long double
, long double
) __LIBMLDBL_COMPAT(powl
);
164 extern long double
sqrtl( long double
) __LIBMLDBL_COMPAT(sqrtl
);
165 extern long double
erfl( long double
) __LIBMLDBL_COMPAT(erfl
);
166 extern long double
erfcl( long double
) __LIBMLDBL_COMPAT(erfcl
);
167 extern long double
lgammal( long double
) __LIBMLDBL_COMPAT(lgammal
);
168 extern long double
tgammal( long double
) __LIBMLDBL_COMPAT(tgammal
);
169 extern long double
ceill( long double
) __LIBMLDBL_COMPAT(ceill
);
170 extern long double
floorl( long double
) __LIBMLDBL_COMPAT(floorl
);
171 extern long double
nearbyintl( long double
) __LIBMLDBL_COMPAT(nearbyintl
);
172 extern long double
rintl( long double
) __LIBMLDBL_COMPAT(rintl
);
173 extern long int
lrintl( long double
) __LIBMLDBL_COMPAT(lrintl
);
174 extern long long int
llrintl( long double
) __LIBMLDBL_COMPAT(llrintl
);
175 extern long double
roundl( long double
) __LIBMLDBL_COMPAT(roundl
);
176 extern long int
lroundl( long double
) __LIBMLDBL_COMPAT(lroundl
);
177 extern long long int
llroundl( long double
) __LIBMLDBL_COMPAT(llroundl
);
178 extern long double
truncl( long double
) __LIBMLDBL_COMPAT(truncl
);
179 extern long double
fmodl( long double
, long double
) __LIBMLDBL_COMPAT(fmodl
);
180 extern long double
remainderl( long double
, long double
) __LIBMLDBL_COMPAT(remainderl
);
181 extern long double
remquol( long double
, long double
, int
* ) __LIBMLDBL_COMPAT(remquol
);
182 extern long double
copysignl( long double
, long double
) __LIBMLDBL_COMPAT(copysignl
);
183 extern long double
nanl( const char
* ) __LIBMLDBL_COMPAT(nanl
);
184 extern long double
nextafterl( long double
, long double
) __LIBMLDBL_COMPAT(nextafterl
);
185 extern long double
nexttowardl( long double
, long double
) __LIBMLDBL_COMPAT(nexttowardl
);
186 extern long double
fdiml( long double
, long double
) __LIBMLDBL_COMPAT(fdiml
);
187 extern long double
fmaxl( long double
, long double
) __LIBMLDBL_COMPAT(fmaxl
);
188 extern long double
fminl( long double
, long double
) __LIBMLDBL_COMPAT(fminl
);
189 extern long double
fmal( long double
, long double
, long double
) __LIBMLDBL_COMPAT(fmal
);
193 #endif
/* __MATH__
*/
198 * This fixes __FD_ZERO bug for linux
2.x.
y (x
<= 2 && y
<= some n
)
201 hackname
= AAB_fd_zero_asm_posix_types_h
;
202 files
= asm
/posix_types.h
;
203 mach
= 'i[34567]86-*-linux*';
206 bypass
= 'posix_types_64';
209 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper
, not
210 * the start
, so that if #include_next gets another instance of
211 * the wrapper
, this will follow the #include_next chain until
212 * we arrive at the real
<asm
/posix_types.h
>.
214 replace
= <<- _EndOfHeader_
215 /* This file fixes a bug in the __FD_ZERO macro
216 for older versions of the Linux kernel.
*/
217 #ifndef _POSIX_TYPES_H_WRAPPER
218 #include
<features.h
>
219 #include_next
<asm
/posix_types.h
>
221 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
223 #define
__FD_ZERO(fdsetp
) \
226 __asm__
__volatile__("cld ; rep ; stosl" \
227 : "=&c" (__d0
), "=&D" (__d1
) \
228 : "a" (0), "0" (__FDSET_LONGS
), \
229 "1" ((__kernel_fd_set *)
(fdsetp
)) :"memory"); \
233 #define _POSIX_TYPES_H_WRAPPER
234 #endif
/* _POSIX_TYPES_H_WRAPPER
*/
239 * This fixes __FD_ZERO bug for glibc
-1.x
242 hackname
= AAB_fd_zero_gnu_types_h
;
244 mach
= 'i[34567]86-*-linux*';
247 * Define _TYPES_H_WRAPPER at the end of the wrapper
, not
248 * the start
, so that if #include_next gets another instance of
249 * the wrapper
, this will follow the #include_next chain until
250 * we arrive at the real
<gnu
/types.h
>.
252 replace
= <<- _EndOfHeader_
253 /* This file fixes a bug in the __FD_ZERO macro present in glibc
1.x.
*/
254 #ifndef _TYPES_H_WRAPPER
255 #include
<features.h
>
256 #include_next
<gnu
/types.h
>
258 #if
defined(__FD_ZERO
) && !defined(__GLIBC__
)
260 # define
__FD_ZERO(fdsetp
) \
263 __asm__
__volatile__("cld ; rep ; stosl" \
264 : "=&c" (__d0
), "=&D" (__d1
) \
265 : "a" (0), "0" (__FDSET_LONGS
), \
266 "1" ((__fd_set *)
(fdsetp
)) :"memory"); \
270 #define _TYPES_H_WRAPPER
271 #endif
/* _TYPES_H_WRAPPER
*/
276 * This fixes __FD_ZERO bug for glibc
-2.0.x
279 hackname
= AAB_fd_zero_selectbits_h
;
280 files
= selectbits.h
;
281 mach
= 'i[34567]86-*-linux*';
284 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper
, not
285 * the start
, so that if #include_next gets another instance of
286 * the wrapper
, this will follow the #include_next chain until
287 * we arrive at the real
<selectbits.h
>.
289 replace
= <<- _EndOfHeader_
290 /* This file fixes a bug in the __FD_ZERO macro present in glibc
2.0.x.
*/
291 #ifndef _SELECTBITS_H_WRAPPER
292 #include
<features.h
>
293 #include_next
<selectbits.h
>
295 #if
defined(__FD_ZERO
) && defined(__GLIBC__
) \\
296 && defined(__GLIBC_MINOR__
) && __GLIBC__
== 2 \\
297 && __GLIBC_MINOR__
== 0
299 #define
__FD_ZERO(fdsetp
) \\
302 __asm__
__volatile__ ("cld; rep; stosl" \\
303 : "=&c" (__d0
), "=&D" (__d1
) \\
304 : "a" (0), "0" (sizeof (__fd_set
) \\
305 / sizeof (__fd_mask
)), \\
306 "1" ((__fd_mask *)
(fdsetp
)) \\
311 #define _SELECTBITS_H_WRAPPER
312 #endif
/* _SELECTBITS_H_WRAPPER
*/
317 * Solaris
<sys
/varargs.h
> is a
DDK (aka kernel
-land
) header providing
318 * the same interface as
<stdarg.h
>. No idea why they couldn
't have just
319 * used the standard header.
322 hackname = AAB_solaris_sys_varargs_h;
323 files = "sys/varargs.h";
324 mach = '*-*-solaris
*';
325 replace = <<- _EndOfHeader_
335 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
336 * declaration on Sun OS
4.x. We must only fix this on Sun OS
4.x
, because
337 * many other systems have similar text but correct versions of the file.
338 * To ensure only Sun
's is fixed, we grep for a likely unique string.
339 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
342 hackname = AAB_sun_memcpy;
344 select = "/\\*\t@\\(#\\)"
345 "(head/memory.h\t50.1\t "
346 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
348 replace = <<- _EndOfHeader_
349 /* This file was generated by fixincludes */
354 extern void *memccpy();
355 extern void *memchr();
356 extern void *memcpy();
357 extern void *memset();
359 extern char *memccpy();
360 extern char *memchr();
361 extern char *memcpy();
362 extern char *memset();
363 #endif /* __STDC__ */
367 #endif /* __memory_h__ */
372 * Fix assert.h on VxWorks:
375 hackname = AAB_vxworks_assert;
377 mach = "*-*-vxworks*";
379 replace = <<- _EndOfHeader_
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
390 extern void __assert ();
394 #define assert(ign) ((void)0)
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
416 hackname = AAB_vxworks_regs_vxtypes;
418 mach = "*-*-vxworks*";
420 replace = <<- _EndOfHeader_
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
430 * Make VxWorks stdint.h a bit more compliant - add typedefs
433 hackname = AAB_vxworks_stdint;
435 mach = "*-*-vxworks*";
437 replace = <<- _EndOfHeader_
440 /* get int*_t, uint*_t */
441 #include <types/vxTypes.h>
443 /* get legacy vxworks types for compatibility */
444 #include <types/vxTypesOld.h>
446 typedef long intptr_t;
447 typedef unsigned long uintptr_t;
449 typedef int64_t intmax_t;
450 typedef uint64_t uintmax_t;
452 typedef int8_t int_least8_t;
453 typedef int16_t int_least16_t;
454 typedef int32_t int_least32_t;
455 typedef int64_t int_least64_t;
457 typedef uint8_t uint_least8_t;
458 typedef uint16_t uint_least16_t;
459 typedef uint32_t uint_least32_t;
460 typedef uint64_t uint_least64_t;
462 typedef int8_t int_fast8_t;
463 typedef int int_fast16_t;
464 typedef int32_t int_fast32_t;
465 typedef int64_t int_fast64_t;
467 typedef uint8_t uint_fast8_t;
468 typedef unsigned int uint_fast16_t;
469 typedef uint32_t uint_fast32_t;
470 typedef uint64_t uint_fast64_t;
473 #define UINT8_MAX (~(uint8_t)0)
475 #define UINT16_MAX (~(uint16_t)0)
477 #define UINT32_MAX (~(uint32_t)0)
479 #define UINT64_MAX (~(uint64_t)0)
482 #define UINTPTR_MAX (~(uintptr_t)0)
483 #define UINTPTR_MIN 0
485 /* Need to do int_fast16_t as well, as type
486 size may be architecture dependent */
487 #define UINT_FAST16_MAX (~(uint_fast16_t)0)
488 #define UINT_FAST16_MAX 0
490 #define INT8_MAX (UINT8_MAX>>1)
491 #define INT8_MIN (INT8_MAX+1)
492 #define INT16_MAX (UINT16_MAX>>1)
493 #define INT16_MIN (INT16_MAX+1)
494 #define INT32_MAX (UINT32_MAX>>1)
495 #define INT32_MIN (INT32_MAX+1)
496 #define INT64_MAX (UINT64_MAX>>1)
497 #define INT64_MIN (INT64_MAX+1)
499 #define INTPTR_MAX (UINTPTR_MAX>>1)
500 #define INTPTR_MIN (INTPTR_MAX+1)
502 #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
503 #define INT_FAST16_MIN (INT_FAST16_MAX+1)
505 /* now define equiv. constants */
506 #define UINT_FAST8_MAX UINT8_MAX
507 #define UINT_FAST8_MIN UINT_FAST8_MIN
508 #define INT_FAST8_MAX INT8_MAX
509 #define INT_FAST8_MIN INT8_MIN
510 #define UINT_FAST32_MAX UINT32_MAX
511 #define UINT_FAST32_MIN UINT32_MIN
512 #define INT_FAST32_MAX INT32_MAX
513 #define INT_FAST32_MIN INT32_MIN
514 #define UINT_FAST64_MAX UINT64_MAX
515 #define UINT_FAST64_MIN UINT64_MIN
516 #define INT_FAST64_MAX INT64_MAX
517 #define INT_FAST64_MIN INT64_MIN
519 #define UINT_LEAST8_MAX UINT8_MAX
520 #define UINT_LEAST8_MIN UINT8_MIN
521 #define INT_LEAST8_MAX INT8_MAX
522 #define INT_LEAST8_MIN INT8_MIN
523 #define UINT_LEAST16_MAX UINT16_MAX
524 #define UINT_LEAST16_MIN UINT16_MIN
525 #define INT_LEAST16_MAX INT16_MAX
526 #define INT_LEAST16_MIN INT16_MIN
527 #define UINT_LEAST32_MAX UINT32_MAX
528 #define UINT_LEAST32_MIN UINT32_MIN
529 #define INT_LEAST32_MAX INT32_MAX
530 #define INT_LEAST32_MIN INT32_MIN
531 #define UINT_LEAST64_MAX UINT64_MAX
532 #define UINT_LEAST64_MIN UINT64_MIN
533 #define INT_LEAST64_MAX INT64_MAX
534 #define INT_LEAST64_MIN INT64_MIN
536 #define UINTMAX_MAX UINT64_MAX
537 #define UINTMAX_MIN UINT64_MIN
538 #define INTMAX_MAX INT64_MAX
539 #define INTMAX_MIN INT64_MIN
546 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
549 hackname = AAB_vxworks_unistd;
551 mach = "*-*-vxworks*";
553 replace = <<- _EndOfHeader_
556 #include_next <unistd.h>
559 #define STDIN_FILENO 0
561 #ifndef STDOUT_FILENO
562 #define STDOUT_FILENO 1
564 #ifndef STDERR_FILENO
565 #define STDERR_FILENO 2
567 #endif /* _UNISTD_H */
572 * assert.h on AIX 7 redefines static_assert as _Static_assert without
576 hackname = aix_assert;
579 select = "#define[ \t]static_assert[ \t]_Static_assert";
581 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
582 test_text = "#define static_assert _Static_assert";
586 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
587 * which only is provided by AIX xlc C99.
590 hackname = aix_complex;
593 select = "#define[ \t]_Complex_I[ \t]__I";
595 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
596 test_text = "#define _Complex_I __I\n";
600 * On AIX some headers are not properly guarded by 'extern
"C"'.
603 hackname = aix_externc;
609 files = sys/localedef.h;
611 bypass = "extern \"C\"";
613 c_fix_arg = "#ifdef __cplusplus\n"
616 c_fix_arg = "#ifdef __cplusplus\n"
619 test_text = "extern int __n_pthreads;\n";
623 * On AIX sys/socket.h assumes C++.
626 hackname = aix_externcpp1;
628 files = "sys/socket.h";
629 select = "#ifdef __cplusplus";
631 c_fix_arg = "#ifdef __cplusplus\n"
633 test_text = "#ifdef __cplusplus";
638 hackname = aix_externcpp2;
640 files = "sys/socket.h";
641 select = "#else /\\* __cplusplus \\*/";
643 c_fix_arg = "} /* extern \"C++\" */\n"
644 "#else /* __cplusplus */";
645 test_text = "#else /* __cplusplus */";
650 * malloc.h on AIX6 uses XLC++ specific builtin syntax
653 hackname = aix_malloc;
656 select = "#ifdef __cplusplus";
658 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
659 test_text = "#ifdef __cplusplus";
663 * net/if_arp.h defines a variable fc_softc instead of adding a
664 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
667 hackname = aix_net_if_arp;
669 files = "net/if_arp.h";
670 select = "^struct fc_softc \\{";
672 c_fix_arg = "typedef struct _fc_softc {";
673 test_text = "struct fc_softc {\n int a;\n};";
677 * Fix AIX definition of NULL for G++.
682 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
683 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
685 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
687 c_fix_arg = <<- _EOFix_
692 #else /* ! __GNUG__ */
694 #endif /* __GNUG__ */
695 #else /* ! __cplusplus */
696 #define NULL ((void *)0)
697 #endif /* __cplusplus */
700 test_text = "# define\tNULL \t(0L) /* typed NULL */";
704 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
705 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
709 hackname = aix_once_init_1;
712 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
715 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
717 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
722 hackname = aix_once_init_2;
725 select = "[ \t]0 \\\\\n"
728 c_fix_arg = " 0 \\\n"
730 test_text = " 0 \\\\\n"
735 hackname = aix_mutex_initializer_1;
738 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
741 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
743 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
748 hackname = aix_cond_initializer_1;
751 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
754 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
756 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
761 hackname = aix_rwlock_initializer_1;
764 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
767 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
769 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
774 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
775 * which violates a requirement of ISO C.
778 hackname = aix_pthread;
780 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
783 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
784 "{...init stuff...}";
788 * AIX stdint.h fixes.
791 hackname = aix_stdint_1;
793 files = stdint-aix.h, stdint.h;
794 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
795 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
797 c_fix_arg = "#define UINT8_MAX (255)\n"
798 "#define UINT16_MAX (65535)";
799 test_text = "#define UINT8_MAX (255U)\n"
800 "#define UINT16_MAX (65535U)";
807 hackname = aix_stdint_2;
809 files = stdint-aix.h, stdint.h;
810 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
811 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
812 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
814 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
815 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
816 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
818 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
819 "#define INTPTR_MAX 9223372036854775807L\n"
820 "#define UINTPTR_MAX 18446744073709551615UL\n"
822 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
823 "#define INTPTR_MAX 2147483647L\n"
824 "#define UINTPTR_MAX 4294967295UL";
825 test_text = "#define INTPTR_MIN INT64_MIN\n"
826 "#define INTPTR_MAX INT64_MAX\n"
827 "#define UINTPTR_MAX UINT64_MAX\n"
829 "#define INTPTR_MIN INT32_MIN\n"
830 "#define INTPTR_MAX INT32_MAX\n"
831 "#define UINTPTR_MAX UINT32_MAX";
838 hackname = aix_stdint_3;
840 files = stdint-aix.h, stdint.h;
841 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
842 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
844 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
845 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
847 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
848 "#define PTRDIFF_MAX 9223372036854775807L\n"
850 "#define PTRDIFF_MIN (-2147483647L - 1)\n"
851 "#define PTRDIFF_MAX 2147483647L";
852 test_text = "#define PTRDIFF_MIN INT64_MIN\n"
853 "#define PTRDIFF_MAX INT64_MAX\n"
855 "#define PTRDIFF_MIN INT32_MIN\n"
856 "#define PTRDIFF_MAX INT32_MAX";
863 hackname = aix_stdint_4;
865 files = stdint-aix.h, stdint.h;
866 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
868 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
870 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
872 "#define SIZE_MAX 4294967295UL";
873 test_text = "#define SIZE_MAX UINT64_MAX\n"
875 "#define SIZE_MAX UINT32_MAX";
882 hackname = aix_stdint_5;
884 files = stdint-aix.h, stdint.h;
885 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
886 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
888 c_fix_arg = "#define UINT8_C(c) c\n"
889 "#define UINT16_C(c) c";
890 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
891 "#define UINT16_C(c) __CONCAT__(c,U)";
895 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
896 produces wrong code with G++.
899 hackname = aix_stdio_inline;
902 select = "#ifdef __cplusplus\\\n"
906 c_fix_arg = "#ifdef __cplusplus\n"
909 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
911 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
915 * stdlib.h on AIX uses #define on malloc and friends.
918 hackname = aix_stdlib_malloc;
921 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
923 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
924 test_text = "#define malloc __linux_malloc";
928 hackname = aix_stdlib_realloc;
931 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
933 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
934 test_text = "#define realloc __linux_realloc";
938 hackname = aix_stdlib_calloc;
941 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
943 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
944 test_text = "#define calloc __linux_calloc";
948 hackname = aix_stdlib_valloc;
951 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
953 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
954 test_text = "#define valloc __linux_valloc";
958 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
961 hackname = aix_strtof_const;
964 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
966 c_fix_arg = "%1(const char *, char **);";
967 test_text = "extern float strtof(char *, char **);";
971 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
972 * in an otherwise harmless (and #ifed out) macro definition
975 hackname = aix_sysmachine;
977 files = sys/machine.h;
981 test_text = "#define FOO \\\n"
982 " bar \\ \n baz \\ \n bat";
986 * sys/wait.h on AIX 5.2 defines macros that have both signed and
987 * unsigned types in conditional expressions.
990 hackname = aix_syswait_2;
993 select = '\? (\
(\
(\
(\
(unsigned
[^
)]*\
)[^
)]*\
) >> [^
)]*\
) \
& 0xff\
) : -1)';
995 c_fix_arg = "? (int)%1";
996 test_text = "#define WSTOPSIG(__x) "
997 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
1001 * sys/signal.h on some versions of AIX uses volatile in the typedef of
1002 * sig_atomic_t, which causes gcc to generate a warning about duplicate
1003 * volatile when a sig_atomic_t variable is declared volatile, as
1004 * required by ANSI C.
1007 hackname = aix_volatile;
1009 files = sys/signal.h;
1010 select = "typedef volatile int sig_atomic_t";
1012 c_fix_arg = "typedef int sig_atomic_t";
1013 test_text = "typedef volatile int sig_atomic_t;";
1017 * Fix __assert declaration in assert.h on Alpha OSF/1.
1020 hackname = alpha___assert;
1022 select = '__assert\
(char \
*, char \
*, int\
)';
1024 c_fix_arg = "__assert(const char *, const char *, int)";
1025 test_text = 'extern void
__assert(char
*, char
*, int
);';
1029 * Fix assert macro in assert.h on Alpha OSF/1.
1030 * The superfluous int cast breaks C++.
1033 hackname = alpha_assert;
1035 select = "(#[ \t]*" 'define assert\
(EX\
).*)\
(\
(int\
) \
(EX\
)\
)';
1037 c_fix_arg = "%1(EX)";
1038 test_text = '#define
assert(EX
) (((int
) (EX
)) ?
(void
)0 '
1039 ': __assert(#EX
, __FILE__
, __LINE__
))';
1043 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1046 hackname = alpha_getopt;
1049 select = 'getopt\
(int
, char \
*\
[\
], *char \
*\
)';
1051 c_fix_arg = "getopt(int, char *const[], const char *)";
1052 test_text = 'extern int
getopt(int
, char
*[], char *)
;';
1056 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
1059 hackname = alpha_if_semicolon;
1061 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
1063 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
1064 test_text = ' struct sockaddr vmif_paddr
/* protocol address
*/';
1068 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
1071 hackname = alpha_parens;
1073 select = '#ifndef\
(__mips64\
)';
1075 c_fix_arg = "#ifndef __mips64";
1076 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
1080 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
1084 hackname = alpha_sbrk;
1086 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
1088 c_fix_arg = "void *sbrk(";
1089 test_text = "extern char* sbrk(ptrdiff_t increment);";
1093 * For C++, avoid any typedef or macro definition of bool,
1094 * and use the built in type instead.
1095 * HP/UX 10.20 also has it in curses_colr/curses.h.
1098 hackname = avoid_bool_define;
1100 files = curses_colr/curses.h;
1104 select = "#[ \t]*define[ \t]+bool[ \t]";
1105 bypass = "__cplusplus";
1108 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1109 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
1111 test_text = "# define bool\t char \n";
1118 hackname = avoid_bool_type;
1120 files = curses_colr/curses.h;
1124 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
1125 bypass = "__cplusplus";
1128 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1130 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
1134 * For C++, avoid any typedef definition of wchar_t,
1135 * and use the built in type instead.
1136 * Don't do this for headers that are smart enough to do the right
1137 * thing (recent
[n
]curses.h and Xlib.h
).
1138 * Don
't do it for <linux/nls.h> which is never used from C++ anyway,
1139 * and will be broken by the edit.
1143 hackname = avoid_wchar_t_type;
1145 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
1146 bypass = "__cplusplus";
1147 bypass = "_LINUX_NLS_H";
1148 bypass = "XFree86: xc/lib/X11/Xlib\\.h";
1151 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1153 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1157 * Fix `typedef struct term;' on hppa1.1
-hp
-hpux9.
1160 hackname
= bad_struct_term
;
1162 select
= "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1164 c_fix_arg
= "struct term;";
1166 test_text
= 'typedef struct term;';
1170 * Fix one other error in this file
:
1171 * a mismatched quote not inside a C comment.
1174 hackname
= badquote
;
1175 files
= sundev
/vuid_event.h
;
1178 c_fix_arg
= "does not";
1180 test_text
= "/* doesn't have matched single quotes */";
1184 * check for broken assert.h that needs stdio.h
1187 hackname
= broken_assert_stdio
;
1190 bypass
= "include.*stdio\\.h";
1192 c_fix_arg
= "#include <stdio.h>\n";
1193 test_text
= "extern FILE* stderr;";
1197 * check for broken assert.h that needs stdlib.h
1200 hackname
= broken_assert_stdlib
;
1202 select
= 'exit *\(|abort *\(';
1203 bypass
= "include.*stdlib\\.h";
1205 c_fix_arg
= "#ifdef __cplusplus\n"
1206 "#include <stdlib.h>\n"
1208 test_text
= "extern void exit ( int );";
1212 * Remove `extern double cabs
' declarations from math.h.
1213 * This conflicts with C99. Discovered on AIX.
1214 * Darwin hides its broken cabs in architecture-specific subdirs.
1217 hackname = broken_cabs;
1218 files = math.h, "architecture/*/math.h";
1219 select = "^extern[ \t]+double[ \t]+cabs";
1221 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1222 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1224 test_text = "#ifdef __STDC__\n"
1225 "extern double cabs(struct dbl_hypot);\n"
1227 "extern double cabs();\n"
1229 "extern double cabs ( _Complex z );";
1233 * Fixup Darwin's broken check for __builtin_nanf.
1236 hackname
= broken_nan
;
1238 * It is tempting to omit the first
"files" entry. Do not.
1239 * The testing machinery will take the first
"files" entry as the name
1240 * of a test file to play with. It would be a nuisance to have a directory
1241 * with the name
"*".
1243 files
= "architecture/ppc/math.h";
1244 files
= "architecture/*/math.h";
1245 select
= '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1248 c_fix_arg
= "#if 1";
1249 test_text
= "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1253 * Various systems derived from BSD4.4 contain a macro definition
1254 * for vfscanf that interacts badly with requirements of builtin
-attrs.def.
1255 * Known to be fixed in FreeBSD
5 system headers.
1258 hackname
= bsd_stdio_attrs_conflict
;
1260 mach
= "*-*-*darwin*";
1262 select
= "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1264 c_fix_arg
= '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1265 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1266 'int vfscanf(FILE *, const char *, __builtin_va_list) '
1267 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1268 test_text
= '#define vfscanf __svfscanf';
1272 * Fix various macros used to define ioctl numbers.
1273 * The traditional syntax was
:
1275 * #define
_CTRL(n
, x
) (('n'<<8)+x
)
1276 * #define TCTRLCFOO
_CTRL(T
, 1)
1278 * but this does not work with the C standard
, which disallows macro
1279 * expansion inside strings. We have to rewrite it thus
:
1281 * #define
_CTRL(n
, x
) ((n
<<8)+x
)
1282 * #define TCTRLCFOO
_CTRL('T', 1)
1284 * The select expressions match too much
, but the c_fix code is cautious.
1286 * CTRL might be
: CTRL _CTRL ISCTRL BSD43_CTRL ...
1289 hackname
= ctrl_quotes_def
;
1290 select
= "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1291 c_fix
= char_macro_def
;
1295 * This is two tests in order to ensure that the
"CTRL(c)" can
1296 * be selected in isolation from the multi
-arg format
1298 test_text
= "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1299 test_text
= "#define _CTRL(c) ('c'&037)";
1303 * Fix various macros used to define ioctl numbers.
1306 hackname
= ctrl_quotes_use
;
1307 select
= "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1308 c_fix
= char_macro_use
;
1310 test_text
= "#define TCTRLFOO BSD43_CTRL(T, 1)";
1314 * sys
/mman.h on HP
/UX is not C
++ ready
,
1315 * even though NO_IMPLICIT_EXTERN_C is defined on HP
/UX.
1317 * rpc
/types.h on OSF1
/2.0 is not C
++ ready
,
1318 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1320 * The problem is the declaration of malloc.
1323 hackname
= cxx_unready
;
1325 files
= rpc
/types.h
;
1326 select
= '[^#]+malloc.*;'; /* Catch any form of declaration
1327 not within a macro.
*/
1328 bypass
= '"C"|__BEGIN_DECLS';
1331 c_fix_arg
= "#ifdef __cplusplus\n"
1334 c_fix_arg
= "#ifdef __cplusplus\n"
1337 test_text
= "extern void* malloc( size_t );";
1341 * For the AAB_darwin7_9_long_double_funcs fix to be useful
,
1342 * you have to not use
"" includes.
1345 hackname
= darwin_9_long_double_funcs_2
;
1346 mach
= "*-*-darwin7.9*";
1348 select
= '#include[ \t]+\"';
1350 c_fix_arg
= "%1<%2.h>";
1352 c_fix_arg
= '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1354 test_text
= '#include "architecture/ppc/math.h"';
1358 * On darwin8 and earlier
, mach
-o
/swap.h isn
't properly guarded
1359 * by 'extern
"C"'. On darwin7 some mach/ headers aren't properly guarded.
1362 hackname
= darwin_externc
;
1363 mach
= "*-*-darwin*";
1364 files
= mach
-o
/swap.h
;
1365 files
= mach
/mach_time.h
;
1366 files
= mach
/mach_traps.h
;
1367 files
= mach
/message.h
;
1369 files
= mach
/semaphore.h
;
1370 bypass
= "extern \"C\"";
1371 bypass
= "__BEGIN_DECLS";
1373 c_fix_arg
= "#ifdef __cplusplus\n"
1376 c_fix_arg
= "#ifdef __cplusplus\n"
1379 test_text
= "extern void swap_fat_header();\n";
1383 * AvailabilityMacros.h on Darwin breaks with GCC
4.0, because of
1384 * bad __GNUC__ tests.
1387 hackname
= darwin_gcc4_breakage
;
1388 mach
= "*-*-darwin*";
1389 files
= AvailabilityMacros.h
;
1390 select
= "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1392 c_fix_arg
= "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1393 test_text
= "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1394 "(__GNUC_MINOR__ >= 1)\n";
1398 * __private_extern__ doesn
't exist in FSF GCC. Even if it did,
1399 * why would you ever put it in a system header file?
1402 hackname = darwin_private_extern;
1403 mach = "*-*-darwin*";
1404 files = mach-o/dyld.h;
1405 select = "__private_extern__ [a-z_]+ _dyld_";
1407 c_fix_arg = "extern";
1408 c_fix_arg = "__private_extern__";
1409 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1410 "const char *dyld_func_name,\n"
1411 "unsigned long *address);\n";
1415 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1416 * unsigned constants.
1419 hackname = darwin_stdint_1;
1420 mach = "*-*-darwin*";
1421 files = stdint-darwin.h, stdint.h;
1423 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1424 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1425 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1426 test_text = "#define UINT8_C(v) (v ## U)\n"
1427 "#define UINT16_C(v) (v ## U)";
1431 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1435 hackname = darwin_stdint_2;
1436 mach = "*-*-darwin*";
1437 files = stdint-darwin.h, stdint.h;
1439 c_fix_arg = "#if __WORDSIZE == 64\n"
1440 "#define INTPTR_MAX 9223372036854775807L\n"
1441 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1443 "#define INTPTR_MAX 2147483647L\n"
1444 "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1446 select = "#if __WORDSIZE == 64\n"
1447 "#define INTPTR_MIN[ \t]+INT64_MIN\n"
1448 "#define INTPTR_MAX[ \t]+INT64_MAX\n"
1450 "#define INTPTR_MIN[ \t]+INT32_MIN\n"
1451 "#define INTPTR_MAX[ \t]+INT32_MAX\n"
1453 test_text = "#if __WORDSIZE == 64\n"
1454 "#define INTPTR_MIN INT64_MIN\n"
1455 "#define INTPTR_MAX INT64_MAX\n"
1457 "#define INTPTR_MIN INT32_MIN\n"
1458 "#define INTPTR_MAX INT32_MAX\n"
1463 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1466 hackname = darwin_stdint_3;
1467 mach = "*-*-darwin*";
1468 files = stdint-darwin.h, stdint.h;
1470 c_fix_arg = "#if __WORDSIZE == 64\n"
1471 "#define UINTPTR_MAX 18446744073709551615UL\n"
1473 "#define UINTPTR_MAX 4294967295UL\n"
1475 select = "#if __WORDSIZE == 64\n"
1476 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1478 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1480 test_text = "#if __WORDSIZE == 64\n"
1481 "#define UINTPTR_MAX UINT64_MAX\n"
1483 "#define UINTPTR_MAX UINT32_MAX\n"
1488 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1491 hackname = darwin_stdint_4;
1492 mach = "*-*-darwin*";
1493 files = stdint-darwin.h, stdint.h;
1495 c_fix_arg = "#if __WORDSIZE == 64\n"
1496 "#define SIZE_MAX 18446744073709551615UL\n"
1498 "#define SIZE_MAX 4294967295UL\n"
1500 select = "#if __WORDSIZE == 64\n"
1501 "#define SIZE_MAX[ \t]+UINT64_MAX\n"
1503 "#define SIZE_MAX[ \t]+UINT32_MAX\n"
1505 test_text = "#if __WORDSIZE == 64\n"
1506 "#define SIZE_MAX UINT64_MAX\n"
1508 "#define SIZE_MAX UINT32_MAX\n"
1513 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1514 * with a wrong type.
1517 hackname = darwin_stdint_5;
1518 mach = "*-*-darwin*";
1519 files = stdint-darwin.h, stdint.h;
1521 c_fix_arg = "#if __WORDSIZE == 64\n"
1522 "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
1523 "#define INTMAX_MAX 9223372036854775807L\n"
1524 "#define UINTMAX_MAX 18446744073709551615UL\n"
1526 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
1527 "#define INTMAX_MAX 9223372036854775807LL\n"
1528 "#define UINTMAX_MAX 18446744073709551615ULL\n"
1530 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1531 "#define INTMAX_MAX[ \t]+INT64_MAX\n"
1533 "#define UINTMAX_MAX[ \t]+UINT64_MAX";
1534 test_text = "#define INTMAX_MIN INT64_MIN\n"
1535 "#define INTMAX_MAX INT64_MAX\n"
1537 "#define UINTMAX_MAX UINT64_MAX";
1541 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1542 * with a wrong type.
1545 hackname = darwin_stdint_6;
1546 mach = "*-*-darwin*";
1547 files = stdint-darwin.h, stdint.h;
1549 c_fix_arg = "#if __WORDSIZE == 64\n"
1550 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1551 "#define PTRDIFF_MAX 9223372036854775807L\n"
1553 "#define PTRDIFF_MIN (-2147483647 - 1)\n"
1554 "#define PTRDIFF_MAX 2147483647\n"
1556 select = "#if __WORDSIZE == 64\n"
1557 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1558 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1560 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1561 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1563 test_text = "#if __WORDSIZE == 64\n"
1564 "#define PTRDIFF_MIN INT64_MIN\n"
1565 "#define PTRDIFF_MAX INT64_MAX\n"
1567 "#define PTRDIFF_MIN INT32_MIN\n"
1568 "#define PTRDIFF_MAX INT32_MAX\n"
1573 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1574 * with a wrong type.
1577 hackname = darwin_stdint_7;
1578 mach = "*-*-darwin*";
1579 files = stdint-darwin.h, stdint.h;
1581 c_fix_arg = "#if __WORDSIZE == 64\n"
1582 "#define INTMAX_C(v) (v ## L)\n"
1583 "#define UINTMAX_C(v) (v ## UL)\n"
1585 "#define INTMAX_C(v) (v ## LL)\n"
1586 "#define UINTMAX_C(v) (v ## ULL)\n"
1588 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1589 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1590 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1591 "#define UINTMAX_C(v) (v ## ULL)";
1595 * Fix <c_asm.h> on Digital UNIX V4.0:
1596 * It contains a prototype for a DEC C internal asm() function,
1597 * clashing with gcc's asm keyword. So protect this with __DECC.
1600 hackname
= dec_intern_asm
;
1602 sed
= "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1603 sed
= "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1607 " ... asm stuff ...\n"
1608 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1612 * Fix typo in
<wchar.h
> on DJGPP
2.03.
1615 hackname
= djgpp_wchar_h
;
1617 select
= "__DJ_wint_t";
1618 bypass
= "sys/djtypes.h";
1620 c_fix_arg
= "%0\n#include <sys/djtypes.h>";
1621 c_fix_arg
= "#include <stddef.h>";
1622 test_text
= "#include <stddef.h>\n"
1623 "extern __DJ_wint_t x;\n";
1627 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1630 hackname
= ecd_cursor
;
1631 files
= "sunwindow/win_lock.h";
1632 files
= "sunwindow/win_cursor.h";
1633 select
= 'ecd\.cursor';
1635 c_fix_arg
= 'ecd_cursor';
1637 test_text
= "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1641 * Incorrect feraiseexcept extern inline in bits
/fenv.h on x86_64
1642 * that fails when compiling for SSE
-less
32-bit x86.
1645 hackname
= feraiseexcept_nosse_divbyzero
;
1646 mach
= 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1647 files
= bits
/fenv.h
, '*/bits/fenv.h';
1648 select
= "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1649 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1650 bypass
= "\"fdivp .*; fwait\"";
1653 c_fix_arg
= <<- _EOText_
1654 # ifdef __SSE_MATH__
1657 %1__asm__
__volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1658 %1 : "=t" (__f
) : "0" (__f
), "u" (__g
) : "st(1)");
1662 test_text
= <<- _EOText_
1663 __asm__
__volatile__ ("divss %1, %0" : : "x" (__f
), "x" (__g
));
1668 * Incorrect feraiseexcept extern inline in bits
/fenv.h on x86_64
1669 * that fails when compiling for SSE
-less
32-bit x86.
1672 hackname
= feraiseexcept_nosse_invalid
;
1673 mach
= 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1674 files
= bits
/fenv.h
, '*/bits/fenv.h';
1675 select
= "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1676 ": \"x\" \\(__f\\)\\);$";
1677 bypass
= "\"fdiv .*; fwait\"";
1680 c_fix_arg
= <<- _EOText_
1681 # ifdef __SSE_MATH__
1684 %1__asm__
__volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1685 %1 : "=t" (__f
) : "0" (__f
));
1689 test_text
= <<- _EOText_
1690 __asm__
__volatile__ ("divss %0, %0" : : "x" (__f
));
1695 * Between
8/24/1998 and
2/17/2001, FreeBSD system headers presume
1696 * neither the existence of GCC
3 nor its exact feature set yet break
1697 * (by design?
) when __GNUC__ is set beyond
2.
1700 hackname
= freebsd_gcc3_breakage
;
1701 mach
= "*-*-freebsd*";
1702 files
= sys
/cdefs.h
;
1703 select
= '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1704 bypass
= '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1706 c_fix_arg
= '%0 || __GNUC__ >= 3';
1707 test_text
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1711 * Some releases of FreeBSD
4 and FreeBSD
5.0 and
5.1 system headers presume
1712 * neither the existence of GCC
4 nor its exact feature set yet break
1713 * (by design?
) when __GNUC__ is set beyond
3.
1716 hackname
= freebsd_gcc4_breakage
;
1717 mach
= "*-*-freebsd*";
1718 files
= sys
/cdefs.h
;
1719 select
= '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1721 c_fix_arg
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1722 test_text
= '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1726 * Some versions of glibc don
't expect the C99 inline semantics.
1729 hackname = glibc_c99_inline_1;
1730 files = features.h, '*/features.h
';
1731 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1733 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1735 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1736 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1737 # define __USE_EXTERN_INLINES 1
1743 * Similar, but a version that didn't have __NO_INLINE__
1746 hackname
= glibc_c99_inline_1a
;
1747 files
= features.h
, '*/features.h';
1748 select
= "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1749 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1751 c_fix_arg
= "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1753 #if
__GNUC_PREREQ (2, 7) && defined __OPTIMIZE__
&& !defined __OPTIMIZE_SIZE__
1754 # define __USE_EXTERN_INLINES
1
1760 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1761 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1762 * The remaining glibc_c99_inline_
* fixes deal with some of those headers.
1765 hackname
= glibc_c99_inline_2
;
1766 files
= sys
/stat.h
, '*/sys/stat.h';
1767 select
= "extern __inline__ int";
1768 sed
= "s/extern int \\(stat\\)/"
1769 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1770 "__inline__ int \\1/";
1771 sed
= "s/extern int \\([lf]stat\\)/"
1772 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1773 "__inline__ int \\1/";
1774 sed
= "s/extern int \\(mknod\\)/"
1775 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1776 "__inline__ int \\1/";
1777 sed
= "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1778 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1779 "__inline__ int __REDIRECT\\1 (\\2/";
1780 sed
= "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1781 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1782 "__inline__ int __REDIRECT\\1 (\\2/";
1783 sed
= "s/^extern __inline__ int/"
1784 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1787 extern int
fstat64 (int __fd
, struct stat64
*__buf
) __THROW
__nonnull ((2));
1788 extern __inline__ int
1789 __NTH (fstat64 (int __fd
, struct stat64
*__statbuf
))
1795 * glibc_c99_inline_3
1798 hackname
= glibc_c99_inline_3
;
1799 files
= bits
/string2.h
, '*/bits/string2.h';
1800 select
= "extern __inline";
1801 bypass
= "__extern_inline|__GNU_STDC_INLINE__";
1803 c_fix_arg
= "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1804 c_fix_arg
= "^# ifdef __cplusplus$";
1807 # define __STRING_INLINE inline
1809 # define __STRING_INLINE extern __inline
1815 * glibc_c99_inline_4
1818 hackname
= glibc_c99_inline_4
;
1819 files
= sys
/sysmacros.h
, '*/sys/sysmacros.h', wchar.h
, '*/wchar.h',
1820 pthread.h
, '*/pthread.h';
1821 bypass
= "__extern_inline|__gnu_inline__";
1822 select
= "(^| )extern __inline";
1824 c_fix_arg
= "%0 __attribute__ ((__gnu_inline__))";
1826 __extension__ extern __inline unsigned int
1827 extern __inline unsigned int
1831 /* glibc
-2.3.5 defines pthread mutex initializers incorrectly
,
1832 * so we replace them with versions that correspond to the
1836 hackname
= glibc_mutex_init
;
1838 select
= '\{ *\{ *0, *\} *\}';
1839 sed
= "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1840 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1841 sed
= "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1842 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1843 sed
= "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1844 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1845 sed
= "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1846 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1847 sed
= "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1848 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1849 sed
= "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1850 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1851 sed
= "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1852 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1853 sed
= "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1854 "N;s/^[ \t]*#[ \t]*"
1855 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1856 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1858 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1861 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1863 sed
= "s/{ \\(0, 0, 0, 0, 0, 0, "
1864 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1865 sed
= "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1866 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1868 test_text
= <<- _EOText_
1869 #define PTHREAD_MUTEX_INITIALIZER
\\
1872 # if __WORDSIZE
== 64
1873 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
\\
1874 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP
} }
1875 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
\\
1876 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP
} }
1877 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
\\
1878 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP
} }
1880 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
\\
1881 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP
} }
1882 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
\\
1883 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP
} }
1884 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
\\
1885 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP
} }
1888 # define PTHREAD_RWLOCK_INITIALIZER
\\
1891 # if __WORDSIZE
== 64
1892 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
\\
1893 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
1894 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
} }
1896 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
\\
1897 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
} }
1900 #define PTHREAD_COND_INITIALIZER
{ { 0, } }
1904 /* glibc versions before
2.5 have a version of stdint.h that defines
1905 UINT8_C and UINT16_C to produce unsigned constants
, as do uClibc
1906 versions with stdint.h based on those glibc versions.
*/
1908 hackname
= glibc_stdint
;
1910 select
= "GNU C Library";
1912 c_fix_arg
= "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1913 c_fix_arg
= "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1914 test_text
= "/* This file is part of the GNU C Library. */\n"
1915 "# define UINT8_C(c)\tc ## U\n"
1916 "# define UINT16_C(c)\tc ## U";
1919 /* Some versions of glibc have a version of bits
/string2.h that
1920 produces
"value computed is not used" warnings from strncpy
; fix
1921 this definition by using __builtin_strncpy instead as in newer
1924 hackname
= glibc_strncpy
;
1925 files
= bits
/string2.h
, '*/bits/string2.h';
1926 bypass
= "__builtin_strncpy";
1928 c_fix_arg
= "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1929 c_fix_arg
= "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1931 # define
strncpy(dest
, src
, n
) \
1932 (__extension__ (__builtin_constant_p (src
) && __builtin_constant_p (n
) \\
1933 ?
(strlen (src
) + 1 >= ((size_t
) (n
)) \\
1934 ?
(char *)
memcpy (dest
, src
, n
) \\
1935 : strncpy (dest
, src
, n
)) \\
1936 : strncpy (dest
, src
, n
)))
1941 /* glibc
's tgmath.h relies on an expression that is not an integer
1942 constant expression being treated as it was by GCC 4.4 and
1945 hackname = glibc_tgmath;
1947 select = '\
(\
(\
(type\
) 0.25\
) && \
(\
(type\
) 0.25 - 1\
)\
)';
1948 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1950 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1951 "(__builtin_classify_type ((type) 0) == 9 && "
1952 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1953 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1957 * Fix these files to use the types we think they should for
1958 * ptrdiff_t, size_t, and wchar_t.
1960 * This defines the types in terms of macros predefined by our 'cpp
'.
1961 * This is supposedly necessary for glibc's handling of these types.
1962 * It
's probably not necessary for anyone else, but it doesn't hurt.
1965 hackname
= gnu_types
;
1966 files
= "sys/types.h";
1968 files
= "sys/stdtypes.h";
1972 bypass
= '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1973 select
= "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1975 /* The Solaris
10 headers already define these types correctly.
*/
1976 mach
= '*-*-solaris2.1[0-9]*';
1979 test_text
= "typedef long int ptrdiff_t; /* long int */\n"
1980 "typedef uint_t size_t; /* uint_t */\n"
1981 "typedef ushort_t wchar_t; /* ushort_t */";
1985 * Fix HP
& Sony
's use of "../machine/xxx.h"
1986 * to refer to: <machine/xxx.h>
1989 hackname = hp_inline;
1990 files = sys/spinlock.h;
1991 files = machine/machparam.h;
1992 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
1995 c_fix_arg = "%1<machine
/%2.h
>";
1997 c_fix_arg = "([ \t]*#
[ \t]*include
[ \t]+)" '"\.\.
/machine
/'
2000 test_text = ' # include "..
/machine
/mumble.h
"';
2004 * Check for (...) in C++ code in HP/UX sys/file.h.
2007 hackname = hp_sysfile;
2009 select = "HPUX_SOURCE
";
2012 c_fix_arg = "(struct file
*, ...
)";
2013 c_fix_arg = '\(\.\.\.\)';
2015 test_text = "extern void
foo(...
); /* HPUX_SOURCE
- bad varargs
*/";
2019 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
2020 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
2023 hackname = hppa_hpux_fp_macros;
2024 mach = "hppa
*-hp
-hpux11
*";
2026 select = "#
[ \t]*define
[ \t]*FP_NORMAL.
*\n"
2027 "#
[ \t]*define
[ \t]*FP_ZERO.
*\n"
2028 "#
[ \t]*define
[ \t]*FP_INFINITE.
*\n"
2029 "#
[ \t]*define
[ \t]*FP_SUBNORMAL.
*\n"
2030 "#
[ \t]*define
[ \t]*FP_NAN.
*\n";
2032 c_fix_arg = <<- _EOFix_
2033 #endif /* _INCLUDE_HPUX_SOURCE */
2035 #if defined(_INCLUDE_HPUX_SOURCE) || \
2036 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
2039 #ifdef _INCLUDE_HPUX_SOURCE
2044 "# define FP_NORMAL
0\n"
2045 "# define FP_ZERO
1\n"
2046 "# define FP_INFINITE
2\n"
2047 "# define FP_SUBNORMAL
3\n"
2048 "# define FP_NAN
4\n";
2052 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
2053 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
2056 hackname = hpux10_cpp_pow_inline;
2057 files = fixinc-test-limits.h, math.h;
2058 select = <<- END_POW_INLINE
2059 ^# +ifdef +__cplusplus
2061 +inline +double +pow\(double +__d,int +__expon\) +\{
2062 [ ]+return +pow\(__d,\(double\)__expon\);
2073 "# ifdef __cplusplus
\n"
2075 " inline double
pow(double __d
,int __expon
) {\n"
2076 "\t return
pow(__d
,(double
)__expon
);\n"
2078 ' extern "C
"' " {\n"
2084 hackname = hpux11_cpp_pow_inline;
2086 select = " +inline double pow
\\(double d
,int expon
\\) \\{\n"
2087 " +return pow
\\(d
, \\(double
\\)expon
\\);\n"
2093 " inline double
pow(double d
,int expon
) {\n"
2094 " return
pow(d
, (double
)expon
);\n"
2099 * Fix hpux 10.X missing ctype declarations 1
2102 hackname = hpux10_ctype_declarations1;
2104 select = "^#
[ \t]*define _toupper
\\(__c
\\)[ \t]*__toupper
\\(__c
\\)";
2105 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*__tolower
[ \t]*\\(";
2107 c_fix_arg = "#ifdef _PROTOTYPES
\n"
2108 "extern int
__tolower(int
);\n"
2109 "extern int
__toupper(int
);\n"
2110 "#else
/* NOT _PROTOTYPES
*/\n"
2111 "extern int
__tolower();\n"
2112 "extern int
__toupper();\n"
2113 "#endif
/* _PROTOTYPES
*/\n\n"
2116 test_text = "# define
_toupper(__c
) __toupper(__c
)\n";
2120 * Fix hpux 10.X missing ctype declarations 2
2123 hackname = hpux10_ctype_declarations2;
2125 select = "^# if defined
\\(_SB_CTYPE_MACROS
\\) && \\!defined
\\(__lint
\\)";
2126 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*_isalnum
[ \t]*\\(";
2128 c_fix_arg = "%0\n\n"
2129 "#ifdef _PROTOTYPES
\n"
2130 " extern int
_isalnum(int
);\n"
2131 " extern int
_isalpha(int
);\n"
2132 " extern int
_iscntrl(int
);\n"
2133 " extern int
_isdigit(int
);\n"
2134 " extern int
_isgraph(int
);\n"
2135 " extern int
_islower(int
);\n"
2136 " extern int
_isprint(int
);\n"
2137 " extern int
_ispunct(int
);\n"
2138 " extern int
_isspace(int
);\n"
2139 " extern int
_isupper(int
);\n"
2140 " extern int
_isxdigit(int
);\n"
2141 "# else
/* not _PROTOTYPES
*/\n"
2142 " extern int
_isalnum();\n"
2143 " extern int
_isalpha();\n"
2144 " extern int
_iscntrl();\n"
2145 " extern int
_isdigit();\n"
2146 " extern int
_isgraph();\n"
2147 " extern int
_islower();\n"
2148 " extern int
_isprint();\n"
2149 " extern int
_ispunct();\n"
2150 " extern int
_isspace();\n"
2151 " extern int
_isupper();\n"
2152 " extern int
_isxdigit();\n"
2153 "#endif
/* _PROTOTYPES
*/\n";
2155 test_text = "# if
defined(_SB_CTYPE_MACROS
) && !defined(__lint
)\n"
2156 " extern unsigned int
*__SB_masks
;\n";
2160 * Fix hpux 10.X missing stdio declarations
2163 hackname = hpux10_stdio_declarations;
2165 select = "^#
[ \t]*define _iob
[ \t]*__iob
";
2166 bypass = "^
[ \t]*extern
[ \t]*int
[ \t]*vsnprintf
[ \t]*\\(";
2168 c_fix_arg = "%0\n\n"
2169 "# if
defined(__STDC__
) ||
defined(__cplusplus
)\n"
2170 " extern int
snprintf(char
*, size_t
, const char
*, ...
);\n"
2171 " extern int
vsnprintf(char
*, size_t
, const char
*, __va_list
);\n"
2172 "# else
/* not __STDC__
) || __cplusplus
*/\n"
2173 " extern int
snprintf();\n"
2174 " extern int
vsnprintf();\n"
2175 "# endif
/* __STDC__
) || __cplusplus
*/\n";
2177 test_text = "# define _iob __iob
\n";
2181 * Make sure hpux defines abs in header.
2184 hackname = hpux11_abs;
2185 mach = "*-hp
-hpux11
*";
2187 select = "ifndef _MATH_INCLUDED
";
2189 c_fix_arg = "if
!defined(_MATH_INCLUDED
) ||
defined(__GNUG__
)";
2190 test_text = "#ifndef _MATH_INCLUDED
";
2194 * Fix hpux11 __LWP_RWLOCK_VALID define
2197 hackname = hpux11_lwp_rwlock_valid;
2198 mach = "*-hp
-hpux11
*";
2199 files = sys/pthread.h;
2200 select = "#define __LWP_RWLOCK_VALID
[ \t]*0x8c91";
2202 c_fix_arg = "#define __LWP_RWLOCK_VALID
-29551";
2203 test_text = "#define __LWP_RWLOCK_VALID
0x8c91";
2210 hackname = hpux11_extern_sendfile;
2211 mach = "*-hp
-hpux11.
[12]*";
2212 files = sys/socket.h;
2213 select = "^
[ \t]*extern sbsize_t sendfile.
*\n.
*, int
\\)\\);\n";
2215 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T
\n%0#endif
\n";
2216 test_text = " extern sbsize_t sendfile
__((int
, int
, off_t
, bsize_t
,\n"
2217 " const struct iovec
*, int
));\n";
2224 hackname = hpux11_extern_sendpath;
2225 mach = "*-hp
-hpux11.
[12]*";
2226 files = sys/socket.h;
2227 select = "^
[ \t]*extern sbsize_t sendpath.
*\n.
*, int
\\)\\);\n";
2229 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T
\n%0#endif
\n";
2230 test_text = " extern sbsize_t sendpath
__((int
, int
, off_t
, bsize_t
,\n"
2231 " const struct iovec
*, int
));\n";
2235 * Keep HP-UX 11 from stomping on C++ math namespace
2236 * with defines for fabsf.
2239 hackname = hpux11_fabsf;
2241 select = "^
[ \t]*#
[ \t]*define
[ \t]+fabsf
\\(.
*";
2242 bypass = "__cplusplus
";
2245 c_fix_arg = "#ifndef __cplusplus
\n%0\n#endif
";
2249 "# define
fabsf(x
) ((float
)fabs((double
)(float
)(x
)))\n"
2254 * Fix C99 constant in __POINTER_SET define.
2257 hackname = hpux11_pthread_const;
2258 mach = "*-hp
-hpux11.
[0-3]*";
2259 files = sys/pthread.h;
2260 select = "^#define
[ \t]*__POINTER_SET
[ \t]*\\(\\(void
\\*\\) 1LL\\)";
2263 c_fix_arg = "#define __POINTER_SET
\t\t((void *)
1L)";
2264 test_text = "#define __POINTER_SET
\t\t((void *)
1LL)";
2268 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2269 * being defined by having it define _hpux_size_t instead.
2272 hackname = hpux11_size_t;
2273 mach = "*-hp
-hpux11
*";
2274 select = "__size_t
";
2277 c_fix_arg = "_hpux_size_t
";
2280 "#define __size_t size_t
\n"
2281 " extern int
getpwuid_r( char
*, __size_t
, struct passwd
**)
;\n";
2285 * Fix hpux 11.00 broken snprintf declaration
2286 * (third argument is char *, needs to be const char * to prevent
2287 * spurious warnings with -Wwrite-strings or in C++).
2290 hackname = hpux11_snprintf;
2292 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2293 ' *(char *\*, *\.\.\.\);)';
2295 c_fix_arg = '%1 const %3';
2297 test_text = "extern int
snprintf(char
*, size_t
, char
*, ...
);\n"
2298 "extern int
snprintf(char
*, __size_t
, char
*, ...
);\n"
2299 "extern int
snprintf(char
*, _hpux_size_t
, char
*, ...
);";
2303 * Fix hpux 11.00 broken vsnprintf declaration
2306 hackname = hpux11_vsnprintf;
2308 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2309 'const char \*,) __va__list\);';
2311 c_fix_arg = "%1 __va_list
);";
2313 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2318 * Fix missing const in hpux vsscanf declaration
2321 hackname = hpux_vsscanf;
2324 select = '(extern int vsscanf\()char';
2326 c_fix_arg = "%1const char
";
2328 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2332 * get rid of bogus inline definitions in HP-UX 8.0
2335 hackname = hpux8_bogus_inlines;
2338 bypass = "__GNUG__
";
2339 sed = "s@inline int
abs(int
[a
-z
][a
-z
]*)
{.
*}"
2340 "@extern
\"C
\" int
abs(int
);@
";
2341 sed = "s@inline double
abs(double
[a
-z
][a
-z
]*)
{.
*}@@
";
2342 sed = "s@inline int
sqr(int
[a
-z
][a
-z
]*)
{.
*}@@
";
2343 sed = "s@inline double
sqr(double
[a
-z
][a
-z
]*)
{.
*}@@
";
2344 test_text = "inline int
abs(int v
) { return (v
>=0)?v
:-v
; }\n"
2345 "inline double
sqr(double v
) { return v
**0.5; }";
2352 hackname = hpux_c99_intptr;
2353 mach = "*-hp
-hpux11.3
*";
2354 files = stdint-hpux11.h, stdint.h;
2355 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*PTRDIFF_MAX
[ \t]*"
2356 "INT32_MAX
[ \t]*$@#define
PTRDIFF_MAX (2147483647l)@
";
2357 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*PTRDIFF_MIN
[ \t]*"
2358 "INT32_MIN
[ \t]*$@#define
PTRDIFF_MIN (-PTRDIFF_MAX
- 1)@
";
2359 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*INTPTR_MAX
[ \t]*"
2360 "INT32_MAX
[ \t]*$@#define
INTPTR_MAX (2147483647l)@
";
2361 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*INTPTR_MIN
[ \t]*"
2362 "INT32_MIN
[ \t]*$@#define
INTPTR_MIN (-INTPTR_MAX
- 1)@
";
2363 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINTPTR_MAX
[ \t]*"
2364 "UINT32_MAX
[ \t]*$@#define
UINTPTR_MAX (4294967295ul)@
";
2365 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*SIZE_MAX
[ \t]*"
2366 "UINT32_MAX
[ \t]*$@#define
SIZE_MAX (4294967295ul)@
";
2367 test_text = "#define PTRDIFF_MAX INT32_MAX
\n"
2368 "#define PTRDIFF_MIN INT32_MIN
\n"
2369 "#define INTPTR_MAX INT32_MAX
\n"
2370 "#define INTPTR_MIN INT32_MIN
\n"
2371 "#define UINTPTR_MAX UINT32_MAX
\n"
2372 "#define SIZE_MAX UINT32_MAX
\n";
2376 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2379 hackname = hpux_c99_inttypes;
2380 mach = "*-hp
-hpux11.
[23]*";
2382 files = stdint-hpux11.h, stdint.h;
2383 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINT8_C(__c
)[ \t]*"
2384 "__CONCAT_U__(__c
)[ \t]*$@#define
UINT8_C(__c
) (__c
)@
";
2385 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINT16_C(__c
)[ \t]*"
2386 "__CONCAT_U__(__c
)[ \t]*$@#define
UINT16_C(__c
) (__c
)@
";
2387 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*INT32_C(__c
)[ \t]*"
2388 "__CONCAT__(__c
,l
)[ \t]*$@#define
INT32_C(__c
) (__c
)@
";
2389 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINT32_C(__c
)[ \t].
*$@
"
2390 "#define
UINT32_C(__c
) __CONCAT__(__c
,u
)@
";
2391 test_text = "#define
UINT8_C(__c
) __CONCAT_U__(__c
)\n"
2392 "#define
UINT16_C(__c
) __CONCAT_U__(__c
)\n"
2393 "#define
INT32_C(__c
) __CONCAT__(__c
,l
)\n"
2394 "#define
UINT32_C(__c
) __CONCAT__(__c
,ul
)\n";
2398 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2401 hackname = hpux_c99_inttypes2;
2402 mach = "*-hp
-hpux11.2
*";
2403 files = stdint-hpux11.h, stdint.h;
2404 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*INT8_C(__c
)[ \t]*"
2405 "((signed char
)(__c
))[ \t]*$@#define
INT8_C(__c
) (__c
)@
";
2406 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINT8_C(__c
)[ \t]*"
2407 "((unsigned char
)(__c
))[ \t]*$@#define
UINT8_C(__c
) (__c
)@
";
2408 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*INT16_C(__c
)[ \t]*"
2409 "((short
)(__c
))[ \t]*$@#define
INT16_C(__c
) (__c
)@
";
2410 sed = "s@^
[ \t]*#
[ \t]*define
[ \t]*UINT16_C(__c
)[ \t]*"
2411 "((unsigned short
)(__c
))[ \t]*$@#define
UINT16_C(__c
) (__c
)@
";
2412 test_text = "# define
INT8_C(__c
) ((signed char
)(__c
))\n"
2413 "# define
UINT8_C(__c
) ((unsigned char
)(__c
))\n"
2414 "# define
INT16_C(__c
) ((short
)(__c
))\n"
2415 "# define
UINT16_C(__c
) ((unsigned short
)(__c
))\n";
2419 * Fix hpux broken ctype macros
2422 hackname = hpux_ctype_macros;
2424 select = '((: |\()__SB_masks \? )'
2425 '(__SB_masks\[__(alnum|c)\] & _IS)';
2427 c_fix_arg = "%1(int
)%3";
2429 test_text = ": __SB_masks ? __SB_masks
[__alnum
] & _ISCNTRL
\n"
2430 "# define
isalpha(__c
) (__SB_masks ? __SB_masks
[__c
] & _IS
\n";
2437 hackname = hpux_extern_errno;
2438 mach = "*-hp
-hpux10.
*";
2439 mach = "*-hp
-hpux11.
[0-2]*";
2441 select = "^
[ \t]*extern int errno
;$
";
2443 c_fix_arg = "#ifdef __cplusplus
\n"
2447 "#ifdef __cplusplus
\n"
2450 test_text = " extern int errno
;\n";
2454 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2457 hackname = hpux_htonl;
2458 files = netinet/in.h;
2459 select = "#ifndef _XOPEN_SOURCE_EXTENDED
[ \t]*\n"
2461 " \\* Macros for number representation conversion
\\.
\n"
2465 c_fix_arg = "#if
1\n%1";
2467 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED
\n"
2469 " * Macros for number representation conversion.
\n"
2472 "#define
ntohl(x
) (x
)\n"
2473 "#define
ntohs(x
) (x
)\n"
2474 "#define
htonl(x
) (x
)\n"
2475 "#define
htons(x
) (x
)\n"
2477 "#endif
/* ! _XOPEN_SOURCE_EXTENDED
*/";
2481 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2484 hackname = hpux_imaginary_i;
2485 mach = "ia64
-hp
-hpux11.
*";
2487 select = "^
[ \t]*#
[ \t]*define
[ \t]*_Complex_I.
*";
2489 c_fix_arg = "#define
_Complex_I (__extension__
1.0iF
)";
2490 test_text = "#define
_Complex_I (0.f
+_Imaginary_I
)\n";
2494 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2497 hackname = hpux_inttype_int8_t;
2498 mach = "*-hp
-hpux1
[01].
*";
2499 files = sys/_inttypes.h;
2500 select = "^
[ \t]*typedef
[ \t]*char
[ \t]*int(_least
){0,1}8_t.
*";
2502 c_fix_arg = "typedef signed char int
%18_t
;";
2503 test_text = "typedef char int_least8_t
;\n"
2504 "typedef char int8_t
;\n";
2511 hackname = hpux_long_double;
2512 mach = "*-*-hpux10
*";
2513 mach = "*-*-hpux11.
[012]*";
2515 select = "extern
[ \t]long_double
[ \t]strtold
";
2516 bypass = "long_double_t
";
2517 sed = "/^#
[ \t]*ifndef _LONG_DOUBLE
/,/\\/\\* _LONG_DOUBLE
\\*\\//D
";
2518 sed = "s
/long_double
/long double
/g
";
2520 test_text = "# ifndef _LONG_DOUBLE
\n"
2521 "# define _LONG_DOUBLE
\n"
2522 " typedef struct
{\n"
2523 " unsigned int word1
, word2
, word3
, word4
;\n"
2525 "# endif
/* _LONG_DOUBLE
*/\n"
2526 "extern long_double
strtold(const char
*, char
**)
;\n";
2530 * We cannot use the above rule on 11.31 because it removes the strtold
2531 * definition. ia64 is OK with no hack, PA needs some help.
2534 hackname = hpux_long_double_2;
2535 mach = "hppa
*-*-hpux11.3
*";
2537 select = "#
[ \t]*if
[ \t]*!defined
\\(__ia64
\\) \\|
\\|
"
2538 "defined
\\(_PROTOTYPES
\\) \\|
\\|
"
2539 "defined
\\(_LONG_DOUBLE_STRUCT
\\)";
2541 c_fix_arg = "# if
!defined(_PROTOTYPES
) ||
defined(_LONG_DOUBLE_STRUCT
)";
2543 test_text = "# if
!defined(__ia64
) ||
"
2544 "!defined(_PROTOTYPES
) ||
"
2545 "defined(_LONG_DOUBLE_STRUCT
)\n";
2549 * Add missing braces to pthread initializer defines.
2552 hackname = hpux_pthread_initializers;
2553 mach = "*-hp
-hpux11.
[0-3]*";
2554 files = sys/pthread.h;
2555 sed = "s@^
[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2556 "@
\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@
";
2557 sed = "s@^
[ \t]*1,[ \t]*\\\\"
2559 sed = "/^
[ \t]*0$
/d
";
2560 sed = "s@__PTHREAD_MUTEX_VALID
, 0"
2561 "@
{ __PTHREAD_MUTEX_VALID
, 0 }@
";
2562 sed = "s@^
[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2563 "@
\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@
";
2564 sed = "s@
0, __LWP_MTX_VALID
, 0, 1, 1, 1, 1,[ \t]*\\\\"
2565 "@
{ 0, __LWP_MTX_VALID
}, { 0, 1, 1, 1, 1 },\t\t\t\\\\@
";
2566 sed = "s@^
[ \t]*__LWP_MTX_VALID
, 0, 1, 1, 1, 1,[ \t]*\\\\"
2567 "@
\t{ 0, __LWP_MTX_VALID
}, { 0, 1, 1, 1, 1 },\t\t\t\\\\@
";
2568 sed = "s@^
[ \t]*0, 0[ \t]*\\\\"
2569 "@
\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@
";
2570 sed = "s@__PTHREAD_COND_VALID
, 0"
2571 "@
{ __PTHREAD_COND_VALID
, 0 }@
";
2572 sed = "s@__LWP_COND_VALID
, 0,[ \t]*\\\\"
2573 "@
{ __LWP_COND_VALID
, 0 },\t\t\t\t\t\\\\@
";
2574 sed = "s@__PTHREAD_RWLOCK_VALID
, 0"
2575 "@
{ __PTHREAD_RWLOCK_VALID
, 0 }@
";
2576 sed = "s@__LWP_RWLOCK_VALID
, 0,[ \t]*\\\\"
2577 "@
{ __LWP_RWLOCK_VALID
, 0 },\t\t\t\t\t\\\\@
";
2578 sed = "s@^
[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2579 "@
\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@
";
2580 test_text = "#define PTHREAD_MUTEX_INITIALIZER
{\t\t\t\t\t\\\\\n"
2581 "\t__PTHREAD_MUTEX_VALID
, 0,\t\t\t\t\t\\\\\n"
2582 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE
),\t\t\\\\\n"
2583 "\t__SPNLCK_INITIALIZER
,\t\t\t\t\t\t\\\\\n"
2584 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2585 "\t0, __LWP_MTX_VALID
, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2586 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2591 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2592 * type and mpinfou is only defined when _KERNEL is set.
2595 hackname = hpux_spu_info;
2596 mach = "*-hp
-hpux
*";
2598 * It is tempting to omit the first "files
" entry. Do not.
2599 * The testing machinery will take the first "files
" entry as the name
2600 * of a test file to play with. It would be a nuisance to have a directory
2601 * with the name "*".
2603 files = "ia64
/sys
/getppdp.h
";
2604 files = "*/sys
/getppdp.h
";
2605 select = "^.
*extern.
*spu_info.
*";
2608 c_fix_arg = "#ifdef _KERNEL
\n%0\n#endif
";
2610 test_text = "extern union mpinfou spu_info
[];";
2614 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2617 hackname = hpux_stdint_least_fast;
2618 mach = "*-hp
-hpux11.2
*";
2619 files = stdint-hpux11.h, stdint.h;
2621 "^
[ \t]*#
[ \t]*define
[ \t]+UINT_(LEAST|FAST
)64_MAX
[ \t]+ULLONG_MAX
";
2623 c-fix-arg = "# define UINT_
%164_MAX __UINT64_MAX__
";
2624 test-text = "# define UINT_FAST64_MAX ULLONG_MAX
\n"
2625 "# define UINT_LEAST64_MAX ULLONG_MAX
\n";
2630 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2633 hackname = hpux_systime;
2635 select = "^extern struct sigevent
;";
2638 c_fix_arg = "struct sigevent
;";
2640 test_text = 'extern struct sigevent;';
2644 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2647 hackname = huge_val_hex;
2648 files = bits/huge_val.h, '*/bits/huge_val.h';
2649 select = "^#
[ \t]*define
[ \t]*HUGE_VAL
[ \t].
*0x1\\.0p.
*";
2650 bypass = "__builtin_huge_val
";
2653 c_fix_arg = "#define
HUGE_VAL (__builtin_huge_val())\n";
2655 test_text = "# define HUGE_VAL
\t(__extension__
0x1.0p2047
)";
2659 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2662 hackname = huge_valf_hex;
2663 files = bits/huge_val.h, '*/bits/huge_val.h';
2664 select = "^#
[ \t]*define
[ \t]*HUGE_VALF
[ \t].
*0x1\\.0p.
*";
2665 bypass = "__builtin_huge_valf
";
2668 c_fix_arg = "#define
HUGE_VALF (__builtin_huge_valf())\n";
2670 test_text = "# define
HUGE_VALF (__extension__
0x1.0p255f
)";
2674 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2677 hackname = huge_vall_hex;
2678 files = bits/huge_val.h, '*/bits/huge_val.h';
2679 select = "^#
[ \t]*define
[ \t]*HUGE_VALL
[ \t].
*0x1\\.0p.
*";
2680 bypass = "__builtin_huge_vall
";
2683 c_fix_arg = "#define
HUGE_VALL (__builtin_huge_vall())\n";
2685 test_text = "# define
HUGE_VALL (__extension__
0x1.0p32767L
)";
2689 * Fix return type of abort and free
2692 hackname = int_abort_free_and_exit;
2694 select = "int
[ \t]+(abort|free|exit
)[ \t]*\\(";
2695 bypass = "_CLASSIC_ANSI_TYPES
";
2698 c_fix_arg = "void
\t%1(";
2700 test_text = "extern int
abort(int
);\n"
2701 "extern int
free(void*)
;\n"
2702 "extern int
exit(void*)
;";
2706 * Fix various macros used to define ioctl numbers.
2707 * The traditional syntax was:
2709 * #define _IO(n, x) (('n'<<8)+x)
2710 * #define TIOCFOO _IO(T, 1)
2712 * but this does not work with the C standard, which disallows macro
2713 * expansion inside strings. We have to rewrite it thus:
2715 * #define _IO(n, x) ((n<<8)+x)
2716 * #define TIOCFOO _IO('T', 1)
2718 * The select expressions match too much, but the c_fix code is cautious.
2720 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2723 hackname = io_quotes_def;
2724 select = "define
[ \t]+[A
-Z0
-9_
]+IO
[A
-Z
]*\\([a
-zA
-Z
][,)]";
2725 c_fix = char_macro_def;
2728 "#define
BSD43__IOWR(n
, x
) (('n'<<8)+x
)\n"
2729 "#define
_IOWN(x
,y
,t
) (_IOC_IN|
(((t
)&_IOCPARM_MASK
)<<16)|
('x'<<8)|y
)\n"
2730 "#define
_IO(x
,y
) ('x'<<8|y
)";
2732 "#define
XX_IO(x
) ('x'<<8|
256)";
2736 * Fix the usage of the ioctl macro numbers.
2739 hackname = io_quotes_use;
2740 select = "define
[ \t]+[A
-Z0
-9_
]+[ \t]+[A
-Z0
-9_
]+IO
[A
-Z
]*[ \t]*"
2742 c_fix = char_macro_use;
2744 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2745 "#define TIOCFOO \\\\\n"
2746 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2750 * Check for missing ';' in struct
2753 hackname = ip_missing_semi;
2754 files = netinet/ip.h;
2756 sed = "/^struct/,/^};/s/}$/};/";
2762 "}; /* mumbled struct */\n";
2766 * Non-traditional "const" declaration in Irix's limits.h.
2769 hackname
= irix_limits_const
;
2770 files
= fixinc
-test
-limits.h
, limits.h
;
2771 select
= "^extern const ";
2773 c_fix_arg
= "extern __const ";
2774 test_text
= "extern const char limit; /* test limits */";
2778 * IRIX
5.x
's stdio.h declares some functions that take a va_list as
2779 * taking char *. However, GCC uses void * for va_list, so
2780 * calling vfprintf with a va_list fails in C++. */
2782 hackname = irix_stdio_va_list;
2785 select = '/\
* va_list \
*/ char \
*';
2787 c_fix_arg = "__gnuc_va_list";
2789 "extern int printf( const char *, /* va_list */ char * );";
2793 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2794 * use / * * / to concatenate tokens.
2797 hackname = kandr_concat;
2798 files = "sparc/asm_linkage.h";
2799 files = "sun*/asm_linkage.h";
2800 files = "arm/as_support.h";
2801 files = "arm/mc_type.h";
2802 files = "arm/xcb.h";
2803 files = "dev/chardefmac.h";
2804 files = "dev/ps_irq.h";
2805 files = "dev/screen.h";
2806 files = "dev/scsi.h";
2807 files = "sys/tty.h";
2808 files = "Xm.acorn/XmP.h";
2809 files = bsd43/bsd43_.h;
2813 test_text = "#define __CONCAT__(a,b) a/**/b";
2817 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2818 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2819 * constant on recent versions of g
++.
2822 hackname
= linux_ia64_ucontext
;
2823 files
= "sys/ucontext.h";
2824 mach
= "ia64-*-linux*";
2825 select
= '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2826 '->sc_gr\[0\]\) - \(char \*\) 0\)';
2828 c_fix_arg
= "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2829 test_text
= "# define _SC_GR0_OFFSET\t\\\\\n"
2830 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2834 * Remove header file warning from sys
/time.h. Autoconf
's
2835 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2836 * which causes warning on LynxOS. Remove the warning.
2839 hackname = lynxos_no_warning_in_sys_time_h;
2841 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2844 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2848 * Add missing declaration for putenv.
2851 hackname = lynxos_missing_putenv;
2852 mach = '*-*-lynxos
*';
2854 bypass = 'putenv
[ \t]*\\(';
2855 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2858 "extern int putenv _AP((char *));";
2859 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2860 test_text = "extern char *getenv _AP((const char *));";
2864 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2866 * On NetBSD, machine is a symbolic link to an architecture specific
2867 * directory name, so we can't match a specific file name here.
2870 hackname
= machine_ansi_h_va_list
;
2871 select
= "define[ \t]+_BSD_VA_LIST_[ \t]";
2872 bypass
= '__builtin_va_list';
2875 c_fix_arg
= "%1__builtin_va_list";
2876 c_fix_arg
= "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2878 test_text
= " # define _BSD_VA_LIST_\tchar**";
2882 * Fix non
-ansi machine name defines
2885 hackname
= machine_name
;
2886 c_test
= machine_name
;
2887 c_fix
= machine_name
;
2889 test_text
= "/* MACH_DIFF: */\n"
2890 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2891 "\n/* no uniform test, so be careful :-) */";
2895 * Some math.h files define struct
exception (it
's in the System V
2896 * Interface Definition), which conflicts with the class exception defined
2897 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2898 * This is not a great fix, but I haven't been able to think of anything
2902 hackname
= math_exception
;
2904 select
= "struct exception";
2906 * This should be bypassed on __cplusplus
, but some supposedly C
++
2907 * aware headers
, such as Solaris
8 and
9, don
't wrap their struct
2908 * exception either. So currently we bypass only for glibc, based on a
2909 * comment in the fixed glibc header. Ick.
2911 bypass = 'We have a problem when using C\
+\
+|for C\
+\
+, '
2912 '_
[a
-z0
-9A
-Z_
]+_exception
; for C
, exception
';
2913 /* The Solaris 10 headers already get this right. */
2914 mach = '*-*-solaris2.1
[0-9]*';
2918 c_fix_arg = "#ifdef __cplusplus\n"
2919 "#define exception __math_exception\n"
2922 c_fix_arg = "#ifdef __cplusplus\n"
2923 "#undef exception\n"
2926 test_text = "typedef struct exception t_math_exception;";
2930 * This looks pretty broken to me. ``dbl_max_def'' will contain
2931 * "define DBL_MAX " at the start, when what we really want is just
2932 * the value portion. Can't figure out how to write a test case
2933 * for this either
:-(
2936 hackname
= math_huge_val_from_dbl_max
;
2940 * IF HUGE_VAL is defined to be DBL_MAX
*and
* DBL_MAX is _not_ defined
2941 * in math.h
, this fix applies.
2943 select
= "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2944 bypass
= "define[ \t]+DBL_MAX";
2948 * See if we have a definition for DBL_MAX in float.h.
2949 * If we do
, we will replace the one in math.h with that one.
2952 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2953 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2955 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2956 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2957 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
2962 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2963 "#define HUGE_VAL DBL_MAX";
2970 hackname
= nested_auth_des
;
2972 select
= '(/\*.*rpc/auth_des\.h>.*)/\*';
2974 c_fix_arg
= "%1*/ /*";
2975 test_text
= "/*#include <rpc/auth_des.h> /* skip this */";
2979 * Some versions of NetBSD don
't expect the C99 inline semantics.
2982 hackname = netbsd_c99_inline_1;
2983 mach = "*-*-netbsd*";
2985 select = "extern __inline int";
2988 c_fix_arg = "extern\n"
2989 "#ifdef __GNUC_STDC_INLINE__\n"
2990 "__attribute__((__gnu_inline__))\n"
2994 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2998 * netbsd_c99_inline_2
3001 hackname = netbsd_c99_inline_2;
3002 mach = "*-*-netbsd*";
3004 select = "#define _SIGINLINE extern __inline";
3007 c_fix_arg = <<- _EOArg_
3008 #ifdef __GNUC_STDC_INLINE__
3009 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
3015 test_text = "#define _SIGINLINE extern __inline";
3019 * NetBSD has a semicolon after the ending '}' for some extern "C".
3022 hackname = netbsd_extra_semicolon;
3023 mach = "*-*-netbsd*";
3024 files = sys/cdefs.h;
3025 select = "#define[ \t]*__END_DECLS[ \t]*};";
3028 c_fix_arg = "#define __END_DECLS }";
3030 test_text = "#define __END_DECLS };";
3034 * newlib's stdint.h has several failures to conform to C99. The fix
3035 * for these removed a comment that can be matched to identify unfixed
3039 hackname
= newlib_stdint_1
;
3040 files
= stdint
-newlib.h
, stdint.h
;
3041 select
= "@todo - Add support for wint_t types";
3042 sed
= "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
3043 sed
= "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
3044 sed
= "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
3045 sed
= "s@#define INT_LEAST32_MIN.*@"
3046 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
3047 sed
= "s@#define INT_LEAST32_MAX.*@"
3048 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
3049 sed
= "s@#define UINT_LEAST32_MAX.*@"
3050 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3051 sed
= 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3052 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3053 sed
= 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3054 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3055 sed
= 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3056 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
3057 sed
= "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
3058 sed
= "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
3059 sed
= "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
3060 sed
= "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
3061 sed
= "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
3062 test_text
= "/* @todo - Add support for wint_t types. */\n"
3063 "#define INT32_MIN (-2147483647-1)\n"
3064 "#define INT32_MAX 2147483647\n"
3065 "#define UINT32_MAX 4294967295U\n"
3066 "#define INT_LEAST32_MIN (-2147483647-1)\n"
3067 "#define INT_LEAST32_MAX 2147483647\n"
3068 "#define UINT_LEAST32_MAX 4294967295U\n"
3069 "#define INT_FAST8_MIN INT8_MIN\n"
3070 "#define INT_FAST8_MAX INT8_MAX\n"
3071 "#define UINT_FAST8_MAX UINT8_MAX\n"
3072 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
3073 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
3074 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
3075 "#define UINT8_C(x) x##U\n"
3076 "#define UINT16_C(x) x##U";
3083 hackname
= newlib_stdint_2
;
3084 files
= stdint
-newlib.h
, stdint.h
;
3085 select
= "@todo - Add support for wint_t types";
3087 c_fix_arg
= "#define INTMAX_MAX __INTMAX_MAX__\n"
3088 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
3089 "#define UINTMAX_MAX __UINTMAX_MAX__\n"
3090 "#define WCHAR_MAX __WCHAR_MAX__\n"
3091 "#define WCHAR_MIN __WCHAR_MIN__\n"
3092 "#define WINT_MAX __WINT_MAX__\n"
3093 "#define WINT_MIN __WINT_MIN__\n\n"
3095 c_fix_arg
= '/\*\* Macros for minimum-width integer constant expressions \*/';
3096 test_text
= "/* @todo - Add support for wint_t types. */\n"
3097 "/** Macros for minimum-width integer constant expressions */";
3101 * NeXT
3.2 adds const prefix to some math functions.
3102 * These conflict with the built
-in functions.
3105 hackname
= next_math_prefix
;
3106 files
= ansi
/math.h
;
3107 select
= "^extern[ \t]+double[ \t]+__const__[ \t]";
3110 c_fix_arg
= "extern double %1(";
3111 c_fix_arg
= "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
3113 test_text
= "extern\tdouble\t__const__\tmumble();";
3117 * NeXT
3.2 uses the word
"template" as a parameter for some
3118 * functions. GCC reports an invalid use of a reserved key word
3119 * with the built
-in functions.
3122 hackname
= next_template
;
3124 select
= "[ \t]template\\)";
3128 c_fix_arg
= "\\(([^)]*)[ \t]template\\)";
3129 test_text
= "extern mumble( char * template); /* fix */";
3133 * NeXT
3.2 includes the keyword volatile in the
abort() and
exit()
3134 * function prototypes. That conflicts with the built
-in functions.
3137 hackname
= next_volitile
;
3138 files
= ansi
/stdlib.h
;
3139 select
= "^extern[ \t]+volatile[ \t]+void[ \t]";
3142 c_fix_arg
= "extern void %1(";
3143 c_fix_arg
= "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3145 test_text
= "extern\tvolatile\tvoid\tabort();";
3149 * NeXT
2.0 defines
'int wait(union wait*)', which conflicts with Posix
.1.
3150 * Note that version
3 of the NeXT system has wait.h in a different directory
,
3151 * so that this code won
't do anything. But wait.h in version 3 has a
3152 * conditional, so it doesn't need this fix. So everything is okay.
3155 hackname
= next_wait_union
;
3158 select
= 'wait\(union wait';
3160 c_fix_arg
= "wait(void";
3161 test_text
= "extern pid_d wait(union wait*);";
3165 * a missing semi
-colon at the end of the nodeent structure definition.
3168 hackname
= nodeent_syntax
;
3169 files
= netdnet
/dnetdb.h
;
3170 select
= "char[ \t]*\\*na_addr[ \t]*$";
3173 test_text
= "char *na_addr\t";
3177 * Fix OpenBSD
's NULL definition.
3180 hackname = openbsd_null_definition;
3181 mach = "*-*-openbsd*";
3182 files = locale.h, stddef.h, stdio.h, string.h,
3183 time.h, unistd.h, wchar.h, sys/param.h;
3184 select = "__GNUG__";
3186 c_fix_arg = "#ifndef NULL\n"
3187 "#ifdef __cplusplus\n"
3189 "#define NULL\t__null\n"
3190 "#else\t /* ! __GNUG__ */\n"
3191 "#define NULL\t0L\n"
3192 "#endif\t /* __GNUG__ */\n"
3193 "#else\t /* ! __cplusplus */\n"
3194 "#define NULL\t((void *)0)\n"
3195 "#endif\t /* __cplusplus */\n"
3196 "#endif\t /* !NULL */";
3198 c_fix_arg = "^#ifndef[ \t]*NULL\n"
3199 "^#ifdef[ \t]*__GNUG__\n"
3200 "^#define[ \t]*NULL[ \t]*__null\n"
3202 "^#define[ \t]*NULL[ \t]*0L\n"
3208 "#define NULL __null\n"
3216 * obstack.h used casts as lvalues.
3218 * We need to change postincrements of casted pointers (which are
3219 * then dereferenced and assigned into) of the form
3221 * *((TYPE*)PTRVAR)++ = (VALUE)
3223 * into expressions like
3225 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3227 * which is correct for the cases used in obstack.h since PTRVAR is
3228 * of type char * and the value of the expression is not used.
3231 hackname = obstack_lvalue_cast;
3233 select = '\
*\
(\
(([^
()]*)\
*\
)(.*)\
)\
+\
+ = \
(([^
()]*)\
)';
3235 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3236 test_text = "*((void **) (h)->next_free)++ = (aptr)";
3240 * Fix OpenBSD's va_start define.
3243 hackname
= openbsd_va_start
;
3244 mach
= "*-*-openbsd*";
3246 select
= '__builtin_stdarg_start';
3248 c_fix_arg
= __builtin_va_start
;
3250 test_text
= "#define va_start(v,l) __builtin_stdarg_start((v),l)";
3254 * sys
/lc_core.h on some versions of OSF1
/4.x pollutes the namespace by
3255 * defining regex.h related types. This causes libg
++ build and usage
3256 * failures. Fixing this correctly requires checking and modifying
3 files.
3259 hackname
= osf_namespace_a
;
3260 files
= reg_types.h
;
3261 files
= sys
/lc_core.h
;
3262 test
= " -r reg_types.h";
3263 test
= " -r sys/lc_core.h";
3264 test
= " -n \"`grep '} regex_t;' reg_types.h`\"";
3265 test
= " -z \"`grep __regex_t regex.h`\"";
3269 c_fix_arg
= "reg(ex|off|match)_t";
3271 test_text
= "`touch sys/lc_core.h`"
3272 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
3273 "extern regex_t re;\n"
3274 "extern regoff_t ro;\n"
3275 "extern regmatch_t rm;\n";
3279 hackname
= osf_namespace_c
;
3281 test
= " -r reg_types.h";
3282 test
= " -r sys/lc_core.h";
3283 test
= " -n \"`grep '} regex_t;' reg_types.h`\"";
3284 test
= " -z \"`grep __regex_t regex.h`\"";
3286 select
= "#include <reg_types\.h>.*";
3289 "typedef __regex_t\tregex_t;\n"
3290 "typedef __regoff_t\tregoff_t;\n"
3291 "typedef __regmatch_t\tregmatch_t;";
3293 test_text
= "#include <reg_types.h>";
3297 * On broken glibc
-2.3.3 systems an array of incomplete structures is
3298 * passed to __sigsetjmp. Fix that to take a pointer instead.
3301 hackname
= pthread_incomplete_struct_argument
;
3303 select
= "struct __jmp_buf_tag";
3305 c_fix_arg
= "%1 *%2%3";
3306 c_fix_arg
= "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3307 "(__env)\\[1\\](.*)$";
3308 test_text
= "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3313 * Fix return type of fread and fwrite on sysV68
3316 hackname
= read_ret_type
;
3318 select
= "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3320 c_fix_arg
= "extern unsigned int fread(), fwrite();\n%1%2";
3321 c_fix_arg
= "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3323 test_text
= "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3327 * Fix casts as lvalues in glibc
's <rpc/xdr.h>.
3330 hackname = rpc_xdr_lvalue_cast_a;
3332 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3334 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3335 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3336 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3340 * rpc_xdr_lvalue_cast_b
3343 hackname = rpc_xdr_lvalue_cast_b;
3345 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3347 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3348 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3349 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3353 * function class(double x) conflicts with C++ keyword on rs/6000
3356 hackname = rs6000_double;
3358 select = '[^a
-zA
-Z_
]class\
(';
3361 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3362 c_fix_arg = '^.
*[^a
-zA
-Z_
]class\
(.
*';
3364 test_text = "extern int class();";
3368 * Wrong fchmod prototype on RS/6000.
3371 hackname = rs6000_fchmod;
3373 select = 'fchmod\
(char \
*';
3375 c_fix_arg = "fchmod(int";
3376 test_text = "extern int fchmod(char *, mode_t);";
3380 * parameters conflict with C++ new on rs/6000
3383 hackname = rs6000_param;
3387 select = 'rename\
(const char \
*old
, const char \
*new\
)';
3389 c_fix_arg = 'rename(const char
*_old
, const char
*_new
)';
3391 test_text = 'extern int
rename(const char
*old
, const char
*new
);';
3395 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3396 * for C99. This is wrong for C++, which needs many C99 features, but
3397 * only supports __restrict.
3400 hackname = solaris___restrict;
3401 files = sys/feature_tests.h;
3402 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3403 mach = "*-*-solaris2*";
3405 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3406 "#else\n%0\n#endif";
3407 test_text = "#define _RESTRICT_KYWD restrict";
3411 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3412 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3413 * and imaginary definitions which are not supported by GCC.
3416 hackname = solaris_complex;
3417 mach = "*-*-solaris2.*";
3419 select = "#define[ \t]_Complex_I[ \t]_Complex_I";
3420 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3421 "#define\t_Complex_I\t(__extension__ 1.0iF)/";
3422 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3423 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3424 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3425 test_text = "#define _Complex_I _Complex_I\n"
3426 "#define complex _Complex\n"
3427 "#define _Imaginary_I _Imaginary_I\n"
3428 "#define imaginary _Imaginary\n"
3430 "#define I _Imaginary_I";
3434 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3435 * extern "C" instead so libstdc++ can use it.
3438 hackname = solaris_complex_cxx;
3439 mach = "*-*-solaris2.*";
3441 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3442 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3443 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3444 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3445 test_text = "#if !defined(__cplusplus)\n"
3446 "#endif /* !defined(__cplusplus) */";
3450 * g++ rejects functions declared with both C and C++ linkage.
3453 hackname = solaris_cxx_linkage;
3454 mach = '*-*-solaris2
*';
3455 files = "iso/stdlib_iso.h";
3456 select = "(#if __cplusplus >= 199711L)\n"
3457 "(extern \"C\\+\\+\" \\{\n)"
3458 "(.*(bsearch|qsort).*)";
3460 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3463 "#if __cplusplus >= 199711L\n"
3464 "extern \"C++\" {\n"
3465 " void *bsearch(const void *, const void *, size_t, size_t,";
3469 * Solaris <iso/stdio_iso.h> doesn't declare getc for C
++ with
3470 * _STRICT_STDC
, but uses it.
3473 hackname
= solaris_getc_strict_stdc
;
3474 mach
= "*-*-solaris2*";
3475 files
= "iso/stdio_iso.h";
3476 select
= "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3478 c_fix_arg
= "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3481 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3485 * Sun Solaris
2 has a version of sys
/int_const.h that defines
3486 * UINT8_C and UINT16_C to unsigned constants.
3489 hackname
= solaris_int_const
;
3490 files
= sys
/int_const.h
;
3491 mach
= '*-*-solaris2*';
3493 c_fix_arg
= "#define\tUINT8_C(c)\t(c)\n"
3495 "#define\tUINT16_C(c)\t(c)";
3496 select
= "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3498 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3500 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3502 "#define UINT16_C(c) __CONCAT__(c,u)";
3506 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3507 * UINT8_MAX and UINT16_MAX to unsigned constants.
3510 hackname
= solaris_int_limits_1
;
3511 files
= sys
/int_limits.h
;
3512 mach
= '*-*-solaris2*';
3514 c_fix_arg
= "#define\tUINT8_MAX\t(255)\n"
3515 "#define\tUINT16_MAX\t(65535)";
3516 select
= "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3517 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3519 "#define UINT8_MAX (255U)\n"
3520 "#define UINT16_MAX (65535U)";
3524 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3525 * INT_FAST16 limits to wrong values for sys
/int_types.h.
3528 hackname
= solaris_int_limits_2
;
3529 files
= sys
/int_limits.h
;
3530 mach
= '*-*-solaris2*';
3532 c_fix_arg
= "#define\t%1_FAST16_%2 %132_%2";
3533 select
= "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3535 "#define INT_FAST16_MAX INT16_MAX\n"
3536 "#define UINT_FAST16_MAX UINT16_MAX\n"
3537 "#define INT_FAST16_MIN INT16_MIN";
3541 * Sun Solaris
2 has a version of sys
/int_limits.h that defines
3542 * SIZE_MAX as unsigned long.
3545 hackname
= solaris_int_limits_3
;
3546 files
= sys
/int_limits.h
;
3547 mach
= '*-*-solaris2*';
3549 c_fix_arg
= "#define\tSIZE_MAX\t4294967295U";
3550 select
= "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3552 "#define SIZE_MAX 4294967295UL";
3556 * Sun Solaris
10 defines several C99 math macros in terms of
3557 * builtins specific to the Studio compiler
, in particular not
3558 * compatible with the GNU compiler.
3561 hackname
= solaris_math_1
;
3562 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3563 bypass
= "__GNUC__";
3564 files
= iso
/math_c99.h
;
3566 c_fix_arg
= "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3567 c_fix_arg
= "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3569 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3571 "#define HUGE_VAL __builtin_huge_val\n"
3572 "#undef HUGE_VALF\n"
3573 "#define HUGE_VALF __builtin_huge_valf\n"
3574 "#undef HUGE_VALL\n"
3575 "#define HUGE_VALL __builtin_huge_vall";
3579 * On Solaris
11, if you do
isinf(NaN
) you
'll get a floating point
3580 * exception. Provide an alternative using GCC's builtin.
3583 hackname
= solaris_math_10
;
3584 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3585 files
= iso
/math_c99.h
;
3587 c_fix_arg
= "#define\tisinf(x) __builtin_isinf(x)";
3588 c_fix_arg
= "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3589 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3591 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3592 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3593 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3594 "\\(-INFINITY\\);[ \t]*\\}\\)";
3596 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3598 "#define isinf(x) __extension__( \\\\\n"
3599 " { __typeof(x) __x_i = (x); \\\\\n"
3600 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3601 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3605 * Solaris math INFINITY
3608 hackname
= solaris_math_2
;
3609 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3610 bypass
= "__GNUC__";
3611 files
= iso
/math_c99.h
;
3613 c_fix_arg
= "#define\tINFINITY\t(__builtin_inff())";
3614 c_fix_arg
= "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3616 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3618 "#define INFINITY __builtin_infinity";
3625 hackname
= solaris_math_3
;
3626 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3627 bypass
= "__GNUC__";
3628 files
= iso
/math_c99.h
;
3630 c_fix_arg
= "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3631 c_fix_arg
= "^#define[ \t]+NAN[ \t]+__builtin_nan";
3633 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3635 "#define NAN __builtin_nan";
3639 * Solaris math fpclassify
3642 hackname
= solaris_math_4
;
3643 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3644 bypass
= "__GNUC__";
3645 files
= iso
/math_c99.h
;
3647 c_fix_arg
= "#define\tfpclassify(x) \\\n"
3648 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3649 "FP_SUBNORMAL, FP_ZERO, (x))";
3650 c_fix_arg
= "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3652 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3653 "#undef fpclassify\n"
3654 "#define fpclassify(x) __builtin_fpclassify(x)";
3658 * Solaris math signbit
3661 hackname
= solaris_math_8
;
3662 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3663 bypass
= "__GNUC__";
3664 files
= iso
/math_c99.h
;
3666 c_fix_arg
= "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3667 "\t\t\t ? __builtin_signbitf(x) \\\n"
3668 "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
3669 "\t\t\t ? __builtin_signbitl(x) \\\n"
3670 "\t\t\t : __builtin_signbit(x))";
3671 c_fix_arg
= "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3672 test_text
= <<- _EOText_
3673 #ident
"@(#)math_c99.h 1.9 04/11/01 SMI"
3675 #define
signbit(x
) __builtin_signbit(x
)
3680 * Solaris math comparison macros
3683 hackname
= solaris_math_9
;
3684 select
= '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3685 bypass
= "__GNUC__";
3686 files
= iso
/math_c99.h
;
3688 c_fix_arg
= "#define\t%1(x, y)%2__builtin_%1(x, y)";
3689 c_fix_arg
= "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3690 "__builtin_[a-z]+\\(y\\)\\)";
3692 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3693 "#undef isgreater\n"
3694 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3695 "#undef isgreaterequal\n"
3696 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
3698 "#define isless(x, y) ((x) __builtin_isless(y))\n"
3699 "#undef islessequal\n"
3700 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
3701 "#undef islessgreater\n"
3702 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
3703 "#undef isunordered\n"
3704 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3708 * Newer Solaris
10/11 GCC signbit implementations cause strict
-aliasing
3712 hackname
= solaris_math_11
;
3713 select
= '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3714 files
= iso
/math_c99.h
;
3716 c_fix_arg
= << _EOArg_
3718 #define
signbit(x
) (sizeof(x
) == sizeof(float
) \
3719 ?
__builtin_signbitf(x
) \
3720 : sizeof(x
) == sizeof(long double
) \
3721 ?
__builtin_signbitl(x
) \
3722 : __builtin_signbit(x
))
3724 c_fix_arg
= << _EOArg_
3726 #if defined\
(__sparc\
)
3727 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3728 [ ]+\
{[ ]*__typeof\
(x\
)[ ]*__x_s
[ ]*=[ ]*\
(x\
);[ ]*\\
3729 [ ]+\
(int\
)[ ]*\
(\
*\
(unsigned
[ ]*\
*\
)[ ]*\
&__x_s
[ ]*>>[ ]*31\
);[ ]*\
}\
)
3730 #elif defined\
(__i386\
) \|\| defined\
(__amd64\
)
3731 #define
[ ]+signbit\
(x\
)[ ]+__extension__\
( \\
3732 [ ]+\
{ __typeof\
(x\
) __x_s
= \
(x\
); \\
3733 [ ]+\
(sizeof \
(__x_s\
) == sizeof \
(float\
) \? \\
3734 [ ]+\
(int\
) \
(\
*\
(unsigned \
*\
) \
&__x_s
>> 31\
) : \\
3735 [ ]+sizeof \
(__x_s\
) == sizeof \
(double\
) \? \\
3736 [ ]+\
(int\
) \
(\
(\
(unsigned \
*\
) \
&__x_s\
)\
[1\
] >> 31\
) : \\
3737 [ ]+\
(int\
) \
(\
(\
(unsigned short \
*\
) \
&__x_s\
)\
[4\
] >> 15\
)\
); \
}\
)
3740 test_text
= << _EOText_
3741 /* @
(#
)math_c99.h
1.14 13/03/27 */
3743 #if
defined(__sparc
)
3744 #define
signbit(x
) __extension__( \\
3745 { __typeof(x
) __x_s
= (x
); \\
3746 (int
) (*(unsigned *) &__x_s
>> 31); })
3747 #elif
defined(__i386
) ||
defined(__amd64
)
3748 #define
signbit(x
) __extension__( \\
3749 { __typeof(x
) __x_s
= (x
); \\
3750 (sizeof (__x_s
) == sizeof (float
) ?
\\
3751 (int
) (*(unsigned *) &__x_s
>> 31) : \\
3752 sizeof (__x_s
) == sizeof (double
) ?
\\
3753 (int
) (((unsigned *)
&__x_s
)[1] >> 31) : \\
3754 (int
) (((unsigned short *)
&__x_s
)[4] >> 15)); })
3760 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3761 * structure. As such
, it need two levels of brackets
, but only
3762 * contains one. Wrap the macro definition in an extra layer.
3765 hackname
= solaris_once_init_1
;
3766 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3768 mach
= '*-*-solaris*';
3770 c_fix_arg
= "%1{%2}%3";
3771 c_fix_arg
= "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3773 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3774 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3778 * Solaris
10+ <spawn.h
> uses char
*const argv
[_RESTRICT_KYWD
] in the
3779 * posix_spawn declarations
, which doesn
't work with C++.
3782 hackname = solaris_posix_spawn_restrict;
3784 mach = '*-*-solaris2
*';
3786 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3787 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3789 "char *const argv[_RESTRICT_KYWD],\n"
3790 "char *const envp[_RESTRICT_KYWD]);";
3794 * The pow overloads with int were removed in C++ 2011 DR 550.
3797 hackname = solaris_pow_int_overload;
3798 mach = '*-*-solaris2
*';
3799 files = "iso/math_iso.h";
3800 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3801 " *\\{[^{}]*\n[^{}]*\\}";
3803 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3806 " inline long double pow(long double __X, int __Y) { return\n"
3807 " __powl(__X, (long double) (__Y)); }";
3811 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3812 * fields of the pthread_rwlock_t structure, which are of type
3813 * upad64_t, which itself is typedef'd to int64_t
, but with __STDC__
3814 * defined (e.g. by
-ansi
) it is a union. So change the initializer
3818 hackname
= solaris_rwlock_init_1
;
3819 select
= '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3821 mach
= '*-*-solaris*';
3823 c_fix_arg
= "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3826 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3828 c_fix_arg
= "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3829 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3832 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3833 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3837 * Before Solaris
10, <stdio.h
> lacks declarations of std
::__filbuf and
3838 * std
::__flsbuf
, but
<iso
/stdio_iso.h
> uses them.
3841 hackname
= solaris_std___filbuf
;
3843 mach
= '*-*-solaris2*';
3844 bypass
= "using std::__filbuf";
3845 select
= "(using std::perror;\n)(#endif)";
3847 c_fix_arg
= "%1#ifndef _LP64\n"
3848 "using std::__filbuf;\n"
3849 "using std::__flsbuf;\n"
3852 test_text
= "using std::perror;\n"
3857 * Sun Solaris
8 has what appears to be some gross workaround for
3858 * some old version of their c
++ compiler. G
++ doesn
't want it
3859 * either, but doesn't want to be tied to SunPRO version numbers.
3862 hackname
= solaris_stdio_tag
;
3863 files
= stdio_tag.h
;
3865 select
= '__cplusplus < 54321L';
3866 /* In Solaris
10, the code in stdio_tag.h is conditionalized on
3867 "!defined(__GNUC__)" so we no longer need to fix it.
*/
3868 bypass
= '__GNUC__';
3869 sed
= 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3871 test_text
= "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3875 * a missing semi
-colon at the end of the statsswtch structure definition.
3878 hackname
= statsswtch
;
3879 files
= rpcsvc
/rstat.h
;
3880 select
= "boottime$";
3882 c_fix_arg
= "boottime;";
3883 test_text
= "struct statswtch {\n int boottime\n};";
3887 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3888 * On
4BSD
-derived systems
, stdio.h defers to machine
/ansi.h
; that
's
3892 hackname = stdio_stdarg_h;
3894 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
3896 * On Solaris 10, this fix is unncessary; <stdio.h> includes
3897 * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3899 mach = '*-*-solaris2.1
[0-9]*';
3904 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3910 * Don't use or define the name va_list in stdio.h. This is for
3911 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3912 * of __gnuc_va_list
, __DJ_va_list
, or _G_va_list is taken to
3913 * indicate that the header knows what it
's doing -- under SUSv2,
3914 * stdio.h is required to define va_list, and we shouldn't break
3918 hackname
= stdio_va_list
;
3920 bypass
= '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3922 * On Solaris
10, the definition in
3923 * <stdio.h
> is guarded appropriately by the _XPG4 feature macro
;
3924 * there is therefore no need for this fix there.
3926 mach
= '*-*-solaris2.1[0-9]*';
3930 * Use __gnuc_va_list in arg types in place of va_list.
3931 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3932 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
3933 * trailing parentheses and semicolon save all other systems from this.
3934 * Define __not_va_list__ (something harmless and unused)
3935 * instead of va_list.
3936 * Don't claim to have defined va_list.
3938 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3939 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3940 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3941 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3942 "s@ va_list@ __not_va_list__@\n"
3943 "s@\\*va_list@*__not_va_list__@\n"
3944 "s@ __va_list)@ __gnuc_va_list)@\n"
3945 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3946 "@typedef \\1 __not_va_list__;@\n"
3947 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3948 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3949 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3950 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3951 "s@VA_LIST@DUMMY_VA_LIST@\n"
3952 "s@_Va_LIST@_VA_LIST@";
3953 test_text
= "extern void mumble( va_list);";
3957 * Fix headers that use va_list from stdio.h to use the updated
3958 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3959 * dealt with elsewhere. The presence of __gnuc_va_list
,
3960 * __DJ_va_list
, or _G_va_list is taken to indicate that the header
3961 * knows what it
's doing.
3964 hackname = stdio_va_list_clients;
3972 files = curses_colr/curses.h;
3973 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list
';
3974 /* Don't fix
, if we use va_list from stdarg.h
, or if the use is
3975 otherwise protected.
*/
3976 bypass
= 'include <stdarg\.h>|#ifdef va_start';
3979 * Use __gnuc_va_list in arg types in place of va_list.
3980 * On
386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
3981 * use __gnuc_va_list instead of __VA_LIST__. We
're hoping the
3982 * trailing parentheses and semicolon save all other systems from this.
3983 * Define __not_va_list__ (something harmless and unused)
3984 * instead of va_list.
3985 * Don't claim to have defined va_list.
3987 sed
= "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3988 "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3989 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3990 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3991 "s@ va_list@ __not_va_list__@\n"
3992 "s@\\*va_list@*__not_va_list__@\n"
3993 "s@ __va_list)@ __gnuc_va_list)@\n"
3994 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3995 "@typedef \\1 __not_va_list__;@\n"
3996 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3997 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3998 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3999 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
4000 "s@VA_LIST@DUMMY_VA_LIST@\n"
4001 "s@_Va_LIST@_VA_LIST@";
4002 test_text
= "extern void mumble( va_list);";
4006 * "!__STDC__" or
"__STDC__==0" or
"__STDC__!=1" or
"__STDC__-0==0"
4007 * is
"!defined( __STRICT_ANSI__ )"
4010 hackname
= strict_ansi_not
;
4011 select
= "^([ \t]*#[ \t]*if.*)"
4013 "|__STDC__[ \t]*==[ \t]*0"
4014 "|__STDC__[ \t]*!=[ \t]*1"
4015 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
4016 /* Tru64 UNIX V4.0F
/V5.1
<standards.h
> supports GCC usage of __STDC__.
*/
4017 bypass
= 'GNU and MIPS C compilers define __STDC__ differently';
4018 /* GNU gmp.h uses
"__STDC__ != 1" only if __SCO_VERSION__
, which
4019 is not defined by GCC
, so it is safe.
*/
4020 bypass
= '__SCO_VERSION__.*__STDC__ != 1';
4021 c_test
= stdc_0_in_system_headers
;
4024 c_fix_arg
= "%1 !defined(__STRICT_ANSI__)";
4026 test_text
= "#if !__STDC__ \n"
4027 "#if __STDC__ == 0\n"
4028 "#if __STDC__ != 1\n"
4029 "#if __STDC__ - 0 == 0"
4030 "/* not std C */\nint foo;\n"
4031 "\n#end-end-end-end-if :-)";
4036 * is
"!defined( __STRICT_ANSI__ )" on continued #if
-s
4039 hackname
= strict_ansi_not_ctd
;
4040 files
= math.h
, limits.h
, stdio.h
, signal.h
,
4041 stdlib.h
, sys
/signal.h
, time.h
;
4043 * Starting at the beginning of a line
, skip white space and
4044 * a leading
"(" or
"&&" or
"||". One of those must be found.
4045 * Then
, zero
, one or more copies of a
"defined(_FOO_BAR_) &&"
4046 * expression. If these are nested
, then they must accumulate
4047 * because we won
't match any closing parentheses. Finally,
4048 * after skipping over all that, we must then match our suspect
4049 * phrase: "__STDC__-0==0" with or without white space.
4051 select = "^([ \t]*" '(\
(|
&&|\|\|
)'
4052 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
4054 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
4055 c_test = stdc_0_in_system_headers;
4058 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
4060 test_text = "#if 1 && \\\\\n"
4061 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
4062 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
4063 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
4068 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
4069 * is "defined( __STRICT_ANSI__ )"
4072 hackname = strict_ansi_only;
4073 select = "^([ \t]*#[ \t]*if.*)"
4074 "(__STDC__[ \t]*!=[ \t]*0"
4075 "|__STDC__[ \t]*==[ \t]*1"
4076 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
4077 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
4078 c_test = stdc_0_in_system_headers;
4081 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
4083 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
4087 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
4088 * in prototype without previous definition.
4091 hackname = struct_file;
4093 select = '^.
*xdrstdio_create.
*struct __file_s
';
4095 c_fix_arg = "struct __file_s;\n%0";
4096 test_text = "extern void xdrstdio_create( struct __file_s* );";
4100 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
4101 * in prototype without previous definition.
4103 * Don't fix OpenBSD
, which uses struct sockaddr_in prototyping the same
4104 * function
, and does define it.
4107 hackname
= struct_sockaddr
;
4109 select
= "^.*authdes_create.*struct sockaddr[^_]";
4110 bypass
= "<sys/socket\.h>";
4111 bypass
= "struct sockaddr;\n";
4113 c_fix_arg
= "struct sockaddr;\n%0";
4114 test_text
= "extern AUTH* authdes_create( struct sockaddr* );";
4118 * Apply fix this to all OSs since this problem seems to effect
4119 * more than just SunOS.
4122 hackname
= sun_auth_proto
;
4127 bypass
= "__cplusplus";
4129 * Select those files containing
'(*name)()'.
4131 select
= '\(\*[a-z][a-z_]*\)\(\)';
4134 c_fix_arg
= "#ifdef __cplusplus\n%1(...);%2\n"
4135 "#else\n%1();%2\n#endif";
4136 c_fix_arg
= '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4140 " int (*name)(); /* C++ bad */\n"
4145 * Fix bogus #ifdef on SunOS
4.1.
4148 hackname
= sun_bogus_ifdef
;
4149 files
= "hsfs/hsfs_spec.h";
4150 files
= "hsfs/iso_spec.h";
4151 select
= '#ifdef(.*\|\|.*)';
4153 c_fix_arg
= "#if%1";
4155 test_text
= "#ifdef __i386__ || __vax__ || __sun4c__";
4159 * Fix the CAT macro in SunOS memvar.h.
4162 hackname
= sun_catmacro
;
4163 files
= pixrect
/memvar.h
;
4164 select
= "^#define[ \t]+CAT\\(a,b\\).*";
4169 "# define CAT(a,b) a##b\n"
4170 "#else\n%0\n#endif";
4173 "#define CAT(a,b)\ta/**/b";
4177 * Fix return type of free and
{c
,m
,re
}alloc in
<malloc.h
> on SunOS
4.1.
4178 * Also fix return type of
{m
,re
}alloc in
<malloc.h
> on sysV68
4181 hackname
= sun_malloc
;
4183 bypass
= "_CLASSIC_ANSI_TYPES";
4185 sed
= "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4186 sed
= "s/int[ \t][ \t]*free/void\tfree/g";
4187 sed
= "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4188 sed
= "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4189 sed
= "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4192 "typedef char *\tmalloc_t;\n"
4194 "char*\tmalloc();\n"
4195 "char*\tcalloc();\n"
4196 "char*\trealloc();";
4200 * Check for yet more missing
';' in
struct (in SunOS
4.0.x
)
4203 hackname
= sun_rusers_semi
;
4204 files
= rpcsvc
/rusers.h
;
4206 sed
= "/^struct/,/^};/s/_cnt$/_cnt;/";
4207 test_text
= "struct mumble\n int _cnt\n};";
4211 * signal.h on SunOS defines signal
using (),
4212 * which causes trouble when compiling with g
++ -pedantic.
4215 hackname
= sun_signal
;
4216 files
= sys
/signal.h
;
4218 select
= "^void\t" '\(\*signal\(\)\)\(\);.*';
4222 "#ifdef __cplusplus\n"
4223 "void\t(*signal(...))(...);\n"
4224 "#else\n%0\n#endif";
4226 test_text
= "void\t(*signal())();";
4230 * Correct the return type for strlen in strings.h in SunOS
4.
4233 hackname
= sunos_strlen
;
4235 select
= "int[ \t]*strlen\\(\\);(.*)";
4237 c_fix_arg
= "__SIZE_TYPE__ strlen();%1";
4238 test_text
= " int\tstrlen(); /* string length */";
4242 * Linux kernel
's vt.h breaks C++
4245 hackname = suse_linux_vt_cxx;
4248 select = "^[ \t]*unsigned int new;";
4250 c_fix_arg = "unsigned int newev;";
4252 test_text = " unsigned int new; /* New console (if changing) */";
4256 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4257 * that is visible to any ANSI compiler using this include. Simply
4258 * delete the lines that #define some string functions to internal forms.
4261 hackname = svr4_disable_opt;
4263 select = '#define.
*__std_hdr_
';
4264 sed = '/#define.
*__std_hdr_
/d
';
4265 test_text = "#define strlen __std_hdr_strlen\n";
4269 * Fix broken decl of getcwd present on some svr4 systems.
4272 hackname = svr4_getcwd;
4275 files = prototypes.h;
4276 select = 'getcwd\
(char \
*, int\
)';
4279 c_fix_arg = "getcwd(char *, size_t)";
4281 test_text = "extern char* getcwd(char *, int);";
4285 * Fix broken decl of profil present on some svr4 systems.
4288 hackname = svr4_profil;
4293 'profil\
(unsigned short \
*, unsigned int
, unsigned int
, unsigned int\
)';
4295 c_fix_arg = 'profil(unsigned short
*, size_t
, int
, unsigned int
)';
4298 'profil(unsigned short
*, unsigned int
, unsigned int
, unsigned int
);';
4302 * Correct types for signal handler constants like SIG_DFL; they might be
4303 * void (*) (), and should be void (*) (int). C++ doesn't like the
4307 hackname
= svr4_sighandler_type
;
4308 files
= sys
/signal.h
;
4309 select
= 'void *\(\*\)\(\)';
4311 c_fix_arg
= "void (*)(int)";
4312 test_text
= "#define SIG_DFL (void(*)())0\n"
4313 "#define SIG_IGN (void (*)())0\n";
4317 * Some SysV r4 systems
, including Sequent
's DYNIX/ptx, use the local
4318 * function 'getrnge
' in <regexp.h> before they declare it. For these
4319 * systems add a 'static int
' declaration of 'getrnge
' into <regexp.h>
4322 * 'getrnge
' traditionally manipulates a file-scope global called 'size
',
4323 * so put the declaration right after the declaration of 'size
'.
4325 * Don't do this if there is already a `static void getrnge
' declaration
4326 * present, since this would cause a redeclaration error. Solaris 2.x has
4327 * such a declaration.
4330 hackname = svr4_undeclared_getrnge;
4333 bypass = "static void getrnge";
4336 "static int getrnge ();";
4337 c_fix_arg = "^static int[ \t]+size;";
4338 test_text = "static int size;\n"
4339 "/* stuff which calls getrnge() */\n"
4340 "static getrnge()\n"
4345 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4346 * in string.h on sysV68
4347 * Correct the return type for strlen in string.h on Lynx.
4348 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4349 * Add missing const for strdup on OSF/1 V3.0.
4350 * On sysV88 layout is slightly different.
4353 hackname = sysv68_string;
4356 bypass = "_CLASSIC_ANSI_TYPES";
4358 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4359 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4360 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4362 sed = "/^extern char$/N";
4363 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4365 sed = "/^extern int$/N";
4366 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4368 sed = "/^\tstrncmp(),$/N";
4369 sed = 's
/^\
(' "\t" 'strncmp()\
),\n\
(' "\t" 'strlen(),\
)$
/'
4370 '\
1;' "\\\nextern unsigned int\\\n\\2/";
4373 "extern int strlen();\n"
4375 "extern int ffs(long);\n"
4388 "\tstrlen(), strspn();";
4392 * Fix return type of calloc, malloc, realloc, bsearch and exit
4395 hackname = sysz_stdlib_for_sun;
4397 bypass = "_CLASSIC_ANSI_TYPES";
4399 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4401 c_fix_arg = "void *\t%1(";
4404 "extern char*\tcalloc(size_t);\n"
4405 "extern char*\tmalloc(size_t);\n"
4406 "extern char*\trealloc(void*,size_t);\n"
4407 "extern char*\tbsearch(void*,size_t,size_t);\n";
4411 * __thread is now a keyword.
4414 hackname = thread_keyword;
4415 files = "pthread.h";
4416 files = bits/sigthread.h, '*/bits
/sigthread.h
';
4417 select = "([* ])__thread([,)])";
4419 c_fix_arg = "%1__thr%2";
4422 "extern int pthread_create (pthread_t *__restrict __thread,\n"
4423 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
4424 "extern int pthread_cancel (pthread_t __thread);";
4428 * if the #if says _cplusplus, not the double underscore __cplusplus
4432 hackname = tinfo_cplusplus;
4434 select = "[ \t]_cplusplus";
4437 c_fix_arg = " __cplusplus";
4438 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4442 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4445 hackname = ultrix_const;
4447 select = 'perror\
( char \
*';
4450 c_fix_arg = "%1 const %3 *__";
4451 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4452 "[ \t]+(char|void) \\*__";
4455 "extern void perror( char *__s );\n"
4456 "extern int fputs( char *__s, FILE *);\n"
4457 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4458 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4459 "extern int scanf( char *__format, ...);\n";
4463 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4466 hackname = ultrix_const2;
4469 select = '\
*fopen\
( char \
*';
4471 c_fix_arg = "%1( const char *%3, const char *";
4472 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4473 "[ \t]*char[ \t]*\\*([^,]*),"
4474 "[ \t]*char[ \t]*\\*[ \t]*";
4477 "extern FILE *fopen( char *__filename, char *__type );\n"
4478 "extern int sscanf( char *__s, char *__format, ...);\n"
4479 "extern FILE *popen(char *, char *);\n"
4480 "extern char *tempnam(char*,char*);\n";
4484 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4487 hackname = va_i960_macro;
4488 files = arch/i960/archI960.h;
4489 select = "__(vsiz|vali|vpad|alignof__)";
4492 c_fix_arg = "__vx%1";
4495 "extern int __vsiz vsiz;\n"
4496 "extern int __vali vali;\n"
4497 "extern int __vpad vpad;\n"
4498 "#define __alignof__(x) ...";
4502 * On VMS, add missing braces around sigset_t constants.
4505 hackname = vms_add_missing_braces;
4506 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4508 files = "rtldef/signal.h";
4511 c_fix_arg = '%1 {%2} ';
4513 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4514 "{0x00000000, 0x00000000},\n"
4515 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4519 * On VMS, some DEC-C builtins are directly used.
4522 hackname = vms_decc_builtin;
4523 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4525 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4527 sed = "s@__MEMSET@memset@";
4528 sed = "s@__MEMMOVE@memmove@";
4529 sed = "s@__MEMCPY@memcpy@";
4530 sed = "s@__STRLEN@strlen@";
4531 sed = "s@__STRCPY@strcpy@";
4533 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4537 * Define __CAN_USE_EXTERN_PREFIX on vms.
4540 hackname = vms_define_can_use_extern_prefix;
4541 files = "rtldef/decc$types.h";
4542 select = "#[ \t]*else\n"
4543 "#[ \t]*if defined\\(__DECCXX\\)\n"
4544 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4549 "# elif defined (__GNUC__)\n"
4550 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4552 test_text = "# else\n"
4553 "# if defined(__DECCXX)\n"
4554 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4560 * On VMS, disable the use of dec-c string builtins
4563 hackname = vms_disable_decc_string_builtins;
4564 select = "#if !defined\\(__VAX\\)\n";
4566 files = "rtldef/string.h";
4569 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4571 test_text = "#if !defined(__VAX)\n";
4575 * On VMS, fix incompatible redeclaration of hostalias.
4578 hackname = vms_do_not_redeclare_hostalias;
4579 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4580 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4582 files = "rtldef/resolv.h";
4588 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4589 "__char_ptr32 hostalias (const char *);\n";
4593 * On VMS, forward declare structure before referencing them in prototypes.
4596 hackname = vms_forward_declare_struct;
4597 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4598 "#ifdef __cplusplus\n";
4600 files = rtldef/if.h;
4604 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4606 test_text = "/* forward decls for C++ */\n"
4607 "#ifdef __cplusplus\n"
4613 * On VMS, do not declare getopt and al if pointers are 64 bit.
4616 hackname = vms_no_64bit_getopt;
4617 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4618 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4620 files = rtldef/stdio.h, rtldef/unistd.h;
4623 c_fix_arg = <<- _EOArg_
4624 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4629 test_text = "int getopt (int, char * const [], const char *);";
4633 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4634 * which is not yet fully supported by gcc.
4637 hackname = vms_use_fast_setjmp;
4638 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4640 files = rtldef/setjmp.h;
4643 c_fix_arg = "%0 defined (__GNUC__) ||";
4645 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4649 * On VMS, use pragma extern_model instead of VAX-C keywords.
4652 hackname = vms_use_pragma_extern_model;
4653 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4654 "# pragma extern_model __save\n";
4658 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4659 "# pragma extern_model __save\n";
4661 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4662 "# pragma extern_model __save\n"
4663 "# pragma extern_model strict_refdef\n"
4664 " extern struct x zz$yy;\n"
4665 "# pragma extern_model __restore\n"
4670 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4671 * conflict while building gcc. Likewise for <builtins.h>
4674 hackname = vms_use_quoted_include;
4675 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4677 files = rtldef/wait.h, starlet_c/pthread.h;
4680 c_fix_arg = '%1<sys
/%2.h
>';
4682 test_text = "# include <resource.h>";
4686 * AIX and Interix headers define NULL to be cast to a void pointer,
4687 * which is illegal in ANSI C++.
4690 hackname = void_null;
4691 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4692 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4693 /* avoid changing C++ friendly NULL */
4694 bypass = __cplusplus;
4696 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4698 c_fix_arg = <<- _EOFix_
4703 #else /* ! __GNUG__ */
4705 #endif /* __GNUG__ */
4706 #else /* ! __cplusplus */
4707 #define NULL ((void *)0)
4708 #endif /* __cplusplus */
4711 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4715 * Make VxWorks header which is almost gcc ready fully gcc ready.
4718 hackname = vxworks_gcc_problem;
4719 files = types/vxTypesBase.h;
4720 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4722 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4725 sed = "/[ \t]size_t/i\\\n"
4726 "#ifndef _GCC_SIZE_T\\\n"
4727 "#define _GCC_SIZE_T\n";
4729 sed = "/[ \t]size_t/a\\\n"
4732 sed = "/[ \t]ptrdiff_t/i\\\n"
4733 "#ifndef _GCC_PTRDIFF_T\\\n"
4734 "#define _GCC_PTRDIFF_T\n";
4736 sed = "/[ \t]ptrdiff_t/a\\\n"
4739 sed = "/[ \t]wchar_t/i\\\n"
4740 "#ifndef _GCC_WCHAR_T\\\n"
4741 "#define _GCC_WCHAR_T\n";
4743 sed = "/[ \t]wchar_t/a\\\n"
4747 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4748 "typedef unsigned int size_t;\n"
4749 "typedef long ptrdiff_t;\n"
4750 "typedef unsigned short wchar_t;\n"
4751 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4755 * Wrap VxWorks ioctl to keep everything pretty
4758 hackname = vxworks_ioctl_macro;
4760 mach = "*-*-vxworks*";
4764 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4765 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4767 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4771 * Wrap VxWorks mkdir to be posix compliant
4774 hackname = vxworks_mkdir_macro;
4776 mach = "*-*-vxworks*";
4780 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4781 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4782 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4783 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4786 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4790 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4793 hackname = vxworks_needs_vxtypes;
4795 select = "uint_t([ \t]+_clocks_per_sec)";
4797 c_fix_arg = "unsigned int%1";
4798 test_text = "uint_t\t_clocks_per_sec;";
4802 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4805 hackname = vxworks_needs_vxworks;
4807 test = " -r types/vxTypesOld.h";
4808 test = " -n \"`egrep '#include
' $file`\"";
4809 test = " -n \"`egrep ULONG $file`\"";
4810 select = "#[ \t]define[ \t]+__INCstath";
4812 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4813 "#include <types/vxTypesOld.h>\n";
4815 test_text = "`touch types/vxTypesOld.h`"
4816 "#include </dev/null> /* ULONG */\n"
4817 "# define\t__INCstath <sys/stat.h>";
4821 * Make it so VxWorks does not include gcc/regs.h accidentally
4824 hackname = vxworks_regs;
4825 mach = "*-*-vxworks*";
4827 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4829 c_fix_arg = "#include <arch/../regs.h>";
4831 test_text = "#include <regs.h>\n";
4835 * Another bad dependency in VxWorks 5.2 <time.h>.
4838 hackname = vxworks_time;
4840 test = " -r vxWorks.h";
4842 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4846 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4847 "#ifdef __cplusplus\n"
4848 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4850 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4852 "#define __gcc_VOIDFUNCPTR_defined\n"
4854 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4856 test_text = "`touch vxWorks.h`"
4857 "#define VOIDFUNCPTR (void(*)())";
4861 * This hack makes write const-correct on VxWorks
4864 hackname = vxworks_write_const;
4866 mach = "*-*-vxworks*";
4869 c_fix_arg = "extern int write (int, const char*, size_t);";
4870 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4872 "[\t ]*char[\t ]*\\*[\t ]*,"
4873 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4875 test_text = "extern int write ( int , char * , size_t ) ;";
4879 * There are several name conflicts with C++ reserved words in X11 header
4880 * files. These are fixed in some versions, so don't do the fixes if
4881 * we find __cplusplus in the file. These were found on the RS
/6000.
4884 hackname
= x11_class
;
4885 files
= X11
/ShellP.h
;
4886 bypass
= __cplusplus
;
4887 select
= "^([ \t]*char \\*)class;(.*)";
4889 c_fix_arg
= "#ifdef __cplusplus\n%1c_class;%2\n"
4890 "#else\n%1class;%2\n#endif";
4898 * class in Xm
/BaseClassI.h
4901 hackname
= x11_class_usage
;
4902 files
= Xm
/BaseClassI.h
;
4903 bypass
= "__cplusplus";
4905 select
= " class\\)";
4907 c_fix_arg
= " c_class)";
4909 test_text
= "extern mumble (int class);\n";
4913 * new in Xm
/Traversal.h
4917 files
= Xm
/Traversal.h
;
4918 bypass
= __cplusplus
;
4920 sed
= "/Widget\told, new;/i\\\n"
4921 "#ifdef __cplusplus\\\n"
4922 "\\\tWidget\told, c_new;\\\n"
4925 sed
= "/Widget\told, new;/a\\\n"
4928 sed
= "s/Widget new,/Widget c_new,/g";
4931 " Widget\told, new;\n"
4932 "};\nextern Wedged( Widget new, Widget old );";
4936 * Incorrect sprintf declaration in X11
/Xmu.h
4939 hackname
= x11_sprintf
;
4941 files
= X11
/Xmu
/Xmu.h
;
4942 select
= "^extern char \\*\tsprintf\\(\\);$";
4945 c_fix_arg
= "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4947 test_text
= "extern char *\tsprintf();";