]>
Commit | Line | Data |
---|---|---|
6bd06916 | 1 | /* -*- Mode: C -*- */ |
6274714d | 2 | |
85eaefbc | 3 | autogen definitions fixincl; |
6274714d | 4 | |
95748a84 | 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. | |
5daf7ede | 7 | |
3072d11f | 8 | This is the sort command: |
9 | ||
281c8073 | 10 | blocksort output=inclhack.sorted \ |
3072d11f | 11 | pattern='^/\*$' \ |
3072d11f | 12 | trailer='^/\*EOF\*[/]' \ |
13 | input=inclhack.def \ | |
14 | key='hackname[ ]*=[ ]*(.*);' | |
15 | ||
95748a84 | 16 | Set up a debug test so we can make the templates emit special |
17 | code while debugging these fixes: */ | |
5daf7ede | 18 | |
a98784e9 | 19 | #ifdef DEBUG |
20 | FIXINC_DEBUG = yes; | |
21 | #endif | |
5daf7ede | 22 | |
3d906fac | 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 | |
29 | */ | |
30 | fix = { | |
3452f1c7 | 31 | hackname = AAB_aix_stdio; |
32 | files = stdio.h; | |
33 | select = "define fopen fopen64"; | |
34 | mach = "*-*-aix*"; | |
35 | test-text = ''; /* no way to test */ | |
36 | ||
37 | c_fix = wrap; | |
38 | ||
39 | c_fix_arg = ""; | |
40 | ||
41 | c_fix_arg = <<- _EOArg_ | |
42 | ||
43 | #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus | |
44 | #define __need__aix_stdio_h_fix | |
45 | #ifdef __need__aix_stdio_h_fix | |
46 | #undef fseeko | |
47 | #undef ftello | |
48 | #undef fgetpos | |
49 | #undef fsetpos | |
50 | #undef fopen | |
51 | #undef freopen | |
52 | /* Alias the symbols using asm */ | |
53 | extern "C" { | |
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"); | |
60 | } | |
61 | #endif | |
81911845 | 62 | #endif |
63 | ||
64 | _EOArg_; | |
65 | }; | |
66 | ||
67 | ||
68 | /* On AIX when _LARGE_FILES is defined fcntl.h defines open to | |
69 | * open64 and creat to creat64. This fixes fcntl.h to | |
70 | * undef those defines and use __asm__ to alias the symbols if | |
71 | * building with g++ and -D_LARGE_FILES | |
72 | */ | |
73 | fix = { | |
74 | hackname = AAB_aix_fcntl; | |
75 | files = fcntl.h; | |
76 | select = "define open[ \t]open64"; | |
77 | mach = "*-*-aix*"; | |
78 | test-text = ''; /* no way to test */ | |
79 | ||
80 | c_fix = wrap; | |
81 | ||
82 | c_fix_arg = ""; | |
83 | ||
84 | c_fix_arg = <<- _EOArg_ | |
85 | ||
86 | #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus | |
87 | #define __need__aix_fcntl_h_fix | |
88 | #ifdef __need__aix_fcntl_h_fix | |
89 | #undef open | |
90 | #undef creat | |
91 | #undef openat | |
92 | /* Alias the symbols using asm */ | |
93 | extern "C" { | |
94 | extern int open(const char *, int, ...) __asm__("open64"); | |
95 | extern int creat(const char *, mode_t) __asm__("creat64"); | |
96 | #if (_XOPEN_SOURCE >= 700) | |
97 | extern int openat(int, const char *, int, ...) __asm__("open64at"); | |
98 | #endif | |
99 | } | |
100 | #endif | |
3452f1c7 | 101 | #endif |
102 | ||
103 | _EOArg_; | |
3d906fac | 104 | }; |
105 | ||
baee91be | 106 | |
f2563b02 | 107 | /* |
108 | * On Mac OS 10.3.9, the 'long double' functions are available in | |
109 | * libSystem, but are not prototyped in math.h. | |
110 | */ | |
111 | fix = { | |
112 | hackname = AAB_darwin7_9_long_double_funcs; | |
113 | mach = "*-*-darwin7.9*"; | |
114 | files = architecture/ppc/math.h; | |
115 | bypass = "powl"; | |
116 | replace = <<- _EndOfHeader_ | |
b55bf7ea | 117 | /* This file prototypes the long double functions available on Mac OS |
118 | 10.3.9. */ | |
119 | #ifndef __MATH__ | |
120 | # undef __APPLE_CC__ | |
121 | # define __APPLE_CC__ 1345 | |
122 | # include_next <architecture/ppc/math.h> | |
123 | # undef __APPLE_CC__ | |
124 | # define __APPLE_CC__ 1 | |
125 | # ifndef __LIBMLDBL_COMPAT | |
126 | # ifdef __LONG_DOUBLE_128__ | |
127 | # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128") | |
128 | # else | |
129 | # define __LIBMLDBL_COMPAT(sym) | |
130 | # endif /* __LONG_DOUBLE_128__ */ | |
131 | # endif /* __LIBMLDBL_COMPAT */ | |
132 | # ifdef __cplusplus | |
133 | extern "C" { | |
134 | # endif | |
135 | extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl); | |
136 | extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl); | |
137 | extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl); | |
138 | extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l); | |
139 | extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl); | |
140 | extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl); | |
141 | extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl); | |
142 | extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl); | |
143 | extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl); | |
144 | extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl); | |
145 | extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl); | |
146 | extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl); | |
147 | extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl); | |
148 | extern long double expl( long double ) __LIBMLDBL_COMPAT(expl); | |
149 | extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l); | |
150 | extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l); | |
151 | extern long double logl( long double ) __LIBMLDBL_COMPAT(logl); | |
152 | extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l); | |
153 | extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l); | |
154 | extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl); | |
155 | extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl); | |
156 | extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl); | |
157 | extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl); | |
158 | extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl); | |
159 | extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl); | |
160 | extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl); | |
161 | extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl); | |
162 | extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl); | |
163 | extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl); | |
164 | extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl); | |
165 | extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl); | |
166 | extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl); | |
167 | extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl); | |
168 | extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl); | |
169 | extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal); | |
170 | extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal); | |
171 | extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill); | |
172 | extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl); | |
173 | extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl); | |
174 | extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl); | |
175 | extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl); | |
176 | extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl); | |
177 | extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl); | |
178 | extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl); | |
179 | extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl); | |
180 | extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl); | |
181 | extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl); | |
182 | extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl); | |
183 | extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol); | |
184 | extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl); | |
185 | extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl); | |
186 | extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl); | |
187 | extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl); | |
188 | extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml); | |
189 | extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl); | |
190 | extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl); | |
191 | extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal); | |
192 | # ifdef __cplusplus | |
193 | } | |
194 | # endif | |
195 | #endif /* __MATH__ */ | |
196 | _EndOfHeader_; | |
f2563b02 | 197 | }; |
198 | ||
199 | ||
200 | /* | |
201 | * ... and for the previous fix to be useful, you have to not use "" | |
202 | * includes. | |
203 | */ | |
204 | fix = { | |
205 | hackname = AAB_darwin7_9_long_double_funcs_2; | |
206 | mach = "*-*-darwin7.9*"; | |
207 | files = math.h; | |
208 | select = '#include[ \t]+\"'; | |
209 | c_fix = format; | |
210 | c_fix_arg = "%1<%2.h>"; | |
211 | ||
212 | c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"'; | |
213 | ||
214 | test_text = '#include "architecture/ppc/math.h"'; | |
215 | }; | |
216 | ||
217 | ||
e26c299a | 218 | /* |
bb304030 | 219 | * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n) |
e26c299a | 220 | */ |
221 | fix = { | |
bb304030 | 222 | hackname = AAB_fd_zero_asm_posix_types_h; |
e26c299a | 223 | files = asm/posix_types.h; |
e800dd2f | 224 | mach = 'i[34567]86-*-linux*'; |
bb304030 | 225 | bypass = '} while'; |
54bb64fb | 226 | bypass = 'x86_64'; |
8f4ca8fb | 227 | bypass = 'posix_types_64'; |
e26c299a | 228 | |
229 | /* | |
230 | * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not | |
231 | * the start, so that if #include_next gets another instance of | |
232 | * the wrapper, this will follow the #include_next chain until | |
233 | * we arrive at the real <asm/posix_types.h>. | |
234 | */ | |
2b5c5c15 | 235 | replace = <<- _EndOfHeader_ |
3ff85771 | 236 | /* This file fixes a bug in the __FD_ZERO macro |
237 | for older versions of the Linux kernel. */ | |
238 | #ifndef _POSIX_TYPES_H_WRAPPER | |
239 | #include <features.h> | |
240 | #include_next <asm/posix_types.h> | |
241 | ||
242 | #if defined(__FD_ZERO) && !defined(__GLIBC__) | |
243 | #undef __FD_ZERO | |
244 | #define __FD_ZERO(fdsetp) \ | |
245 | do { \ | |
246 | int __d0, __d1; \ | |
3452f1c7 | 247 | __asm__ __volatile__("cld ; rep ; stosl" \ |
248 | : "=&c" (__d0), "=&D" (__d1) \ | |
249 | : "a" (0), "0" (__FDSET_LONGS), \ | |
250 | "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \ | |
3ff85771 | 251 | } while (0) |
252 | #endif | |
253 | ||
254 | #define _POSIX_TYPES_H_WRAPPER | |
255 | #endif /* _POSIX_TYPES_H_WRAPPER */ | |
2b5c5c15 | 256 | _EndOfHeader_; |
e26c299a | 257 | }; |
258 | ||
259 | ||
260 | /* | |
261 | * This fixes __FD_ZERO bug for glibc-1.x | |
262 | */ | |
263 | fix = { | |
bb304030 | 264 | hackname = AAB_fd_zero_gnu_types_h; |
e26c299a | 265 | files = gnu/types.h; |
e800dd2f | 266 | mach = 'i[34567]86-*-linux*'; |
e26c299a | 267 | |
268 | /* | |
269 | * Define _TYPES_H_WRAPPER at the end of the wrapper, not | |
270 | * the start, so that if #include_next gets another instance of | |
271 | * the wrapper, this will follow the #include_next chain until | |
272 | * we arrive at the real <gnu/types.h>. | |
273 | */ | |
2b5c5c15 | 274 | replace = <<- _EndOfHeader_ |
275 | /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ | |
276 | #ifndef _TYPES_H_WRAPPER | |
277 | #include <features.h> | |
278 | #include_next <gnu/types.h> | |
279 | ||
280 | #if defined(__FD_ZERO) && !defined(__GLIBC__) | |
281 | #undef __FD_ZERO | |
9b20d84f | 282 | # define __FD_ZERO(fdsetp) \ |
283 | do { \ | |
284 | int __d0, __d1; \ | |
285 | __asm__ __volatile__("cld ; rep ; stosl" \ | |
286 | : "=&c" (__d0), "=&D" (__d1) \ | |
287 | : "a" (0), "0" (__FDSET_LONGS), \ | |
288 | "1" ((__fd_set *) (fdsetp)) :"memory"); \ | |
2b5c5c15 | 289 | } while (0) |
290 | #endif | |
e26c299a | 291 | |
2b5c5c15 | 292 | #define _TYPES_H_WRAPPER |
293 | #endif /* _TYPES_H_WRAPPER */ | |
294 | _EndOfHeader_; | |
e26c299a | 295 | }; |
296 | ||
297 | ||
298 | /* | |
299 | * This fixes __FD_ZERO bug for glibc-2.0.x | |
300 | */ | |
301 | fix = { | |
bb304030 | 302 | hackname = AAB_fd_zero_selectbits_h; |
e26c299a | 303 | files = selectbits.h; |
e800dd2f | 304 | mach = 'i[34567]86-*-linux*'; |
e26c299a | 305 | |
306 | /* | |
307 | * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not | |
308 | * the start, so that if #include_next gets another instance of | |
309 | * the wrapper, this will follow the #include_next chain until | |
310 | * we arrive at the real <selectbits.h>. | |
311 | */ | |
2b5c5c15 | 312 | replace = <<- _EndOfHeader_ |
313 | /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ | |
314 | #ifndef _SELECTBITS_H_WRAPPER | |
315 | #include <features.h> | |
316 | #include_next <selectbits.h> | |
317 | ||
318 | #if defined(__FD_ZERO) && defined(__GLIBC__) \\ | |
319 | && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\ | |
320 | && __GLIBC_MINOR__ == 0 | |
321 | #undef __FD_ZERO | |
322 | #define __FD_ZERO(fdsetp) \\ | |
323 | do { \\ | |
324 | int __d0, __d1; \\ | |
325 | __asm__ __volatile__ ("cld; rep; stosl" \\ | |
bb304030 | 326 | : "=&c" (__d0), "=&D" (__d1) \\ |
327 | : "a" (0), "0" (sizeof (__fd_set) \\ | |
328 | / sizeof (__fd_mask)), \\ | |
329 | "1" ((__fd_mask *) (fdsetp)) \\ | |
330 | : "memory"); \\ | |
2b5c5c15 | 331 | } while (0) |
332 | #endif | |
e26c299a | 333 | |
2b5c5c15 | 334 | #define _SELECTBITS_H_WRAPPER |
335 | #endif /* _SELECTBITS_H_WRAPPER */ | |
336 | _EndOfHeader_; | |
e26c299a | 337 | }; |
338 | ||
339 | ||
4f56733a | 340 | /* |
341 | * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing | |
342 | * the same interface as <stdarg.h>. No idea why they couldn't have just | |
343 | * used the standard header. | |
344 | */ | |
345 | fix = { | |
346 | hackname = AAB_solaris_sys_varargs_h; | |
347 | files = "sys/varargs.h"; | |
348 | mach = '*-*-solaris*'; | |
2b5c5c15 | 349 | replace = <<- _EndOfHeader_ |
350 | #ifdef __STDC__ | |
351 | #include <stdarg.h> | |
352 | #else | |
353 | #include <varargs.h> | |
354 | #endif | |
355 | _EndOfHeader_; | |
4f56733a | 356 | }; |
357 | ||
358 | ||
d6d7d999 | 359 | /* |
360 | * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin | |
361 | * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
362 | * many other systems have similar text but correct versions of the file. | |
363 | * To ensure only Sun's is fixed, we grep for a likely unique string. | |
364 | * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) | |
365 | */ | |
366 | fix = { | |
367 | hackname = AAB_sun_memcpy; | |
368 | files = memory.h; | |
2b5c5c15 | 369 | select = "/\\*\t@\\(#\\)" |
d6d7d999 | 370 | "(head/memory.h\t50.1\t " |
371 | "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/"; | |
372 | ||
2b5c5c15 | 373 | replace = <<- _EndOfHeader_ |
374 | /* This file was generated by fixincludes */ | |
375 | #ifndef __memory_h__ | |
376 | #define __memory_h__ | |
d6d7d999 | 377 | |
2b5c5c15 | 378 | #ifdef __STDC__ |
379 | extern void *memccpy(); | |
380 | extern void *memchr(); | |
381 | extern void *memcpy(); | |
382 | extern void *memset(); | |
383 | #else | |
384 | extern char *memccpy(); | |
385 | extern char *memchr(); | |
386 | extern char *memcpy(); | |
387 | extern char *memset(); | |
388 | #endif /* __STDC__ */ | |
d6d7d999 | 389 | |
2b5c5c15 | 390 | extern int memcmp(); |
d6d7d999 | 391 | |
2b5c5c15 | 392 | #endif /* __memory_h__ */ |
3452f1c7 | 393 | _EndOfHeader_; |
d6d7d999 | 394 | }; |
395 | ||
74ee6ab5 | 396 | /* |
397 | * Fix assert.h on VxWorks: | |
398 | */ | |
399 | fix = { | |
400 | hackname = AAB_vxworks_assert; | |
401 | files = assert.h; | |
402 | mach = "*-*-vxworks*"; | |
403 | ||
404 | replace = <<- _EndOfHeader_ | |
405 | #ifndef _ASSERT_H | |
406 | #define _ASSERT_H | |
407 | ||
408 | #ifdef assert | |
409 | #undef assert | |
410 | #endif | |
411 | ||
412 | #if defined(__STDC__) || defined(__cplusplus) | |
413 | extern void __assert (const char*); | |
414 | #else | |
415 | extern void __assert (); | |
416 | #endif | |
417 | ||
418 | #ifdef NDEBUG | |
419 | #define assert(ign) ((void)0) | |
420 | #else | |
421 | ||
422 | #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str) | |
423 | #define ASSERT_STRINGIFY_HELPER(str) #str | |
424 | ||
425 | #define assert(test) ((void) \ | |
426 | ((test) ? ((void)0) : \ | |
427 | __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \ | |
428 | __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n"))) | |
429 | ||
430 | #endif | |
431 | ||
432 | #endif | |
433 | _EndOfHeader_; | |
434 | }; | |
435 | ||
436 | /* | |
437 | * Add needed include to regs.h (NOT the gcc header) on VxWorks | |
438 | */ | |
439 | ||
440 | fix = { | |
441 | hackname = AAB_vxworks_regs_vxtypes; | |
442 | files = regs.h; | |
443 | mach = "*-*-vxworks*"; | |
444 | ||
445 | replace = <<- _EndOfHeader_ | |
446 | #ifndef _REGS_H | |
447 | #define _REGS_H | |
448 | #include <types/vxTypesOld.h> | |
449 | #include_next <arch/../regs.h> | |
450 | #endif | |
451 | _EndOfHeader_; | |
452 | }; | |
453 | ||
454 | /* | |
455 | * Make VxWorks stdint.h a bit more compliant - add typedefs | |
456 | */ | |
457 | fix = { | |
458 | hackname = AAB_vxworks_stdint; | |
459 | files = stdint.h; | |
460 | mach = "*-*-vxworks*"; | |
461 | ||
462 | replace = <<- _EndOfHeader_ | |
463 | #ifndef _STDINT_H | |
464 | #define _STDINT_H | |
465 | /* get int*_t, uint*_t */ | |
466 | #include <types/vxTypes.h> | |
467 | ||
468 | /* get legacy vxworks types for compatibility */ | |
469 | #include <types/vxTypesOld.h> | |
470 | ||
471 | typedef long intptr_t; | |
472 | typedef unsigned long uintptr_t; | |
473 | ||
474 | typedef int64_t intmax_t; | |
475 | typedef uint64_t uintmax_t; | |
476 | ||
477 | typedef int8_t int_least8_t; | |
478 | typedef int16_t int_least16_t; | |
479 | typedef int32_t int_least32_t; | |
480 | typedef int64_t int_least64_t; | |
481 | ||
482 | typedef uint8_t uint_least8_t; | |
483 | typedef uint16_t uint_least16_t; | |
484 | typedef uint32_t uint_least32_t; | |
485 | typedef uint64_t uint_least64_t; | |
486 | ||
487 | typedef int8_t int_fast8_t; | |
488 | typedef int int_fast16_t; | |
489 | typedef int32_t int_fast32_t; | |
490 | typedef int64_t int_fast64_t; | |
491 | ||
492 | typedef uint8_t uint_fast8_t; | |
493 | typedef unsigned int uint_fast16_t; | |
494 | typedef uint32_t uint_fast32_t; | |
495 | typedef uint64_t uint_fast64_t; | |
496 | ||
497 | /* Ranges */ | |
498 | #define UINT8_MAX (~(uint8_t)0) | |
499 | #define UINT8_MIN 0 | |
500 | #define UINT16_MAX (~(uint16_t)0) | |
501 | #define UINT16_MIN 0 | |
502 | #define UINT32_MAX (~(uint32_t)0) | |
503 | #define UINT32_MIN 0 | |
504 | #define UINT64_MAX (~(uint64_t)0) | |
505 | #define UINT64_MIN 0 | |
506 | ||
507 | #define UINTPTR_MAX (~(uintptr_t)0) | |
508 | #define UINTPTR_MIN 0 | |
509 | ||
510 | /* Need to do int_fast16_t as well, as type | |
511 | size may be architecture dependent */ | |
512 | #define UINT_FAST16_MAX (~(uint_fast16_t)0) | |
513 | #define UINT_FAST16_MAX 0 | |
514 | ||
515 | #define INT8_MAX (UINT8_MAX>>1) | |
516 | #define INT8_MIN (INT8_MAX+1) | |
517 | #define INT16_MAX (UINT16_MAX>>1) | |
518 | #define INT16_MIN (INT16_MAX+1) | |
519 | #define INT32_MAX (UINT32_MAX>>1) | |
520 | #define INT32_MIN (INT32_MAX+1) | |
521 | #define INT64_MAX (UINT64_MAX>>1) | |
522 | #define INT64_MIN (INT64_MAX+1) | |
523 | ||
524 | #define INTPTR_MAX (UINTPTR_MAX>>1) | |
525 | #define INTPTR_MIN (INTPTR_MAX+1) | |
526 | ||
527 | #define INT_FAST16_MAX (UINT_FAST16_MAX>>1) | |
528 | #define INT_FAST16_MIN (INT_FAST16_MAX+1) | |
529 | ||
530 | /* now define equiv. constants */ | |
531 | #define UINT_FAST8_MAX UINT8_MAX | |
532 | #define UINT_FAST8_MIN UINT_FAST8_MIN | |
533 | #define INT_FAST8_MAX INT8_MAX | |
534 | #define INT_FAST8_MIN INT8_MIN | |
535 | #define UINT_FAST32_MAX UINT32_MAX | |
536 | #define UINT_FAST32_MIN UINT32_MIN | |
537 | #define INT_FAST32_MAX INT32_MAX | |
538 | #define INT_FAST32_MIN INT32_MIN | |
539 | #define UINT_FAST64_MAX UINT64_MAX | |
540 | #define UINT_FAST64_MIN UINT64_MIN | |
541 | #define INT_FAST64_MAX INT64_MAX | |
542 | #define INT_FAST64_MIN INT64_MIN | |
543 | ||
544 | #define UINT_LEAST8_MAX UINT8_MAX | |
545 | #define UINT_LEAST8_MIN UINT8_MIN | |
546 | #define INT_LEAST8_MAX INT8_MAX | |
547 | #define INT_LEAST8_MIN INT8_MIN | |
548 | #define UINT_LEAST16_MAX UINT16_MAX | |
549 | #define UINT_LEAST16_MIN UINT16_MIN | |
550 | #define INT_LEAST16_MAX INT16_MAX | |
551 | #define INT_LEAST16_MIN INT16_MIN | |
552 | #define UINT_LEAST32_MAX UINT32_MAX | |
553 | #define UINT_LEAST32_MIN UINT32_MIN | |
554 | #define INT_LEAST32_MAX INT32_MAX | |
555 | #define INT_LEAST32_MIN INT32_MIN | |
556 | #define UINT_LEAST64_MAX UINT64_MAX | |
557 | #define UINT_LEAST64_MIN UINT64_MIN | |
558 | #define INT_LEAST64_MAX INT64_MAX | |
559 | #define INT_LEAST64_MIN INT64_MIN | |
560 | ||
561 | #define UINTMAX_MAX UINT64_MAX | |
562 | #define UINTMAX_MIN UINT64_MIN | |
563 | #define INTMAX_MAX INT64_MAX | |
564 | #define INTMAX_MIN INT64_MIN | |
565 | ||
566 | #endif | |
567 | _EndOfHeader_; | |
568 | }; | |
569 | ||
570 | /* | |
571 | * This hack makes makes unistd.h more POSIX-compliant on VxWorks | |
572 | */ | |
573 | fix = { | |
574 | hackname = AAB_vxworks_unistd; | |
575 | files = unistd.h; | |
576 | mach = "*-*-vxworks*"; | |
577 | ||
578 | replace = <<- _EndOfHeader_ | |
579 | #ifndef _UNISTD_H | |
580 | #define _UNISTD_H | |
581 | #include_next <unistd.h> | |
582 | #include <ioLib.h> | |
583 | #ifndef STDIN_FILENO | |
584 | #define STDIN_FILENO 0 | |
585 | #endif | |
586 | #ifndef STDOUT_FILENO | |
587 | #define STDOUT_FILENO 1 | |
588 | #endif | |
589 | #ifndef STDERR_FILENO | |
590 | #define STDERR_FILENO 2 | |
591 | #endif | |
592 | #endif /* _UNISTD_H */ | |
593 | _EndOfHeader_; | |
594 | }; | |
595 | ||
d6d7d999 | 596 | |
253f9954 | 597 | /* |
598 | * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I, | |
599 | * which only is provided by AIX xlc C99. | |
600 | */ | |
601 | fix = { | |
602 | hackname = aix_complex; | |
82c99fed | 603 | mach = "*-*-aix*"; |
253f9954 | 604 | files = complex.h; |
82c99fed | 605 | select = "#define[ \t]_Complex_I[ \t]__I"; |
606 | c_fix = format; | |
607 | c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; | |
608 | test_text = "#define _Complex_I __I\n"; | |
253f9954 | 609 | }; |
610 | ||
0560f6fc | 611 | /* |
612 | * malloc.h on AIX6 uses XLC++ specific builtin syntax | |
613 | */ | |
614 | fix = { | |
615 | hackname = aix_malloc; | |
616 | mach = "*-*-aix*"; | |
617 | files = "malloc.h"; | |
618 | select = "#ifdef __cplusplus"; | |
619 | c_fix = format; | |
620 | c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))"; | |
621 | test_text = "#ifdef __cplusplus"; | |
622 | }; | |
623 | ||
eafa229b | 624 | /* |
625 | * net/if_arp.h defines a variable fc_softc instead of adding a | |
626 | * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1 | |
627 | */ | |
628 | fix = { | |
629 | hackname = aix_net_if_arp; | |
630 | mach = "*-*-aix*"; | |
631 | files = "net/if_arp.h"; | |
632 | select = "^struct fc_softc \\{"; | |
633 | c_fix = format; | |
634 | c_fix_arg = "typedef struct _fc_softc {"; | |
635 | test_text = "struct fc_softc {\n int a;\n};"; | |
636 | }; | |
253f9954 | 637 | |
4cad3a31 | 638 | /* |
3adcc56f | 639 | * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER, |
640 | * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough | |
641 | * braces. | |
4cad3a31 | 642 | */ |
643 | fix = { | |
644 | hackname = aix_once_init_1; | |
645 | mach = "*-*-aix*"; | |
646 | files = "pthread.h"; | |
647 | select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n" | |
648 | "\\{ \\\\\n"; | |
649 | c_fix = format; | |
650 | c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n" | |
651 | "{{ \\\n"; | |
652 | test_text = "#define PTHREAD_ONCE_INIT \\\\\n" | |
653 | "{ \\\\\n"; | |
654 | }; | |
655 | ||
656 | fix = { | |
657 | hackname = aix_once_init_2; | |
658 | mach = "*-*-aix*"; | |
659 | files = "pthread.h"; | |
660 | select = "[ \t]0 \\\\\n" | |
661 | "\\}\n"; | |
662 | c_fix = format; | |
663 | c_fix_arg = " 0 \\\n" | |
664 | "}}\n"; | |
665 | test_text = " 0 \\\\\n" | |
666 | "}\n"; | |
667 | }; | |
668 | ||
3adcc56f | 669 | fix = { |
670 | hackname = aix_mutex_initializer_1; | |
671 | mach = "*-*-aix*"; | |
672 | files = "pthread.h"; | |
673 | select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n" | |
674 | "\\{ \\\\\n"; | |
675 | c_fix = format; | |
676 | c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n" | |
677 | "{{ \\\n"; | |
678 | test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n" | |
679 | "{ \\\\\n"; | |
680 | }; | |
681 | ||
682 | fix = { | |
683 | hackname = aix_cond_initializer_1; | |
684 | mach = "*-*-aix*"; | |
685 | files = "pthread.h"; | |
686 | select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n" | |
687 | "\\{ \\\\\n"; | |
688 | c_fix = format; | |
689 | c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n" | |
690 | "{{ \\\n"; | |
691 | test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n" | |
692 | "{ \\\\\n"; | |
693 | }; | |
694 | ||
695 | fix = { | |
696 | hackname = aix_rwlock_initializer_1; | |
697 | mach = "*-*-aix*"; | |
698 | files = "pthread.h"; | |
699 | select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n" | |
700 | "\\{ \\\\\n"; | |
701 | c_fix = format; | |
702 | c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n" | |
703 | "{{ \\\n"; | |
704 | test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n" | |
705 | "{ \\\\\n"; | |
706 | }; | |
707 | ||
e494b1bb | 708 | /* |
709 | * pthread.h on AIX 4.3.3 tries to define a macro without whitspace | |
710 | * which violates a requirement of ISO C. | |
711 | */ | |
712 | fix = { | |
713 | hackname = aix_pthread; | |
714 | files = "pthread.h"; | |
715 | select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])"; | |
716 | c_fix = format; | |
717 | c_fix_arg = "%1 %2"; | |
807fa3a5 | 718 | test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n" |
719 | "{...init stuff...}"; | |
e494b1bb | 720 | }; |
721 | ||
722 | ||
82c99fed | 723 | /* |
724 | * AIX stdint.h fixes. | |
725 | */ | |
726 | fix = { | |
727 | hackname = aix_stdint_1; | |
728 | mach = "*-*-aix*"; | |
e2fb821c | 729 | files = stdint-aix.h, stdint.h; |
82c99fed | 730 | select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n" |
731 | "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)"; | |
732 | c_fix = format; | |
733 | c_fix_arg = "#define UINT8_MAX (255)\n" | |
734 | "#define UINT16_MAX (65535)"; | |
735 | test_text = "#define UINT8_MAX (255U)\n" | |
736 | "#define UINT16_MAX (65535U)"; | |
737 | }; | |
738 | ||
739 | ||
740 | fix = { | |
741 | hackname = aix_stdint_2; | |
742 | mach = "*-*-aix*"; | |
e2fb821c | 743 | files = stdint-aix.h, stdint.h; |
82c99fed | 744 | select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n" |
745 | "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n" | |
746 | "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n" | |
747 | "#else\n" | |
748 | "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n" | |
749 | "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n" | |
750 | "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX"; | |
751 | c_fix = format; | |
752 | c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n" | |
753 | "#define INTPTR_MAX 9223372036854775807L\n" | |
754 | "#define UINTPTR_MAX 18446744073709551615UL\n" | |
755 | "#else\n" | |
756 | "#define INTPTR_MIN (-INTPTR_MAX-1)\n" | |
757 | "#define INTPTR_MAX 2147483647L\n" | |
758 | "#define UINTPTR_MAX 4294967295UL"; | |
759 | test_text = "#define INTPTR_MIN INT64_MIN\n" | |
760 | "#define INTPTR_MAX INT64_MAX\n" | |
761 | "#define UINTPTR_MAX UINT64_MAX\n" | |
762 | "#else\n" | |
763 | "#define INTPTR_MIN INT32_MIN\n" | |
764 | "#define INTPTR_MAX INT32_MAX\n" | |
765 | "#define UINTPTR_MAX UINT32_MAX"; | |
766 | }; | |
767 | ||
768 | ||
769 | fix = { | |
770 | hackname = aix_stdint_3; | |
771 | mach = "*-*-aix*"; | |
e2fb821c | 772 | files = stdint-aix.h, stdint.h; |
82c99fed | 773 | select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n" |
774 | "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n" | |
775 | "#else\n" | |
776 | "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n" | |
777 | "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX"; | |
778 | c_fix = format; | |
779 | c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n" | |
780 | "#define PTRDIFF_MAX 9223372036854775807L\n" | |
781 | "#else\n" | |
782 | "#define PTRDIFF_MIN (-2147483647L - 1)\n" | |
783 | "#define PTRDIFF_MAX 2147483647L"; | |
784 | test_text = "#define PTRDIFF_MIN INT64_MIN\n" | |
785 | "#define PTRDIFF_MAX INT64_MAX\n" | |
786 | "#else\n" | |
787 | "#define PTRDIFF_MIN INT32_MIN\n" | |
788 | "#define PTRDIFF_MAX INT32_MAX"; | |
789 | }; | |
790 | ||
791 | ||
792 | fix = { | |
793 | hackname = aix_stdint_4; | |
794 | mach = "*-*-aix*"; | |
e2fb821c | 795 | files = stdint-aix.h, stdint.h; |
82c99fed | 796 | select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n" |
797 | "#else\n" | |
798 | "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX"; | |
799 | c_fix = format; | |
800 | c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n" | |
801 | "#else\n" | |
802 | "#define SIZE_MAX 4294967295UL"; | |
803 | test_text = "#define SIZE_MAX UINT64_MAX\n" | |
804 | "#else\n" | |
805 | "#define SIZE_MAX UINT32_MAX"; | |
806 | }; | |
807 | ||
808 | ||
809 | fix = { | |
810 | hackname = aix_stdint_5; | |
811 | mach = "*-*-aix*"; | |
e2fb821c | 812 | files = stdint-aix.h, stdint.h; |
82c99fed | 813 | select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n" |
814 | "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)"; | |
815 | c_fix = format; | |
816 | c_fix_arg = "#define UINT8_C(c) c\n" | |
817 | "#define UINT16_C(c) c"; | |
818 | test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n" | |
819 | "#define UINT16_C(c) __CONCAT__(c,U)"; | |
820 | }; | |
821 | ||
822 | ||
e494b1bb | 823 | /* |
824 | * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline | |
825 | * in an otherwise harmless (and #ifed out) macro definition | |
826 | */ | |
827 | fix = { | |
828 | hackname = aix_sysmachine; | |
829 | files = sys/machine.h; | |
830 | select = "\\\\ +\n"; | |
831 | c_fix = format; | |
832 | c_fix_arg = "\\\n"; | |
833 | test_text = "#define FOO \\\n" | |
834 | " bar \\ \n baz \\ \n bat"; | |
835 | }; | |
836 | ||
837 | ||
85df6fdf | 838 | /* |
839 | * sys/wait.h on AIX 5.2 defines macros that have both signed and | |
840 | * unsigned types in conditional expressions. | |
841 | */ | |
842 | fix = { | |
843 | hackname = aix_syswait_2; | |
844 | files = sys/wait.h; | |
845 | select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)'; | |
846 | c_fix = format; | |
847 | c_fix_arg = "? (int)%1"; | |
848 | test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)"; | |
849 | }; | |
850 | ||
851 | ||
6274714d | 852 | /* |
853 | * sys/signal.h on some versions of AIX uses volatile in the typedef of | |
854 | * sig_atomic_t, which causes gcc to generate a warning about duplicate | |
855 | * volatile when a sig_atomic_t variable is declared volatile, as | |
856 | * required by ANSI C. | |
857 | */ | |
858 | fix = { | |
85eaefbc | 859 | hackname = aix_volatile; |
860 | files = sys/signal.h; | |
861 | select = "typedef volatile int sig_atomic_t"; | |
472aa368 | 862 | c_fix = format; |
863 | c_fix_arg = "typedef int sig_atomic_t"; | |
85eaefbc | 864 | test_text = "typedef volatile int sig_atomic_t;"; |
6274714d | 865 | }; |
866 | ||
867 | ||
d1ec871e | 868 | /* |
869 | * Fix __assert declaration in assert.h on Alpha OSF/1. | |
870 | */ | |
871 | fix = { | |
872 | hackname = alpha___assert; | |
873 | files = "assert.h"; | |
874 | select = '__assert\(char \*, char \*, int\)'; | |
875 | c_fix = format; | |
876 | c_fix_arg = "__assert(const char *, const char *, int)"; | |
877 | test_text = 'extern void __assert(char *, char *, int);'; | |
878 | }; | |
879 | ||
880 | ||
03112946 | 881 | /* |
882 | * Fix assert macro in assert.h on Alpha OSF/1. | |
883 | * The superfluous int cast breaks C++. | |
884 | */ | |
885 | fix = { | |
886 | hackname = alpha_assert; | |
887 | files = "assert.h"; | |
84d20ec8 | 888 | select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)'; |
03112946 | 889 | c_fix = format; |
890 | c_fix_arg = "%1(EX)"; | |
560b9c9b | 891 | test_text = '#define assert(EX) (((int) (EX)) ? (void)0 ' |
892 | ': __assert(#EX, __FILE__, __LINE__))'; | |
03112946 | 893 | }; |
894 | ||
895 | ||
6274714d | 896 | /* |
897 | * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. | |
898 | */ | |
899 | fix = { | |
85eaefbc | 900 | hackname = alpha_getopt; |
901 | files = "stdio.h"; | |
902 | files = "stdlib.h"; | |
903 | select = 'getopt\(int, char \*\[\], *char \*\)'; | |
472aa368 | 904 | c_fix = format; |
905 | c_fix_arg = "getopt(int, char *const[], const char *)"; | |
85eaefbc | 906 | test_text = 'extern int getopt(int, char *[], char *);'; |
6274714d | 907 | }; |
908 | ||
909 | ||
2013a847 | 910 | /* |
911 | * Fix missing semicolon on Alpha OSF/4 in <net/if.h> | |
912 | */ | |
913 | fix = { | |
914 | hackname = alpha_if_semicolon; | |
915 | files = net/if.h; | |
916 | select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*"; | |
917 | c_fix = format; | |
918 | c_fix_arg = "struct sockaddr vmif_paddr;\t/*"; | |
919 | test_text = ' struct sockaddr vmif_paddr /* protocol address */'; | |
920 | }; | |
921 | ||
922 | ||
2706a435 | 923 | /* |
a22ae698 | 924 | * Remove erroneous parentheses in sym.h on Alpha OSF/1. |
6274714d | 925 | */ |
926 | fix = { | |
85eaefbc | 927 | hackname = alpha_parens; |
928 | files = sym.h; | |
929 | select = '#ifndef\(__mips64\)'; | |
472aa368 | 930 | c_fix = format; |
931 | c_fix_arg = "#ifndef __mips64"; | |
85eaefbc | 932 | test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif"; |
6274714d | 933 | }; |
934 | ||
935 | ||
936 | /* | |
937 | * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 | |
7509ad3c | 938 | * And OpenBSD. |
6274714d | 939 | */ |
940 | fix = { | |
941 | hackname = alpha_sbrk; | |
942 | files = unistd.h; | |
943 | select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; | |
472aa368 | 944 | c_fix = format; |
945 | c_fix_arg = "void *sbrk("; | |
85eaefbc | 946 | test_text = "extern char* sbrk(ptrdiff_t increment);"; |
6274714d | 947 | }; |
948 | ||
949 | ||
6274714d | 950 | /* |
951 | * For C++, avoid any typedef or macro definition of bool, | |
952 | * and use the built in type instead. | |
a22ae698 | 953 | * HP/UX 10.20 also has it in curses_colr/curses.h. |
6274714d | 954 | */ |
955 | fix = { | |
2c59c6d3 | 956 | hackname = avoid_bool_define; |
957 | files = curses.h; | |
958 | files = curses_colr/curses.h; | |
959 | files = term.h; | |
960 | files = tinfo.h; | |
ada96dc2 | 961 | |
2c59c6d3 | 962 | select = "#[ \t]*define[ \t]+bool[ \t]"; |
162e05b3 | 963 | bypass = "__cplusplus"; |
6274714d | 964 | |
2c59c6d3 | 965 | c_fix = format; |
966 | c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
967 | c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*"; | |
97703fb0 | 968 | |
2c59c6d3 | 969 | test_text = "# define bool\t char \n"; |
970 | }; | |
02f88d3c | 971 | |
2b5c5c15 | 972 | |
2c59c6d3 | 973 | fix = { |
974 | hackname = avoid_bool_type; | |
975 | files = curses.h; | |
976 | files = curses_colr/curses.h; | |
977 | files = term.h; | |
978 | files = tinfo.h; | |
02f88d3c | 979 | |
2c59c6d3 | 980 | select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;"; |
162e05b3 | 981 | bypass = "__cplusplus"; |
02f88d3c | 982 | |
2c59c6d3 | 983 | c_fix = format; |
984 | c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
02f88d3c | 985 | |
faebe86a | 986 | test_text = "typedef unsigned int\tbool \t; /* bool\n type */"; |
6274714d | 987 | }; |
988 | ||
2b5c5c15 | 989 | |
7ab30fe8 | 990 | /* |
991 | * For C++, avoid any typedef definition of wchar_t, | |
992 | * and use the built in type instead. | |
5f6aa019 | 993 | * Don't do this for headers that are smart enough to do the right |
994 | * thing (recent [n]curses.h and Xlib.h). | |
995 | * Don't do it for <linux/nls.h> which is never used from C++ anyway, | |
996 | * and will be broken by the edit. | |
7ab30fe8 | 997 | */ |
998 | ||
999 | fix = { | |
1000 | hackname = avoid_wchar_t_type; | |
1001 | ||
1002 | select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;"; | |
37e6e5d2 | 1003 | bypass = "__cplusplus"; |
5f6aa019 | 1004 | bypass = "_LINUX_NLS_H"; |
1005 | bypass = "XFree86: xc/lib/X11/Xlib\\.h"; | |
7ab30fe8 | 1006 | |
1007 | c_fix = format; | |
1008 | c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
7ab30fe8 | 1009 | |
faebe86a | 1010 | test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */"; |
7ab30fe8 | 1011 | }; |
6274714d | 1012 | |
2b5c5c15 | 1013 | |
cfe5be71 | 1014 | /* |
1015 | * Fix `typedef struct term;' on hppa1.1-hp-hpux9. | |
1016 | */ | |
1017 | fix = { | |
2c59c6d3 | 1018 | hackname = bad_struct_term; |
1019 | files = curses.h; | |
1020 | select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;"; | |
1021 | c_fix = format; | |
1022 | c_fix_arg = "struct term;"; | |
1023 | ||
cfe5be71 | 1024 | test_text = 'typedef struct term;'; |
1025 | }; | |
1026 | ||
1027 | ||
1028 | /* | |
1029 | * Fix one other error in this file: | |
1030 | * a mismatched quote not inside a C comment. | |
1031 | */ | |
1032 | fix = { | |
2c59c6d3 | 1033 | hackname = badquote; |
1034 | files = sundev/vuid_event.h; | |
1035 | select = "doesn't"; | |
1036 | c_fix = format; | |
1037 | c_fix_arg = "does not"; | |
1038 | ||
cfe5be71 | 1039 | test_text = "/* doesn't have matched single quotes */"; |
1040 | }; | |
1041 | ||
1042 | ||
6274714d | 1043 | /* |
1044 | * check for broken assert.h that needs stdio.h | |
1045 | */ | |
1046 | fix = { | |
e6650807 | 1047 | hackname = broken_assert_stdio; |
1048 | files = assert.h; | |
1049 | select = stderr; | |
1050 | bypass = "include.*stdio\\.h"; | |
1051 | c_fix = wrap; | |
1052 | c_fix_arg = "#include <stdio.h>\n"; | |
85eaefbc | 1053 | test_text = "extern FILE* stderr;"; |
6274714d | 1054 | }; |
1055 | ||
1056 | ||
1057 | /* | |
1058 | * check for broken assert.h that needs stdlib.h | |
1059 | */ | |
1060 | fix = { | |
e6650807 | 1061 | hackname = broken_assert_stdlib; |
1062 | files = assert.h; | |
1063 | select = 'exit *\(|abort *\('; | |
1064 | bypass = "include.*stdlib\\.h"; | |
1065 | c_fix = wrap; | |
1066 | c_fix_arg = "#ifdef __cplusplus\n" | |
1067 | "#include <stdlib.h>\n" | |
1068 | "#endif\n"; | |
85eaefbc | 1069 | test_text = "extern void exit ( int );"; |
6274714d | 1070 | }; |
1071 | ||
1072 | ||
58d8674b | 1073 | /* |
1074 | * Remove `extern double cabs' declarations from math.h. | |
ea15b501 | 1075 | * This conflicts with C99. Discovered on AIX. |
e0ec1c44 | 1076 | * Darwin hides its broken cabs in architecture-specific subdirs. |
58d8674b | 1077 | */ |
1078 | fix = { | |
1079 | hackname = broken_cabs; | |
e9afa104 | 1080 | files = math.h, "architecture/*/math.h"; |
19754f2b | 1081 | select = "^extern[ \t]+double[ \t]+cabs"; |
2c59c6d3 | 1082 | |
462510b2 | 1083 | sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//"; |
1084 | sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//"; | |
2c59c6d3 | 1085 | |
85eaefbc | 1086 | test_text = "#ifdef __STDC__\n" |
a67943d7 | 1087 | "extern double cabs(struct dbl_hypot);\n" |
85eaefbc | 1088 | "#else\n" |
a67943d7 | 1089 | "extern double cabs();\n" |
420a8094 | 1090 | "#endif\n" |
5641963c | 1091 | "extern double cabs ( _Complex z );"; |
58d8674b | 1092 | }; |
1093 | ||
b32d497c | 1094 | |
baee91be | 1095 | /* |
1096 | * Fixup Darwin's broken check for __builtin_nanf. | |
b32d497c | 1097 | */ |
baee91be | 1098 | fix = { |
1099 | hackname = broken_nan; | |
e9afa104 | 1100 | /* |
1101 | * It is tempting to omit the first "files" entry. Do not. | |
1102 | * The testing machinery will take the first "files" entry as the name | |
1103 | * of a test file to play with. It would be a nuisance to have a directory | |
1104 | * with the name "*". | |
1105 | */ | |
baee91be | 1106 | files = "architecture/ppc/math.h"; |
e9afa104 | 1107 | files = "architecture/*/math.h"; |
baee91be | 1108 | select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; |
1109 | bypass = "powl"; | |
1110 | c_fix = format; | |
1111 | c_fix_arg = "#if 1"; | |
1112 | test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; | |
b32d497c | 1113 | }; |
baee91be | 1114 | |
58d8674b | 1115 | |
d45e22c2 | 1116 | /* |
1117 | * Various systems derived from BSD4.4 contain a macro definition | |
1118 | * for vfscanf that interacts badly with requirements of builtin-attrs.def. | |
1119 | * Known to be fixed in FreeBSD 5 system headers. | |
1120 | */ | |
1121 | fix = { | |
1122 | hackname = bsd_stdio_attrs_conflict; | |
b8780944 | 1123 | mach = "*-*-*bsd*"; |
1124 | mach = "*-*-*darwin*"; | |
d45e22c2 | 1125 | files = stdio.h; |
1126 | select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$"; | |
1127 | c_fix = format; | |
1128 | c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n" | |
1129 | '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n" | |
1130 | 'int vfscanf(FILE *, const char *, __builtin_va_list) ' | |
1131 | '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");'; | |
1132 | test_text = '#define vfscanf __svfscanf'; | |
1133 | }; | |
1134 | ||
e660f239 | 1135 | /* |
1136 | * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests | |
0eb9814c | 1137 | * that it conforms to ISO/IEC 14882:2011. It currently does |
e660f239 | 1138 | * not support the [[noreturn]] procedure attribute. |
1139 | * When it does, this hack should be removed. | |
1140 | * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776 | |
1141 | */ | |
1142 | fix = { | |
1143 | hackname = cdef_cplusplus; | |
1144 | files = sys/cdefs.h; | |
1145 | select = '\[\[noreturn\]\]'; | |
1146 | c_fix = format; | |
1147 | c_fix_arg = '__attribute__((__noreturn__))'; | |
1148 | test_text = "#define _Noreturn [[noreturn]]"; | |
1149 | }; | |
d45e22c2 | 1150 | |
cfe5be71 | 1151 | /* |
1152 | * Fix various macros used to define ioctl numbers. | |
1153 | * The traditional syntax was: | |
1154 | * | |
1155 | * #define _CTRL(n, x) (('n'<<8)+x) | |
1156 | * #define TCTRLCFOO _CTRL(T, 1) | |
1157 | * | |
1158 | * but this does not work with the C standard, which disallows macro | |
1159 | * expansion inside strings. We have to rewrite it thus: | |
1160 | * | |
1161 | * #define _CTRL(n, x) ((n<<8)+x) | |
1162 | * #define TCTRLCFOO _CTRL('T', 1) | |
1163 | * | |
1164 | * The select expressions match too much, but the c_fix code is cautious. | |
1165 | * | |
1166 | * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ... | |
1167 | */ | |
1168 | fix = { | |
1169 | hackname = ctrl_quotes_def; | |
edb5e81d | 1170 | select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]"; |
cfe5be71 | 1171 | c_fix = char_macro_def; |
1172 | c_fix_arg = "CTRL"; | |
4c6f2eda | 1173 | |
1174 | /* | |
1175 | * This is two tests in order to ensure that the "CTRL(c)" can | |
1176 | * be selected in isolation from the multi-arg format | |
1177 | */ | |
1178 | test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"; | |
1179 | test_text = "#define _CTRL(c) ('c'&037)"; | |
cfe5be71 | 1180 | }; |
1181 | ||
1182 | fix = { | |
1183 | hackname = ctrl_quotes_use; | |
1184 | select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']"; | |
1185 | c_fix = char_macro_use; | |
1186 | c_fix_arg = "CTRL"; | |
57adc3a9 | 1187 | test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)"; |
cfe5be71 | 1188 | }; |
1189 | ||
1190 | ||
1191 | /* | |
1192 | * sys/mman.h on HP/UX is not C++ ready, | |
1193 | * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. | |
1194 | * | |
2c59c6d3 | 1195 | * rpc/types.h on OSF1/2.0 is not C++ ready, |
1196 | * even though NO_IMPLICIT_EXTERN_C is defined for the alpha. | |
1197 | * | |
1198 | * The problem is the declaration of malloc. | |
cfe5be71 | 1199 | */ |
1200 | fix = { | |
1201 | hackname = cxx_unready; | |
1202 | files = sys/mman.h; | |
1203 | files = rpc/types.h; | |
1204 | select = '[^#]+malloc.*;'; /* Catch any form of declaration | |
1205 | not within a macro. */ | |
1206 | bypass = '"C"|__BEGIN_DECLS'; | |
1207 | ||
1208 | c_fix = wrap; | |
1209 | c_fix_arg = "#ifdef __cplusplus\n" | |
1210 | "extern \"C\" {\n" | |
1211 | "#endif\n"; | |
1212 | c_fix_arg = "#ifdef __cplusplus\n" | |
1213 | "}\n" | |
1214 | "#endif\n"; | |
1215 | test_text = "extern void* malloc( size_t );"; | |
1216 | }; | |
1217 | ||
1218 | ||
1908d6ac | 1219 | /* |
1220 | * On darwin8 and earlier, mach-o/swap.h isn't properly guarded | |
1221 | * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded. | |
1222 | */ | |
1223 | fix = { | |
1224 | hackname = darwin_externc; | |
1225 | mach = "*-*-darwin*"; | |
1226 | files = mach-o/swap.h; | |
1227 | files = mach/mach_time.h; | |
1228 | files = mach/mach_traps.h; | |
1229 | files = mach/message.h; | |
1230 | files = mach/mig.h; | |
1231 | files = mach/semaphore.h; | |
1232 | bypass = "extern \"C\""; | |
1233 | bypass = "__BEGIN_DECLS"; | |
1234 | c_fix = wrap; | |
1235 | c_fix_arg = "#ifdef __cplusplus\n" | |
1236 | "extern \"C\" {\n" | |
1237 | "#endif\n"; | |
1238 | c_fix_arg = "#ifdef __cplusplus\n" | |
1239 | "}\n" | |
1240 | "#endif\n"; | |
1241 | test_text = "extern void swap_fat_header();\n"; | |
1242 | }; | |
1243 | ||
1244 | ||
975d636c | 1245 | /* |
1246 | * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of | |
1247 | * bad __GNUC__ tests. | |
1248 | */ | |
1249 | ||
1250 | fix = { | |
1251 | hackname = darwin_gcc4_breakage; | |
1252 | mach = "*-*-darwin*"; | |
1253 | files = AvailabilityMacros.h; | |
1254 | select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)"; | |
1255 | c_fix = format; | |
1256 | c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))"; | |
1257 | test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && " | |
1258 | "(__GNUC_MINOR__ >= 1)\n"; | |
1259 | }; | |
1260 | ||
1261 | ||
e056fca3 | 1262 | /* |
1263 | * __private_extern__ doesn't exist in FSF GCC. Even if it did, | |
1264 | * why would you ever put it in a system header file? | |
1265 | */ | |
3067e435 | 1266 | fix = { |
1267 | hackname = darwin_private_extern; | |
1268 | mach = "*-*-darwin*"; | |
1269 | files = mach-o/dyld.h; | |
1270 | select = "__private_extern__ [a-z_]+ _dyld_"; | |
1271 | c_fix = format; | |
1272 | c_fix_arg = "extern"; | |
1273 | c_fix_arg = "__private_extern__"; | |
1274 | test_text = "__private_extern__ int _dyld_func_lookup(\n" | |
1275 | "const char *dyld_func_name,\n" | |
1276 | "unsigned long *address);\n"; | |
1277 | }; | |
1278 | ||
1279 | ||
0e1f6b4f | 1280 | /* |
1281 | * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to | |
1282 | * unsigned constants. | |
1283 | */ | |
1284 | fix = { | |
1285 | hackname = darwin_stdint_1; | |
1286 | mach = "*-*-darwin*"; | |
e2fb821c | 1287 | files = stdint-darwin.h, stdint.h; |
0e1f6b4f | 1288 | c_fix = format; |
1289 | c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv"; | |
1290 | select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n" | |
1291 | "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)"; | |
1292 | test_text = "#define UINT8_C(v) (v ## U)\n" | |
1293 | "#define UINT16_C(v) (v ## U)"; | |
1294 | }; | |
1295 | ||
1296 | ||
1297 | /* | |
1298 | * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX | |
1299 | * with wrong types. | |
1300 | */ | |
1301 | fix = { | |
1302 | hackname = darwin_stdint_2; | |
1303 | mach = "*-*-darwin*"; | |
e2fb821c | 1304 | files = stdint-darwin.h, stdint.h; |
0e1f6b4f | 1305 | c_fix = format; |
1306 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1307 | "#define INTPTR_MAX 9223372036854775807L\n" | |
1308 | "#define INTPTR_MIN (-INTPTR_MAX-1)\n" | |
1309 | "#else\n" | |
1310 | "#define INTPTR_MAX 2147483647L\n" | |
1311 | "#define INTPTR_MIN (-INTPTR_MAX-1)\n" | |
1312 | "#endif"; | |
1313 | select = "#if __WORDSIZE == 64\n" | |
1314 | "#define INTPTR_MIN[ \t]+INT64_MIN\n" | |
1315 | "#define INTPTR_MAX[ \t]+INT64_MAX\n" | |
1316 | "#else\n" | |
1317 | "#define INTPTR_MIN[ \t]+INT32_MIN\n" | |
1318 | "#define INTPTR_MAX[ \t]+INT32_MAX\n" | |
1319 | "#endif"; | |
1320 | test_text = "#if __WORDSIZE == 64\n" | |
1321 | "#define INTPTR_MIN INT64_MIN\n" | |
1322 | "#define INTPTR_MAX INT64_MAX\n" | |
1323 | "#else\n" | |
1324 | "#define INTPTR_MIN INT32_MIN\n" | |
1325 | "#define INTPTR_MAX INT32_MAX\n" | |
1326 | "#endif"; | |
1327 | }; | |
1328 | ||
1329 | ||
1330 | /* | |
1331 | * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type. | |
1332 | */ | |
1333 | fix = { | |
1334 | hackname = darwin_stdint_3; | |
1335 | mach = "*-*-darwin*"; | |
e2fb821c | 1336 | files = stdint-darwin.h, stdint.h; |
0e1f6b4f | 1337 | c_fix = format; |
1338 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1339 | "#define UINTPTR_MAX 18446744073709551615UL\n" | |
1340 | "#else\n" | |
1341 | "#define UINTPTR_MAX 4294967295UL\n" | |
1342 | "#endif"; | |
1343 | select = "#if __WORDSIZE == 64\n" | |
1344 | "#define UINTPTR_MAX[ \t]+UINT64_MAX\n" | |
1345 | "#else\n" | |
1346 | "#define UINTPTR_MAX[ \t]+UINT32_MAX\n" | |
1347 | "#endif"; | |
1348 | test_text = "#if __WORDSIZE == 64\n" | |
1349 | "#define UINTPTR_MAX UINT64_MAX\n" | |
1350 | "#else\n" | |
1351 | "#define UINTPTR_MAX UINT32_MAX\n" | |
1352 | "#endif"; | |
1353 | }; | |
1354 | ||
1355 | ||
1356 | /* | |
1357 | * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type. | |
1358 | */ | |
1359 | fix = { | |
1360 | hackname = darwin_stdint_4; | |
1361 | mach = "*-*-darwin*"; | |
e2fb821c | 1362 | files = stdint-darwin.h, stdint.h; |
0e1f6b4f | 1363 | c_fix = format; |
1364 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1365 | "#define SIZE_MAX 18446744073709551615UL\n" | |
1366 | "#else\n" | |
1367 | "#define SIZE_MAX 4294967295UL\n" | |
1368 | "#endif"; | |
1369 | select = "#if __WORDSIZE == 64\n" | |
1370 | "#define SIZE_MAX[ \t]+UINT64_MAX\n" | |
1371 | "#else\n" | |
1372 | "#define SIZE_MAX[ \t]+UINT32_MAX\n" | |
1373 | "#endif"; | |
1374 | test_text = "#if __WORDSIZE == 64\n" | |
1375 | "#define SIZE_MAX UINT64_MAX\n" | |
1376 | "#else\n" | |
1377 | "#define SIZE_MAX UINT32_MAX\n" | |
1378 | "#endif"; | |
1379 | }; | |
1380 | ||
1381 | ||
c73f01c5 | 1382 | /* |
1383 | * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX} | |
1384 | * with a wrong type. | |
1385 | */ | |
1386 | fix = { | |
1387 | hackname = darwin_stdint_5; | |
1388 | mach = "*-*-darwin*"; | |
e2fb821c | 1389 | files = stdint-darwin.h, stdint.h; |
c73f01c5 | 1390 | c_fix = format; |
1391 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1392 | "#define INTMAX_MIN (-9223372036854775807L - 1)\n" | |
1393 | "#define INTMAX_MAX 9223372036854775807L\n" | |
1394 | "#define UINTMAX_MAX 18446744073709551615UL\n" | |
1395 | "#else\n" | |
1396 | "#define INTMAX_MIN (-9223372036854775807LL - 1)\n" | |
1397 | "#define INTMAX_MAX 9223372036854775807LL\n" | |
1398 | "#define UINTMAX_MAX 18446744073709551615ULL\n" | |
1399 | "#endif"; | |
1400 | select = "#define INTMAX_MIN[ \t]+INT64_MIN\n" | |
1401 | "#define INTMAX_MAX[ \t]+INT64_MAX\n" | |
1402 | "\n" | |
1403 | "#define UINTMAX_MAX[ \t]+UINT64_MAX"; | |
1404 | test_text = "#define INTMAX_MIN INT64_MIN\n" | |
1405 | "#define INTMAX_MAX INT64_MAX\n" | |
1406 | "\n" | |
1407 | "#define UINTMAX_MAX UINT64_MAX"; | |
1408 | }; | |
1409 | ||
1410 | ||
1411 | /* | |
1412 | * Darwin headers have a stdint.h that defines {U,}INTMAX_C | |
1413 | * with a wrong type. | |
1414 | */ | |
1415 | fix = { | |
1416 | hackname = darwin_stdint_6; | |
1417 | mach = "*-*-darwin*"; | |
e2fb821c | 1418 | files = stdint-darwin.h, stdint.h; |
c73f01c5 | 1419 | c_fix = format; |
1420 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1421 | "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n" | |
1422 | "#define PTRDIFF_MAX 9223372036854775807L\n" | |
1423 | "#else\n" | |
1424 | "#define PTRDIFF_MIN (-2147483647 - 1)\n" | |
1425 | "#define PTRDIFF_MAX 2147483647\n" | |
1426 | "#endif"; | |
1427 | select = "#if __WORDSIZE == 64\n" | |
1428 | "#define PTRDIFF_MIN[ \t]+INT64_MIN\n" | |
1429 | "#define PTRDIFF_MAX[ \t]+INT64_MAX\n" | |
1430 | "#else\n" | |
1431 | "#define PTRDIFF_MIN[ \t]+INT32_MIN\n" | |
1432 | "#define PTRDIFF_MAX[ \t]+INT32_MAX\n" | |
1433 | "#endif"; | |
1434 | test_text = "#if __WORDSIZE == 64\n" | |
1435 | "#define PTRDIFF_MIN INT64_MIN\n" | |
1436 | "#define PTRDIFF_MAX INT64_MAX\n" | |
1437 | "#else\n" | |
1438 | "#define PTRDIFF_MIN INT32_MIN\n" | |
1439 | "#define PTRDIFF_MAX INT32_MAX\n" | |
1440 | "#endif"; | |
1441 | }; | |
1442 | ||
1443 | ||
1444 | /* | |
1445 | * Darwin headers have a stdint.h that defines {U,}INTMAX_C | |
1446 | * with a wrong type. | |
1447 | */ | |
1448 | fix = { | |
1449 | hackname = darwin_stdint_7; | |
1450 | mach = "*-*-darwin*"; | |
e2fb821c | 1451 | files = stdint-darwin.h, stdint.h; |
c73f01c5 | 1452 | c_fix = format; |
1453 | c_fix_arg = "#if __WORDSIZE == 64\n" | |
1454 | "#define INTMAX_C(v) (v ## L)\n" | |
1455 | "#define UINTMAX_C(v) (v ## UL)\n" | |
1456 | "#else\n" | |
1457 | "#define INTMAX_C(v) (v ## LL)\n" | |
1458 | "#define UINTMAX_C(v) (v ## ULL)\n" | |
1459 | "#endif"; | |
1460 | select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n" | |
1461 | "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)"; | |
1462 | test_text = "#define INTMAX_C(v) (v ## LL)\n" | |
1463 | "#define UINTMAX_C(v) (v ## ULL)"; | |
1464 | }; | |
1465 | ||
1466 | ||
a22ae698 | 1467 | /* |
1468 | * Fix <c_asm.h> on Digital UNIX V4.0: | |
1469 | * It contains a prototype for a DEC C internal asm() function, | |
1470 | * clashing with gcc's asm keyword. So protect this with __DECC. | |
1471 | */ | |
1472 | fix = { | |
1473 | hackname = dec_intern_asm; | |
1474 | files = c_asm.h; | |
cc49a6e2 | 1475 | sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; |
1476 | sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" | |
a22ae698 | 1477 | "#endif\n"; |
85eaefbc | 1478 | test_text = |
1479 | "float fasm {\n" | |
1480 | " ... asm stuff ...\n" | |
1481 | "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/"; | |
a22ae698 | 1482 | }; |
1483 | ||
1484 | ||
8c74272d | 1485 | /* |
1486 | * Fix typo in <wchar.h> on DJGPP 2.03. | |
1487 | */ | |
1488 | fix = { | |
1489 | hackname = djgpp_wchar_h; | |
1490 | file = wchar.h; | |
1491 | select = "__DJ_wint_t"; | |
1492 | bypass = "sys/djtypes.h"; | |
1493 | c_fix = format; | |
1494 | c_fix_arg = "%0\n#include <sys/djtypes.h>"; | |
1495 | c_fix_arg = "#include <stddef.h>"; | |
08eb4bb9 | 1496 | test_text = "#include <stddef.h>\n" |
1497 | "extern __DJ_wint_t x;\n"; | |
8c74272d | 1498 | }; |
1499 | ||
2b5c5c15 | 1500 | |
6274714d | 1501 | /* |
1502 | * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. | |
1503 | */ | |
1504 | fix = { | |
2c59c6d3 | 1505 | hackname = ecd_cursor; |
1506 | files = "sunwindow/win_lock.h"; | |
1507 | files = "sunwindow/win_cursor.h"; | |
1508 | select = 'ecd\.cursor'; | |
1509 | c_fix = format; | |
1510 | c_fix_arg = 'ecd_cursor'; | |
1511 | ||
85eaefbc | 1512 | test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */"; |
6274714d | 1513 | }; |
1514 | ||
e26c299a | 1515 | |
65a92405 | 1516 | /* |
1517 | * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume | |
1518 | * neither the existence of GCC 3 nor its exact feature set yet break | |
1519 | * (by design?) when __GNUC__ is set beyond 2. | |
1520 | */ | |
1521 | fix = { | |
1522 | hackname = freebsd_gcc3_breakage; | |
b8780944 | 1523 | mach = "*-*-freebsd*"; |
65a92405 | 1524 | files = sys/cdefs.h; |
1525 | select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'; | |
1526 | bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)'; | |
1527 | c_fix = format; | |
1528 | c_fix_arg = '%0 || __GNUC__ >= 3'; | |
1529 | test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7'; | |
1530 | }; | |
1531 | ||
1532 | ||
f9ac0b87 | 1533 | /* |
1534 | * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume | |
1535 | * neither the existence of GCC 4 nor its exact feature set yet break | |
1536 | * (by design?) when __GNUC__ is set beyond 3. | |
1537 | */ | |
1538 | fix = { | |
1539 | hackname = freebsd_gcc4_breakage; | |
b8780944 | 1540 | mach = "*-*-freebsd*"; |
f9ac0b87 | 1541 | files = sys/cdefs.h; |
1542 | select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$'; | |
1543 | c_fix = format; | |
1544 | c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3'; | |
1545 | test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3'; | |
1546 | }; | |
1547 | ||
1548 | ||
efb8e7bf | 1549 | /* |
1550 | * Some versions of glibc don't expect the C99 inline semantics. | |
1551 | */ | |
1552 | fix = { | |
1553 | hackname = glibc_c99_inline_1; | |
e9afa104 | 1554 | files = features.h, '*/features.h'; |
efb8e7bf | 1555 | select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$"; |
1556 | c_fix = format; | |
7e4d47f0 | 1557 | c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)"; |
efb8e7bf | 1558 | test_text = <<-EOT |
3452f1c7 | 1559 | #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ |
1560 | && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ | |
1561 | # define __USE_EXTERN_INLINES 1 | |
1562 | #endif | |
1563 | EOT; | |
efb8e7bf | 1564 | }; |
1565 | ||
1566 | ||
661832db | 1567 | /* |
1568 | * Similar, but a version that didn't have __NO_INLINE__ | |
1569 | */ | |
1570 | fix = { | |
1571 | hackname = glibc_c99_inline_1a; | |
1572 | files = features.h, '*/features.h'; | |
1573 | select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n" | |
1574 | "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)"; | |
1575 | c_fix = format; | |
1576 | c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2"; | |
1577 | test_text = <<-EOT | |
3452f1c7 | 1578 | #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ |
1579 | # define __USE_EXTERN_INLINES 1 | |
1580 | #endif | |
1581 | EOT; | |
661832db | 1582 | }; |
1583 | ||
1584 | ||
efb8e7bf | 1585 | /* |
1586 | * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately | |
1587 | * there are many glibc headers which do not respect __USE_EXTERN_INLINES. | |
1588 | * The remaining glibc_c99_inline_* fixes deal with some of those headers. | |
1589 | */ | |
1590 | fix = { | |
1591 | hackname = glibc_c99_inline_2; | |
e9afa104 | 1592 | files = sys/stat.h, '*/sys/stat.h'; |
efb8e7bf | 1593 | select = "extern __inline__ int"; |
b795c8d1 | 1594 | sed = "s/extern int \\(stat\\)/" |
7e4d47f0 | 1595 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" |
560b9c9b | 1596 | "__inline__ int \\1/"; |
b795c8d1 | 1597 | sed = "s/extern int \\([lf]stat\\)/" |
1598 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1599 | "__inline__ int \\1/"; | |
1600 | sed = "s/extern int \\(mknod\\)/" | |
1601 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1602 | "__inline__ int \\1/"; | |
1603 | sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/" | |
1604 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1605 | "__inline__ int __REDIRECT\\1 (\\2/"; | |
1606 | sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/" | |
7e4d47f0 | 1607 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" |
560b9c9b | 1608 | "__inline__ int __REDIRECT\\1 (\\2/"; |
1609 | sed = "s/^extern __inline__ int/" | |
7e4d47f0 | 1610 | "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" |
560b9c9b | 1611 | "__inline__ int/"; |
efb8e7bf | 1612 | test_text = <<-EOT |
560b9c9b | 1613 | extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); |
1614 | extern __inline__ int | |
1615 | __NTH (fstat64 (int __fd, struct stat64 *__statbuf)) | |
1616 | {} | |
1617 | EOT; | |
efb8e7bf | 1618 | }; |
1619 | ||
1620 | ||
1621 | fix = { | |
1622 | hackname = glibc_c99_inline_3; | |
e9afa104 | 1623 | files = bits/string2.h, '*/bits/string2.h'; |
7e4d47f0 | 1624 | select = "extern __inline"; |
661832db | 1625 | bypass = "__extern_inline|__GNU_STDC_INLINE__"; |
efb8e7bf | 1626 | c_fix = format; |
7e4d47f0 | 1627 | c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)"; |
efb8e7bf | 1628 | c_fix_arg = "^# ifdef __cplusplus$"; |
1629 | test_text = <<-EOT | |
560b9c9b | 1630 | # ifdef __cplusplus |
1631 | # define __STRING_INLINE inline | |
1632 | # else | |
1633 | # define __STRING_INLINE extern __inline | |
1634 | # endif | |
1635 | EOT; | |
efb8e7bf | 1636 | }; |
1637 | ||
1638 | ||
1639 | fix = { | |
1640 | hackname = glibc_c99_inline_4; | |
661832db | 1641 | files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h'; |
1642 | bypass = "__extern_inline|__gnu_inline__"; | |
1643 | select = "(^| )extern __inline"; | |
efb8e7bf | 1644 | c_fix = format; |
661832db | 1645 | c_fix_arg = "%0 __attribute__ ((__gnu_inline__))"; |
efb8e7bf | 1646 | test_text = <<-EOT |
560b9c9b | 1647 | __extension__ extern __inline unsigned int |
b67f0bc6 | 1648 | extern __inline unsigned int |
560b9c9b | 1649 | EOT; |
efb8e7bf | 1650 | }; |
1651 | ||
1652 | ||
a1b11617 | 1653 | /* glibc-2.3.5 defines pthread mutex initializers incorrectly, |
1654 | * so we replace them with versions that correspond to the | |
1655 | * definition. | |
1656 | */ | |
1657 | fix = { | |
1658 | hackname = glibc_mutex_init; | |
1659 | files = pthread.h; | |
1660 | select = '\{ *\{ *0, *\} *\}'; | |
b795c8d1 | 1661 | sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n" |
b32d497c | 1662 | "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}"; |
1663 | sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" | |
b795c8d1 | 1664 | "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/"; |
1665 | sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" | |
1666 | "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/"; | |
1667 | sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" | |
1668 | "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/"; | |
1669 | sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" | |
1670 | "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/"; | |
1671 | sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" | |
1672 | "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/"; | |
b32d497c | 1673 | sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" |
b795c8d1 | 1674 | "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/"; |
1675 | sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/" | |
a1b11617 | 1676 | "N;s/^[ \t]*#[ \t]*" |
b795c8d1 | 1677 | "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n" |
1678 | "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n" | |
1679 | "# \\1\\\n" | |
1680 | " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n" | |
1681 | "# else\\\n" | |
1682 | "# \\1\\\n" | |
1683 | " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n" | |
a1b11617 | 1684 | "# endif/"; |
b32d497c | 1685 | sed = "s/{ \\(0, 0, 0, 0, 0, 0, " |
1686 | "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/"; | |
b795c8d1 | 1687 | sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/" |
a1b11617 | 1688 | "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/"; |
1689 | ||
d0f017a1 | 1690 | test_text = <<- _EOText_ |
3452f1c7 | 1691 | #define PTHREAD_MUTEX_INITIALIZER \\ |
1692 | { { 0, } } | |
1693 | #ifdef __USE_GNU | |
1694 | # if __WORDSIZE == 64 | |
1695 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ | |
1696 | { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } | |
1697 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ | |
1698 | { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } | |
1699 | # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ | |
1700 | { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } | |
1701 | # else | |
1702 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ | |
1703 | { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } | |
1704 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ | |
1705 | { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } | |
1706 | # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ | |
1707 | { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } | |
1708 | # endif | |
1709 | #endif | |
1710 | # define PTHREAD_RWLOCK_INITIALIZER \\ | |
1711 | { { 0, } } | |
1712 | # ifdef __USE_GNU | |
1713 | # if __WORDSIZE == 64 | |
1714 | # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ | |
1715 | { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ | |
1716 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } | |
1717 | # else | |
1718 | # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ | |
1719 | { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } | |
1720 | # endif | |
1721 | # endif | |
1722 | #define PTHREAD_COND_INITIALIZER { { 0, } } | |
1723 | _EOText_; | |
a1b11617 | 1724 | }; |
1725 | ||
1726 | ||
57a812b7 | 1727 | /* glibc versions before 2.5 have a version of stdint.h that defines |
1728 | UINT8_C and UINT16_C to produce unsigned constants, as do uClibc | |
1729 | versions with stdint.h based on those glibc versions. */ | |
1730 | fix = { | |
1731 | hackname = glibc_stdint; | |
1732 | files = stdint.h; | |
1733 | select = "GNU C Library"; | |
1734 | c_fix = format; | |
1735 | c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc"; | |
1736 | c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U"; | |
1737 | test_text = "/* This file is part of the GNU C Library. */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U"; | |
1738 | }; | |
1739 | ||
1740 | ||
5aee6890 | 1741 | /* Some versions of glibc have a version of bits/string2.h that |
1742 | produces "value computed is not used" warnings from strncpy; fix | |
1743 | this definition by using __builtin_strncpy instead as in newer | |
1744 | versions. */ | |
1745 | fix = { | |
1746 | hackname = glibc_strncpy; | |
1747 | files = bits/string2.h; | |
1748 | bypass = "__builtin_strncpy"; | |
1749 | c_fix = format; | |
1750 | c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)"; | |
1751 | c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*"; | |
1752 | test_text = <<-EOT | |
1753 | # define strncpy(dest, src, n) \ | |
1754 | (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\ | |
1755 | ? (strlen (src) + 1 >= ((size_t) (n)) \\ | |
1756 | ? (char *) memcpy (dest, src, n) \\ | |
1757 | : strncpy (dest, src, n)) \\ | |
1758 | : strncpy (dest, src, n))) | |
1759 | EOT; | |
1760 | ||
1761 | }; | |
1762 | ||
a75b1c71 | 1763 | /* glibc's tgmath.h relies on an expression that is not an integer |
1764 | constant expression being treated as it was by GCC 4.4 and | |
1765 | earlier. */ | |
1766 | fix = { | |
1767 | hackname = glibc_tgmath; | |
1768 | files = tgmath.h; | |
1769 | select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)'; | |
5873f213 | 1770 | bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type"; |
a75b1c71 | 1771 | c_fix = format; |
1772 | c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))"; | |
1773 | test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))"; | |
1774 | }; | |
1775 | ||
3072d11f | 1776 | /* |
aa6d4aed | 1777 | * Fix these files to use the types we think they should for |
1778 | * ptrdiff_t, size_t, and wchar_t. | |
1779 | * | |
1780 | * This defines the types in terms of macros predefined by our 'cpp'. | |
1781 | * This is supposedly necessary for glibc's handling of these types. | |
1782 | * It's probably not necessary for anyone else, but it doesn't hurt. | |
3072d11f | 1783 | */ |
1784 | fix = { | |
1785 | hackname = gnu_types; | |
1786 | files = "sys/types.h"; | |
1787 | files = "stdlib.h"; | |
1788 | files = "sys/stdtypes.h"; | |
1789 | files = "stddef.h"; | |
1790 | files = "memory.h"; | |
1791 | files = "unistd.h"; | |
1792 | bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T'; | |
1793 | select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;"; | |
1794 | c_fix = gnu_type; | |
09a31484 | 1795 | /* The Solaris 10 headers already define these types correctly. */ |
1796 | mach = '*-*-solaris2.1[0-9]*'; | |
1797 | not_machine = true; | |
3072d11f | 1798 | |
1799 | test_text = "typedef long int ptrdiff_t; /* long int */\n" | |
1800 | "typedef uint_t size_t; /* uint_t */\n" | |
1801 | "typedef ushort_t wchar_t; /* ushort_t */"; | |
1802 | }; | |
1803 | ||
1804 | ||
6274714d | 1805 | /* |
6c013a2f | 1806 | * Fix HP & Sony's use of "../machine/xxx.h" |
1807 | * to refer to: <machine/xxx.h> | |
6274714d | 1808 | */ |
1809 | fix = { | |
2c59c6d3 | 1810 | hackname = hp_inline; |
1811 | files = sys/spinlock.h; | |
1812 | files = machine/machparam.h; | |
1813 | select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/'; | |
1814 | ||
1815 | c_fix = format; | |
1816 | c_fix_arg = "%1<machine/%2.h>"; | |
1817 | ||
1818 | c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/' | |
1819 | '([a-z]+)\.h"'; | |
1820 | ||
1821 | test_text = ' # include "../machine/mumble.h"'; | |
6274714d | 1822 | }; |
1823 | ||
1824 | ||
1825 | /* | |
1826 | * Check for (...) in C++ code in HP/UX sys/file.h. | |
1827 | */ | |
1828 | fix = { | |
85eaefbc | 1829 | hackname = hp_sysfile; |
1830 | files = sys/file.h; | |
1831 | select = "HPUX_SOURCE"; | |
2c59c6d3 | 1832 | |
1833 | c_fix = format; | |
1834 | c_fix_arg = "(struct file *, ...)"; | |
1835 | c_fix_arg = '\(\.\.\.\)'; | |
1836 | ||
49b4955b | 1837 | test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */"; |
6274714d | 1838 | }; |
1839 | ||
1840 | ||
b32d497c | 1841 | /* |
1842 | * Un-Hide a series of five FP defines from post-1999 compliance GCC: | |
1843 | * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN | |
1844 | */ | |
1845 | fix = { | |
1846 | hackname = hppa_hpux_fp_macros; | |
1847 | mach = "hppa*-hp-hpux11*"; | |
1848 | files = math.h; | |
1849 | select = "#[ \t]*define[ \t]*FP_NORMAL.*\n" | |
1850 | "#[ \t]*define[ \t]*FP_ZERO.*\n" | |
1851 | "#[ \t]*define[ \t]*FP_INFINITE.*\n" | |
1852 | "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n" | |
1853 | "#[ \t]*define[ \t]*FP_NAN.*\n"; | |
1854 | c_fix = format; | |
1855 | c_fix_arg = <<- _EOFix_ | |
1856 | #endif /* _INCLUDE_HPUX_SOURCE */ | |
1857 | ||
1858 | #if defined(_INCLUDE_HPUX_SOURCE) || \ | |
1859 | (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) | |
1860 | %0#endif | |
1861 | ||
1862 | #ifdef _INCLUDE_HPUX_SOURCE | |
1863 | ||
1864 | _EOFix_; | |
1865 | ||
1866 | test_text = | |
1867 | "# define FP_NORMAL 0\n" | |
1868 | "# define FP_ZERO 1\n" | |
1869 | "# define FP_INFINITE 2\n" | |
1870 | "# define FP_SUBNORMAL 3\n" | |
1871 | "# define FP_NAN 4\n"; | |
1872 | }; | |
1873 | ||
1874 | ||
7b900f1a | 1875 | /* |
c6738ff5 | 1876 | * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11 |
7b900f1a | 1877 | * math.h to prevent clash with define in c_std/bits/std_cmath.h. |
1878 | */ | |
1879 | fix = { | |
1880 | hackname = hpux10_cpp_pow_inline; | |
e61fb0ae | 1881 | files = fixinc-test-limits.h, math.h; |
7b900f1a | 1882 | select = <<- END_POW_INLINE |
1883 | ^# +ifdef +__cplusplus | |
30f9dc1c | 1884 | +\} |
1885 | +inline +double +pow\(double +__d,int +__expon\) +\{ | |
7b900f1a | 1886 | [ ]+return +pow\(__d,\(double\)__expon\); |
30f9dc1c | 1887 | +\} |
1888 | +extern +"C" +\{ | |
7b900f1a | 1889 | #else |
1890 | # +endif | |
1891 | END_POW_INLINE; | |
1892 | ||
1893 | c_fix = format; | |
1894 | c_fix_arg = ""; | |
1895 | ||
1896 | test_text = | |
1897 | "# ifdef __cplusplus\n" | |
1898 | " }\n" | |
1899 | " inline double pow(double __d,int __expon) {\n" | |
1900 | "\t return pow(__d,(double)__expon);\n" | |
1901 | " }\n" | |
1902 | ' extern "C"' " {\n" | |
1903 | "#else\n" | |
1904 | "# endif"; | |
1905 | }; | |
1906 | ||
c6738ff5 | 1907 | fix = { |
1908 | hackname = hpux11_cpp_pow_inline; | |
1909 | files = math.h; | |
30f9dc1c | 1910 | select = " +inline double pow\\(double d,int expon\\) \\{\n" |
c6738ff5 | 1911 | " +return pow\\(d, \\(double\\)expon\\);\n" |
30f9dc1c | 1912 | " +\\}\n"; |
c6738ff5 | 1913 | c_fix = format; |
1914 | c_fix_arg = ""; | |
1915 | ||
1916 | test_text = | |
1917 | " inline double pow(double d,int expon) {\n" | |
1918 | " return pow(d, (double)expon);\n" | |
1919 | " }\n"; | |
1920 | }; | |
7b900f1a | 1921 | |
c0854bd5 | 1922 | |
e22a6b11 | 1923 | /* |
1924 | * Fix hpux 10.X missing ctype declarations 1 | |
1925 | */ | |
1926 | fix = { | |
1927 | hackname = hpux10_ctype_declarations1; | |
1928 | files = ctype.h; | |
1929 | select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)"; | |
1930 | bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\("; | |
1931 | c_fix = format; | |
1932 | c_fix_arg = "#ifdef _PROTOTYPES\n" | |
1933 | "extern int __tolower(int);\n" | |
1934 | "extern int __toupper(int);\n" | |
1935 | "#else /* NOT _PROTOTYPES */\n" | |
1936 | "extern int __tolower();\n" | |
1937 | "extern int __toupper();\n" | |
1938 | "#endif /* _PROTOTYPES */\n\n" | |
1939 | "%0\n"; | |
1940 | ||
1941 | test_text = "# define _toupper(__c) __toupper(__c)\n"; | |
1942 | }; | |
1943 | ||
1944 | ||
1945 | /* | |
1946 | * Fix hpux 10.X missing ctype declarations 2 | |
1947 | */ | |
1948 | fix = { | |
1949 | hackname = hpux10_ctype_declarations2; | |
1950 | files = ctype.h; | |
1951 | select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)"; | |
1952 | bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\("; | |
1953 | c_fix = format; | |
1954 | c_fix_arg = "%0\n\n" | |
1955 | "#ifdef _PROTOTYPES\n" | |
1956 | " extern int _isalnum(int);\n" | |
1957 | " extern int _isalpha(int);\n" | |
1958 | " extern int _iscntrl(int);\n" | |
1959 | " extern int _isdigit(int);\n" | |
1960 | " extern int _isgraph(int);\n" | |
1961 | " extern int _islower(int);\n" | |
1962 | " extern int _isprint(int);\n" | |
1963 | " extern int _ispunct(int);\n" | |
1964 | " extern int _isspace(int);\n" | |
1965 | " extern int _isupper(int);\n" | |
1966 | " extern int _isxdigit(int);\n" | |
1967 | "# else /* not _PROTOTYPES */\n" | |
1968 | " extern int _isalnum();\n" | |
1969 | " extern int _isalpha();\n" | |
1970 | " extern int _iscntrl();\n" | |
1971 | " extern int _isdigit();\n" | |
1972 | " extern int _isgraph();\n" | |
1973 | " extern int _islower();\n" | |
1974 | " extern int _isprint();\n" | |
1975 | " extern int _ispunct();\n" | |
1976 | " extern int _isspace();\n" | |
1977 | " extern int _isupper();\n" | |
1978 | " extern int _isxdigit();\n" | |
1979 | "#endif /* _PROTOTYPES */\n"; | |
1980 | ||
1981 | test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n" | |
1982 | " extern unsigned int *__SB_masks;\n"; | |
1983 | }; | |
1984 | ||
1985 | ||
37935110 | 1986 | /* |
1987 | * Fix hpux 10.X missing stdio declarations | |
1988 | */ | |
1989 | fix = { | |
1990 | hackname = hpux10_stdio_declarations; | |
1991 | files = stdio.h; | |
1992 | select = "^#[ \t]*define _iob[ \t]*__iob"; | |
1993 | bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\("; | |
1994 | c_fix = format; | |
1995 | c_fix_arg = "%0\n\n" | |
1996 | "# if defined(__STDC__) || defined(__cplusplus)\n" | |
1997 | " extern int snprintf(char *, size_t, const char *, ...);\n" | |
1998 | " extern int vsnprintf(char *, size_t, const char *, __va_list);\n" | |
1999 | "# else /* not __STDC__) || __cplusplus */\n" | |
2000 | " extern int snprintf();\n" | |
2001 | " extern int vsnprintf();\n" | |
2002 | "# endif /* __STDC__) || __cplusplus */\n"; | |
2003 | ||
2004 | test_text = "# define _iob __iob\n"; | |
2005 | }; | |
2006 | ||
2007 | ||
281c8073 | 2008 | /* |
2009 | * Make sure hpux defines abs in header. | |
2010 | */ | |
2011 | fix = { | |
2012 | hackname = hpux11_abs; | |
dd60921e | 2013 | mach = "*-hp-hpux11*"; |
281c8073 | 2014 | files = stdlib.h; |
2015 | select = "ifndef _MATH_INCLUDED"; | |
2016 | c_fix = format; | |
2017 | c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)"; | |
281c8073 | 2018 | test_text = "#ifndef _MATH_INCLUDED"; |
2019 | }; | |
2020 | ||
2021 | ||
05fc9903 | 2022 | /* |
2023 | * Keep HP-UX 11 from stomping on C++ math namespace | |
2024 | * with defines for fabsf. | |
2025 | */ | |
2026 | fix = { | |
2027 | hackname = hpux11_fabsf; | |
2028 | files = math.h; | |
2029 | select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*"; | |
2030 | bypass = "__cplusplus"; | |
2031 | ||
2032 | c_fix = format; | |
2033 | c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
2034 | ||
2035 | test_text = | |
2036 | "#ifdef _PA_RISC\n" | |
2037 | "# define fabsf(x) ((float)fabs((double)(float)(x)))\n" | |
2038 | "#endif"; | |
2039 | }; | |
2040 | ||
2041 | ||
b32d497c | 2042 | /* |
2043 | * Fix C99 constant in __POINTER_SET define. | |
2044 | */ | |
2045 | fix = { | |
2046 | hackname = hpux11_pthread_const; | |
2047 | mach = "*-hp-hpux11.[0-3]*"; | |
2048 | files = sys/pthread.h; | |
2049 | select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)"; | |
2050 | ||
2051 | c_fix = format; | |
2052 | c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)"; | |
2053 | test_text = "#define __POINTER_SET\t\t((void *) 1LL)"; | |
2054 | }; | |
2055 | ||
2056 | ||
c0854bd5 | 2057 | /* |
2058 | * Prevent HP-UX 11 from defining __size_t and preventing size_t from | |
2059 | * being defined by having it define _hpux_size_t instead. | |
2060 | */ | |
2061 | fix = { | |
2062 | hackname = hpux11_size_t; | |
3ff85771 | 2063 | mach = "*-hp-hpux11*"; |
2064 | select = "__size_t"; | |
c0854bd5 | 2065 | |
2066 | c_fix = format; | |
2067 | c_fix_arg = "_hpux_size_t"; | |
c0854bd5 | 2068 | |
2069 | test_text = | |
2070 | "#define __size_t size_t\n" | |
2071 | " extern int getpwuid_r( char *, __size_t, struct passwd **);\n"; | |
2072 | }; | |
2073 | ||
2074 | ||
75dc2242 | 2075 | /* |
2076 | * Fix hpux 11.00 broken snprintf declaration | |
2077 | * (third argument is char *, needs to be const char * to prevent | |
2078 | * spurious warnings with -Wwrite-strings or in C++). | |
2079 | */ | |
2080 | fix = { | |
2081 | hackname = hpux11_snprintf; | |
2082 | files = stdio.h; | |
2083 | select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)' | |
2084 | ' *(char *\*, *\.\.\.\);)'; | |
2085 | c_fix = format; | |
2086 | c_fix_arg = '%1 const %3'; | |
2087 | ||
2088 | test_text = "extern int snprintf(char *, size_t, char *, ...);\n" | |
2089 | "extern int snprintf(char *, __size_t, char *, ...);\n" | |
2090 | "extern int snprintf(char *, _hpux_size_t, char *, ...);"; | |
2091 | }; | |
2092 | ||
6b5183e9 | 2093 | /* |
e22a6b11 | 2094 | * Fix hpux 11.00 broken vsnprintf declaration |
6b5183e9 | 2095 | */ |
2096 | fix = { | |
e22a6b11 | 2097 | hackname = hpux11_vsnprintf; |
2098 | files = stdio.h; | |
2099 | select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, ' | |
2100 | 'const char \*,) __va__list\);'; | |
6b5183e9 | 2101 | c_fix = format; |
e22a6b11 | 2102 | c_fix_arg = "%1 __va_list);"; |
6b5183e9 | 2103 | |
e22a6b11 | 2104 | test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,' |
2105 | ' __va__list);'; | |
6b5183e9 | 2106 | }; |
2107 | ||
2108 | ||
2109 | /* | |
e22a6b11 | 2110 | * get rid of bogus inline definitions in HP-UX 8.0 |
6b5183e9 | 2111 | */ |
2112 | fix = { | |
e22a6b11 | 2113 | hackname = hpux8_bogus_inlines; |
2114 | files = math.h; | |
2115 | select = inline; | |
69c13546 | 2116 | bypass = "__GNUG__"; |
e22a6b11 | 2117 | sed = "s@inline int abs(int [a-z][a-z]*) {.*}" |
2118 | "@extern \"C\" int abs(int);@"; | |
2119 | sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@"; | |
2120 | sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@"; | |
2121 | sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; | |
2122 | test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n" | |
2123 | "inline double sqr(double v) { return v**0.5; }"; | |
6b5183e9 | 2124 | }; |
2125 | ||
2126 | ||
2127 | /* | |
2128 | * Fix hpux broken ctype macros | |
2129 | */ | |
2130 | fix = { | |
2131 | hackname = hpux_ctype_macros; | |
2132 | files = ctype.h; | |
2133 | select = '((: |\()__SB_masks \? )' | |
2134 | '(__SB_masks\[__(alnum|c)\] & _IS)'; | |
2135 | c_fix = format; | |
2136 | c_fix_arg = "%1(int)%3"; | |
2137 | ||
2138 | test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n" | |
2139 | "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n"; | |
2140 | }; | |
2141 | ||
2142 | ||
1589683c | 2143 | /* |
2144 | * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc. | |
2145 | */ | |
2146 | fix = { | |
2147 | hackname = hpux_htonl; | |
2148 | files = netinet/in.h; | |
bf31bf36 | 2149 | select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n" |
1589683c | 2150 | "(/\\*\n" |
2151 | " \\* Macros for number representation conversion\\.\n" | |
2152 | " \\*/\n" | |
2153 | "#ifndef ntohl)"; | |
2154 | c_fix = format; | |
2155 | c_fix_arg = "#if 1\n%1"; | |
2156 | ||
2157 | test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n" | |
2158 | "/*\n" | |
2159 | " * Macros for number representation conversion.\n" | |
2160 | " */\n" | |
2161 | "#ifndef ntohl\n" | |
2162 | "#define ntohl(x) (x)\n" | |
2163 | "#define ntohs(x) (x)\n" | |
2164 | "#define htonl(x) (x)\n" | |
2165 | "#define htons(x) (x)\n" | |
2166 | "#endif\n" | |
2167 | "#endif /* ! _XOPEN_SOURCE_EXTENDED */"; | |
2168 | }; | |
2169 | ||
2170 | ||
97803087 | 2171 | /* |
e22a6b11 | 2172 | * HP-UX long_double |
97803087 | 2173 | */ |
2174 | fix = { | |
e22a6b11 | 2175 | hackname = hpux_long_double; |
8869ef73 | 2176 | mach = "*-*-hpux10*"; |
2177 | mach = "*-*-hpux11.[012]*"; | |
e22a6b11 | 2178 | files = stdlib.h; |
2179 | select = "extern[ \t]long_double[ \t]strtold"; | |
2180 | bypass = "long_double_t"; | |
2181 | sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D"; | |
2182 | sed = "s/long_double/long double/g"; | |
97803087 | 2183 | |
e22a6b11 | 2184 | test_text = "# ifndef _LONG_DOUBLE\n" |
2185 | "# define _LONG_DOUBLE\n" | |
2186 | " typedef struct {\n" | |
2187 | " unsigned int word1, word2, word3, word4;\n" | |
2188 | " } long_double;\n" | |
2189 | "# endif /* _LONG_DOUBLE */\n" | |
2190 | "extern long_double strtold(const char *, char **);\n"; | |
2c59c6d3 | 2191 | }; |
2192 | ||
8869ef73 | 2193 | /* |
2194 | * We cannot use the above rule on 11.31 because it removes the strtold | |
2195 | * definition. ia64 is OK with no hack, PA needs some help. | |
2196 | */ | |
2197 | fix = { | |
2198 | hackname = hpux_long_double_2; | |
2199 | mach = "hppa*-*-hpux11.3*"; | |
2200 | files = stdlib.h; | |
2201 | select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)"; | |
2202 | c_fix = format; | |
2203 | c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)"; | |
2204 | ||
2205 | test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n"; | |
2206 | }; | |
2c59c6d3 | 2207 | |
6274714d | 2208 | /* |
3072d11f | 2209 | * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl |
6274714d | 2210 | */ |
2211 | fix = { | |
3072d11f | 2212 | hackname = hpux_systime; |
2213 | files = sys/time.h; | |
2214 | select = "^extern struct sigevent;"; | |
6274714d | 2215 | |
3072d11f | 2216 | c_fix = format; |
2217 | c_fix_arg = "struct sigevent;"; | |
2218 | ||
2219 | test_text = 'extern struct sigevent;'; | |
2220 | }; | |
2221 | ||
2222 | ||
5dabcff3 | 2223 | /* |
2224 | * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown | |
2225 | * type and mpinfou is only defined when _KERNEL is set. | |
2226 | */ | |
2227 | fix = { | |
2228 | hackname = hpux_spu_info; | |
2229 | mach = "*-hp-hpux*"; | |
82e0c24e | 2230 | /* |
2231 | * It is tempting to omit the first "files" entry. Do not. | |
2232 | * The testing machinery will take the first "files" entry as the name | |
2233 | * of a test file to play with. It would be a nuisance to have a directory | |
2234 | * with the name "*". | |
2235 | */ | |
2236 | files = "ia64/sys/getppdp.h"; | |
0789791e | 2237 | files = "*/sys/getppdp.h"; |
5dabcff3 | 2238 | select = "^.*extern.*spu_info.*"; |
2239 | ||
2240 | c_fix = format; | |
2241 | c_fix_arg = "#ifdef _KERNEL\n%0\n#endif"; | |
2242 | ||
2243 | test_text = "extern union mpinfou spu_info[];"; | |
2244 | }; | |
2245 | ||
1cb3e86d | 2246 | fix = { |
2247 | hackname = hpux11_extern_sendfile; | |
2248 | mach = "*-hp-hpux11.[12]*"; | |
2249 | files = sys/socket.h; | |
2250 | select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n"; | |
2251 | c_fix = format; | |
2252 | c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; | |
2253 | test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; | |
2254 | }; | |
2255 | ||
2256 | fix = { | |
2257 | hackname = hpux11_extern_sendpath; | |
2258 | mach = "*-hp-hpux11.[12]*"; | |
2259 | files = sys/socket.h; | |
2260 | select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n"; | |
2261 | c_fix = format; | |
2262 | c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; | |
2263 | test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; | |
2264 | }; | |
2265 | ||
898b6c0f | 2266 | fix = { |
2267 | hackname = hpux_extern_errno; | |
2268 | mach = "*-hp-hpux10.*"; | |
2269 | mach = "*-hp-hpux11.[0-2]*"; | |
2270 | files = errno.h; | |
2271 | select = "^[ \t]*extern int errno;$"; | |
2272 | c_fix = format; | |
2273 | c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif"; | |
2274 | test_text = " extern int errno;\n"; | |
2275 | }; | |
2276 | ||
3c6ef6a2 | 2277 | |
3dd59d44 | 2278 | /* |
2279 | * Add missing braces to pthread initializer defines. | |
2280 | */ | |
2281 | fix = { | |
2282 | hackname = hpux_pthread_initializers; | |
2283 | mach = "*-hp-hpux11.[0-3]*"; | |
2284 | files = sys/pthread.h; | |
2285 | sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\" | |
2286 | "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@"; | |
2287 | sed = "s@^[ \t]*1,[ \t]*\\\\" | |
2288 | "@\t{ 1, 0 }@"; | |
2289 | sed = "/^[ \t]*0$/d"; | |
2290 | sed = "s@__PTHREAD_MUTEX_VALID, 0" | |
2291 | "@{ __PTHREAD_MUTEX_VALID, 0 }@"; | |
2292 | sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\" | |
2293 | "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@"; | |
2294 | sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" | |
2295 | "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; | |
2296 | sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" | |
2297 | "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; | |
2298 | sed = "s@^[ \t]*0, 0[ \t]*\\\\" | |
2299 | "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@"; | |
2300 | sed = "s@__PTHREAD_COND_VALID, 0" | |
2301 | "@{ __PTHREAD_COND_VALID, 0 }@"; | |
2302 | sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\" | |
2303 | "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@"; | |
2304 | sed = "s@__PTHREAD_RWLOCK_VALID, 0" | |
2305 | "@{ __PTHREAD_RWLOCK_VALID, 0 }@"; | |
2306 | sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\" | |
2307 | "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@"; | |
2308 | sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\" | |
2309 | "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@"; | |
2310 | test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n" | |
2311 | "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n" | |
2312 | "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n" | |
2313 | "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n" | |
2314 | "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n" | |
2315 | "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n" | |
2316 | "\t0, 0\t\t\t\t\t\t\t\t\\\\\n" | |
2317 | "}\n"; | |
2318 | }; | |
5dabcff3 | 2319 | |
8869ef73 | 2320 | fix = { |
2321 | hackname = hpux_c99_intptr; | |
2322 | mach = "*-hp-hpux11.3*"; | |
e2fb821c | 2323 | files = stdint-hpux11.h, stdint.h; |
8869ef73 | 2324 | sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@"; |
2325 | sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; | |
2326 | sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@"; | |
2327 | sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@"; | |
2328 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@"; | |
2329 | sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@"; | |
2330 | test_text = "#define PTRDIFF_MAX INT32_MAX\n" | |
2331 | "#define PTRDIFF_MIN INT32_MIN\n" | |
2332 | "#define INTPTR_MAX INT32_MAX\n" | |
2333 | "#define INTPTR_MIN INT32_MIN\n" | |
2334 | "#define UINTPTR_MAX UINT32_MAX\n" | |
2335 | "#define SIZE_MAX UINT32_MAX\n"; | |
2336 | }; | |
2337 | ||
2338 | /* | |
2339 | * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31. | |
2340 | */ | |
2341 | ||
2342 | fix = { | |
2343 | hackname = hpux_c99_inttypes; | |
2344 | mach = "*-hp-hpux11.[23]*"; | |
2345 | files = inttypes.h; | |
e2fb821c | 2346 | files = stdint-hpux11.h, stdint.h; |
8869ef73 | 2347 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@"; |
2348 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@"; | |
2349 | sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@"; | |
2350 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@"; | |
2351 | test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n" | |
2352 | "#define UINT16_C(__c) __CONCAT_U__(__c)\n" | |
2353 | "#define INT32_C(__c) __CONCAT__(__c,l)\n" | |
2354 | "#define UINT32_C(__c) __CONCAT__(__c,ul)\n"; | |
2355 | }; | |
2356 | ||
2357 | fix = { | |
2358 | hackname = hpux_c99_inttypes2; | |
2359 | mach = "*-hp-hpux11.2*"; | |
e2fb821c | 2360 | files = stdint-hpux11.h, stdint.h; |
8869ef73 | 2361 | sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@"; |
2362 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@"; | |
2363 | sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@"; | |
2364 | sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@"; | |
2365 | test_text = "# define INT8_C(__c) ((signed char)(__c))\n" | |
2366 | "# define UINT8_C(__c) ((unsigned char)(__c))\n" | |
2367 | "# define INT16_C(__c) ((short)(__c))\n" | |
2368 | "# define UINT16_C(__c) ((unsigned short)(__c))\n"; | |
2369 | }; | |
2370 | ||
2371 | fix = { | |
3c36388d | 2372 | hackname = hpux_stdint_least_fast; |
8869ef73 | 2373 | mach = "*-hp-hpux11.2*"; |
e2fb821c | 2374 | files = stdint-hpux11.h, stdint.h; |
3c36388d | 2375 | select = |
2376 | "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX"; | |
8869ef73 | 2377 | c_fix = format; |
1684f52d | 2378 | c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__"; |
2379 | test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n" | |
2380 | "# define UINT_LEAST64_MAX ULLONG_MAX\n"; | |
3c36388d | 2381 | _EOFix_; |
8869ef73 | 2382 | }; |
2383 | ||
2384 | fix = { | |
2385 | hackname = hpux_inttype_int8_t; | |
50847300 | 2386 | mach = "*-hp-hpux1[01].*"; |
8869ef73 | 2387 | files = sys/_inttypes.h; |
3c36388d | 2388 | select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*"; |
8869ef73 | 2389 | c_fix = format; |
3c36388d | 2390 | c_fix_arg = "typedef signed char int%18_t;"; |
2391 | test_text = "typedef char int_least8_t;\n" | |
2392 | "typedef char int8_t;\n"; | |
8869ef73 | 2393 | }; |
2394 | ||
9436a006 | 2395 | fix = { |
2396 | hackname = hpux_imaginary_i; | |
2397 | mach = "ia64-hp-hpux11.*"; | |
2398 | files = complex.h; | |
2399 | select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*"; | |
2400 | c_fix = format; | |
c939099a | 2401 | c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; |
2402 | test_text = "#define _Complex_I (0.f+_Imaginary_I)\n"; | |
9436a006 | 2403 | }; |
2404 | ||
96eced21 | 2405 | /* |
2406 | * Fix glibc definition of HUGE_VAL in terms of hex floating point constant | |
2407 | */ | |
2408 | fix = { | |
2409 | hackname = huge_val_hex; | |
2410 | files = bits/huge_val.h; | |
2411 | select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*"; | |
2412 | bypass = "__builtin_huge_val"; | |
2413 | ||
2414 | c_fix = format; | |
2415 | c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n"; | |
2416 | ||
2417 | test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)"; | |
2418 | }; | |
2419 | ||
2420 | ||
2421 | /* | |
2422 | * Fix glibc definition of HUGE_VALF in terms of hex floating point constant | |
2423 | */ | |
2424 | fix = { | |
2425 | hackname = huge_valf_hex; | |
2426 | files = bits/huge_val.h; | |
2427 | select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*"; | |
2428 | bypass = "__builtin_huge_valf"; | |
2429 | ||
2430 | c_fix = format; | |
2431 | c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n"; | |
2432 | ||
2433 | test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)"; | |
2434 | }; | |
2435 | ||
2436 | ||
2437 | /* | |
2438 | * Fix glibc definition of HUGE_VALL in terms of hex floating point constant | |
2439 | */ | |
2440 | fix = { | |
2441 | hackname = huge_vall_hex; | |
2442 | files = bits/huge_val.h; | |
2443 | select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*"; | |
2444 | bypass = "__builtin_huge_vall"; | |
2445 | ||
2446 | c_fix = format; | |
2447 | c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n"; | |
2448 | ||
2449 | test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)"; | |
2450 | }; | |
2451 | ||
2452 | ||
3072d11f | 2453 | /* |
2454 | * Fix return type of abort and free | |
2455 | */ | |
2456 | fix = { | |
2457 | hackname = int_abort_free_and_exit; | |
2458 | files = stdlib.h; | |
2459 | select = "int[ \t]+(abort|free|exit)[ \t]*\\("; | |
69c13546 | 2460 | bypass = "_CLASSIC_ANSI_TYPES"; |
85eaefbc | 2461 | |
cfe5be71 | 2462 | c_fix = format; |
3072d11f | 2463 | c_fix_arg = "void\t%1("; |
2464 | ||
2465 | test_text = "extern int abort(int);\n" | |
2466 | "extern int free(void*);\n" | |
2467 | "extern int exit(void*);"; | |
6274714d | 2468 | }; |
2469 | ||
2c59c6d3 | 2470 | |
6274714d | 2471 | /* |
472aa368 | 2472 | * Fix various macros used to define ioctl numbers. |
2473 | * The traditional syntax was: | |
2474 | * | |
2475 | * #define _IO(n, x) (('n'<<8)+x) | |
2476 | * #define TIOCFOO _IO(T, 1) | |
2477 | * | |
ada96dc2 | 2478 | * but this does not work with the C standard, which disallows macro |
2479 | * expansion inside strings. We have to rewrite it thus: | |
472aa368 | 2480 | * |
2481 | * #define _IO(n, x) ((n<<8)+x) | |
2482 | * #define TIOCFOO _IO('T', 1) | |
2483 | * | |
ada96dc2 | 2484 | * The select expressions match too much, but the c_fix code is cautious. |
2485 | * | |
2486 | * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes. | |
6274714d | 2487 | */ |
2488 | fix = { | |
472aa368 | 2489 | hackname = io_quotes_def; |
edb5e81d | 2490 | select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]"; |
472aa368 | 2491 | c_fix = char_macro_def; |
c940c2ae | 2492 | c_fix_arg = "IO"; |
2c59c6d3 | 2493 | test_text = |
2494 | "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n" | |
2495 | "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n" | |
2496 | "#define _IO(x,y) ('x'<<8|y)"; | |
4c6f2eda | 2497 | test_text = |
2498 | "#define XX_IO(x) ('x'<<8|256)"; | |
6274714d | 2499 | }; |
2500 | ||
ada96dc2 | 2501 | fix = { |
472aa368 | 2502 | hackname = io_quotes_use; |
2503 | select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*" | |
2504 | "\\( *[^,']"; | |
2505 | c_fix = char_macro_use; | |
c940c2ae | 2506 | c_fix_arg = "IO"; |
57adc3a9 | 2507 | test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n" |
2508 | "#define TIOCFOO \\\\\n" | |
2509 | "BSD43__IOWR(T, 1) /* Some are multi-line */"; | |
ada96dc2 | 2510 | }; |
6274714d | 2511 | |
2512 | ||
6274714d | 2513 | /* |
cfe5be71 | 2514 | * Check for missing ';' in struct |
6274714d | 2515 | */ |
2516 | fix = { | |
cfe5be71 | 2517 | hackname = ip_missing_semi; |
2518 | files = netinet/ip.h; | |
2519 | select = "}$"; | |
2520 | sed = "/^struct/,/^};/s/}$/};/"; | |
2521 | test_text= | |
2522 | "struct mumble {\n" | |
2523 | " union {\n" | |
2524 | " int x;\n" | |
2525 | " }\n" | |
2526 | "}; /* mumbled struct */\n"; | |
6274714d | 2527 | }; |
2528 | ||
01719fc0 | 2529 | |
3072d11f | 2530 | /* |
2531 | * Non-traditional "const" declaration in Irix's limits.h. | |
2532 | */ | |
2533 | fix = { | |
2534 | hackname = irix_limits_const; | |
2535 | files = fixinc-test-limits.h, limits.h; | |
2536 | select = "^extern const "; | |
2537 | c_fix = format; | |
2538 | c_fix_arg = "extern __const "; | |
2539 | test_text = "extern const char limit; /* test limits */"; | |
2540 | }; | |
2541 | ||
2542 | ||
bfce477d | 2543 | /* |
5641963c | 2544 | * IRIX 5.x's stdio.h declares some functions that take a va_list as |
3072d11f | 2545 | * taking char *. However, GCC uses void * for va_list, so |
06730757 | 2546 | * calling vfprintf with a va_list fails in C++. */ |
2547 | fix = { | |
2548 | hackname = irix_stdio_va_list; | |
2549 | files = stdio.h; | |
2550 | ||
38f81ce5 | 2551 | select = '/\* va_list \*/ char \*'; |
06730757 | 2552 | c_fix = format; |
38f81ce5 | 2553 | c_fix_arg = "__gnuc_va_list"; |
08eb4bb9 | 2554 | test_text = |
2555 | "extern int printf( const char *, /* va_list */ char * );"; | |
06730757 | 2556 | }; |
2557 | ||
2558 | ||
6274714d | 2559 | /* |
2560 | * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 | |
2561 | * use / * * / to concatenate tokens. | |
2562 | */ | |
2563 | fix = { | |
2564 | hackname = kandr_concat; | |
2565 | files = "sparc/asm_linkage.h"; | |
e9afa104 | 2566 | files = "sun*/asm_linkage.h"; |
6274714d | 2567 | files = "arm/as_support.h"; |
2568 | files = "arm/mc_type.h"; | |
2569 | files = "arm/xcb.h"; | |
2570 | files = "dev/chardefmac.h"; | |
2571 | files = "dev/ps_irq.h"; | |
2572 | files = "dev/screen.h"; | |
2573 | files = "dev/scsi.h"; | |
2574 | files = "sys/tty.h"; | |
2575 | files = "Xm.acorn/XmP.h"; | |
2576 | files = bsd43/bsd43_.h; | |
2577 | select = '/\*\*/'; | |
cfe5be71 | 2578 | c_fix = format; |
2579 | c_fix_arg = '##'; | |
2580 | test_text = "#define __CONCAT__(a,b) a/**/b"; | |
6274714d | 2581 | }; |
2582 | ||
2583 | ||
d92db5b6 | 2584 | /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines |
2585 | * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time | |
2586 | * constant on recent versions of g++. | |
2587 | */ | |
2588 | fix = { | |
2589 | hackname = linux_ia64_ucontext; | |
2590 | files = "sys/ucontext.h"; | |
2591 | mach = "ia64-*-linux*"; | |
2592 | select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)' | |
2593 | '->sc_gr\[0\]\) - \(char \*\) 0\)'; | |
2594 | c_fix = format; | |
2595 | c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)"; | |
2596 | test_text = "# define _SC_GR0_OFFSET\t\\\\\n" | |
2597 | "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n"; | |
2598 | }; | |
2599 | ||
2600 | ||
435ea059 | 2601 | /* |
2602 | * Remove header file warning from sys/time.h. Autoconf's | |
2603 | * AC_HEADER_TIME recommends to include both sys/time.h and time.h | |
2604 | * which causes warning on LynxOS. Remove the warning. | |
6274714d | 2605 | */ |
2606 | fix = { | |
435ea059 | 2607 | hackname = lynxos_no_warning_in_sys_time_h; |
2608 | files = sys/time.h; | |
2609 | select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>"; | |
cfe5be71 | 2610 | c_fix = format; |
2611 | c_fix_arg = ""; | |
435ea059 | 2612 | test_text = "#warning Using <time.h> instead of <sys/time.h>"; |
6274714d | 2613 | }; |
2614 | ||
2615 | ||
435ea059 | 2616 | /* |
2617 | * Add missing declaration for putenv. | |
6274714d | 2618 | */ |
2619 | fix = { | |
435ea059 | 2620 | hackname = lynxos_missing_putenv; |
2621 | mach = '*-*-lynxos*'; | |
2622 | files = stdlib.h; | |
2623 | bypass = 'putenv[ \t]*\\('; | |
2624 | select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; | |
cfe5be71 | 2625 | c_fix = format; |
435ea059 | 2626 | c_fix_arg = "%0\n" |
2627 | "extern int putenv _AP((char *));"; | |
2628 | c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; | |
2629 | test_text = "extern char *getenv _AP((const char *));"; | |
6274714d | 2630 | }; |
2631 | ||
2632 | ||
d4c4b01d | 2633 | /* |
2634 | * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_. | |
3072d11f | 2635 | * |
0efa04d0 | 2636 | * On NetBSD, machine is a symbolic link to an architecture specific |
2637 | * directory name, so we can't match a specific file name here. | |
d4c4b01d | 2638 | */ |
2639 | fix = { | |
2640 | hackname = machine_ansi_h_va_list; | |
a83746ef | 2641 | select = "define[ \t]+_BSD_VA_LIST_[ \t]"; |
d4c4b01d | 2642 | bypass = '__builtin_va_list'; |
2643 | ||
a83746ef | 2644 | c_fix = format; |
2645 | c_fix_arg = "%1__builtin_va_list"; | |
2646 | c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*"; | |
2647 | ||
2648 | test_text = " # define _BSD_VA_LIST_\tchar**"; | |
d4c4b01d | 2649 | }; |
2650 | ||
2651 | ||
6274714d | 2652 | /* |
a22ae698 | 2653 | * Fix non-ansi machine name defines |
6274714d | 2654 | */ |
2655 | fix = { | |
472aa368 | 2656 | hackname = machine_name; |
2657 | c_test = machine_name; | |
2658 | c_fix = machine_name; | |
038a3e7a | 2659 | |
a83746ef | 2660 | test_text = "/* MACH_DIFF: */\n" |
038a3e7a | 2661 | "#if defined( i386 ) || defined( sparc ) || defined( vax )" |
a83746ef | 2662 | "\n/* no uniform test, so be careful :-) */"; |
6274714d | 2663 | }; |
2664 | ||
2665 | ||
2666 | /* | |
25670b67 | 2667 | * Some math.h files define struct exception (it's in the System V |
cee0cd59 | 2668 | * Interface Definition), which conflicts with the class exception defined |
2669 | * in the C++ file std/stdexcept.h. We redefine it to __math_exception. | |
2670 | * This is not a great fix, but I haven't been able to think of anything | |
f2397fc4 | 2671 | * better. |
6274714d | 2672 | */ |
2673 | fix = { | |
e6650807 | 2674 | hackname = math_exception; |
2675 | files = math.h; | |
2676 | select = "struct exception"; | |
cee0cd59 | 2677 | /* |
264a5d11 | 2678 | * This should be bypassed on __cplusplus, but some supposedly C++ |
cee0cd59 | 2679 | * aware headers, such as Solaris 8 and 9, don't wrap their struct |
2680 | * exception either. So currently we bypass only for glibc, based on a | |
2681 | * comment in the fixed glibc header. Ick. | |
2682 | */ | |
b32d497c | 2683 | bypass = 'We have a problem when using C\+\+|for C\+\+, ' |
2684 | '_[a-z0-9A-Z_]+_exception; for C, exception'; | |
e6650807 | 2685 | c_fix = wrap; |
2686 | ||
2687 | c_fix_arg = "#ifdef __cplusplus\n" | |
2688 | "#define exception __math_exception\n" | |
2689 | "#endif\n"; | |
2690 | ||
2691 | c_fix_arg = "#ifdef __cplusplus\n" | |
2692 | "#undef exception\n" | |
2693 | "#endif\n"; | |
2694 | ||
2695 | test_text = "typedef struct exception t_math_exception;"; | |
6274714d | 2696 | }; |
2697 | ||
a83746ef | 2698 | |
2699 | /* | |
2700 | * This looks pretty broken to me. ``dbl_max_def'' will contain | |
2701 | * "define DBL_MAX " at the start, when what we really want is just | |
2702 | * the value portion. Can't figure out how to write a test case | |
2703 | * for this either :-( | |
2704 | */ | |
6274714d | 2705 | fix = { |
bb304030 | 2706 | hackname = math_huge_val_from_dbl_max; |
6274714d | 2707 | files = math.h; |
6c013a2f | 2708 | |
a22ae698 | 2709 | /* |
bb304030 | 2710 | * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined |
2711 | * in math.h, this fix applies. | |
a22ae698 | 2712 | */ |
6c013a2f | 2713 | select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX"; |
2714 | bypass = "define[ \t]+DBL_MAX"; | |
6274714d | 2715 | |
bb304030 | 2716 | shell = |
a22ae698 | 2717 | /* |
bb304030 | 2718 | * See if we have a definition for DBL_MAX in float.h. |
2719 | * If we do, we will replace the one in math.h with that one. | |
a22ae698 | 2720 | */ |
6274714d | 2721 | |
a22ae698 | 2722 | "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " |
6c013a2f | 2723 | "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n" |
6274714d | 2724 | |
bb304030 | 2725 | "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n" |
2726 | "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/" | |
6c013a2f | 2727 | "s@DBL_MAX@'\"$dbl_max_def@\"\n" |
bb304030 | 2728 | "\telse cat\n" |
2729 | "\tfi"; | |
6c013a2f | 2730 | |
2731 | test_text = | |
2732 | "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n" | |
2733 | "#define HUGE_VAL DBL_MAX"; | |
6274714d | 2734 | }; |
2735 | ||
a83746ef | 2736 | |
3072d11f | 2737 | /* |
2738 | * nested comment | |
2739 | */ | |
2740 | fix = { | |
2741 | hackname = nested_auth_des; | |
2742 | files = rpc/rpc.h; | |
2743 | select = '(/\*.*rpc/auth_des\.h>.*)/\*'; | |
2744 | c_fix = format; | |
2745 | c_fix_arg = "%1*/ /*"; | |
2746 | test_text = "/*#include <rpc/auth_des.h> /* skip this */"; | |
2747 | }; | |
2748 | ||
2749 | ||
4cbf73b4 | 2750 | /* |
2751 | * Some versions of NetBSD don't expect the C99 inline semantics. | |
2752 | */ | |
2753 | fix = { | |
2754 | hackname = netbsd_c99_inline_1; | |
b8780944 | 2755 | mach = "*-*-netbsd*"; |
4cbf73b4 | 2756 | files = signal.h; |
2757 | select = "extern __inline int"; | |
2758 | ||
2759 | c_fix = format; | |
b32d497c | 2760 | c_fix_arg = "extern\n" |
2761 | "#ifdef __GNUC_STDC_INLINE__\n" | |
2762 | "__attribute__((__gnu_inline__))\n" | |
2763 | "#endif\n" | |
2764 | "__inline int"; | |
4cbf73b4 | 2765 | |
2766 | test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}"; | |
2767 | }; | |
2768 | ||
2769 | ||
759bfb14 | 2770 | fix = { |
2771 | hackname = netbsd_c99_inline_2; | |
b8780944 | 2772 | mach = "*-*-netbsd*"; |
759bfb14 | 2773 | files = signal.h; |
2774 | select = "#define _SIGINLINE extern __inline"; | |
2775 | ||
2776 | c_fix = format; | |
2777 | c_fix_arg = <<- _EOArg_ | |
2778 | #ifdef __GNUC_STDC_INLINE__ | |
2779 | #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline | |
2780 | #else | |
2781 | %0 | |
2782 | #endif | |
2783 | _EOArg_; | |
2784 | ||
2785 | test_text = "#define _SIGINLINE extern __inline"; | |
2786 | }; | |
2787 | ||
2788 | ||
81a897fb | 2789 | /* |
2790 | * NetBSD has a semicolon after the ending '}' for some extern "C". | |
2791 | */ | |
2792 | fix = { | |
2793 | hackname = netbsd_extra_semicolon; | |
b8780944 | 2794 | mach = "*-*-netbsd*"; |
81a897fb | 2795 | files = sys/cdefs.h; |
2796 | select = "#define[ \t]*__END_DECLS[ \t]*};"; | |
2797 | ||
2798 | c_fix = format; | |
2799 | c_fix_arg = "#define __END_DECLS }"; | |
2800 | ||
2801 | test_text = "#define __END_DECLS };"; | |
2802 | }; | |
2803 | ||
2804 | ||
f3449a3c | 2805 | /* newlib's stdint.h has several failures to conform to C99. The fix |
2806 | for these removed a comment that can be matched to identify unfixed | |
2807 | versions. */ | |
2808 | fix = { | |
2809 | hackname = newlib_stdint_1; | |
e2fb821c | 2810 | files = stdint-newlib.h, stdint.h; |
f3449a3c | 2811 | select = "@todo - Add support for wint_t types"; |
2812 | sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@"; | |
2813 | sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@"; | |
2814 | sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@"; | |
2815 | sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@"; | |
2816 | sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@"; | |
2817 | sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@"; | |
2818 | sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@'; | |
2819 | sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@'; | |
2820 | sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@'; | |
2821 | sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@"; | |
2822 | sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; | |
2823 | sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@"; | |
2824 | sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@"; | |
2825 | sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@"; | |
2826 | test_text = "/* @todo - Add support for wint_t types. */\n" | |
2827 | "#define INT32_MIN (-2147483647-1)\n" | |
2828 | "#define INT32_MAX 2147483647\n" | |
2829 | "#define UINT32_MAX 4294967295U\n" | |
2830 | "#define INT_LEAST32_MIN (-2147483647-1)\n" | |
2831 | "#define INT_LEAST32_MAX 2147483647\n" | |
2832 | "#define UINT_LEAST32_MAX 4294967295U\n" | |
2833 | "#define INT_FAST8_MIN INT8_MIN\n" | |
2834 | "#define INT_FAST8_MAX INT8_MAX\n" | |
2835 | "#define UINT_FAST8_MAX UINT8_MAX\n" | |
2836 | "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n" | |
2837 | "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n" | |
2838 | "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n" | |
2839 | "#define UINT8_C(x) x##U\n" | |
2840 | "#define UINT16_C(x) x##U"; | |
2841 | }; | |
2842 | ||
2843 | ||
2844 | fix = { | |
2845 | hackname = newlib_stdint_2; | |
e2fb821c | 2846 | files = stdint-newlib.h, stdint.h; |
f3449a3c | 2847 | select = "@todo - Add support for wint_t types"; |
2848 | c_fix = format; | |
2849 | c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n" | |
2850 | "#define INTMAX_MIN (-INTMAX_MAX - 1)\n" | |
2851 | "#define UINTMAX_MAX __UINTMAX_MAX__\n" | |
2852 | "#define WCHAR_MAX __WCHAR_MAX__\n" | |
2853 | "#define WCHAR_MIN __WCHAR_MIN__\n" | |
2854 | "#define WINT_MAX __WINT_MAX__\n" | |
2855 | "#define WINT_MIN __WINT_MIN__\n\n" | |
2856 | "%0"; | |
2857 | c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/'; | |
2858 | test_text = "/* @todo - Add support for wint_t types. */\n" | |
2859 | "/** Macros for minimum-width integer constant expressions */"; | |
2860 | }; | |
2861 | ||
2862 | ||
6274714d | 2863 | /* |
2864 | * NeXT 3.2 adds const prefix to some math functions. | |
2865 | * These conflict with the built-in functions. | |
2866 | */ | |
2867 | fix = { | |
a83746ef | 2868 | hackname = next_math_prefix; |
2869 | files = ansi/math.h; | |
2870 | select = "^extern[ \t]+double[ \t]+__const__[ \t]"; | |
2871 | ||
2872 | c_fix = format; | |
2873 | c_fix_arg = "extern double %1("; | |
2874 | c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\("; | |
6274714d | 2875 | |
a83746ef | 2876 | test_text = "extern\tdouble\t__const__\tmumble();"; |
6274714d | 2877 | }; |
2878 | ||
2879 | ||
2880 | /* | |
2881 | * NeXT 3.2 uses the word "template" as a parameter for some | |
2882 | * functions. GCC reports an invalid use of a reserved key word | |
a83746ef | 2883 | * with the built-in functions. |
6274714d | 2884 | */ |
2885 | fix = { | |
2886 | hackname = next_template; | |
2887 | files = bsd/libc.h; | |
a83746ef | 2888 | select = "[ \t]template\\)"; |
6274714d | 2889 | |
a83746ef | 2890 | c_fix = format; |
2891 | c_fix_arg = "(%1)"; | |
2892 | c_fix_arg = "\\(([^)]*)[ \t]template\\)"; | |
2893 | test_text = "extern mumble( char * template); /* fix */"; | |
6274714d | 2894 | }; |
2895 | ||
2896 | ||
2897 | /* | |
2898 | * NeXT 3.2 includes the keyword volatile in the abort() and exit() | |
2899 | * function prototypes. That conflicts with the built-in functions. | |
2900 | */ | |
2901 | fix = { | |
2902 | hackname = next_volitile; | |
2903 | files = ansi/stdlib.h; | |
a83746ef | 2904 | select = "^extern[ \t]+volatile[ \t]+void[ \t]"; |
2905 | ||
2906 | c_fix = format; | |
2907 | c_fix_arg = "extern void %1("; | |
2908 | c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\("; | |
6274714d | 2909 | |
a83746ef | 2910 | test_text = "extern\tvolatile\tvoid\tabort();"; |
6274714d | 2911 | }; |
2912 | ||
2913 | ||
2914 | /* | |
2915 | * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. | |
2916 | * Note that version 3 of the NeXT system has wait.h in a different directory, | |
2917 | * so that this code won't do anything. But wait.h in version 3 has a | |
2918 | * conditional, so it doesn't need this fix. So everything is okay. | |
2919 | */ | |
2920 | fix = { | |
038a3e7a | 2921 | hackname = next_wait_union; |
2922 | files = sys/wait.h; | |
6274714d | 2923 | |
038a3e7a | 2924 | select = 'wait\(union wait'; |
2925 | c_fix = format; | |
2926 | c_fix_arg = "wait(void"; | |
2927 | test_text = "extern pid_d wait(union wait*);"; | |
6274714d | 2928 | }; |
2929 | ||
2930 | ||
2931 | /* | |
2932 | * a missing semi-colon at the end of the nodeent structure definition. | |
2933 | */ | |
2934 | fix = { | |
038a3e7a | 2935 | hackname = nodeent_syntax; |
2936 | files = netdnet/dnetdb.h; | |
2937 | select = "char[ \t]*\\*na_addr[ \t]*$"; | |
2938 | c_fix = format; | |
2939 | c_fix_arg = "%0;"; | |
2940 | test_text = "char *na_addr\t"; | |
6274714d | 2941 | }; |
2942 | ||
6dcfb197 | 2943 | /* |
2944 | * Fix OpenBSD's NULL definition. | |
2945 | */ | |
2946 | fix = { | |
2947 | hackname = openbsd_null_definition; | |
2948 | mach = "*-*-openbsd*"; | |
2949 | files = locale.h, stddef.h, stdio.h, string.h, | |
2950 | time.h, unistd.h, wchar.h, sys/param.h; | |
2951 | select = "__GNUG__"; | |
2952 | c_fix = format; | |
2953 | c_fix_arg = "#ifndef NULL\n" | |
2954 | "#ifdef __cplusplus\n" | |
2955 | "#ifdef __GNUG__\n" | |
2956 | "#define NULL\t__null\n" | |
2957 | "#else\t /* ! __GNUG__ */\n" | |
2958 | "#define NULL\t0L\n" | |
2959 | "#endif\t /* __GNUG__ */\n" | |
2960 | "#else\t /* ! __cplusplus */\n" | |
2961 | "#define NULL\t((void *)0)\n" | |
2962 | "#endif\t /* __cplusplus */\n" | |
2963 | "#endif\t /* !NULL */"; | |
2964 | ||
2965 | c_fix_arg = "^#ifndef[ \t]*NULL\n" | |
2966 | "^#ifdef[ \t]*__GNUG__\n" | |
2967 | "^#define[ \t]*NULL[ \t]*__null\n" | |
2968 | "^#else\n" | |
2969 | "^#define[ \t]*NULL[ \t]*0L\n" | |
2970 | "^#endif\n" | |
2971 | "^#endif"; | |
2972 | test_text = | |
2973 | "#ifndef NULL\n" | |
2974 | "#ifdef __GNUG__\n" | |
2975 | "#define NULL __null\n" | |
2976 | "#else\n" | |
2977 | "#define NULL 0L\n" | |
2978 | "#endif\n" | |
2979 | "#endif\n"; | |
2980 | }; | |
6274714d | 2981 | |
129b92e3 | 2982 | /* |
2983 | * obstack.h used casts as lvalues. | |
2984 | * | |
2985 | * We need to change postincrements of casted pointers (which are | |
2986 | * then dereferenced and assigned into) of the form | |
2987 | * | |
2988 | * *((TYPE*)PTRVAR)++ = (VALUE) | |
2989 | * | |
2990 | * into expressions like | |
2991 | * | |
2992 | * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE))) | |
2993 | * | |
2994 | * which is correct for the cases used in obstack.h since PTRVAR is | |
2995 | * of type char * and the value of the expression is not used. | |
2996 | */ | |
2997 | fix = { | |
2998 | hackname = obstack_lvalue_cast; | |
2999 | files = obstack.h; | |
3000 | select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)'; | |
3001 | c_fix = format; | |
3002 | c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))"; | |
3003 | test_text = "*((void **) (h)->next_free)++ = (aptr)"; | |
3004 | }; | |
3005 | ||
2b0752cc | 3006 | /* |
3007 | * Fix OpenBSD's va_start define. | |
3008 | */ | |
3009 | fix = { | |
3010 | hackname = openbsd_va_start; | |
3011 | mach = "*-*-openbsd*"; | |
3012 | files = stdarg.h; | |
3013 | select = '__builtin_stdarg_start'; | |
3014 | c_fix = format; | |
3015 | c_fix_arg = __builtin_va_start; | |
3016 | ||
3017 | test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)"; | |
3018 | }; | |
129b92e3 | 3019 | |
6274714d | 3020 | /* |
3021 | * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by | |
3022 | * defining regex.h related types. This causes libg++ build and usage | |
3023 | * failures. Fixing this correctly requires checking and modifying 3 files. | |
3024 | */ | |
3025 | fix = { | |
3026 | hackname = osf_namespace_a; | |
3027 | files = reg_types.h; | |
3028 | files = sys/lc_core.h; | |
a22ae698 | 3029 | test = " -r reg_types.h"; |
3030 | test = " -r sys/lc_core.h"; | |
3031 | test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
3032 | test = " -z \"`grep __regex_t regex.h`\""; | |
6274714d | 3033 | |
038a3e7a | 3034 | c_fix = format; |
3035 | c_fix_arg = "__%0"; | |
8908831d | 3036 | c_fix_arg = "reg(ex|off|match)_t"; |
038a3e7a | 3037 | |
f74d6549 | 3038 | test_text = "`touch sys/lc_core.h`" |
038a3e7a | 3039 | "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n" |
3040 | "extern regex_t re;\n" | |
3041 | "extern regoff_t ro;\n" | |
3042 | "extern regmatch_t rm;\n"; | |
6274714d | 3043 | }; |
3044 | ||
3045 | fix = { | |
038a3e7a | 3046 | hackname = osf_namespace_c; |
6274714d | 3047 | files = regex.h; |
a22ae698 | 3048 | test = " -r reg_types.h"; |
3049 | test = " -r sys/lc_core.h"; | |
3050 | test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
3051 | test = " -z \"`grep __regex_t regex.h`\""; | |
3052 | ||
038a3e7a | 3053 | select = "#include <reg_types\.h>.*"; |
3054 | c_fix = format; | |
3055 | c_fix_arg = "%0\n" | |
3056 | "typedef __regex_t\tregex_t;\n" | |
3057 | "typedef __regoff_t\tregoff_t;\n" | |
3058 | "typedef __regmatch_t\tregmatch_t;"; | |
3059 | ||
3060 | test_text = "#include <reg_types.h>"; | |
6274714d | 3061 | }; |
3062 | ||
3063 | ||
a11c2c4d | 3064 | /* |
3065 | * On broken glibc-2.3.3 systems an array of incomplete structures is | |
3066 | * passed to __sigsetjmp. Fix that to take a pointer instead. | |
3067 | */ | |
3068 | fix = { | |
3069 | hackname = pthread_incomplete_struct_argument; | |
3070 | files = pthread.h; | |
3071 | select = "struct __jmp_buf_tag"; | |
3072 | c_fix = format; | |
3073 | c_fix_arg = "%1 *%2%3"; | |
3074 | c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$"; | |
3075 | test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);"; | |
3076 | }; | |
6274714d | 3077 | |
3078 | /* | |
3079 | * Fix return type of fread and fwrite on sysV68 | |
3080 | */ | |
6274714d | 3081 | fix = { |
3082 | hackname = read_ret_type; | |
3083 | files = stdio.h; | |
d0f5620b | 3084 | select = "extern int\t.*, fread\\(\\), fwrite\\(\\)"; |
038a3e7a | 3085 | c_fix = format; |
3086 | c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2"; | |
3087 | c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)"; | |
3088 | ||
3089 | test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();"; | |
6274714d | 3090 | }; |
6274714d | 3091 | |
3092 | ||
e68aa18b | 3093 | /* |
3094 | * Fix casts as lvalues in glibc's <rpc/xdr.h>. | |
3095 | */ | |
3096 | fix = { | |
3097 | hackname = rpc_xdr_lvalue_cast_a; | |
3098 | files = rpc/xdr.h; | |
3099 | select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*"; | |
3100 | c_fix = format; | |
3101 | c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))"; | |
3102 | test_text = "#define IXDR_GET_LONG(buf) \\\\\n" | |
3103 | "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))"; | |
3104 | }; | |
3105 | ||
3106 | ||
3107 | fix = { | |
3108 | hackname = rpc_xdr_lvalue_cast_b; | |
3109 | files = rpc/xdr.h; | |
3110 | select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*"; | |
3111 | c_fix = format; | |
3112 | c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))"; | |
3113 | test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n" | |
3114 | "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))"; | |
3115 | }; | |
3116 | ||
3117 | ||
6274714d | 3118 | /* |
3072d11f | 3119 | * function class(double x) conflicts with C++ keyword on rs/6000 |
6274714d | 3120 | */ |
3121 | fix = { | |
038a3e7a | 3122 | hackname = rs6000_double; |
3123 | files = math.h; | |
3124 | select = '[^a-zA-Z_]class\('; | |
3125 | ||
3126 | c_fix = format; | |
3127 | c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
3128 | c_fix_arg = '^.*[^a-zA-Z_]class\(.*'; | |
3129 | ||
3130 | test_text = "extern int class();"; | |
6274714d | 3131 | }; |
3132 | ||
3133 | ||
3134 | /* | |
3135 | * Wrong fchmod prototype on RS/6000. | |
3136 | */ | |
3137 | fix = { | |
038a3e7a | 3138 | hackname = rs6000_fchmod; |
3139 | files = sys/stat.h; | |
3140 | select = 'fchmod\(char \*'; | |
3141 | c_fix = format; | |
3142 | c_fix_arg = "fchmod(int"; | |
3143 | test_text = "extern int fchmod(char *, mode_t);"; | |
6274714d | 3144 | }; |
3145 | ||
3146 | ||
3147 | /* | |
3072d11f | 3148 | * parameters conflict with C++ new on rs/6000 |
6274714d | 3149 | */ |
3150 | fix = { | |
038a3e7a | 3151 | hackname = rs6000_param; |
3152 | files = "stdio.h"; | |
3153 | files = "unistd.h"; | |
6274714d | 3154 | |
038a3e7a | 3155 | select = 'rename\(const char \*old, const char \*new\)'; |
3156 | c_fix = format; | |
3157 | c_fix_arg = 'rename(const char *_old, const char *_new)'; | |
3158 | ||
3159 | test_text = 'extern int rename(const char *old, const char *new);'; | |
6274714d | 3160 | }; |
3161 | ||
e537c831 | 3162 | |
a6905708 | 3163 | /* |
3164 | * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict | |
3165 | * for C99. This is wrong for C++, which needs many C99 features, but | |
3166 | * only supports __restrict. | |
3167 | */ | |
3168 | fix = { | |
3169 | hackname = solaris___restrict; | |
3170 | files = sys/feature_tests.h; | |
3171 | select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict"; | |
3172 | mach = "*-*-solaris2*"; | |
3173 | c_fix = format; | |
3174 | c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n" | |
3175 | "#else\n%0\n#endif"; | |
3176 | test_text = "#define _RESTRICT_KYWD restrict"; | |
3177 | }; | |
3178 | ||
3179 | ||
aee500d5 | 3180 | /* |
3181 | * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of | |
3182 | * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I | |
3183 | * and imaginary definitions which are not supported by GCC. | |
3184 | */ | |
3185 | fix = { | |
3186 | hackname = solaris_complex; | |
3187 | mach = "*-*-solaris2.*"; | |
3188 | files = complex.h; | |
3189 | select = "#define[ \t]_Complex_I[ \t]_Complex_I"; | |
3190 | sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/" | |
b795c8d1 | 3191 | "#define\t_Complex_I\t(__extension__ 1.0iF)/"; |
aee500d5 | 3192 | sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d"; |
3193 | sed = "/#define[ \t]imaginary[ \t]_Imaginary/d"; | |
b795c8d1 | 3194 | sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/"; |
aee500d5 | 3195 | test_text = "#define _Complex_I _Complex_I\n" |
3196 | "#define complex _Complex\n" | |
3197 | "#define _Imaginary_I _Imaginary_I\n" | |
3198 | "#define imaginary _Imaginary\n" | |
3199 | "#undef I\n" | |
3200 | "#define I _Imaginary_I"; | |
3201 | }; | |
3202 | ||
3203 | ||
a6905708 | 3204 | /* |
3205 | * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in | |
3206 | * extern "C" instead so libstdc++ can use it. | |
3207 | */ | |
3208 | fix = { | |
3209 | hackname = solaris_complex_cxx; | |
3210 | mach = "*-*-solaris2.*"; | |
3211 | files = complex.h; | |
521cb370 | 3212 | sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n" |
a6905708 | 3213 | "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif"; |
521cb370 | 3214 | sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n" |
a6905708 | 3215 | "#ifdef\t__cplusplus\\\n}\\\n#endif"; |
3216 | test_text = "#if !defined(__cplusplus)\n" | |
3217 | "#endif /* !defined(__cplusplus) */"; | |
3218 | }; | |
3219 | ||
3220 | ||
5f7d4d97 | 3221 | /* |
3222 | * g++ rejects functions declared with both C and C++ linkage. | |
3223 | */ | |
3224 | fix = { | |
3225 | hackname = solaris_cxx_linkage; | |
3226 | mach = '*-*-solaris2*'; | |
3227 | files = "iso/stdlib_iso.h"; | |
3228 | select = "(#if __cplusplus >= 199711L)\n" | |
3229 | "(extern \"C\\+\\+\" \\{\n)" | |
3230 | "(.*(bsearch|qsort).*)"; | |
3231 | c_fix = format; | |
3232 | c_fix_arg = "%1 && !__GNUG__\n%2%3"; | |
3233 | ||
3234 | test_text = | |
3235 | "#if __cplusplus >= 199711L\n" | |
3236 | "extern \"C++\" {\n" | |
3237 | " void *bsearch(const void *, const void *, size_t, size_t,"; | |
3238 | }; | |
3239 | ||
3240 | ||
3241 | /* | |
3242 | * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with | |
3243 | * _STRICT_STDC, but uses it. | |
3244 | */ | |
3245 | fix = { | |
3246 | hackname = solaris_getc_strict_stdc; | |
3247 | mach = "*-*-solaris2*"; | |
3248 | files = "iso/stdio_iso.h"; | |
3249 | select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)"; | |
3250 | c_fix = format; | |
3251 | c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2"; | |
3252 | ||
3253 | test_text = | |
3254 | "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)"; | |
3255 | }; | |
3256 | ||
3257 | ||
3258 | /* | |
3259 | * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn. | |
3260 | */ | |
3261 | fix = { | |
3262 | hackname = solaris_longjmp_noreturn; | |
3263 | mach = "*-*-solaris2*"; | |
3264 | files = "iso/setjmp_iso.h"; | |
3265 | bypass = "__NORETURN"; | |
3266 | select = "(.*longjmp\\(jmp_buf.*[^)]+\\));"; | |
3267 | c_fix = format; | |
3268 | c_fix_arg = "%1 __attribute__ ((__noreturn__));"; | |
3269 | ||
3270 | test_text = "extern void longjmp(jmp_buf, int);"; | |
3271 | }; | |
3272 | ||
3273 | ||
e849ea70 | 3274 | /* |
3275 | * Sun Solaris 10 defines several C99 math macros in terms of | |
3276 | * builtins specific to the Studio compiler, in particular not | |
3277 | * compatible with the GNU compiler. | |
3278 | */ | |
3279 | fix = { | |
3280 | hackname = solaris_math_1; | |
3281 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3282 | bypass = "__GNUC__"; | |
3283 | files = iso/math_c99.h; | |
3284 | c_fix = format; | |
3285 | c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())"; | |
3286 | c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)"; | |
3287 | test_text = | |
3288 | '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
3289 | "#undef HUGE_VAL\n" | |
3290 | "#define HUGE_VAL __builtin_huge_val\n" | |
3291 | "#undef HUGE_VALF\n" | |
3292 | "#define HUGE_VALF __builtin_huge_valf\n" | |
3293 | "#undef HUGE_VALL\n" | |
3294 | "#define HUGE_VALL __builtin_huge_vall"; | |
3295 | }; | |
3296 | ||
3297 | fix = { | |
3298 | hackname = solaris_math_2; | |
3299 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3300 | bypass = "__GNUC__"; | |
3301 | files = iso/math_c99.h; | |
3302 | c_fix = format; | |
3303 | c_fix_arg = "#define\tINFINITY\t(__builtin_inff())"; | |
3304 | c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity"; | |
3305 | test_text = | |
3306 | '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
3307 | "#undef INFINITY\n" | |
3308 | "#define INFINITY __builtin_infinity"; | |
3309 | }; | |
3310 | ||
3311 | fix = { | |
3312 | hackname = solaris_math_3; | |
3313 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3314 | bypass = "__GNUC__"; | |
3315 | files = iso/math_c99.h; | |
3316 | c_fix = format; | |
3317 | c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))"; | |
3318 | c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan"; | |
3319 | test_text = | |
3320 | '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
3321 | "#undef NAN\n" | |
3322 | "#define NAN __builtin_nan"; | |
3323 | }; | |
3324 | ||
3325 | fix = { | |
3326 | hackname = solaris_math_4; | |
3327 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3328 | bypass = "__GNUC__"; | |
3329 | files = iso/math_c99.h; | |
3330 | c_fix = format; | |
3331 | c_fix_arg = "#define\tfpclassify(x) \\\n" | |
35fcf460 | 3332 | " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))"; |
e849ea70 | 3333 | c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)"; |
3334 | test_text = | |
3335 | '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
3336 | "#undef fpclassify\n" | |
3337 | "#define fpclassify(x) __builtin_fpclassify(x)"; | |
3338 | }; | |
3339 | ||
e849ea70 | 3340 | fix = { |
3341 | hackname = solaris_math_8; | |
4e2a89e2 | 3342 | select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI"; |
e849ea70 | 3343 | bypass = "__GNUC__"; |
3344 | files = iso/math_c99.h; | |
3345 | c_fix = format; | |
3346 | c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n" | |
3347 | "\t\t\t ? __builtin_signbitf(x) \\\n" | |
3348 | "\t\t\t : sizeof(x) == sizeof(long double) \\\n" | |
3349 | "\t\t\t ? __builtin_signbitl(x) \\\n" | |
3350 | "\t\t\t : __builtin_signbit(x))"; | |
3351 | c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)"; | |
ac2bc44b | 3352 | test_text = <<- _EOText_ |
3353 | #ident "@(#)math_c99.h 1.9 04/11/01 SMI" | |
3354 | #undef signbit | |
4e2a89e2 | 3355 | #define signbit(x) __builtin_signbit(x) |
ac2bc44b | 3356 | _EOText_; |
e849ea70 | 3357 | }; |
3358 | ||
3359 | fix = { | |
3360 | hackname = solaris_math_9; | |
3361 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3362 | bypass = "__GNUC__"; | |
3363 | files = iso/math_c99.h; | |
3364 | c_fix = format; | |
3365 | c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)"; | |
3366 | c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)"; | |
3367 | test_text = | |
3368 | '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
3369 | "#undef isgreater\n" | |
3370 | "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n" | |
3371 | "#undef isgreaterequal\n" | |
3372 | "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n" | |
3373 | "#undef isless\n" | |
3374 | "#define isless(x, y) ((x) __builtin_isless(y))\n" | |
3375 | "#undef islessequal\n" | |
3376 | "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n" | |
3377 | "#undef islessgreater\n" | |
3378 | "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n" | |
3379 | "#undef isunordered\n" | |
3380 | "#define isunordered(x, y) ((x) __builtin_isunordered(y))"; | |
3381 | }; | |
a712e12c | 3382 | |
1b0a9ef1 | 3383 | /* |
3384 | * On Solaris 11, if you do isinf(NaN) you'll get a floating point | |
3385 | * exception. Provide an alternative using GCC's builtin. | |
3386 | */ | |
3387 | ||
3388 | fix = { | |
3389 | hackname = solaris_math_10; | |
3390 | select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3391 | files = iso/math_c99.h; | |
3392 | c_fix = format; | |
3393 | c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)"; | |
3394 | c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n" | |
3395 | "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n" | |
3396 | "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n" | |
3397 | "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)"; | |
3398 | test_text = | |
3399 | '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n" | |
3400 | "#undef isinf\n" | |
3401 | "#define isinf(x) __extension__( \\\\\n" | |
3402 | " { __typeof(x) __x_i = (x); \\\\\n" | |
3403 | " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n" | |
3404 | " __x_i == (__typeof(__x_i)) (-INFINITY); })"; | |
3405 | }; | |
3406 | ||
c718ce1e | 3407 | /* |
c6738ff5 | 3408 | * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing |
c718ce1e | 3409 | * "0" for the last field of the pthread_mutex_t structure, which is |
3410 | * of type upad64_t, which itself is typedef'd to int64_t, but with | |
3411 | * __STDC__ defined (e.g. by -ansi) it is a union. So change the | |
3412 | * initializer to "{0}" instead | |
3413 | */ | |
3414 | fix = { | |
4a050cc7 | 3415 | hackname = solaris_mutex_init_2; |
e61fb0ae | 3416 | select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; |
3417 | files = pthread.h; | |
b960b7b7 | 3418 | /* |
3419 | * On Solaris 10, this fix is unnecessary because upad64_t is | |
3420 | * always defined correctly regardless of the definition of the | |
3421 | * __STDC__ macro. The first "mach" pattern matches up to | |
3422 | * solaris9. The second "mach" pattern will not match any two (or | |
3423 | * more) digit solaris version, but it will match e.g. 2.5.1. | |
3424 | */ | |
3425 | mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; | |
e61fb0ae | 3426 | c_fix = format; |
3427 | c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
3428 | "%0\n" | |
3429 | "#else\n" | |
b960b7b7 | 3430 | "%1, {0}}%4\n" |
e61fb0ae | 3431 | "#endif"; |
b960b7b7 | 3432 | c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+" |
3433 | "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)" | |
3918f760 | 3434 | ",[ \t]*0\\}" "(|[ \t].*)$"; |
e61fb0ae | 3435 | test_text = |
3436 | '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
3437 | "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n" | |
b960b7b7 | 3438 | "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n" |
3439 | "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n" | |
3440 | " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n" | |
3441 | "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n" | |
3442 | " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}"; | |
458caa24 | 3443 | }; |
3444 | ||
3445 | ||
5f7d4d97 | 3446 | /* |
3447 | * The pow overloads with int were removed in C++ 2011. | |
3448 | */ | |
3449 | fix = { | |
3450 | hackname = solaris_pow_int_overload; | |
3451 | mach = '*-*-solaris2*'; | |
3452 | files = "iso/math_iso.h"; | |
3453 | select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)" | |
3454 | " *\\{[^{}]*\n[^{}]*\\}"; | |
3455 | c_fix = format; | |
3456 | c_fix_arg = "#ifndef __GXX_EXPERIMENTAL_CXX0X__\n%0\n#endif"; | |
3457 | ||
3458 | test_text = | |
3459 | " inline long double pow(long double __X, int __Y) { return\n" | |
3460 | " __powl(__X, (long double) (__Y)); }"; | |
3461 | }; | |
3462 | ||
3463 | ||
458caa24 | 3464 | /* |
3465 | * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some | |
3466 | * fields of the pthread_rwlock_t structure, which are of type | |
3467 | * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ | |
3468 | * defined (e.g. by -ansi) it is a union. So change the initializer | |
3469 | * to "{0}" instead. | |
3470 | */ | |
3471 | fix = { | |
3472 | hackname = solaris_rwlock_init_1; | |
3473 | select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3474 | files = pthread.h; | |
3475 | mach = '*-*-solaris*'; | |
3476 | c_fix = format; | |
3477 | c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
3478 | "%0\n" | |
3479 | "#else\n" | |
3480 | "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n" | |
3481 | "#endif"; | |
3482 | c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)" | |
3483 | "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$"; | |
3484 | ||
3485 | test_text = | |
3486 | '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
3487 | "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}"; | |
3488 | }; | |
3489 | ||
3490 | ||
3491 | /* | |
3492 | * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a | |
3493 | * structure. As such, it need two levels of brackets, but only | |
3494 | * contains one. Wrap the macro definition in an extra layer. | |
3495 | */ | |
3496 | fix = { | |
3497 | hackname = solaris_once_init_1; | |
3498 | select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3499 | files = pthread.h; | |
3500 | mach = '*-*-solaris*'; | |
3501 | c_fix = format; | |
3502 | c_fix_arg = "%1{%2}%3"; | |
3503 | c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$"; | |
3504 | test_text = | |
3505 | '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n" | |
3506 | "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}"; | |
c718ce1e | 3507 | }; |
3508 | ||
3509 | ||
a96763ff | 3510 | /* |
3511 | * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some | |
3512 | * fields of the pthread_once_t structure, which are of type | |
3513 | * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ | |
3514 | * defined (e.g. by -ansi) it is a union. So change the initializer | |
3515 | * to "{0}" instead. This test relies on solaris_once_init_1. | |
3516 | */ | |
3517 | fix = { | |
3518 | hackname = solaris_once_init_2; | |
3519 | select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3520 | files = pthread.h; | |
3521 | /* | |
3522 | * On Solaris 10, this fix is unnecessary because upad64_t is | |
3523 | * always defined correctly regardless of the definition of the | |
b960b7b7 | 3524 | * __STDC__ macro. The first "mach" pattern matches up to |
a96763ff | 3525 | * solaris9. The second "mach" pattern will not match any two (or |
3526 | * more) digit solaris version, but it will match e.g. 2.5.1. | |
3527 | */ | |
3528 | mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; | |
3529 | c_fix = format; | |
3530 | c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
3531 | "%0\n" | |
3532 | "#else\n" | |
3533 | "%1{0}, {0}, {0}, {%3}%4\n" | |
3534 | "#endif"; | |
3535 | c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)" | |
3536 | "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$"; | |
3537 | test_text = | |
3538 | '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
3539 | "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n"; | |
3540 | }; | |
3541 | ||
3542 | ||
3dbaf01b | 3543 | /* |
d462c2ee | 3544 | * Sun Solaris 2 has a version of sys/int_const.h that defines |
3dbaf01b | 3545 | * UINT8_C and UINT16_C to unsigned constants. |
3546 | */ | |
3547 | fix = { | |
3548 | hackname = solaris_int_const; | |
3dbaf01b | 3549 | files = sys/int_const.h; |
d462c2ee | 3550 | mach = '*-*-solaris2*'; |
3dbaf01b | 3551 | c_fix = format; |
3552 | c_fix_arg = "#define\tUINT8_C(c)\t(c)\n" | |
3553 | "%1\n" | |
3554 | "#define\tUINT16_C(c)\t(c)"; | |
d462c2ee | 3555 | select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n" |
3dbaf01b | 3556 | "(/\*.*\*/)\n" |
3557 | "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*"; | |
3558 | test_text = | |
3dbaf01b | 3559 | "#define UINT8_C(c) __CONCAT__(c,u)\n" |
3560 | "/* CSTYLED */\n" | |
3561 | "#define UINT16_C(c) __CONCAT__(c,u)"; | |
3562 | }; | |
3563 | ||
3564 | ||
3565 | /* | |
d462c2ee | 3566 | * Sun Solaris 2 has a version of sys/int_limits.h that defines |
3dbaf01b | 3567 | * UINT8_MAX and UINT16_MAX to unsigned constants. |
3568 | */ | |
3569 | fix = { | |
3570 | hackname = solaris_int_limits_1; | |
3dbaf01b | 3571 | files = sys/int_limits.h; |
d462c2ee | 3572 | mach = '*-*-solaris2*'; |
3dbaf01b | 3573 | c_fix = format; |
3574 | c_fix_arg = "#define\tUINT8_MAX\t(255)\n" | |
3575 | "#define\tUINT16_MAX\t(65535)"; | |
d462c2ee | 3576 | select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n" |
3dbaf01b | 3577 | "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)"; |
3578 | test_text = | |
3dbaf01b | 3579 | "#define UINT8_MAX (255U)\n" |
3580 | "#define UINT16_MAX (65535U)"; | |
3581 | }; | |
3582 | ||
3583 | ||
3584 | /* | |
d462c2ee | 3585 | * Sun Solaris 2 has a version of sys/int_limits.h that defines |
3dbaf01b | 3586 | * INT_FAST16 limits to wrong values for sys/int_types.h. |
3587 | */ | |
3588 | fix = { | |
3589 | hackname = solaris_int_limits_2; | |
3dbaf01b | 3590 | files = sys/int_limits.h; |
d462c2ee | 3591 | mach = '*-*-solaris2*'; |
3dbaf01b | 3592 | c_fix = format; |
3593 | c_fix_arg = "#define\t%1_FAST16_%2 %132_%2"; | |
d462c2ee | 3594 | select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*"; |
3dbaf01b | 3595 | test_text = |
3dbaf01b | 3596 | "#define INT_FAST16_MAX INT16_MAX\n" |
3597 | "#define UINT_FAST16_MAX UINT16_MAX\n" | |
3598 | "#define INT_FAST16_MIN INT16_MIN"; | |
3599 | }; | |
3600 | ||
3601 | ||
d462c2ee | 3602 | /* |
3603 | * Sun Solaris 2 has a version of sys/int_limits.h that defines | |
3604 | * SIZE_MAX as unsigned long. | |
3605 | */ | |
3606 | fix = { | |
3607 | hackname = solaris_int_limits_3; | |
3608 | files = sys/int_limits.h; | |
3609 | mach = '*-*-solaris2*'; | |
3610 | c_fix = format; | |
3611 | c_fix_arg = "#define\tSIZE_MAX\t4294967295U"; | |
3612 | select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL"; | |
3613 | test_text = | |
3614 | "#define SIZE_MAX 4294967295UL"; | |
3615 | }; | |
3616 | ||
3617 | ||
91eb7bbc | 3618 | /* |
6d87b38c | 3619 | * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use |
3620 | * of Standard C99 64-bit types in 32-bit mode. | |
3621 | */ | |
3622 | fix = { | |
3623 | hackname = solaris_int_types; | |
3624 | select = "__STDC__ - 0 == 0"; | |
3625 | bypass = "_LONGLONG_TYPE"; | |
3626 | files = sys/int_types.h; | |
3627 | c_fix = format; | |
3628 | c_fix_arg = | |
3629 | "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))"; | |
3630 | test_text = | |
3631 | "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
3632 | "typedef long long int64_t;\n" | |
3633 | "#endif\n\n" | |
3634 | "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n" | |
3635 | "typedef int64_t intmax_t;\n" | |
3636 | "#endif"; | |
3637 | }; | |
3638 | ||
3639 | ||
69c86aa4 | 3640 | /* |
3641 | * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the | |
3642 | * posix_spawn declarations, which doesn't work with C++. | |
3643 | */ | |
3644 | fix = { | |
3645 | hackname = solaris_posix_spawn_restrict; | |
3646 | files = spawn.h; | |
3647 | mach = '*-*-solaris2*'; | |
3648 | c_fix = format; | |
3649 | c_fix_arg = "%1*_RESTRICT_KYWD %2%3"; | |
3650 | select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)"; | |
3651 | test_text = | |
3652 | "char *const argv[_RESTRICT_KYWD],\n" | |
3653 | "char *const envp[_RESTRICT_KYWD]);"; | |
3654 | }; | |
3655 | ||
3656 | ||
5f7d4d97 | 3657 | /* |
3658 | * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and | |
3659 | * std::__flsbuf, but <iso/stdio_iso.h> uses them. | |
3660 | */ | |
3661 | fix = { | |
3662 | hackname = solaris_std___filbuf; | |
3663 | files = stdio.h; | |
3664 | mach = '*-*-solaris2*'; | |
3665 | bypass = "using std::__filbuf"; | |
3666 | select = "(using std::perror;\n)(#endif)"; | |
3667 | c_fix = format; | |
3668 | c_fix_arg = "%1#ifndef _LP64\n" | |
3669 | "using std::__filbuf;\n" | |
3670 | "using std::__flsbuf;\n" | |
3671 | "#endif\n%2"; | |
3672 | ||
3673 | test_text = "using std::perror;\n" | |
3674 | "#endif"; | |
3675 | }; | |
3676 | ||
3677 | ||
6d87b38c | 3678 | /* |
3679 | * Sun Solaris 8 has what appears to be some gross workaround for | |
91eb7bbc | 3680 | * some old version of their c++ compiler. G++ doesn't want it |
3681 | * either, but doesn't want to be tied to SunPRO version numbers. | |
3682 | */ | |
3683 | fix = { | |
3684 | hackname = solaris_stdio_tag; | |
3685 | files = stdio_tag.h; | |
3686 | ||
3687 | select = '__cplusplus < 54321L'; | |
09a31484 | 3688 | /* In Solaris 10, the code in stdio_tag.h is conditionalized on |
3689 | "!defined(__GNUC__)" so we no longer need to fix it. */ | |
3690 | bypass = '__GNUC__'; | |
91eb7bbc | 3691 | sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/'; |
3692 | ||
2bfb2bb3 | 3693 | test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)"; |
91eb7bbc | 3694 | }; |
3695 | ||
4dbe9809 | 3696 | |
166b4e81 | 3697 | /* |
264a5d11 | 3698 | * On Solaris 9, __va_list needs to become a typedef for |
166b4e81 | 3699 | * __builtin_va_list to make -Wmissing-format-attribute work. |
3700 | */ | |
3701 | fix = { | |
3702 | hackname = solaris_sys_va_list; | |
3703 | files = sys/va_list.h; | |
264a5d11 | 3704 | mach = '*-*-solaris2.9'; |
166b4e81 | 3705 | select = "#if.*__STDC__.*\n" |
3706 | "typedef void \\*__va_list;\n" | |
3707 | "#else\n" | |
3708 | "typedef char \\*__va_list;\n" | |
3709 | "#endif"; | |
3710 | ||
3711 | c_fix = format; | |
3712 | c_fix_arg = "#ifdef __GNUC__\n" | |
3713 | "typedef __builtin_va_list __va_list;\n" | |
3714 | "#else\n" | |
3715 | "%0\n" | |
3716 | "#endif"; | |
3717 | test_text = "#if defined(__STDC__) && !defined(__ia64)\n" | |
3718 | "typedef void *__va_list;\n" | |
3719 | "#else\n" | |
3720 | "typedef char *__va_list;\n" | |
3721 | "#endif"; | |
3722 | }; | |
3723 | ||
3724 | ||
6274714d | 3725 | /* |
3726 | * a missing semi-colon at the end of the statsswtch structure definition. | |
3727 | */ | |
3728 | fix = { | |
038a3e7a | 3729 | hackname = statsswtch; |
3730 | files = rpcsvc/rstat.h; | |
3731 | select = "boottime$"; | |
3732 | c_fix = format; | |
3733 | c_fix_arg = "boottime;"; | |
3734 | test_text = "struct statswtch {\n int boottime\n};"; | |
6274714d | 3735 | }; |
3736 | ||
3737 | ||
d4c4b01d | 3738 | /* |
3739 | * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list. | |
3740 | * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's | |
3741 | * OK too. | |
3742 | */ | |
3743 | fix = { | |
3744 | hackname = stdio_stdarg_h; | |
3745 | files = stdio.h; | |
3746 | bypass = "include.*(stdarg\.h|machine/ansi\.h)"; | |
09a31484 | 3747 | /* |
3748 | * On Solaris 10, this fix is unncessary; <stdio.h> includes | |
3749 | * <iso/stdio_iso.h>, which includes <sys/va_list.h>. | |
3750 | */ | |
85dedd01 | 3751 | mach = '*-*-solaris2.1[0-9]*'; |
09a31484 | 3752 | not_machine = true; |
d4c4b01d | 3753 | |
e6650807 | 3754 | c_fix = wrap; |
d4c4b01d | 3755 | |
e6650807 | 3756 | c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n"; |
3757 | ||
3758 | test_text = ""; | |
d4c4b01d | 3759 | }; |
3760 | ||
3761 | ||
6274714d | 3762 | /* |
a6c73c6c | 3763 | * Don't use or define the name va_list in stdio.h. This is for |
3764 | * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence | |
3765 | * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to | |
3766 | * indicate that the header knows what it's doing -- under SUSv2, | |
3767 | * stdio.h is required to define va_list, and we shouldn't break | |
5641963c | 3768 | * that. |
6274714d | 3769 | */ |
3770 | fix = { | |
3771 | hackname = stdio_va_list; | |
3772 | files = stdio.h; | |
925b9291 | 3773 | bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; |
09a31484 | 3774 | /* |
3775 | * On Solaris 10, the definition in | |
3776 | * <stdio.h> is guarded appropriately by the _XPG4 feature macro; | |
3777 | * there is therefore no need for this fix there. | |
3778 | */ | |
85dedd01 | 3779 | mach = '*-*-solaris2.1[0-9]*'; |
09a31484 | 3780 | not_machine = true; |
925b9291 | 3781 | |
3782 | /* | |
3783 | * Use __gnuc_va_list in arg types in place of va_list. | |
3784 | * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A | |
3785 | * use __gnuc_va_list instead of __VA_LIST__. We're hoping the | |
3786 | * trailing parentheses and semicolon save all other systems from this. | |
3787 | * Define __not_va_list__ (something harmless and unused) | |
3788 | * instead of va_list. | |
3789 | * Don't claim to have defined va_list. | |
3790 | */ | |
3791 | sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" | |
3792 | "s@(va_list)&@(__gnuc_va_list)\\&@\n" | |
3793 | "s@ _VA_LIST_));@ __gnuc_va_list));@\n" | |
3794 | "s@ __VA_LIST__));@ __gnuc_va_list));@\n" | |
3795 | "s@ va_list@ __not_va_list__@\n" | |
3796 | "s@\\*va_list@*__not_va_list__@\n" | |
3797 | "s@ __va_list)@ __gnuc_va_list)@\n" | |
3798 | "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" | |
3799 | "@typedef \\1 __not_va_list__;@\n" | |
3800 | "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" | |
3801 | "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" | |
3802 | "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" | |
3803 | "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" | |
3804 | "s@VA_LIST@DUMMY_VA_LIST@\n" | |
3805 | "s@_Va_LIST@_VA_LIST@"; | |
3806 | test_text = "extern void mumble( va_list);"; | |
3807 | }; | |
3808 | ||
3809 | ||
3810 | /* | |
3811 | * Fix headers that use va_list from stdio.h to use the updated | |
3812 | * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is | |
3813 | * dealt with elsewhere. The presence of __gnuc_va_list, | |
3814 | * __DJ_va_list, or _G_va_list is taken to indicate that the header | |
3815 | * knows what it's doing. | |
3816 | */ | |
3817 | fix = { | |
3818 | hackname = stdio_va_list_clients; | |
65dc6e0c | 3819 | files = com_err.h; |
3820 | files = cps.h; | |
3821 | files = curses.h; | |
3822 | files = krb5.h; | |
3823 | files = lc_core.h; | |
3824 | files = pfmt.h; | |
3825 | files = wchar.h; | |
3826 | files = curses_colr/curses.h; | |
5f6aa019 | 3827 | bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; |
925b9291 | 3828 | /* Don't fix, if we use va_list from stdarg.h, or if the use is |
3829 | otherwise protected. */ | |
3830 | bypass = 'include <stdarg\.h>|#ifdef va_start'; | |
6274714d | 3831 | |
3832 | /* | |
3833 | * Use __gnuc_va_list in arg types in place of va_list. | |
6bc3b53c | 3834 | * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A |
3835 | * use __gnuc_va_list instead of __VA_LIST__. We're hoping the | |
6274714d | 3836 | * trailing parentheses and semicolon save all other systems from this. |
d4c4b01d | 3837 | * Define __not_va_list__ (something harmless and unused) |
3838 | * instead of va_list. | |
6274714d | 3839 | * Don't claim to have defined va_list. |
3840 | */ | |
2a024ef8 | 3841 | sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" |
857f8fc6 | 3842 | "s@(va_list)&@(__gnuc_va_list)\\&@\n" |
d4c4b01d | 3843 | "s@ _VA_LIST_));@ __gnuc_va_list));@\n" |
6bc3b53c | 3844 | "s@ __VA_LIST__));@ __gnuc_va_list));@\n" |
d4c4b01d | 3845 | "s@ va_list@ __not_va_list__@\n" |
3846 | "s@\\*va_list@*__not_va_list__@\n" | |
3847 | "s@ __va_list)@ __gnuc_va_list)@\n" | |
41298347 | 3848 | "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" |
3849 | "@typedef \\1 __not_va_list__;@\n" | |
b93c3ed1 | 3850 | "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" |
d4c4b01d | 3851 | "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" |
3f2444de | 3852 | "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" |
d4c4b01d | 3853 | "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" |
3854 | "s@VA_LIST@DUMMY_VA_LIST@\n" | |
3855 | "s@_Va_LIST@_VA_LIST@"; | |
6c013a2f | 3856 | test_text = "extern void mumble( va_list);"; |
6274714d | 3857 | }; |
3858 | ||
3859 | ||
3072d11f | 3860 | /* |
3861 | * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0" | |
3862 | * is "!defined( __STRICT_ANSI__ )" | |
3863 | */ | |
3864 | fix = { | |
3865 | hackname = strict_ansi_not; | |
3866 | select = "^([ \t]*#[ \t]*if.*)" | |
3867 | "(!__STDC__" | |
3868 | "|__STDC__[ \t]*==[ \t]*0" | |
3869 | "|__STDC__[ \t]*!=[ \t]*1" | |
3ff85771 | 3870 | "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)"; |
68d0517a | 3871 | /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */ |
3872 | bypass = 'GNU and MIPS C compilers define __STDC__ differently'; | |
5f6aa019 | 3873 | /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which |
3874 | is not defined by GCC, so it is safe. */ | |
3875 | bypass = '__SCO_VERSION__.*__STDC__ != 1'; | |
3072d11f | 3876 | c_test = stdc_0_in_system_headers; |
3877 | ||
3878 | c_fix = format; | |
3ff85771 | 3879 | c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; |
3072d11f | 3880 | |
3881 | test_text = "#if !__STDC__ \n" | |
3882 | "#if __STDC__ == 0\n" | |
3883 | "#if __STDC__ != 1\n" | |
3884 | "#if __STDC__ - 0 == 0" | |
3885 | "/* not std C */\nint foo;\n" | |
3886 | "\n#end-end-end-end-if :-)"; | |
3887 | }; | |
3888 | ||
3889 | /* | |
3890 | * "__STDC__-0==0" | |
3891 | * is "!defined( __STRICT_ANSI__ )" on continued #if-s | |
3892 | */ | |
3893 | fix = { | |
3894 | hackname = strict_ansi_not_ctd; | |
3ff85771 | 3895 | files = math.h, limits.h, stdio.h, signal.h, |
3896 | stdlib.h, sys/signal.h, time.h; | |
3897 | /* | |
3898 | * Starting at the beginning of a line, skip white space and | |
3899 | * a leading "(" or "&&" or "||". One of those must be found. | |
3900 | * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&" | |
3901 | * expression. If these are nested, then they must accumulate | |
3902 | * because we won't match any closing parentheses. Finally, | |
3903 | * after skipping over all that, we must then match our suspect | |
3904 | * phrase: "__STDC__-0==0" with or without white space. | |
3905 | */ | |
3906 | select = "^([ \t]*" '(\(|&&|\|\|)' | |
3907 | "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*" | |
3908 | "[ \t(]*)" | |
3909 | "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)"; | |
3072d11f | 3910 | c_test = stdc_0_in_system_headers; |
3911 | ||
3912 | c_fix = format; | |
3ff85771 | 3913 | c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; |
3072d11f | 3914 | |
3ff85771 | 3915 | test_text = "#if 1 && \\\\\n" |
3916 | "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n" | |
3917 | "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n" | |
3918 | "|| __STDC__ - 0 == 0 ) /* not std C */\n" | |
3919 | "int foo;\n#endif"; | |
3072d11f | 3920 | }; |
3921 | ||
3ff85771 | 3922 | |
3072d11f | 3923 | /* |
3924 | * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1" | |
3925 | * is "defined( __STRICT_ANSI__ )" | |
3926 | */ | |
3927 | fix = { | |
3928 | hackname = strict_ansi_only; | |
3929 | select = "^([ \t]*#[ \t]*if.*)" | |
3930 | "(__STDC__[ \t]*!=[ \t]*0" | |
3931 | "|__STDC__[ \t]*==[ \t]*1" | |
3932 | "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1" | |
3ff85771 | 3933 | "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)"; |
3072d11f | 3934 | c_test = stdc_0_in_system_headers; |
3935 | ||
3936 | c_fix = format; | |
3ff85771 | 3937 | c_fix_arg = "%1 defined(__STRICT_ANSI__)"; |
3072d11f | 3938 | |
3939 | test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif"; | |
3940 | }; | |
3941 | ||
3942 | ||
cfe5be71 | 3943 | /* |
3944 | * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s | |
3945 | * in prototype without previous definition. | |
3946 | */ | |
3947 | fix = { | |
3948 | hackname = struct_file; | |
3949 | files = rpc/xdr.h; | |
3950 | select = '^.*xdrstdio_create.*struct __file_s'; | |
3951 | c_fix = format; | |
3952 | c_fix_arg = "struct __file_s;\n%0"; | |
3953 | test_text = "extern void xdrstdio_create( struct __file_s* );"; | |
3954 | }; | |
3955 | ||
3956 | ||
3957 | /* | |
3958 | * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr | |
3959 | * in prototype without previous definition. | |
4176aa8f | 3960 | * |
3961 | * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same | |
3962 | * function, and does define it. | |
cfe5be71 | 3963 | */ |
3964 | fix = { | |
3965 | hackname = struct_sockaddr; | |
3966 | files = rpc/auth.h; | |
4176aa8f | 3967 | select = "^.*authdes_create.*struct sockaddr[^_]"; |
cfe5be71 | 3968 | bypass = "<sys/socket\.h>"; |
4176aa8f | 3969 | bypass = "struct sockaddr;\n"; |
cfe5be71 | 3970 | c_fix = format; |
3971 | c_fix_arg = "struct sockaddr;\n%0"; | |
3972 | test_text = "extern AUTH* authdes_create( struct sockaddr* );"; | |
3973 | }; | |
3974 | ||
3975 | ||
a712e12c | 3976 | /* |
3977 | * Apply fix this to all OSs since this problem seems to effect | |
3978 | * more than just SunOS. | |
3979 | */ | |
3980 | fix = { | |
3981 | hackname = sun_auth_proto; | |
3982 | files = rpc/auth.h; | |
3983 | files = rpc/clnt.h; | |
3984 | files = rpc/svc.h; | |
3985 | files = rpc/xdr.h; | |
69c13546 | 3986 | bypass = "__cplusplus"; |
a712e12c | 3987 | /* |
3988 | * Select those files containing '(*name)()'. | |
3989 | */ | |
038a3e7a | 3990 | select = '\(\*[a-z][a-z_]*\)\(\)'; |
a712e12c | 3991 | |
038a3e7a | 3992 | c_fix = format; |
3993 | c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n" | |
3994 | "#else\n%1();%2\n#endif"; | |
3995 | c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)'; | |
a712e12c | 3996 | |
038a3e7a | 3997 | test_text = |
3998 | "struct auth_t {\n" | |
3999 | " int (*name)(); /* C++ bad */\n" | |
4000 | "};"; | |
6274714d | 4001 | }; |
4002 | ||
4003 | ||
4004 | /* | |
4005 | * Fix bogus #ifdef on SunOS 4.1. | |
4006 | */ | |
4007 | fix = { | |
038a3e7a | 4008 | hackname = sun_bogus_ifdef; |
4009 | files = "hsfs/hsfs_spec.h"; | |
4010 | files = "hsfs/iso_spec.h"; | |
4011 | select = '#ifdef(.*\|\|.*)'; | |
4012 | c_fix = format; | |
4013 | c_fix_arg = "#if%1"; | |
4014 | ||
4015 | test_text = "#ifdef __i386__ || __vax__ || __sun4c__"; | |
6274714d | 4016 | }; |
4017 | ||
4018 | ||
4019 | /* | |
4020 | * Fix the CAT macro in SunOS memvar.h. | |
4021 | */ | |
4022 | fix = { | |
038a3e7a | 4023 | hackname = sun_catmacro; |
4024 | files = pixrect/memvar.h; | |
4025 | select = "^#define[ \t]+CAT\\(a,b\\).*"; | |
4026 | c_fix = format; | |
6274714d | 4027 | |
038a3e7a | 4028 | c_fix_arg = |
4029 | "#ifdef __STDC__\n" | |
4030 | "# define CAT(a,b) a##b\n" | |
4031 | "#else\n%0\n#endif"; | |
4032 | ||
4033 | test_text = | |
4034 | "#define CAT(a,b)\ta/**/b"; | |
6274714d | 4035 | }; |
4036 | ||
4037 | ||
4038 | /* | |
4039 | * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. | |
4040 | * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 | |
4041 | */ | |
4042 | fix = { | |
4043 | hackname = sun_malloc; | |
4044 | files = malloc.h; | |
69c13546 | 4045 | bypass = "_CLASSIC_ANSI_TYPES"; |
6274714d | 4046 | |
4047 | sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g"; | |
4048 | sed = "s/int[ \t][ \t]*free/void\tfree/g"; | |
4049 | sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g"; | |
4050 | sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g"; | |
6e58c05f | 4051 | sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g"; |
038a3e7a | 4052 | |
4053 | test_text = | |
4054 | "typedef char *\tmalloc_t;\n" | |
4055 | "int \tfree();\n" | |
4056 | "char*\tmalloc();\n" | |
6e58c05f | 4057 | "char*\tcalloc();\n" |
038a3e7a | 4058 | "char*\trealloc();"; |
6274714d | 4059 | }; |
4060 | ||
4061 | ||
6274714d | 4062 | /* |
4063 | * Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
4064 | */ | |
4065 | fix = { | |
4066 | hackname = sun_rusers_semi; | |
4067 | files = rpcsvc/rusers.h; | |
4068 | select = "_cnt$"; | |
4069 | sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; | |
038a3e7a | 4070 | test_text = "struct mumble\n int _cnt\n};"; |
6274714d | 4071 | }; |
4072 | ||
4073 | ||
4074 | /* | |
4075 | * signal.h on SunOS defines signal using (), | |
4076 | * which causes trouble when compiling with g++ -pedantic. | |
4077 | */ | |
4078 | fix = { | |
4079 | hackname = sun_signal; | |
4080 | files = sys/signal.h; | |
4081 | files = signal.h; | |
038a3e7a | 4082 | select = "^void\t" '\(\*signal\(\)\)\(\);.*'; |
6274714d | 4083 | |
038a3e7a | 4084 | c_fix = format; |
4085 | c_fix_arg = | |
4086 | "#ifdef __cplusplus\n" | |
4087 | "void\t(*signal(...))(...);\n" | |
4088 | "#else\n%0\n#endif"; | |
6274714d | 4089 | |
038a3e7a | 4090 | test_text = "void\t(*signal())();"; |
6274714d | 4091 | }; |
4092 | ||
4093 | ||
6274714d | 4094 | /* |
4095 | * Correct the return type for strlen in strings.h in SunOS 4. | |
4096 | */ | |
4097 | fix = { | |
4098 | hackname = sunos_strlen; | |
4099 | files = strings.h; | |
038a3e7a | 4100 | select = "int[ \t]*strlen\\(\\);(.*)"; |
4101 | c_fix = format; | |
4102 | c_fix_arg = "__SIZE_TYPE__ strlen();%1"; | |
4103 | test_text = " int\tstrlen(); /* string length */"; | |
6274714d | 4104 | }; |
4105 | ||
4106 | ||
6274714d | 4107 | /* |
4108 | * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> | |
4109 | * that is visible to any ANSI compiler using this include. Simply | |
4110 | * delete the lines that #define some string functions to internal forms. | |
4111 | */ | |
6274714d | 4112 | fix = { |
4113 | hackname = svr4_disable_opt; | |
4114 | files = string.h; | |
4115 | select = '#define.*__std_hdr_'; | |
4116 | sed = '/#define.*__std_hdr_/d'; | |
3c04ceca | 4117 | test_text = "#define strlen __std_hdr_strlen\n"; |
6274714d | 4118 | }; |
d08a0ac4 | 4119 | |
e537c831 | 4120 | |
6274714d | 4121 | /* |
4122 | * Fix broken decl of getcwd present on some svr4 systems. | |
4123 | */ | |
6274714d | 4124 | fix = { |
4125 | hackname = svr4_getcwd; | |
4126 | files = stdlib.h; | |
4127 | files = unistd.h; | |
a712e12c | 4128 | files = prototypes.h; |
6274714d | 4129 | select = 'getcwd\(char \*, int\)'; |
4130 | ||
038a3e7a | 4131 | c_fix = format; |
4132 | c_fix_arg = "getcwd(char *, size_t)"; | |
4133 | ||
4134 | test_text = "extern char* getcwd(char *, int);"; | |
6274714d | 4135 | }; |
a712e12c | 4136 | |
6274714d | 4137 | |
6274714d | 4138 | /* |
4139 | * Fix broken decl of profil present on some svr4 systems. | |
4140 | */ | |
6274714d | 4141 | fix = { |
4142 | hackname = svr4_profil; | |
4143 | files = stdlib.h; | |
4144 | files = unistd.h; | |
4145 | ||
038a3e7a | 4146 | select = |
4147 | 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)'; | |
4148 | c_fix = format; | |
4149 | c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)'; | |
4150 | ||
4151 | test_text = | |
4152 | 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);'; | |
6274714d | 4153 | }; |
a712e12c | 4154 | |
6274714d | 4155 | |
d23689b2 | 4156 | /* |
4157 | * Correct types for signal handler constants like SIG_DFL; they might be | |
4158 | * void (*) (), and should be void (*) (int). C++ doesn't like the | |
4159 | * old style. | |
4160 | */ | |
4161 | fix = { | |
4162 | hackname = svr4_sighandler_type; | |
4163 | files = sys/signal.h; | |
4164 | select = 'void *\(\*\)\(\)'; | |
4165 | c_fix = format; | |
4166 | c_fix_arg = "void (*)(int)"; | |
4167 | test_text = "#define SIG_DFL (void(*)())0\n" | |
4168 | "#define SIG_IGN (void (*)())0\n"; | |
4169 | }; | |
4170 | ||
d08a0ac4 | 4171 | |
630af039 | 4172 | /* |
4173 | * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local | |
4174 | * function 'getrnge' in <regexp.h> before they declare it. For these | |
4175 | * systems add a 'static int' declaration of 'getrnge' into <regexp.h> | |
4176 | * early on. | |
4177 | * | |
4178 | * 'getrnge' traditionally manipulates a file-scope global called 'size', | |
4179 | * so put the declaration right after the declaration of 'size'. | |
4180 | * | |
4181 | * Don't do this if there is already a `static void getrnge' declaration | |
4182 | * present, since this would cause a redeclaration error. Solaris 2.x has | |
4183 | * such a declaration. | |
4184 | */ | |
4185 | fix = { | |
4186 | hackname = svr4_undeclared_getrnge; | |
4187 | files = regexp.h; | |
4188 | select = "getrnge"; | |
4189 | bypass = "static void getrnge"; | |
4190 | c_fix = format; | |
4191 | c_fix_arg = "%0\n" | |
4192 | "static int getrnge ();"; | |
4193 | c_fix_arg = "^static int[ \t]+size;"; | |
4194 | test_text = "static int size;\n" | |
4195 | "/* stuff which calls getrnge() */\n" | |
4196 | "static getrnge()\n" | |
4197 | "{}"; | |
4198 | }; | |
4199 | ||
4200 | ||
6274714d | 4201 | /* |
d4c4b01d | 4202 | * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} |
4203 | * in string.h on sysV68 | |
4204 | * Correct the return type for strlen in string.h on Lynx. | |
4205 | * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. | |
4206 | * Add missing const for strdup on OSF/1 V3.0. | |
4207 | * On sysV88 layout is slightly different. | |
6274714d | 4208 | */ |
4209 | fix = { | |
4210 | hackname = sysv68_string; | |
6c013a2f | 4211 | files = testing.h; |
6274714d | 4212 | files = string.h; |
69c13546 | 4213 | bypass = "_CLASSIC_ANSI_TYPES"; |
6274714d | 4214 | |
4215 | sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/"; | |
4216 | sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/"; | |
4217 | sed = "s/strdup(char \\*s1);/strdup(const char *s1);/"; | |
6c013a2f | 4218 | |
6274714d | 4219 | sed = "/^extern char$/N"; |
4220 | sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/"; | |
6c013a2f | 4221 | |
76485733 | 4222 | sed = "/^extern int$/N"; |
4223 | sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/"; | |
4224 | ||
6274714d | 4225 | sed = "/^\tstrncmp(),$/N"; |
6c013a2f | 4226 | sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/' |
4227 | '\1;' "\\\nextern unsigned int\\\n\\2/"; | |
4228 | ||
6c013a2f | 4229 | test_text = |
4230 | "extern int strlen();\n" | |
4231 | ||
4232 | "extern int ffs(long);\n" | |
4233 | ||
4234 | "extern char\n" | |
4235 | "\t*memccpy(),\n" | |
4236 | "\tmemcpy();\n" | |
4237 | ||
4238 | "extern int\n" | |
76485733 | 4239 | "\tstrcmp(),\n" |
6c013a2f | 4240 | "\tstrncmp(),\n" |
4241 | "\tstrlen(),\n" | |
4242 | "\tstrspn();\n" | |
4243 | ||
4244 | "extern int\n" | |
4245 | "\tstrlen(), strspn();"; | |
6274714d | 4246 | }; |
4247 | ||
4248 | ||
4249 | /* | |
038a3e7a | 4250 | * Fix return type of calloc, malloc, realloc, bsearch and exit |
6274714d | 4251 | */ |
4252 | fix = { | |
4253 | hackname = sysz_stdlib_for_sun; | |
6274714d | 4254 | files = stdlib.h; |
9119bca7 | 4255 | bypass = "_CLASSIC_ANSI_TYPES"; |
6274714d | 4256 | |
038a3e7a | 4257 | select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\("; |
4258 | c_fix = format; | |
4259 | c_fix_arg = "void *\t%1("; | |
4260 | ||
4261 | test_text = | |
4262 | "extern char*\tcalloc(size_t);\n" | |
4263 | "extern char*\tmalloc(size_t);\n" | |
4264 | "extern char*\trealloc(void*,size_t);\n" | |
4265 | "extern char*\tbsearch(void*,size_t,size_t);\n"; | |
6274714d | 4266 | }; |
4267 | ||
4268 | ||
2a6f0f81 | 4269 | /* |
4270 | * __thread is now a keyword. | |
4271 | */ | |
4272 | fix = { | |
bfdbdaf0 | 4273 | hackname = thread_keyword; |
4274 | files = "pthread.h"; | |
4275 | files = "bits/sigthread.h"; | |
451d3894 | 4276 | select = "([* ])__thread([,)])"; |
bfdbdaf0 | 4277 | c_fix = format; |
451d3894 | 4278 | c_fix_arg = "%1__thr%2"; |
2a6f0f81 | 4279 | |
472b5cb1 | 4280 | test_text = |
4281 | "extern int pthread_create (pthread_t *__restrict __thread,\n" | |
4a2f5ba2 | 4282 | "extern int pthread_kill (pthread_t __thread, int __signo);\n" |
4283 | "extern int pthread_cancel (pthread_t __thread);"; | |
2a6f0f81 | 4284 | }; |
4285 | ||
6274714d | 4286 | /* |
bb304030 | 4287 | * if the #if says _cplusplus, not the double underscore __cplusplus |
4288 | * that it should be | |
6274714d | 4289 | */ |
4290 | fix = { | |
4291 | hackname = tinfo_cplusplus; | |
4292 | files = tinfo.h; | |
bb304030 | 4293 | select = "[ \t]_cplusplus"; |
f74d6549 | 4294 | |
4295 | c_fix = format; | |
4296 | c_fix_arg = " __cplusplus"; | |
4297 | test_text = "#ifdef _cplusplus\nint bogus;\n#endif"; | |
6274714d | 4298 | }; |
4299 | ||
4300 | ||
6274714d | 4301 | /* |
4302 | * parameters not const on DECstation Ultrix V4.0 and OSF/1. | |
4303 | */ | |
4304 | fix = { | |
f74d6549 | 4305 | hackname = ultrix_const; |
4306 | files = stdio.h; | |
4307 | select = 'perror\( char \*'; | |
4308 | ||
4309 | c_fix = format; | |
4310 | c_fix_arg = "%1 const %3 *__"; | |
4311 | c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)" | |
4312 | "[ \t]+(char|void) \\*__"; | |
4313 | ||
4314 | test_text = | |
4315 | "extern void perror( char *__s );\n" | |
4316 | "extern int fputs( char *__s, FILE *);\n" | |
4317 | "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n" | |
4318 | "extern int fscanf( FILE *__stream, char *__format, ...);\n" | |
4319 | "extern int scanf( char *__format, ...);\n"; | |
4320 | }; | |
4321 | ||
4322 | ||
4323 | /* | |
4324 | * parameters not const on DECstation Ultrix V4.0 and OSF/1. | |
4325 | */ | |
4326 | fix = { | |
4327 | hackname = ultrix_const2; | |
4328 | files = stdio.h; | |
4329 | ||
4330 | select = '\*fopen\( char \*'; | |
4331 | c_fix = format; | |
4332 | c_fix_arg = "%1( const char *%3, const char *"; | |
4333 | c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\(" | |
4334 | "[ \t]*char[ \t]*\\*([^,]*)," | |
4335 | "[ \t]*char[ \t]*\\*[ \t]*"; | |
6274714d | 4336 | |
f74d6549 | 4337 | test_text = |
4338 | "extern FILE *fopen( char *__filename, char *__type );\n" | |
4339 | "extern int sscanf( char *__s, char *__format, ...);\n" | |
4340 | "extern FILE *popen(char *, char *);\n" | |
4341 | "extern char *tempnam(char*,char*);\n"; | |
6274714d | 4342 | }; |
4343 | ||
4344 | ||
6274714d | 4345 | /* |
4346 | * Fix definitions of macros used by va-i960.h in VxWorks header file. | |
4347 | */ | |
4348 | fix = { | |
f74d6549 | 4349 | hackname = va_i960_macro; |
4350 | files = arch/i960/archI960.h; | |
4351 | select = "__(vsiz|vali|vpad|alignof__)"; | |
4352 | ||
4353 | c_fix = format; | |
4354 | c_fix_arg = "__vx%1"; | |
4355 | ||
4356 | test_text = | |
4357 | "extern int __vsiz vsiz;\n" | |
4358 | "extern int __vali vali;\n" | |
4359 | "extern int __vpad vpad;\n" | |
4360 | "#define __alignof__(x) ..."; | |
6274714d | 4361 | }; |
4362 | ||
4363 | ||
f13b86b8 | 4364 | /* |
4365 | * Define __CAN_USE_EXTERN_PREFIX on vms. | |
4366 | */ | |
4367 | fix = { | |
4368 | hackname = vms_define_can_use_extern_prefix; | |
4369 | files = "rtldef/decc$types.h"; | |
4370 | select = "#[ \t]*else\n" | |
4371 | "#[ \t]*if defined\\(__DECCXX\\)\n" | |
4372 | "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n"; | |
4373 | mach = "*-*-*vms*"; | |
4374 | c_fix = format; | |
4375 | ||
4376 | c_fix_arg = "%0" | |
4377 | "# elif defined (__GNUC__)\n" | |
4378 | "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"; | |
4379 | ||
4380 | test_text = "# else\n" | |
4381 | "# if defined(__DECCXX)\n" | |
4382 | "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n" | |
4383 | "# endif\n" | |
4384 | "# endif\n"; | |
4385 | }; | |
4386 | ||
4387 | /* | |
4388 | * On VMS, use pragma extern_model instead of VAX-C keywords. | |
4389 | */ | |
4390 | fix = { | |
4391 | hackname = vms_use_pragma_extern_model; | |
4392 | select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n" | |
4393 | "# pragma extern_model __save\n"; | |
4394 | mach = "*-*-*vms*"; | |
4395 | c_fix = format; | |
4396 | ||
4397 | c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n" | |
4398 | "# pragma extern_model __save\n"; | |
4399 | ||
4400 | test_text = "#if defined(__DECC) || defined(__DECCXX)\n" | |
4401 | "# pragma extern_model __save\n" | |
4402 | "# pragma extern_model strict_refdef\n" | |
4403 | " extern struct x zz$yy;\n" | |
4404 | "# pragma extern_model __restore\n" | |
4405 | "#endif\n"; | |
4406 | }; | |
4407 | ||
4408 | /* | |
4409 | * On VMS, disable the use of dec-c string builtins | |
4410 | */ | |
4411 | fix = { | |
4412 | hackname = vms_disable_decc_string_builtins; | |
4413 | select = "#if !defined\\(__VAX\\)\n"; | |
4414 | mach = "*-*-*vms*"; | |
4415 | files = "rtldef/string.h"; | |
4416 | c_fix = format; | |
4417 | ||
4418 | c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n"; | |
4419 | ||
4420 | test_text = "#if !defined(__VAX)\n"; | |
4421 | }; | |
4422 | ||
1e6cd7f6 | 4423 | /* |
4424 | * On VMS, change <resource.h> to <sys/resource.h> to avoid a | |
4425 | * conflict while building gcc. Likewise for <builtins.h> | |
4426 | */ | |
4427 | fix = { | |
4428 | hackname = vms_use_quoted_include; | |
4429 | select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>"; | |
4430 | mach = "*-*-*vms*"; | |
4431 | files = rtldef/wait.h, starlet_c/pthread.h; | |
4432 | c_fix = format; | |
4433 | ||
4434 | c_fix_arg = '%1<sys/%2.h>'; | |
4435 | ||
4436 | test_text = "# include <resource.h>"; | |
4437 | }; | |
4438 | ||
4439 | /* | |
4440 | * On VMS, add missing braces around sigset_t constants. | |
4441 | */ | |
4442 | fix = { | |
4443 | hackname = vms_add_missing_braces; | |
4444 | select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)"; | |
4445 | mach = "*-*-*vms*"; | |
4446 | files = "rtldef/signal.h"; | |
4447 | c_fix = format; | |
4448 | ||
4449 | c_fix_arg = '%1 {%2} '; | |
4450 | ||
4451 | test_text = "static const __sigset_t _SIG_EMPTY_SET = " | |
4452 | "{0x00000000, 0x00000000},\n" | |
4453 | " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n"; | |
4454 | }; | |
4455 | ||
4456 | /* | |
4457 | * On VMS, fix incompatible redeclaration of hostalias. | |
4458 | */ | |
4459 | fix = { | |
4460 | hackname = vms_do_not_redeclare_hostalias; | |
4461 | select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n" | |
4462 | "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)"; | |
4463 | mach = "*-*-*vms*"; | |
4464 | files = "rtldef/resolv.h"; | |
4465 | c_fix = format; | |
4466 | ||
4467 | c_fix_arg = "%1\n" | |
4468 | "/* %2 */"; | |
4469 | ||
4470 | test_text = "void fp_nquery (const u_char *, int, FILE *);\n" | |
4471 | "__char_ptr32 hostalias (const char *);\n"; | |
4472 | }; | |
4473 | ||
4474 | /* | |
4475 | * On VMS, some DEC-C builtins are directly used. | |
4476 | */ | |
4477 | fix = { | |
4478 | hackname = vms_decc_builtin; | |
4479 | select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)"; | |
4480 | mach = "*-*-*vms*"; | |
4481 | files = rtldef/string.h, rtldef/time.h, rtldef/strings.h, | |
4482 | rtldef/socket.h; | |
4483 | sed = "s@__MEMSET@memset@"; | |
4484 | sed = "s@__MEMMOVE@memmove@"; | |
4485 | sed = "s@__MEMCPY@memcpy@"; | |
4486 | sed = "s@__STRLEN@strlen@"; | |
4487 | sed = "s@__STRCPY@strcpy@"; | |
4488 | ||
4489 | test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n"; | |
4490 | }; | |
4491 | ||
4492 | /* | |
4493 | * On VMS, do not declare getopt and al if pointers are 64 bit. | |
4494 | */ | |
4495 | fix = { | |
4496 | hackname = vms_no_64bit_getopt; | |
4497 | select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n"; | |
4498 | /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */ | |
4499 | mach = "*-*-*vms*"; | |
4500 | files = rtldef/stdio.h, rtldef/unistd.h; | |
4501 | c_fix = format; | |
4502 | ||
4503 | c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n" | |
4504 | "%0" | |
4505 | "#endif\n"; | |
4506 | ||
4507 | test_text = "int getopt (int, char * const [], const char *);"; | |
4508 | }; | |
4509 | ||
4510 | /* | |
4511 | * On VMS, forward declare structure before referencing them in prototypes. | |
4512 | */ | |
4513 | fix = { | |
4514 | hackname = vms_forward_declare_struct; | |
4515 | select = "(/\\* forward decls for C\\+\\+ \\*/\n)" | |
4516 | "#ifdef __cplusplus\n"; | |
4517 | mach = "*-*-*vms*"; | |
4518 | files = rtldef/if.h; | |
4519 | c_fix = format; | |
4520 | ||
4521 | c_fix_arg = "%1" | |
4522 | "#if defined (__cplusplus) || defined (__GNUC__)\n"; | |
4523 | ||
4524 | test_text = "/* forward decls for C++ */\n" | |
4525 | "#ifdef __cplusplus\n" | |
4526 | "struct foo;\n" | |
4527 | "#endif\n"; | |
4528 | }; | |
4529 | ||
4530 | /* | |
4531 | * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions | |
4532 | * which is not yet fully supported by gcc. | |
4533 | */ | |
4534 | fix = { | |
4535 | hackname = vms_use_fast_setjmp; | |
4536 | select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)"; | |
4537 | mach = "*-*-*vms*"; | |
4538 | files = rtldef/setjmp.h; | |
4539 | c_fix = format; | |
4540 | ||
4541 | c_fix_arg = "%0 defined (__GNUC__) ||"; | |
4542 | ||
4543 | test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)"; | |
4544 | }; | |
4545 | ||
6274714d | 4546 | /* |
162e05b3 | 4547 | * AIX and Interix headers define NULL to be cast to a void pointer, |
6274714d | 4548 | * which is illegal in ANSI C++. |
4549 | */ | |
4550 | fix = { | |
f74d6549 | 4551 | hackname = void_null; |
4552 | files = curses.h; | |
4553 | files = dbm.h; | |
4554 | files = locale.h; | |
4555 | files = stdio.h; | |
4556 | files = stdlib.h; | |
4557 | files = string.h; | |
4558 | files = time.h; | |
4559 | files = unistd.h; | |
4560 | files = sys/dir.h; | |
4561 | files = sys/param.h; | |
4562 | files = sys/types.h; | |
df2b0bc4 | 4563 | /* avoid changing C++ friendly NULL */ |
4564 | bypass = __cplusplus; | |
f7ac4170 | 4565 | bypass = __null; |
f74d6549 | 4566 | select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)"; |
4567 | c_fix = format; | |
4568 | c_fix_arg = "#define NULL 0"; | |
4569 | test_text = "# define\tNULL \t((void *)0) /* typed NULL */"; | |
6274714d | 4570 | }; |
4571 | ||
4572 | ||
4573 | /* | |
4574 | * Make VxWorks header which is almost gcc ready fully gcc ready. | |
4575 | */ | |
4576 | fix = { | |
4577 | hackname = vxworks_gcc_problem; | |
4578 | files = types/vxTypesBase.h; | |
4579 | select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__"; | |
4580 | ||
4581 | sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/" | |
4582 | "#if 1/"; | |
4583 | ||
4584 | sed = "/[ \t]size_t/i\\\n" | |
4585 | "#ifndef _GCC_SIZE_T\\\n" | |
4586 | "#define _GCC_SIZE_T\n"; | |
4587 | ||
4588 | sed = "/[ \t]size_t/a\\\n" | |
4589 | "#endif\n"; | |
4590 | ||
4591 | sed = "/[ \t]ptrdiff_t/i\\\n" | |
4592 | "#ifndef _GCC_PTRDIFF_T\\\n" | |
4593 | "#define _GCC_PTRDIFF_T\n"; | |
4594 | ||
4595 | sed = "/[ \t]ptrdiff_t/a\\\n" | |
4596 | "#endif\n"; | |
4597 | ||
4598 | sed = "/[ \t]wchar_t/i\\\n" | |
4599 | "#ifndef _GCC_WCHAR_T\\\n" | |
4600 | "#define _GCC_WCHAR_T\n"; | |
4601 | ||
4602 | sed = "/[ \t]wchar_t/a\\\n" | |
4603 | "#endif\n"; | |
f74d6549 | 4604 | |
4605 | test_text = | |
4606 | "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n" | |
4607 | "typedef unsigned int size_t;\n" | |
4608 | "typedef long ptrdiff_t;\n" | |
4609 | "typedef unsigned short wchar_t;\n" | |
4610 | "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n"; | |
6274714d | 4611 | }; |
4612 | ||
74ee6ab5 | 4613 | /* |
4614 | * Wrap VxWorks ioctl to keep everything pretty | |
4615 | */ | |
4616 | fix = { | |
4617 | hackname = vxworks_ioctl_macro; | |
4618 | files = ioLib.h; | |
4619 | mach = "*-*-vxworks*"; | |
4620 | ||
4621 | c_fix = format; | |
4622 | c_fix_arg = "%0\n" | |
4623 | "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n"; | |
4624 | c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);"; | |
4625 | ||
4626 | test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;"; | |
4627 | }; | |
4628 | ||
4629 | /* | |
4630 | * Wrap VxWorks mkdir to be posix compliant | |
4631 | */ | |
4632 | fix = { | |
4633 | hackname = vxworks_mkdir_macro; | |
4634 | files = sys/stat.h; | |
4635 | mach = "*-*-vxworks*"; | |
4636 | ||
4637 | c_fix = format; | |
4638 | c_fix_arg = "%0\n" | |
4639 | "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n"; | |
4640 | c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*" | |
4641 | "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */ | |
4642 | "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */ | |
4643 | "\\)[\t ]*;"; | |
4644 | ||
4645 | test_text = "extern STATUS mkdir (const char * _qwerty) ;"; | |
4646 | }; | |
4647 | ||
6274714d | 4648 | |
4649 | /* | |
4650 | * Fix VxWorks <time.h> to not require including <vxTypes.h>. | |
4651 | */ | |
4652 | fix = { | |
f74d6549 | 4653 | hackname = vxworks_needs_vxtypes; |
4654 | files = time.h; | |
4655 | select = "uint_t([ \t]+_clocks_per_sec)"; | |
4656 | c_fix = format; | |
4657 | c_fix_arg = "unsigned int%1"; | |
85eaefbc | 4658 | test_text = "uint_t\t_clocks_per_sec;"; |
6274714d | 4659 | }; |
4660 | ||
4661 | ||
4662 | /* | |
4663 | * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. | |
4664 | */ | |
4665 | fix = { | |
4666 | hackname = vxworks_needs_vxworks; | |
4667 | files = sys/stat.h; | |
a22ae698 | 4668 | test = " -r types/vxTypesOld.h"; |
4669 | test = " -n \"`egrep '#include' $file`\""; | |
4670 | test = " -n \"`egrep ULONG $file`\""; | |
f74d6549 | 4671 | select = "#[ \t]define[ \t]+__INCstath"; |
6274714d | 4672 | |
4673 | sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" | |
4674 | "#include <types/vxTypesOld.h>\n"; | |
f74d6549 | 4675 | |
4676 | test_text = "`touch types/vxTypesOld.h`" | |
4677 | "#include </dev/null> /* ULONG */\n" | |
4678 | "# define\t__INCstath <sys/stat.h>"; | |
6274714d | 4679 | }; |
4680 | ||
74ee6ab5 | 4681 | /* |
4682 | * Make it so VxWorks does not include gcc/regs.h accidentally | |
4683 | */ | |
4684 | fix = { | |
4685 | hackname = vxworks_regs; | |
4686 | mach = "*-*-vxworks*"; | |
4687 | ||
4688 | select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]"; | |
4689 | c_fix = format; | |
4690 | c_fix_arg = "#include <arch/../regs.h>"; | |
4691 | ||
4692 | test_text = "#include <regs.h>\n"; | |
4693 | }; | |
4694 | ||
6274714d | 4695 | |
4696 | /* | |
4697 | * Another bad dependency in VxWorks 5.2 <time.h>. | |
4698 | */ | |
4699 | fix = { | |
4700 | hackname = vxworks_time; | |
4701 | files = time.h; | |
a22ae698 | 4702 | test = " -r vxWorks.h"; |
6274714d | 4703 | |
f74d6549 | 4704 | select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*"; |
4705 | c_fix = format; | |
4706 | ||
4707 | c_fix_arg = | |
4708 | "#ifndef __gcc_VOIDFUNCPTR_defined\n" | |
4709 | "#ifdef __cplusplus\n" | |
4710 | "typedef void (*__gcc_VOIDFUNCPTR) (...);\n" | |
4711 | "#else\n" | |
4712 | "typedef void (*__gcc_VOIDFUNCPTR) ();\n" | |
4713 | "#endif\n" | |
4714 | "#define __gcc_VOIDFUNCPTR_defined\n" | |
4715 | "#endif\n" | |
4716 | "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR"; | |
4717 | ||
4718 | test_text = "`touch vxWorks.h`" | |
4719 | "#define VOIDFUNCPTR (void(*)())"; | |
6274714d | 4720 | }; |
4721 | ||
74ee6ab5 | 4722 | /* |
4723 | * This hack makes write const-correct on VxWorks | |
4724 | */ | |
4725 | fix = { | |
4726 | hackname = vxworks_write_const; | |
4727 | files = ioLib.h; | |
4728 | mach = "*-*-vxworks*"; | |
4729 | ||
4730 | c_fix = format; | |
4731 | c_fix_arg = "extern int write (int, const char*, size_t);"; | |
4732 | c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\(" | |
4733 | "[\t ]*int[\t ]*," | |
4734 | "[\t ]*char[\t ]*\\*[\t ]*," | |
4735 | "[\t ]*size_t[\t ]*\\)[\t ]*;"; | |
4736 | ||
4737 | test_text = "extern int write ( int , char * , size_t ) ;"; | |
4738 | }; | |
6274714d | 4739 | |
4740 | /* | |
4741 | * There are several name conflicts with C++ reserved words in X11 header | |
4742 | * files. These are fixed in some versions, so don't do the fixes if | |
4743 | * we find __cplusplus in the file. These were found on the RS/6000. | |
4744 | */ | |
4745 | fix = { | |
e7ae4397 | 4746 | hackname = x11_class; |
4747 | files = X11/ShellP.h; | |
4748 | bypass = __cplusplus; | |
4749 | select = "^([ \t]*char \\*)class;(.*)"; | |
4750 | c_fix = format; | |
4751 | c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n" | |
4752 | "#else\n%1class;%2\n#endif"; | |
85eaefbc | 4753 | test_text = |
4754 | "struct {\n" | |
4755 | " char *class;\n" | |
4756 | "} mumble;\n"; | |
6274714d | 4757 | }; |
4758 | ||
4759 | ||
4760 | /* | |
4761 | * class in Xm/BaseClassI.h | |
4762 | */ | |
4763 | fix = { | |
4764 | hackname = x11_class_usage; | |
4765 | files = Xm/BaseClassI.h; | |
4766 | bypass = "__cplusplus"; | |
f74d6549 | 4767 | |
4768 | select = " class\\)"; | |
4769 | c_fix = format; | |
4770 | c_fix_arg = " c_class)"; | |
4771 | ||
85eaefbc | 4772 | test_text = "extern mumble (int class);\n"; |
6274714d | 4773 | }; |
4774 | ||
4775 | ||
4776 | /* | |
4777 | * new in Xm/Traversal.h | |
4778 | */ | |
4779 | fix = { | |
4780 | hackname = x11_new; | |
4781 | files = Xm/Traversal.h; | |
4782 | bypass = __cplusplus; | |
4783 | ||
4784 | sed = "/Widget\told, new;/i\\\n" | |
4785 | "#ifdef __cplusplus\\\n" | |
b795c8d1 | 4786 | "\\\tWidget\told, c_new;\\\n" |
6274714d | 4787 | "#else\n"; |
4788 | ||
4789 | sed = "/Widget\told, new;/a\\\n" | |
4790 | "#endif\n"; | |
4791 | ||
4792 | sed = "s/Widget new,/Widget c_new,/g"; | |
85eaefbc | 4793 | test_text = |
4794 | "struct wedge {\n" | |
b795c8d1 | 4795 | " Widget\told, new;\n" |
85eaefbc | 4796 | "};\nextern Wedged( Widget new, Widget old );"; |
6274714d | 4797 | }; |
4798 | ||
4799 | ||
4800 | /* | |
4801 | * Incorrect sprintf declaration in X11/Xmu.h | |
4802 | */ | |
4803 | fix = { | |
4804 | hackname = x11_sprintf; | |
d6d7d999 | 4805 | files = X11/Xmu.h; |
4806 | files = X11/Xmu/Xmu.h; | |
f74d6549 | 4807 | select = "^extern char \\*\tsprintf\\(\\);$"; |
4808 | ||
4809 | c_fix = format; | |
4810 | c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */"; | |
d6d7d999 | 4811 | |
85eaefbc | 4812 | test_text = "extern char *\tsprintf();"; |
6274714d | 4813 | }; |
4814 | ||
6274714d | 4815 | /*EOF*/ |