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