Mercurial > hg > CbC > CbC_gcc
comparison fixincludes/inclhack.def @ 0:a06113de4d67
first commit
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2009 14:47:48 +0900 |
parents | |
children | 77e2b8dfacca |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a06113de4d67 |
---|---|
1 /* -*- Mode: C -*- */ | |
2 | |
3 autogen definitions fixincl; | |
4 | |
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. | |
7 | |
8 This is the sort command: | |
9 | |
10 blocksort output=inclhack.sorted \ | |
11 pattern='^/\*$' \ | |
12 trailer='^/\*EOF\*[/]' \ | |
13 input=inclhack.def \ | |
14 key='hackname[ ]*=[ ]*(.*);' | |
15 | |
16 Set up a debug test so we can make the templates emit special | |
17 code while debugging these fixes: */ | |
18 | |
19 #ifdef DEBUG | |
20 FIXINC_DEBUG = yes; | |
21 #endif | |
22 | |
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 = { | |
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 | |
62 #endif | |
63 | |
64 _EOArg_; | |
65 }; | |
66 | |
67 | |
68 /* | |
69 * On Mac OS 10.3.9, the 'long double' functions are available in | |
70 * libSystem, but are not prototyped in math.h. | |
71 */ | |
72 fix = { | |
73 hackname = AAB_darwin7_9_long_double_funcs; | |
74 mach = "*-*-darwin7.9*"; | |
75 files = architecture/ppc/math.h; | |
76 bypass = "powl"; | |
77 replace = <<- _EndOfHeader_ | |
78 /* This file prototypes the long double functions available on Mac OS | |
79 10.3.9. */ | |
80 #ifndef __MATH__ | |
81 # undef __APPLE_CC__ | |
82 # define __APPLE_CC__ 1345 | |
83 # include_next <architecture/ppc/math.h> | |
84 # undef __APPLE_CC__ | |
85 # define __APPLE_CC__ 1 | |
86 # ifndef __LIBMLDBL_COMPAT | |
87 # ifdef __LONG_DOUBLE_128__ | |
88 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128") | |
89 # else | |
90 # define __LIBMLDBL_COMPAT(sym) | |
91 # endif /* __LONG_DOUBLE_128__ */ | |
92 # endif /* __LIBMLDBL_COMPAT */ | |
93 # ifdef __cplusplus | |
94 extern "C" { | |
95 # endif | |
96 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl); | |
97 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl); | |
98 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl); | |
99 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l); | |
100 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl); | |
101 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl); | |
102 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl); | |
103 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl); | |
104 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl); | |
105 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl); | |
106 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl); | |
107 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl); | |
108 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl); | |
109 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl); | |
110 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l); | |
111 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l); | |
112 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl); | |
113 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l); | |
114 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l); | |
115 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl); | |
116 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl); | |
117 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl); | |
118 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl); | |
119 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl); | |
120 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl); | |
121 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl); | |
122 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl); | |
123 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl); | |
124 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl); | |
125 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl); | |
126 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl); | |
127 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl); | |
128 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl); | |
129 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl); | |
130 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal); | |
131 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal); | |
132 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill); | |
133 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl); | |
134 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl); | |
135 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl); | |
136 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl); | |
137 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl); | |
138 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl); | |
139 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl); | |
140 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl); | |
141 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl); | |
142 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl); | |
143 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl); | |
144 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol); | |
145 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl); | |
146 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl); | |
147 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl); | |
148 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl); | |
149 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml); | |
150 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl); | |
151 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl); | |
152 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal); | |
153 # ifdef __cplusplus | |
154 } | |
155 # endif | |
156 #endif /* __MATH__ */ | |
157 _EndOfHeader_; | |
158 }; | |
159 | |
160 | |
161 /* | |
162 * ... and for the previous fix to be useful, you have to not use "" | |
163 * includes. | |
164 */ | |
165 fix = { | |
166 hackname = AAB_darwin7_9_long_double_funcs_2; | |
167 mach = "*-*-darwin7.9*"; | |
168 files = math.h; | |
169 select = '#include[ \t]+\"'; | |
170 c_fix = format; | |
171 c_fix_arg = "%1<%2.h>"; | |
172 | |
173 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"'; | |
174 | |
175 test_text = '#include "architecture/ppc/math.h"'; | |
176 }; | |
177 | |
178 | |
179 /* | |
180 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n) | |
181 */ | |
182 fix = { | |
183 hackname = AAB_fd_zero_asm_posix_types_h; | |
184 files = asm/posix_types.h; | |
185 mach = 'i[34567]86-*-linux*'; | |
186 bypass = '} while'; | |
187 bypass = 'x86_64'; | |
188 bypass = 'posix_types_64'; | |
189 | |
190 /* | |
191 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not | |
192 * the start, so that if #include_next gets another instance of | |
193 * the wrapper, this will follow the #include_next chain until | |
194 * we arrive at the real <asm/posix_types.h>. | |
195 */ | |
196 replace = <<- _EndOfHeader_ | |
197 /* This file fixes a bug in the __FD_ZERO macro | |
198 for older versions of the Linux kernel. */ | |
199 #ifndef _POSIX_TYPES_H_WRAPPER | |
200 #include <features.h> | |
201 #include_next <asm/posix_types.h> | |
202 | |
203 #if defined(__FD_ZERO) && !defined(__GLIBC__) | |
204 #undef __FD_ZERO | |
205 #define __FD_ZERO(fdsetp) \ | |
206 do { \ | |
207 int __d0, __d1; \ | |
208 __asm__ __volatile__("cld ; rep ; stosl" \ | |
209 : "=&c" (__d0), "=&D" (__d1) \ | |
210 : "a" (0), "0" (__FDSET_LONGS), \ | |
211 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \ | |
212 } while (0) | |
213 #endif | |
214 | |
215 #define _POSIX_TYPES_H_WRAPPER | |
216 #endif /* _POSIX_TYPES_H_WRAPPER */ | |
217 _EndOfHeader_; | |
218 }; | |
219 | |
220 | |
221 /* | |
222 * This fixes __FD_ZERO bug for glibc-1.x | |
223 */ | |
224 fix = { | |
225 hackname = AAB_fd_zero_gnu_types_h; | |
226 files = gnu/types.h; | |
227 mach = 'i[34567]86-*-linux*'; | |
228 | |
229 /* | |
230 * Define _TYPES_H_WRAPPER at the end of the wrapper, not | |
231 * the start, so that if #include_next gets another instance of | |
232 * the wrapper, this will follow the #include_next chain until | |
233 * we arrive at the real <gnu/types.h>. | |
234 */ | |
235 replace = <<- _EndOfHeader_ | |
236 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ | |
237 #ifndef _TYPES_H_WRAPPER | |
238 #include <features.h> | |
239 #include_next <gnu/types.h> | |
240 | |
241 #if defined(__FD_ZERO) && !defined(__GLIBC__) | |
242 #undef __FD_ZERO | |
243 # define __FD_ZERO(fdsetp) \ | |
244 do { \ | |
245 int __d0, __d1; \ | |
246 __asm__ __volatile__("cld ; rep ; stosl" \ | |
247 : "=&c" (__d0), "=&D" (__d1) \ | |
248 : "a" (0), "0" (__FDSET_LONGS), \ | |
249 "1" ((__fd_set *) (fdsetp)) :"memory"); \ | |
250 } while (0) | |
251 #endif | |
252 | |
253 #define _TYPES_H_WRAPPER | |
254 #endif /* _TYPES_H_WRAPPER */ | |
255 _EndOfHeader_; | |
256 }; | |
257 | |
258 | |
259 /* | |
260 * This fixes __FD_ZERO bug for glibc-2.0.x | |
261 */ | |
262 fix = { | |
263 hackname = AAB_fd_zero_selectbits_h; | |
264 files = selectbits.h; | |
265 mach = 'i[34567]86-*-linux*'; | |
266 | |
267 /* | |
268 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not | |
269 * the start, so that if #include_next gets another instance of | |
270 * the wrapper, this will follow the #include_next chain until | |
271 * we arrive at the real <selectbits.h>. | |
272 */ | |
273 replace = <<- _EndOfHeader_ | |
274 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ | |
275 #ifndef _SELECTBITS_H_WRAPPER | |
276 #include <features.h> | |
277 #include_next <selectbits.h> | |
278 | |
279 #if defined(__FD_ZERO) && defined(__GLIBC__) \\ | |
280 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\ | |
281 && __GLIBC_MINOR__ == 0 | |
282 #undef __FD_ZERO | |
283 #define __FD_ZERO(fdsetp) \\ | |
284 do { \\ | |
285 int __d0, __d1; \\ | |
286 __asm__ __volatile__ ("cld; rep; stosl" \\ | |
287 : "=&c" (__d0), "=&D" (__d1) \\ | |
288 : "a" (0), "0" (sizeof (__fd_set) \\ | |
289 / sizeof (__fd_mask)), \\ | |
290 "1" ((__fd_mask *) (fdsetp)) \\ | |
291 : "memory"); \\ | |
292 } while (0) | |
293 #endif | |
294 | |
295 #define _SELECTBITS_H_WRAPPER | |
296 #endif /* _SELECTBITS_H_WRAPPER */ | |
297 _EndOfHeader_; | |
298 }; | |
299 | |
300 | |
301 /* | |
302 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing | |
303 * the same interface as <stdarg.h>. No idea why they couldn't have just | |
304 * used the standard header. | |
305 */ | |
306 fix = { | |
307 hackname = AAB_solaris_sys_varargs_h; | |
308 files = "sys/varargs.h"; | |
309 mach = '*-*-solaris*'; | |
310 replace = <<- _EndOfHeader_ | |
311 #ifdef __STDC__ | |
312 #include <stdarg.h> | |
313 #else | |
314 #include <varargs.h> | |
315 #endif | |
316 _EndOfHeader_; | |
317 }; | |
318 | |
319 | |
320 /* | |
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin | |
322 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
323 * many other systems have similar text but correct versions of the file. | |
324 * To ensure only Sun's is fixed, we grep for a likely unique string. | |
325 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) | |
326 */ | |
327 fix = { | |
328 hackname = AAB_sun_memcpy; | |
329 files = memory.h; | |
330 select = "/\\*\t@\\(#\\)" | |
331 "(head/memory.h\t50.1\t " | |
332 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/"; | |
333 | |
334 replace = <<- _EndOfHeader_ | |
335 /* This file was generated by fixincludes */ | |
336 #ifndef __memory_h__ | |
337 #define __memory_h__ | |
338 | |
339 #ifdef __STDC__ | |
340 extern void *memccpy(); | |
341 extern void *memchr(); | |
342 extern void *memcpy(); | |
343 extern void *memset(); | |
344 #else | |
345 extern char *memccpy(); | |
346 extern char *memchr(); | |
347 extern char *memcpy(); | |
348 extern char *memset(); | |
349 #endif /* __STDC__ */ | |
350 | |
351 extern int memcmp(); | |
352 | |
353 #endif /* __memory_h__ */ | |
354 _EndOfHeader_; | |
355 }; | |
356 | |
357 | |
358 /* | |
359 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace | |
360 * which violates a requirement of ISO C. | |
361 */ | |
362 fix = { | |
363 hackname = aix_pthread; | |
364 files = "pthread.h"; | |
365 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])"; | |
366 c_fix = format; | |
367 c_fix_arg = "%1 %2"; | |
368 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n" | |
369 "{...init stuff...}"; | |
370 }; | |
371 | |
372 | |
373 /* | |
374 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline | |
375 * in an otherwise harmless (and #ifed out) macro definition | |
376 */ | |
377 fix = { | |
378 hackname = aix_sysmachine; | |
379 files = sys/machine.h; | |
380 select = "\\\\ +\n"; | |
381 c_fix = format; | |
382 c_fix_arg = "\\\n"; | |
383 test_text = "#define FOO \\\n" | |
384 " bar \\ \n baz \\ \n bat"; | |
385 }; | |
386 | |
387 | |
388 /* | |
389 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the | |
390 * definition of struct rusage, so the prototype added by fixproto fails. | |
391 */ | |
392 fix = { | |
393 hackname = aix_syswait; | |
394 files = sys/wait.h; | |
395 select = "^extern pid_t wait3\\(\\);\n"; | |
396 select = "bos325,"; | |
397 c_fix = format; | |
398 c_fix_arg = "struct rusage;\n%0"; | |
399 test_text = "/* bos325, */\n" | |
400 "extern pid_t wait3();\n" | |
401 "\t/* pid_t wait3(int *, int, struct rusage *); */"; | |
402 }; | |
403 | |
404 | |
405 /* | |
406 * sys/wait.h on AIX 5.2 defines macros that have both signed and | |
407 * unsigned types in conditional expressions. | |
408 */ | |
409 fix = { | |
410 hackname = aix_syswait_2; | |
411 files = sys/wait.h; | |
412 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)'; | |
413 c_fix = format; | |
414 c_fix_arg = "? (int)%1"; | |
415 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)"; | |
416 }; | |
417 | |
418 | |
419 /* | |
420 * sys/signal.h on some versions of AIX uses volatile in the typedef of | |
421 * sig_atomic_t, which causes gcc to generate a warning about duplicate | |
422 * volatile when a sig_atomic_t variable is declared volatile, as | |
423 * required by ANSI C. | |
424 */ | |
425 fix = { | |
426 hackname = aix_volatile; | |
427 files = sys/signal.h; | |
428 select = "typedef volatile int sig_atomic_t"; | |
429 c_fix = format; | |
430 c_fix_arg = "typedef int sig_atomic_t"; | |
431 test_text = "typedef volatile int sig_atomic_t;"; | |
432 }; | |
433 | |
434 | |
435 /* | |
436 * Fix __assert declaration in assert.h on Alpha OSF/1. | |
437 */ | |
438 fix = { | |
439 hackname = alpha___assert; | |
440 files = "assert.h"; | |
441 select = '__assert\(char \*, char \*, int\)'; | |
442 c_fix = format; | |
443 c_fix_arg = "__assert(const char *, const char *, int)"; | |
444 test_text = 'extern void __assert(char *, char *, int);'; | |
445 }; | |
446 | |
447 | |
448 /* | |
449 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers. | |
450 */ | |
451 fix = { | |
452 hackname = alpha___extern_prefix; | |
453 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n" | |
454 "(#[ \t]*pragma[ \t]*extern_prefix.*)"; | |
455 | |
456 mach = "alpha*-dec-osf*"; | |
457 c_fix = format; | |
458 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3"; | |
459 | |
460 test_text = "#ifdef __DECC\n" | |
461 "#pragma extern_prefix \"_P\"\n" | |
462 "# if defined(__DECC)\n" | |
463 "# pragma extern_prefix \"_E\"\n" | |
464 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n" | |
465 "# pragma extern_prefix \"\""; | |
466 }; | |
467 | |
468 | |
469 /* | |
470 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>. | |
471 */ | |
472 fix = { | |
473 hackname = alpha___extern_prefix_standards; | |
474 files = standards.h; | |
475 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)"; | |
476 | |
477 mach = "alpha*-dec-osf*"; | |
478 c_fix = format; | |
479 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)"; | |
480 | |
481 test_text = "#if (_ISO_C_SOURCE>=19990L) " | |
482 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)"; | |
483 }; | |
484 | |
485 | |
486 /* | |
487 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and | |
488 * <sys/stat.h>. The tests for __DECC are special in various ways, so | |
489 * alpha__extern_prefix cannot be used. | |
490 */ | |
491 fix = { | |
492 hackname = alpha___extern_prefix_sys_stat; | |
493 files = sys/stat.h; | |
494 files = sys/mount.h; | |
495 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)"; | |
496 | |
497 mach = "alpha*-dec-osf5*"; | |
498 c_fix = format; | |
499 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)"; | |
500 | |
501 test_text = "# if defined(__DECC)"; | |
502 }; | |
503 | |
504 | |
505 /* | |
506 * Fix assert macro in assert.h on Alpha OSF/1. | |
507 * The superfluous int cast breaks C++. | |
508 */ | |
509 fix = { | |
510 hackname = alpha_assert; | |
511 files = "assert.h"; | |
512 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)'; | |
513 c_fix = format; | |
514 c_fix_arg = "%1(EX)"; | |
515 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 ' | |
516 ': __assert(#EX, __FILE__, __LINE__))'; | |
517 }; | |
518 | |
519 | |
520 /* | |
521 * Fix #defines under Alpha OSF/1: | |
522 * The following files contain '#pragma extern_prefix "_FOO"' followed by | |
523 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these | |
524 * statements is to reduce namespace pollution. While these macros work | |
525 * properly in most cases, they don't allow you to take a pointer to the | |
526 * "something" being modified. To get around this limitation, change these | |
527 * statements to be of the form '#define something _FOOsomething'. | |
528 * | |
529 * sed ain't egrep, lesson 2463: sed can use self-referential | |
530 * regular expressions. In the substitute expression below, | |
531 * "\\1" and "\\2" refer to subexpressions found earlier in the | |
532 * same match. So, we continue to use sed. "extern_prefix" will | |
533 * be a rare match anyway... | |
534 */ | |
535 fix = { | |
536 hackname = alpha_bad_lval; | |
537 | |
538 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix"; | |
539 mach = "alpha*-dec-osf*"; | |
540 | |
541 sed = | |
542 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*" | |
543 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/"; | |
544 | |
545 test_text = '#pragma extern_prefix "_FOO"'"\n" | |
546 "#define something(x,y,z) _FOOsomething(x,y,z)\n" | |
547 "#define mumble _FOOmumble"; | |
548 }; | |
549 | |
550 | |
551 /* | |
552 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. | |
553 */ | |
554 fix = { | |
555 hackname = alpha_getopt; | |
556 files = "stdio.h"; | |
557 files = "stdlib.h"; | |
558 select = 'getopt\(int, char \*\[\], *char \*\)'; | |
559 c_fix = format; | |
560 c_fix_arg = "getopt(int, char *const[], const char *)"; | |
561 test_text = 'extern int getopt(int, char *[], char *);'; | |
562 }; | |
563 | |
564 | |
565 /* | |
566 * Fix missing semicolon on Alpha OSF/4 in <net/if.h> | |
567 */ | |
568 fix = { | |
569 hackname = alpha_if_semicolon; | |
570 files = net/if.h; | |
571 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*"; | |
572 c_fix = format; | |
573 c_fix_arg = "struct sockaddr vmif_paddr;\t/*"; | |
574 test_text = ' struct sockaddr vmif_paddr /* protocol address */'; | |
575 }; | |
576 | |
577 | |
578 /* | |
579 * Remove erroneous parentheses in sym.h on Alpha OSF/1. | |
580 */ | |
581 fix = { | |
582 hackname = alpha_parens; | |
583 files = sym.h; | |
584 select = '#ifndef\(__mips64\)'; | |
585 c_fix = format; | |
586 c_fix_arg = "#ifndef __mips64"; | |
587 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif"; | |
588 }; | |
589 | |
590 | |
591 /* | |
592 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>. | |
593 */ | |
594 fix = { | |
595 hackname = alpha_pthread; | |
596 files = pthread.h; | |
597 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)" | |
598 "|def _PTHREAD_ENV_DECC)(.*))\n" | |
599 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)"; | |
600 | |
601 mach = "alpha*-dec-osf*"; | |
602 c_fix = format; | |
603 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 " | |
604 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5"; | |
605 | |
606 test_text = "# if defined (_PTHREAD_ENV_DECC) " | |
607 "|| defined (_PTHREAD_ENV_EPCC)\n" | |
608 "# define _PTHREAD_USE_PTDNAM_\n" | |
609 "# endif\n" | |
610 "# ifdef _PTHREAD_ENV_DECC\n" | |
611 "# define _PTHREAD_USE_PTDNAM_\n" | |
612 "# endif"; | |
613 }; | |
614 | |
615 | |
616 /* | |
617 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>. | |
618 */ | |
619 fix = { | |
620 hackname = alpha_pthread_gcc; | |
621 files = pthread.h; | |
622 select = "#else\n# error <pthread.h>: unrecognized compiler."; | |
623 | |
624 mach = "alpha*-dec-osf*"; | |
625 c_fix = format; | |
626 c_fix_arg = "#elif defined (__GNUC__)\n" | |
627 "# define _PTHREAD_ENV_GCC\n" | |
628 "%0"; | |
629 | |
630 test_text = "# define _PTHREAD_ENV_INTELC\n" | |
631 "#else\n" | |
632 "# error <pthread.h>: unrecognized compiler.\n" | |
633 "#endif"; | |
634 }; | |
635 | |
636 | |
637 /* | |
638 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros | |
639 * incorrectly, specifying less fields in the initializers than are | |
640 * defined in the corresponding structure types. Use of these macros | |
641 * in user code results in spurious warnings. | |
642 */ | |
643 fix = { | |
644 hackname = alpha_pthread_init; | |
645 files = pthread.h; | |
646 select = ' \* @\(#\).RCSfile: pthread\.h,v \$' | |
647 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)' | |
648 ' .Date: 2000/08/15 15:30:13 \$'; | |
649 mach = "alpha*-dec-osf*"; | |
650 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n" | |
651 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n" | |
652 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n" | |
653 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n" | |
654 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n" | |
655 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n"; | |
656 test_text = <<- _EOText_ | |
657 /* | |
658 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $ | |
659 */ | |
660 #ifndef _PTHREAD_NOMETER_STATIC | |
661 # define PTHREAD_MUTEX_INITIALIZER \ | |
662 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA} | |
663 # define PTHREAD_COND_INITIALIZER \ | |
664 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA} | |
665 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \ | |
666 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_} | |
667 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \ | |
668 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_} | |
669 #else | |
670 # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA} | |
671 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \ | |
672 {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_} | |
673 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \ | |
674 {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_} | |
675 #endif | |
676 | |
677 #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA} | |
678 #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \ | |
679 {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_} | |
680 _EOText_; | |
681 }; | |
682 | |
683 | |
684 /* | |
685 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 | |
686 * And OpenBSD. | |
687 */ | |
688 fix = { | |
689 hackname = alpha_sbrk; | |
690 files = unistd.h; | |
691 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; | |
692 c_fix = format; | |
693 c_fix_arg = "void *sbrk("; | |
694 test_text = "extern char* sbrk(ptrdiff_t increment);"; | |
695 }; | |
696 | |
697 | |
698 /* | |
699 * Change external names of wcstok/wcsftime via asm instead of macros on | |
700 * Tru64 UNIX V4.0. | |
701 */ | |
702 fix = { | |
703 hackname = alpha_wchar; | |
704 files = wchar.h; | |
705 | |
706 mach = "alpha*-dec-osf4*"; | |
707 select = "#define wcstok wcstok_r"; | |
708 sed = "s@#define wcstok wcstok_r@" | |
709 "extern wchar_t *wcstok __((wchar_t *, const wchar_t *, " | |
710 "wchar_t **)) __asm__(\"wcstok_r\");@"; | |
711 sed = "s@#define wcsftime __wcsftime_isoc@" | |
712 "extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *" | |
713 ", const struct tm *)) __asm__(\"__wcsftime_isoc\");@"; | |
714 test_text = "#define wcstok wcstok_r\n" | |
715 "#define wcsftime __wcsftime_isoc"; | |
716 }; | |
717 | |
718 | |
719 /* | |
720 * For C++, avoid any typedef or macro definition of bool, | |
721 * and use the built in type instead. | |
722 * HP/UX 10.20 also has it in curses_colr/curses.h. | |
723 */ | |
724 fix = { | |
725 hackname = avoid_bool_define; | |
726 files = curses.h; | |
727 files = curses_colr/curses.h; | |
728 files = term.h; | |
729 files = tinfo.h; | |
730 | |
731 select = "#[ \t]*define[ \t]+bool[ \t]"; | |
732 bypass = "__cplusplus"; | |
733 | |
734 c_fix = format; | |
735 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
736 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*"; | |
737 | |
738 test_text = "# define bool\t char \n"; | |
739 }; | |
740 | |
741 | |
742 fix = { | |
743 hackname = avoid_bool_type; | |
744 files = curses.h; | |
745 files = curses_colr/curses.h; | |
746 files = term.h; | |
747 files = tinfo.h; | |
748 | |
749 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;"; | |
750 bypass = "__cplusplus"; | |
751 | |
752 c_fix = format; | |
753 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
754 | |
755 test_text = "typedef unsigned int\tbool \t; /* bool\n type */"; | |
756 }; | |
757 | |
758 | |
759 /* | |
760 * For C++, avoid any typedef definition of wchar_t, | |
761 * and use the built in type instead. | |
762 * Don't do this for headers that are smart enough to do the right | |
763 * thing (recent [n]curses.h and Xlib.h). | |
764 * Don't do it for <linux/nls.h> which is never used from C++ anyway, | |
765 * and will be broken by the edit. | |
766 */ | |
767 | |
768 fix = { | |
769 hackname = avoid_wchar_t_type; | |
770 | |
771 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;"; | |
772 bypass = "__cplusplus"; | |
773 bypass = "_LINUX_NLS_H"; | |
774 bypass = "XFree86: xc/lib/X11/Xlib\\.h"; | |
775 | |
776 c_fix = format; | |
777 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
778 | |
779 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */"; | |
780 }; | |
781 | |
782 | |
783 /* | |
784 * Fix `typedef struct term;' on hppa1.1-hp-hpux9. | |
785 */ | |
786 fix = { | |
787 hackname = bad_struct_term; | |
788 files = curses.h; | |
789 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;"; | |
790 c_fix = format; | |
791 c_fix_arg = "struct term;"; | |
792 | |
793 test_text = 'typedef struct term;'; | |
794 }; | |
795 | |
796 | |
797 /* | |
798 * Fix one other error in this file: | |
799 * a mismatched quote not inside a C comment. | |
800 */ | |
801 fix = { | |
802 hackname = badquote; | |
803 files = sundev/vuid_event.h; | |
804 select = "doesn't"; | |
805 c_fix = format; | |
806 c_fix_arg = "does not"; | |
807 | |
808 test_text = "/* doesn't have matched single quotes */"; | |
809 }; | |
810 | |
811 | |
812 /* | |
813 * check for broken assert.h that needs stdio.h | |
814 */ | |
815 fix = { | |
816 hackname = broken_assert_stdio; | |
817 files = assert.h; | |
818 select = stderr; | |
819 bypass = "include.*stdio\\.h"; | |
820 c_fix = wrap; | |
821 c_fix_arg = "#include <stdio.h>\n"; | |
822 test_text = "extern FILE* stderr;"; | |
823 }; | |
824 | |
825 | |
826 /* | |
827 * check for broken assert.h that needs stdlib.h | |
828 */ | |
829 fix = { | |
830 hackname = broken_assert_stdlib; | |
831 files = assert.h; | |
832 select = 'exit *\(|abort *\('; | |
833 bypass = "include.*stdlib\\.h"; | |
834 c_fix = wrap; | |
835 c_fix_arg = "#ifdef __cplusplus\n" | |
836 "#include <stdlib.h>\n" | |
837 "#endif\n"; | |
838 test_text = "extern void exit ( int );"; | |
839 }; | |
840 | |
841 | |
842 /* | |
843 * Remove `extern double cabs' declarations from math.h. | |
844 * This conflicts with C99. Discovered on AIX. | |
845 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced) | |
846 * declares cabs() to take a struct __cabs_s argument. | |
847 * SunOS4 has its cabs() declaration followed by a comment which | |
848 * terminates on the following line. | |
849 * Darwin hides its broken cabs in architecture-specific subdirs. | |
850 */ | |
851 fix = { | |
852 hackname = broken_cabs; | |
853 files = math.h, "architecture/*/math.h"; | |
854 select = "^extern[ \t]+double[ \t]+cabs"; | |
855 | |
856 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//"; | |
857 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//"; | |
858 | |
859 test_text = "#ifdef __STDC__\n" | |
860 "extern double cabs(struct dbl_hypot);\n" | |
861 "#else\n" | |
862 "extern double cabs();\n" | |
863 "#endif\n" | |
864 "extern double cabs ( _Complex z );\n" | |
865 "extern double cabs(); /* This is a comment\n" | |
866 " and it ends here. */\n" | |
867 "extern double cabs(struct __cabs_s);\n" | |
868 "extern long double cabsl( struct __cabsl_s );"; | |
869 }; | |
870 | |
871 | |
872 /* | |
873 * Fixup Darwin's broken check for __builtin_nanf. | |
874 */ | |
875 fix = { | |
876 hackname = broken_nan; | |
877 /* | |
878 * It is tempting to omit the first "files" entry. Do not. | |
879 * The testing machinery will take the first "files" entry as the name | |
880 * of a test file to play with. It would be a nuisance to have a directory | |
881 * with the name "*". | |
882 */ | |
883 files = "architecture/ppc/math.h"; | |
884 files = "architecture/*/math.h"; | |
885 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; | |
886 bypass = "powl"; | |
887 c_fix = format; | |
888 c_fix_arg = "#if 1"; | |
889 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; | |
890 }; | |
891 | |
892 | |
893 /* | |
894 * Various systems derived from BSD4.4 contain a macro definition | |
895 * for vfscanf that interacts badly with requirements of builtin-attrs.def. | |
896 * Known to be fixed in FreeBSD 5 system headers. | |
897 */ | |
898 fix = { | |
899 hackname = bsd_stdio_attrs_conflict; | |
900 mach = "*-*-*bsd*"; | |
901 mach = "*-*-*darwin*"; | |
902 files = stdio.h; | |
903 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$"; | |
904 c_fix = format; | |
905 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n" | |
906 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n" | |
907 'int vfscanf(FILE *, const char *, __builtin_va_list) ' | |
908 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");'; | |
909 test_text = '#define vfscanf __svfscanf'; | |
910 }; | |
911 | |
912 | |
913 /* | |
914 * Fix various macros used to define ioctl numbers. | |
915 * The traditional syntax was: | |
916 * | |
917 * #define _CTRL(n, x) (('n'<<8)+x) | |
918 * #define TCTRLCFOO _CTRL(T, 1) | |
919 * | |
920 * but this does not work with the C standard, which disallows macro | |
921 * expansion inside strings. We have to rewrite it thus: | |
922 * | |
923 * #define _CTRL(n, x) ((n<<8)+x) | |
924 * #define TCTRLCFOO _CTRL('T', 1) | |
925 * | |
926 * The select expressions match too much, but the c_fix code is cautious. | |
927 * | |
928 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ... | |
929 */ | |
930 fix = { | |
931 hackname = ctrl_quotes_def; | |
932 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]"; | |
933 c_fix = char_macro_def; | |
934 c_fix_arg = "CTRL"; | |
935 | |
936 /* | |
937 * This is two tests in order to ensure that the "CTRL(c)" can | |
938 * be selected in isolation from the multi-arg format | |
939 */ | |
940 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"; | |
941 test_text = "#define _CTRL(c) ('c'&037)"; | |
942 }; | |
943 | |
944 fix = { | |
945 hackname = ctrl_quotes_use; | |
946 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']"; | |
947 c_fix = char_macro_use; | |
948 c_fix_arg = "CTRL"; | |
949 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)"; | |
950 }; | |
951 | |
952 | |
953 /* | |
954 * sys/mman.h on HP/UX is not C++ ready, | |
955 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. | |
956 * | |
957 * rpc/types.h on OSF1/2.0 is not C++ ready, | |
958 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha. | |
959 * | |
960 * The problem is the declaration of malloc. | |
961 */ | |
962 fix = { | |
963 hackname = cxx_unready; | |
964 files = sys/mman.h; | |
965 files = rpc/types.h; | |
966 select = '[^#]+malloc.*;'; /* Catch any form of declaration | |
967 not within a macro. */ | |
968 bypass = '"C"|__BEGIN_DECLS'; | |
969 | |
970 c_fix = wrap; | |
971 c_fix_arg = "#ifdef __cplusplus\n" | |
972 "extern \"C\" {\n" | |
973 "#endif\n"; | |
974 c_fix_arg = "#ifdef __cplusplus\n" | |
975 "}\n" | |
976 "#endif\n"; | |
977 test_text = "extern void* malloc( size_t );"; | |
978 }; | |
979 | |
980 | |
981 /* | |
982 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded | |
983 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded. | |
984 */ | |
985 fix = { | |
986 hackname = darwin_externc; | |
987 mach = "*-*-darwin*"; | |
988 files = mach-o/swap.h; | |
989 files = mach/mach_time.h; | |
990 files = mach/mach_traps.h; | |
991 files = mach/message.h; | |
992 files = mach/mig.h; | |
993 files = mach/semaphore.h; | |
994 bypass = "extern \"C\""; | |
995 bypass = "__BEGIN_DECLS"; | |
996 c_fix = wrap; | |
997 c_fix_arg = "#ifdef __cplusplus\n" | |
998 "extern \"C\" {\n" | |
999 "#endif\n"; | |
1000 c_fix_arg = "#ifdef __cplusplus\n" | |
1001 "}\n" | |
1002 "#endif\n"; | |
1003 test_text = "extern void swap_fat_header();\n"; | |
1004 }; | |
1005 | |
1006 | |
1007 /* | |
1008 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of | |
1009 * bad __GNUC__ tests. | |
1010 */ | |
1011 | |
1012 fix = { | |
1013 hackname = darwin_gcc4_breakage; | |
1014 mach = "*-*-darwin*"; | |
1015 files = AvailabilityMacros.h; | |
1016 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)"; | |
1017 c_fix = format; | |
1018 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))"; | |
1019 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && " | |
1020 "(__GNUC_MINOR__ >= 1)\n"; | |
1021 }; | |
1022 | |
1023 | |
1024 /* | |
1025 * __private_extern__ doesn't exist in FSF GCC. Even if it did, | |
1026 * why would you ever put it in a system header file? | |
1027 */ | |
1028 fix = { | |
1029 hackname = darwin_private_extern; | |
1030 mach = "*-*-darwin*"; | |
1031 files = mach-o/dyld.h; | |
1032 select = "__private_extern__ [a-z_]+ _dyld_"; | |
1033 c_fix = format; | |
1034 c_fix_arg = "extern"; | |
1035 c_fix_arg = "__private_extern__"; | |
1036 test_text = "__private_extern__ int _dyld_func_lookup(\n" | |
1037 "const char *dyld_func_name,\n" | |
1038 "unsigned long *address);\n"; | |
1039 }; | |
1040 | |
1041 | |
1042 /* | |
1043 * Fix <c_asm.h> on Digital UNIX V4.0: | |
1044 * It contains a prototype for a DEC C internal asm() function, | |
1045 * clashing with gcc's asm keyword. So protect this with __DECC. | |
1046 */ | |
1047 fix = { | |
1048 hackname = dec_intern_asm; | |
1049 files = c_asm.h; | |
1050 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; | |
1051 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" | |
1052 "#endif\n"; | |
1053 test_text = | |
1054 "float fasm {\n" | |
1055 " ... asm stuff ...\n" | |
1056 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/"; | |
1057 }; | |
1058 | |
1059 | |
1060 /* | |
1061 * Fix typo in <wchar.h> on DJGPP 2.03. | |
1062 */ | |
1063 fix = { | |
1064 hackname = djgpp_wchar_h; | |
1065 file = wchar.h; | |
1066 select = "__DJ_wint_t"; | |
1067 bypass = "sys/djtypes.h"; | |
1068 c_fix = format; | |
1069 c_fix_arg = "%0\n#include <sys/djtypes.h>"; | |
1070 c_fix_arg = "#include <stddef.h>"; | |
1071 test_text = "#include <stddef.h>\n" | |
1072 "extern __DJ_wint_t x;\n"; | |
1073 }; | |
1074 | |
1075 | |
1076 /* | |
1077 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. | |
1078 */ | |
1079 fix = { | |
1080 hackname = ecd_cursor; | |
1081 files = "sunwindow/win_lock.h"; | |
1082 files = "sunwindow/win_cursor.h"; | |
1083 select = 'ecd\.cursor'; | |
1084 c_fix = format; | |
1085 c_fix_arg = 'ecd_cursor'; | |
1086 | |
1087 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */"; | |
1088 }; | |
1089 | |
1090 | |
1091 /* | |
1092 * math.h on SunOS 4 puts the declaration of matherr before the definition | |
1093 * of struct exception, so the prototype (added by fixproto) causes havoc. | |
1094 * This must appear before the math_exception fix. | |
1095 */ | |
1096 fix = { | |
1097 hackname = exception_structure; | |
1098 files = math.h; | |
1099 | |
1100 /* If matherr has a prototype already, the header needs no fix. */ | |
1101 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION|[ \t]*__FP_EXCEPTION[ \t]*\*[ \t]*)'; | |
1102 select = matherr; | |
1103 | |
1104 c_fix = wrap; | |
1105 c_fix_arg = "struct exception;\n"; | |
1106 | |
1107 test_text = "extern int matherr();"; | |
1108 }; | |
1109 | |
1110 | |
1111 /* | |
1112 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume | |
1113 * neither the existence of GCC 3 nor its exact feature set yet break | |
1114 * (by design?) when __GNUC__ is set beyond 2. | |
1115 */ | |
1116 fix = { | |
1117 hackname = freebsd_gcc3_breakage; | |
1118 mach = "*-*-freebsd*"; | |
1119 files = sys/cdefs.h; | |
1120 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'; | |
1121 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)'; | |
1122 c_fix = format; | |
1123 c_fix_arg = '%0 || __GNUC__ >= 3'; | |
1124 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7'; | |
1125 }; | |
1126 | |
1127 | |
1128 /* | |
1129 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume | |
1130 * neither the existence of GCC 4 nor its exact feature set yet break | |
1131 * (by design?) when __GNUC__ is set beyond 3. | |
1132 */ | |
1133 fix = { | |
1134 hackname = freebsd_gcc4_breakage; | |
1135 mach = "*-*-freebsd*"; | |
1136 files = sys/cdefs.h; | |
1137 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$'; | |
1138 c_fix = format; | |
1139 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3'; | |
1140 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3'; | |
1141 }; | |
1142 | |
1143 | |
1144 /* | |
1145 * Some versions of glibc don't expect the C99 inline semantics. | |
1146 */ | |
1147 fix = { | |
1148 hackname = glibc_c99_inline_1; | |
1149 files = features.h, '*/features.h'; | |
1150 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$"; | |
1151 c_fix = format; | |
1152 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)"; | |
1153 test_text = <<-EOT | |
1154 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ | |
1155 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ | |
1156 # define __USE_EXTERN_INLINES 1 | |
1157 #endif | |
1158 EOT; | |
1159 }; | |
1160 | |
1161 | |
1162 /* | |
1163 * Similar, but a version that didn't have __NO_INLINE__ | |
1164 */ | |
1165 fix = { | |
1166 hackname = glibc_c99_inline_1a; | |
1167 files = features.h, '*/features.h'; | |
1168 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n" | |
1169 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)"; | |
1170 c_fix = format; | |
1171 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2"; | |
1172 test_text = <<-EOT | |
1173 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ | |
1174 # define __USE_EXTERN_INLINES 1 | |
1175 #endif | |
1176 EOT; | |
1177 }; | |
1178 | |
1179 | |
1180 /* | |
1181 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately | |
1182 * there are many glibc headers which do not respect __USE_EXTERN_INLINES. | |
1183 * The remaining glibc_c99_inline_* fixes deal with some of those headers. | |
1184 */ | |
1185 fix = { | |
1186 hackname = glibc_c99_inline_2; | |
1187 files = sys/stat.h, '*/sys/stat.h'; | |
1188 select = "extern __inline__ int"; | |
1189 sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/" | |
1190 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1191 "__inline__ int \\1/"; | |
1192 sed = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/" | |
1193 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1194 "__inline__ int __REDIRECT\\1 (\\2/"; | |
1195 sed = "s/^extern __inline__ int/" | |
1196 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" | |
1197 "__inline__ int/"; | |
1198 test_text = <<-EOT | |
1199 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); | |
1200 extern __inline__ int | |
1201 __NTH (fstat64 (int __fd, struct stat64 *__statbuf)) | |
1202 {} | |
1203 EOT; | |
1204 }; | |
1205 | |
1206 | |
1207 fix = { | |
1208 hackname = glibc_c99_inline_3; | |
1209 files = bits/string2.h, '*/bits/string2.h'; | |
1210 select = "extern __inline"; | |
1211 bypass = "__extern_inline|__GNU_STDC_INLINE__"; | |
1212 c_fix = format; | |
1213 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)"; | |
1214 c_fix_arg = "^# ifdef __cplusplus$"; | |
1215 test_text = <<-EOT | |
1216 # ifdef __cplusplus | |
1217 # define __STRING_INLINE inline | |
1218 # else | |
1219 # define __STRING_INLINE extern __inline | |
1220 # endif | |
1221 EOT; | |
1222 }; | |
1223 | |
1224 | |
1225 fix = { | |
1226 hackname = glibc_c99_inline_4; | |
1227 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h'; | |
1228 bypass = "__extern_inline|__gnu_inline__"; | |
1229 select = "(^| )extern __inline"; | |
1230 c_fix = format; | |
1231 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))"; | |
1232 test_text = <<-EOT | |
1233 __extension__ extern __inline unsigned int | |
1234 extern __inline unsigned int | |
1235 EOT; | |
1236 }; | |
1237 | |
1238 | |
1239 /* glibc-2.3.5 defines pthread mutex initializers incorrectly, | |
1240 * so we replace them with versions that correspond to the | |
1241 * definition. | |
1242 */ | |
1243 fix = { | |
1244 hackname = glibc_mutex_init; | |
1245 files = pthread.h; | |
1246 select = '\{ *\{ *0, *\} *\}'; | |
1247 sed = "/define[ \t]\\+PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n" | |
1248 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}"; | |
1249 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" | |
1250 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/"; | |
1251 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" | |
1252 "\\(RECURSIVE\\|ERRORCHECK\\|ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/"; | |
1253 sed = "/define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/" | |
1254 "N;s/^[ \t]*#[ \t]*" | |
1255 "\\(define[ \t]\\+PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n" | |
1256 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\n" | |
1257 "# \\1\\n" | |
1258 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\n" | |
1259 "# else\\n" | |
1260 "# \\1\\n" | |
1261 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\n" | |
1262 "# endif/"; | |
1263 sed = "s/{ \\(0, 0, 0, 0, 0, 0, " | |
1264 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/"; | |
1265 sed = "/define[ \t]\\+PTHREAD_COND_INITIALIZER/" | |
1266 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/"; | |
1267 | |
1268 test_text = <<- _EOText_ | |
1269 #define PTHREAD_MUTEX_INITIALIZER \\ | |
1270 { { 0, } } | |
1271 #ifdef __USE_GNU | |
1272 # if __WORDSIZE == 64 | |
1273 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ | |
1274 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } | |
1275 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ | |
1276 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } | |
1277 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ | |
1278 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } | |
1279 # else | |
1280 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ | |
1281 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } | |
1282 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ | |
1283 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } | |
1284 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ | |
1285 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } | |
1286 # endif | |
1287 #endif | |
1288 # define PTHREAD_RWLOCK_INITIALIZER \\ | |
1289 { { 0, } } | |
1290 # ifdef __USE_GNU | |
1291 # if __WORDSIZE == 64 | |
1292 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ | |
1293 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ | |
1294 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } | |
1295 # else | |
1296 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ | |
1297 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } | |
1298 # endif | |
1299 # endif | |
1300 #define PTHREAD_COND_INITIALIZER { { 0, } } | |
1301 _EOText_; | |
1302 }; | |
1303 | |
1304 | |
1305 /* | |
1306 * Fix these files to use the types we think they should for | |
1307 * ptrdiff_t, size_t, and wchar_t. | |
1308 * | |
1309 * This defines the types in terms of macros predefined by our 'cpp'. | |
1310 * This is supposedly necessary for glibc's handling of these types. | |
1311 * It's probably not necessary for anyone else, but it doesn't hurt. | |
1312 */ | |
1313 fix = { | |
1314 hackname = gnu_types; | |
1315 files = "sys/types.h"; | |
1316 files = "stdlib.h"; | |
1317 files = "sys/stdtypes.h"; | |
1318 files = "stddef.h"; | |
1319 files = "memory.h"; | |
1320 files = "unistd.h"; | |
1321 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T'; | |
1322 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;"; | |
1323 c_fix = gnu_type; | |
1324 /* The Solaris 10 headers already define these types correctly. */ | |
1325 mach = '*-*-solaris2.1[0-9]*'; | |
1326 not_machine = true; | |
1327 | |
1328 test_text = "typedef long int ptrdiff_t; /* long int */\n" | |
1329 "typedef uint_t size_t; /* uint_t */\n" | |
1330 "typedef ushort_t wchar_t; /* ushort_t */"; | |
1331 }; | |
1332 | |
1333 | |
1334 /* | |
1335 * Fix HP & Sony's use of "../machine/xxx.h" | |
1336 * to refer to: <machine/xxx.h> | |
1337 */ | |
1338 fix = { | |
1339 hackname = hp_inline; | |
1340 files = sys/spinlock.h; | |
1341 files = machine/machparam.h; | |
1342 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/'; | |
1343 | |
1344 c_fix = format; | |
1345 c_fix_arg = "%1<machine/%2.h>"; | |
1346 | |
1347 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/' | |
1348 '([a-z]+)\.h"'; | |
1349 | |
1350 test_text = ' # include "../machine/mumble.h"'; | |
1351 }; | |
1352 | |
1353 | |
1354 /* | |
1355 * Check for (...) in C++ code in HP/UX sys/file.h. | |
1356 */ | |
1357 fix = { | |
1358 hackname = hp_sysfile; | |
1359 files = sys/file.h; | |
1360 select = "HPUX_SOURCE"; | |
1361 | |
1362 c_fix = format; | |
1363 c_fix_arg = "(struct file *, ...)"; | |
1364 c_fix_arg = '\(\.\.\.\)'; | |
1365 | |
1366 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */"; | |
1367 }; | |
1368 | |
1369 | |
1370 /* | |
1371 * Un-Hide a series of five FP defines from post-1999 compliance GCC: | |
1372 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN | |
1373 */ | |
1374 fix = { | |
1375 hackname = hppa_hpux_fp_macros; | |
1376 mach = "hppa*-hp-hpux11*"; | |
1377 files = math.h; | |
1378 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n" | |
1379 "#[ \t]*define[ \t]*FP_ZERO.*\n" | |
1380 "#[ \t]*define[ \t]*FP_INFINITE.*\n" | |
1381 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n" | |
1382 "#[ \t]*define[ \t]*FP_NAN.*\n"; | |
1383 c_fix = format; | |
1384 c_fix_arg = <<- _EOFix_ | |
1385 #endif /* _INCLUDE_HPUX_SOURCE */ | |
1386 | |
1387 #if defined(_INCLUDE_HPUX_SOURCE) || \ | |
1388 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) | |
1389 %0#endif | |
1390 | |
1391 #ifdef _INCLUDE_HPUX_SOURCE | |
1392 | |
1393 _EOFix_; | |
1394 | |
1395 test_text = | |
1396 "# define FP_NORMAL 0\n" | |
1397 "# define FP_ZERO 1\n" | |
1398 "# define FP_INFINITE 2\n" | |
1399 "# define FP_SUBNORMAL 3\n" | |
1400 "# define FP_NAN 4\n"; | |
1401 }; | |
1402 | |
1403 | |
1404 /* | |
1405 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11 | |
1406 * math.h to prevent clash with define in c_std/bits/std_cmath.h. | |
1407 */ | |
1408 fix = { | |
1409 hackname = hpux10_cpp_pow_inline; | |
1410 files = fixinc-test-limits.h, math.h; | |
1411 select = <<- END_POW_INLINE | |
1412 ^# +ifdef +__cplusplus | |
1413 +\} | |
1414 +inline +double +pow\(double +__d,int +__expon\) +\{ | |
1415 [ ]+return +pow\(__d,\(double\)__expon\); | |
1416 +\} | |
1417 +extern +"C" +\{ | |
1418 #else | |
1419 # +endif | |
1420 END_POW_INLINE; | |
1421 | |
1422 c_fix = format; | |
1423 c_fix_arg = ""; | |
1424 | |
1425 test_text = | |
1426 "# ifdef __cplusplus\n" | |
1427 " }\n" | |
1428 " inline double pow(double __d,int __expon) {\n" | |
1429 "\t return pow(__d,(double)__expon);\n" | |
1430 " }\n" | |
1431 ' extern "C"' " {\n" | |
1432 "#else\n" | |
1433 "# endif"; | |
1434 }; | |
1435 | |
1436 fix = { | |
1437 hackname = hpux11_cpp_pow_inline; | |
1438 files = math.h; | |
1439 select = " +inline double pow\\(double d,int expon\\) \\{\n" | |
1440 " +return pow\\(d, \\(double\\)expon\\);\n" | |
1441 " +\\}\n"; | |
1442 c_fix = format; | |
1443 c_fix_arg = ""; | |
1444 | |
1445 test_text = | |
1446 " inline double pow(double d,int expon) {\n" | |
1447 " return pow(d, (double)expon);\n" | |
1448 " }\n"; | |
1449 }; | |
1450 | |
1451 | |
1452 /* | |
1453 * Fix hpux 10.X missing ctype declarations 1 | |
1454 */ | |
1455 fix = { | |
1456 hackname = hpux10_ctype_declarations1; | |
1457 files = ctype.h; | |
1458 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)"; | |
1459 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\("; | |
1460 c_fix = format; | |
1461 c_fix_arg = "#ifdef _PROTOTYPES\n" | |
1462 "extern int __tolower(int);\n" | |
1463 "extern int __toupper(int);\n" | |
1464 "#else /* NOT _PROTOTYPES */\n" | |
1465 "extern int __tolower();\n" | |
1466 "extern int __toupper();\n" | |
1467 "#endif /* _PROTOTYPES */\n\n" | |
1468 "%0\n"; | |
1469 | |
1470 test_text = "# define _toupper(__c) __toupper(__c)\n"; | |
1471 }; | |
1472 | |
1473 | |
1474 /* | |
1475 * Fix hpux 10.X missing ctype declarations 2 | |
1476 */ | |
1477 fix = { | |
1478 hackname = hpux10_ctype_declarations2; | |
1479 files = ctype.h; | |
1480 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)"; | |
1481 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\("; | |
1482 c_fix = format; | |
1483 c_fix_arg = "%0\n\n" | |
1484 "#ifdef _PROTOTYPES\n" | |
1485 " extern int _isalnum(int);\n" | |
1486 " extern int _isalpha(int);\n" | |
1487 " extern int _iscntrl(int);\n" | |
1488 " extern int _isdigit(int);\n" | |
1489 " extern int _isgraph(int);\n" | |
1490 " extern int _islower(int);\n" | |
1491 " extern int _isprint(int);\n" | |
1492 " extern int _ispunct(int);\n" | |
1493 " extern int _isspace(int);\n" | |
1494 " extern int _isupper(int);\n" | |
1495 " extern int _isxdigit(int);\n" | |
1496 "# else /* not _PROTOTYPES */\n" | |
1497 " extern int _isalnum();\n" | |
1498 " extern int _isalpha();\n" | |
1499 " extern int _iscntrl();\n" | |
1500 " extern int _isdigit();\n" | |
1501 " extern int _isgraph();\n" | |
1502 " extern int _islower();\n" | |
1503 " extern int _isprint();\n" | |
1504 " extern int _ispunct();\n" | |
1505 " extern int _isspace();\n" | |
1506 " extern int _isupper();\n" | |
1507 " extern int _isxdigit();\n" | |
1508 "#endif /* _PROTOTYPES */\n"; | |
1509 | |
1510 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n" | |
1511 " extern unsigned int *__SB_masks;\n"; | |
1512 }; | |
1513 | |
1514 | |
1515 /* | |
1516 * Fix hpux 10.X missing stdio declarations | |
1517 */ | |
1518 fix = { | |
1519 hackname = hpux10_stdio_declarations; | |
1520 files = stdio.h; | |
1521 select = "^#[ \t]*define _iob[ \t]*__iob"; | |
1522 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\("; | |
1523 c_fix = format; | |
1524 c_fix_arg = "%0\n\n" | |
1525 "# if defined(__STDC__) || defined(__cplusplus)\n" | |
1526 " extern int snprintf(char *, size_t, const char *, ...);\n" | |
1527 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n" | |
1528 "# else /* not __STDC__) || __cplusplus */\n" | |
1529 " extern int snprintf();\n" | |
1530 " extern int vsnprintf();\n" | |
1531 "# endif /* __STDC__) || __cplusplus */\n"; | |
1532 | |
1533 test_text = "# define _iob __iob\n"; | |
1534 }; | |
1535 | |
1536 | |
1537 /* | |
1538 * Make sure hpux defines abs in header. | |
1539 */ | |
1540 fix = { | |
1541 hackname = hpux11_abs; | |
1542 mach = "ia64-hp-hpux11*"; | |
1543 files = stdlib.h; | |
1544 select = "ifndef _MATH_INCLUDED"; | |
1545 c_fix = format; | |
1546 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)"; | |
1547 test_text = "#ifndef _MATH_INCLUDED"; | |
1548 }; | |
1549 | |
1550 | |
1551 /* | |
1552 * Keep HP-UX 11 from stomping on C++ math namespace | |
1553 * with defines for fabsf. | |
1554 */ | |
1555 fix = { | |
1556 hackname = hpux11_fabsf; | |
1557 files = math.h; | |
1558 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*"; | |
1559 bypass = "__cplusplus"; | |
1560 | |
1561 c_fix = format; | |
1562 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
1563 | |
1564 test_text = | |
1565 "#ifdef _PA_RISC\n" | |
1566 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n" | |
1567 "#endif"; | |
1568 }; | |
1569 | |
1570 | |
1571 /* | |
1572 * Fix C99 constant in __POINTER_SET define. | |
1573 */ | |
1574 fix = { | |
1575 hackname = hpux11_pthread_const; | |
1576 mach = "*-hp-hpux11.[0-3]*"; | |
1577 files = sys/pthread.h; | |
1578 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)"; | |
1579 | |
1580 c_fix = format; | |
1581 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)"; | |
1582 test_text = "#define __POINTER_SET\t\t((void *) 1LL)"; | |
1583 }; | |
1584 | |
1585 | |
1586 /* | |
1587 * Prevent HP-UX 11 from defining __size_t and preventing size_t from | |
1588 * being defined by having it define _hpux_size_t instead. | |
1589 */ | |
1590 fix = { | |
1591 hackname = hpux11_size_t; | |
1592 mach = "*-hp-hpux11*"; | |
1593 select = "__size_t"; | |
1594 | |
1595 c_fix = format; | |
1596 c_fix_arg = "_hpux_size_t"; | |
1597 | |
1598 test_text = | |
1599 "#define __size_t size_t\n" | |
1600 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n"; | |
1601 }; | |
1602 | |
1603 | |
1604 /* | |
1605 * Fix hpux 11.00 broken snprintf declaration | |
1606 * (third argument is char *, needs to be const char * to prevent | |
1607 * spurious warnings with -Wwrite-strings or in C++). | |
1608 */ | |
1609 fix = { | |
1610 hackname = hpux11_snprintf; | |
1611 files = stdio.h; | |
1612 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)' | |
1613 ' *(char *\*, *\.\.\.\);)'; | |
1614 c_fix = format; | |
1615 c_fix_arg = '%1 const %3'; | |
1616 | |
1617 test_text = "extern int snprintf(char *, size_t, char *, ...);\n" | |
1618 "extern int snprintf(char *, __size_t, char *, ...);\n" | |
1619 "extern int snprintf(char *, _hpux_size_t, char *, ...);"; | |
1620 }; | |
1621 | |
1622 | |
1623 /* | |
1624 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition | |
1625 * of UINT32_C has undefined behavior according to ISO/ANSI: | |
1626 * the arguments to __CONCAT__ are not macro expanded before the | |
1627 * concatination happens so the trailing ')' in the first argument | |
1628 * is concatinated with the 'l' in the second argument creating an | |
1629 * invalid pp token. The behavior of invalid pp tokens is undefined. | |
1630 * GCC does not handle these invalid tokens the way the HP compiler does. | |
1631 * This problem will potentially occur anytime macros are used in the | |
1632 * arguments to __CONCAT__. A general solution to this problem would be to | |
1633 * insert another layer of macro between __CONCAT__ and its use | |
1634 * in UINT32_C. An example of this solution can be found in the C standard. | |
1635 * A more specific solution, the one used here, is to change the UINT32_C | |
1636 * macro to not used macros in the arguments to __CONCAT__. | |
1637 */ | |
1638 fix = { | |
1639 hackname = hpux11_uint32_c; | |
1640 files = inttypes.h; | |
1641 select = "^#define UINT32_C\\(__c\\)[ \t]*" | |
1642 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)"; | |
1643 c_fix = format; | |
1644 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)'; | |
1645 test_text = | |
1646 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n" | |
1647 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)"; | |
1648 }; | |
1649 | |
1650 | |
1651 /* | |
1652 * Fix hpux 11.00 broken vsnprintf declaration | |
1653 */ | |
1654 fix = { | |
1655 hackname = hpux11_vsnprintf; | |
1656 files = stdio.h; | |
1657 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, ' | |
1658 'const char \*,) __va__list\);'; | |
1659 c_fix = format; | |
1660 c_fix_arg = "%1 __va_list);"; | |
1661 | |
1662 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,' | |
1663 ' __va__list);'; | |
1664 }; | |
1665 | |
1666 | |
1667 /* | |
1668 * get rid of bogus inline definitions in HP-UX 8.0 | |
1669 */ | |
1670 fix = { | |
1671 hackname = hpux8_bogus_inlines; | |
1672 files = math.h; | |
1673 select = inline; | |
1674 bypass = "__GNUG__"; | |
1675 sed = "s@inline int abs(int [a-z][a-z]*) {.*}" | |
1676 "@extern \"C\" int abs(int);@"; | |
1677 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@"; | |
1678 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@"; | |
1679 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; | |
1680 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n" | |
1681 "inline double sqr(double v) { return v**0.5; }"; | |
1682 }; | |
1683 | |
1684 | |
1685 /* | |
1686 * Fix hpux broken ctype macros | |
1687 */ | |
1688 fix = { | |
1689 hackname = hpux_ctype_macros; | |
1690 files = ctype.h; | |
1691 select = '((: |\()__SB_masks \? )' | |
1692 '(__SB_masks\[__(alnum|c)\] & _IS)'; | |
1693 c_fix = format; | |
1694 c_fix_arg = "%1(int)%3"; | |
1695 | |
1696 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n" | |
1697 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n"; | |
1698 }; | |
1699 | |
1700 | |
1701 /* | |
1702 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc. | |
1703 */ | |
1704 fix = { | |
1705 hackname = hpux_htonl; | |
1706 files = netinet/in.h; | |
1707 select = "#ifndef _XOPEN_SOURCE_EXTENDED\n" | |
1708 "(/\\*\n" | |
1709 " \\* Macros for number representation conversion\\.\n" | |
1710 " \\*/\n" | |
1711 "#ifndef ntohl)"; | |
1712 c_fix = format; | |
1713 c_fix_arg = "#if 1\n%1"; | |
1714 | |
1715 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n" | |
1716 "/*\n" | |
1717 " * Macros for number representation conversion.\n" | |
1718 " */\n" | |
1719 "#ifndef ntohl\n" | |
1720 "#define ntohl(x) (x)\n" | |
1721 "#define ntohs(x) (x)\n" | |
1722 "#define htonl(x) (x)\n" | |
1723 "#define htons(x) (x)\n" | |
1724 "#endif\n" | |
1725 "#endif /* ! _XOPEN_SOURCE_EXTENDED */"; | |
1726 }; | |
1727 | |
1728 | |
1729 /* | |
1730 * HP-UX long_double | |
1731 */ | |
1732 fix = { | |
1733 hackname = hpux_long_double; | |
1734 files = stdlib.h; | |
1735 select = "extern[ \t]long_double[ \t]strtold"; | |
1736 bypass = "long_double_t"; | |
1737 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D"; | |
1738 sed = "s/long_double/long double/g"; | |
1739 | |
1740 test_text = "# ifndef _LONG_DOUBLE\n" | |
1741 "# define _LONG_DOUBLE\n" | |
1742 " typedef struct {\n" | |
1743 " unsigned int word1, word2, word3, word4;\n" | |
1744 " } long_double;\n" | |
1745 "# endif /* _LONG_DOUBLE */\n" | |
1746 "extern long_double strtold(const char *, char **);\n"; | |
1747 }; | |
1748 | |
1749 | |
1750 /* | |
1751 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl | |
1752 */ | |
1753 fix = { | |
1754 hackname = hpux_systime; | |
1755 files = sys/time.h; | |
1756 select = "^extern struct sigevent;"; | |
1757 | |
1758 c_fix = format; | |
1759 c_fix_arg = "struct sigevent;"; | |
1760 | |
1761 test_text = 'extern struct sigevent;'; | |
1762 }; | |
1763 | |
1764 | |
1765 /* | |
1766 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown | |
1767 * type and mpinfou is only defined when _KERNEL is set. | |
1768 */ | |
1769 fix = { | |
1770 hackname = hpux_spu_info; | |
1771 mach = "*-hp-hpux*"; | |
1772 /* | |
1773 * It is tempting to omit the first "files" entry. Do not. | |
1774 * The testing machinery will take the first "files" entry as the name | |
1775 * of a test file to play with. It would be a nuisance to have a directory | |
1776 * with the name "*". | |
1777 */ | |
1778 files = "ia64/sys/getppdp.h"; | |
1779 files = "*/sys/getppdp.h"; | |
1780 select = "^.*extern.*spu_info.*"; | |
1781 | |
1782 c_fix = format; | |
1783 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif"; | |
1784 | |
1785 test_text = "extern union mpinfou spu_info[];"; | |
1786 }; | |
1787 | |
1788 fix = { | |
1789 hackname = hpux11_extern_sendfile; | |
1790 mach = "*-hp-hpux11.[12]*"; | |
1791 files = sys/socket.h; | |
1792 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n"; | |
1793 c_fix = format; | |
1794 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; | |
1795 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; | |
1796 }; | |
1797 | |
1798 fix = { | |
1799 hackname = hpux11_extern_sendpath; | |
1800 mach = "*-hp-hpux11.[12]*"; | |
1801 files = sys/socket.h; | |
1802 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n"; | |
1803 c_fix = format; | |
1804 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; | |
1805 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; | |
1806 }; | |
1807 | |
1808 fix = { | |
1809 hackname = hpux_extern_errno; | |
1810 mach = "*-hp-hpux10.*"; | |
1811 mach = "*-hp-hpux11.[0-2]*"; | |
1812 files = errno.h; | |
1813 select = "^[ \t]*extern int errno;$"; | |
1814 c_fix = format; | |
1815 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif"; | |
1816 test_text = " extern int errno;\n"; | |
1817 }; | |
1818 | |
1819 | |
1820 /* | |
1821 * Add missing braces to pthread initializer defines. | |
1822 */ | |
1823 fix = { | |
1824 hackname = hpux_pthread_initializers; | |
1825 mach = "*-hp-hpux11.[0-3]*"; | |
1826 files = sys/pthread.h; | |
1827 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\" | |
1828 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@"; | |
1829 sed = "s@^[ \t]*1,[ \t]*\\\\" | |
1830 "@\t{ 1, 0 }@"; | |
1831 sed = "/^[ \t]*0$/d"; | |
1832 sed = "s@__PTHREAD_MUTEX_VALID, 0" | |
1833 "@{ __PTHREAD_MUTEX_VALID, 0 }@"; | |
1834 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\" | |
1835 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@"; | |
1836 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" | |
1837 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; | |
1838 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" | |
1839 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; | |
1840 sed = "s@^[ \t]*0, 0[ \t]*\\\\" | |
1841 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@"; | |
1842 sed = "s@__PTHREAD_COND_VALID, 0" | |
1843 "@{ __PTHREAD_COND_VALID, 0 }@"; | |
1844 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\" | |
1845 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@"; | |
1846 sed = "s@__PTHREAD_RWLOCK_VALID, 0" | |
1847 "@{ __PTHREAD_RWLOCK_VALID, 0 }@"; | |
1848 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\" | |
1849 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@"; | |
1850 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\" | |
1851 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@"; | |
1852 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n" | |
1853 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n" | |
1854 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n" | |
1855 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n" | |
1856 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n" | |
1857 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n" | |
1858 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n" | |
1859 "}\n"; | |
1860 }; | |
1861 | |
1862 /* | |
1863 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant | |
1864 */ | |
1865 fix = { | |
1866 hackname = huge_val_hex; | |
1867 files = bits/huge_val.h; | |
1868 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*"; | |
1869 bypass = "__builtin_huge_val"; | |
1870 | |
1871 c_fix = format; | |
1872 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n"; | |
1873 | |
1874 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)"; | |
1875 }; | |
1876 | |
1877 | |
1878 /* | |
1879 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant | |
1880 */ | |
1881 fix = { | |
1882 hackname = huge_valf_hex; | |
1883 files = bits/huge_val.h; | |
1884 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*"; | |
1885 bypass = "__builtin_huge_valf"; | |
1886 | |
1887 c_fix = format; | |
1888 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n"; | |
1889 | |
1890 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)"; | |
1891 }; | |
1892 | |
1893 | |
1894 /* | |
1895 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant | |
1896 */ | |
1897 fix = { | |
1898 hackname = huge_vall_hex; | |
1899 files = bits/huge_val.h; | |
1900 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*"; | |
1901 bypass = "__builtin_huge_vall"; | |
1902 | |
1903 c_fix = format; | |
1904 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n"; | |
1905 | |
1906 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)"; | |
1907 }; | |
1908 | |
1909 | |
1910 /* | |
1911 * Fix return type of abort and free | |
1912 */ | |
1913 fix = { | |
1914 hackname = int_abort_free_and_exit; | |
1915 files = stdlib.h; | |
1916 select = "int[ \t]+(abort|free|exit)[ \t]*\\("; | |
1917 bypass = "_CLASSIC_ANSI_TYPES"; | |
1918 | |
1919 c_fix = format; | |
1920 c_fix_arg = "void\t%1("; | |
1921 | |
1922 test_text = "extern int abort(int);\n" | |
1923 "extern int free(void*);\n" | |
1924 "extern int exit(void*);"; | |
1925 }; | |
1926 | |
1927 | |
1928 /* | |
1929 * Fix various macros used to define ioctl numbers. | |
1930 * The traditional syntax was: | |
1931 * | |
1932 * #define _IO(n, x) (('n'<<8)+x) | |
1933 * #define TIOCFOO _IO(T, 1) | |
1934 * | |
1935 * but this does not work with the C standard, which disallows macro | |
1936 * expansion inside strings. We have to rewrite it thus: | |
1937 * | |
1938 * #define _IO(n, x) ((n<<8)+x) | |
1939 * #define TIOCFOO _IO('T', 1) | |
1940 * | |
1941 * The select expressions match too much, but the c_fix code is cautious. | |
1942 * | |
1943 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes. | |
1944 */ | |
1945 fix = { | |
1946 hackname = io_quotes_def; | |
1947 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]"; | |
1948 c_fix = char_macro_def; | |
1949 c_fix_arg = "IO"; | |
1950 test_text = | |
1951 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n" | |
1952 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n" | |
1953 "#define _IO(x,y) ('x'<<8|y)"; | |
1954 test_text = | |
1955 "#define XX_IO(x) ('x'<<8|256)"; | |
1956 }; | |
1957 | |
1958 fix = { | |
1959 hackname = io_quotes_use; | |
1960 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*" | |
1961 "\\( *[^,']"; | |
1962 c_fix = char_macro_use; | |
1963 c_fix_arg = "IO"; | |
1964 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n" | |
1965 "#define TIOCFOO \\\\\n" | |
1966 "BSD43__IOWR(T, 1) /* Some are multi-line */"; | |
1967 }; | |
1968 | |
1969 | |
1970 /* | |
1971 * Check for missing ';' in struct | |
1972 */ | |
1973 fix = { | |
1974 hackname = ip_missing_semi; | |
1975 files = netinet/ip.h; | |
1976 select = "}$"; | |
1977 sed = "/^struct/,/^};/s/}$/};/"; | |
1978 test_text= | |
1979 "struct mumble {\n" | |
1980 " union {\n" | |
1981 " int x;\n" | |
1982 " }\n" | |
1983 "}; /* mumbled struct */\n"; | |
1984 }; | |
1985 | |
1986 | |
1987 /* | |
1988 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines | |
1989 * __restrict as restrict iff __c99. This is wrong for C++, which | |
1990 * needs many C99 features, but only supports __restrict. | |
1991 */ | |
1992 fix = { | |
1993 hackname = irix___restrict; | |
1994 files = internal/sgimacros.h; | |
1995 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)"; | |
1996 | |
1997 mach = "mips-sgi-irix6.5"; | |
1998 c_fix = format; | |
1999 c_fix_arg = "%1" | |
2000 "# ifndef __cplusplus\n%2\n# endif"; | |
2001 | |
2002 test_text = "#ifdef __c99\n# define __restrict restrict"; | |
2003 }; | |
2004 | |
2005 /* | |
2006 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic | |
2007 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit | |
2008 * functions. | |
2009 * | |
2010 * This was probably introduced around IRIX 6.5.18 | |
2011 */ | |
2012 fix = { | |
2013 hackname = irix___generic1; | |
2014 files = internal/math_core.h; | |
2015 mach = "mips-sgi-irix6.5"; | |
2016 select = "#define ([a-z]+)\\(x\\) *__generic.*"; | |
2017 | |
2018 c_fix = format; | |
2019 c_fix_arg = "extern int %1(double);\n" | |
2020 "extern int %1f(float);\n" | |
2021 "extern int %1l(long double);\n" | |
2022 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n" | |
2023 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n" | |
2024 " : _%1l(x))\n"; | |
2025 | |
2026 test_text = | |
2027 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n"; | |
2028 }; | |
2029 | |
2030 | |
2031 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI | |
2032 compiler's __generic intrinsic to define isgreater, isgreaterequal, | |
2033 isless, islessequal, islessgreater and isunordered functions. */ | |
2034 fix = { | |
2035 hackname = irix___generic2; | |
2036 files = internal/math_core.h; | |
2037 mach = "mips-sgi-irix6.5"; | |
2038 select = "#define ([a-z]+)\\(x,y\\) *__generic.*"; | |
2039 | |
2040 c_fix = format; | |
2041 c_fix_arg = "#define %1(x,y) \\\n" | |
2042 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n" | |
2043 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n" | |
2044 " : _%1l(x,y))\n"; | |
2045 | |
2046 test_text = | |
2047 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)"; | |
2048 }; | |
2049 | |
2050 | |
2051 /* | |
2052 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction | |
2053 * that causes the assembly preprocessor to complain about an | |
2054 * unterminated character constant. | |
2055 */ | |
2056 fix = { | |
2057 hackname = irix_asm_apostrophe; | |
2058 files = sys/asm.h; | |
2059 | |
2060 select = "^[ \t]*#.*[Ww]e're"; | |
2061 c_fix = format; | |
2062 c_fix_arg = "%1 are"; | |
2063 c_fix_arg = "^([ \t]*#.*[Ww]e)'re"; | |
2064 test_text = "\t# and we're on vacation"; | |
2065 }; | |
2066 | |
2067 | |
2068 /* | |
2069 * Non-traditional "const" declaration in Irix's limits.h. | |
2070 */ | |
2071 fix = { | |
2072 hackname = irix_limits_const; | |
2073 files = fixinc-test-limits.h, limits.h; | |
2074 select = "^extern const "; | |
2075 c_fix = format; | |
2076 c_fix_arg = "extern __const "; | |
2077 test_text = "extern const char limit; /* test limits */"; | |
2078 }; | |
2079 | |
2080 | |
2081 /* | |
2082 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t. | |
2083 * Various socket function prototypes use different types instead, | |
2084 * depending on the API in use (BSD, XPG4/5), but the socklen_t | |
2085 * definition doesn't reflect this (SGI Bug Id 864477, fixed in | |
2086 * IRIX 6.5.19). | |
2087 */ | |
2088 fix = { | |
2089 hackname = irix_socklen_t; | |
2090 files = sys/socket.h; | |
2091 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)"; | |
2092 | |
2093 mach = "mips-sgi-irix6.5"; | |
2094 c_fix = format; | |
2095 c_fix_arg = "%1" | |
2096 "#if _NO_XOPEN4 && _NO_XOPEN5\n" | |
2097 "typedef int socklen_t;\n" | |
2098 "#else\n" | |
2099 "%2\n" | |
2100 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */"; | |
2101 | |
2102 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;"; | |
2103 }; | |
2104 | |
2105 /* | |
2106 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out | |
2107 * otherwise. | |
2108 */ | |
2109 fix = { | |
2110 hackname = irix_stdint_c99; | |
2111 files = stdint.h; | |
2112 select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)"; | |
2113 | |
2114 mach = "mips-sgi-irix6.5"; | |
2115 c_fix = format; | |
2116 c_fix_arg = "#if 0\n" | |
2117 "%2"; | |
2118 test_text = | |
2119 "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else"; | |
2120 }; | |
2121 | |
2122 | |
2123 /* | |
2124 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare | |
2125 * some functions that take a va_list as | |
2126 * taking char *. However, GCC uses void * for va_list, so | |
2127 * calling vfprintf with a va_list fails in C++. */ | |
2128 fix = { | |
2129 hackname = irix_stdio_va_list; | |
2130 files = stdio.h; | |
2131 files = internal/stdio_core.h; | |
2132 | |
2133 select = '/\* va_list \*/ char \*'; | |
2134 c_fix = format; | |
2135 c_fix_arg = "__gnuc_va_list"; | |
2136 test_text = | |
2137 "extern int printf( const char *, /* va_list */ char * );"; | |
2138 }; | |
2139 | |
2140 | |
2141 /* | |
2142 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of | |
2143 * wcsftime by default. ISO C99 requires the XPG5 variant instead. | |
2144 */ | |
2145 fix = { | |
2146 hackname = irix_wcsftime; | |
2147 files = internal/wchar_core.h; | |
2148 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)"; | |
2149 | |
2150 mach = "mips-sgi-irix6.5"; | |
2151 c_fix = format; | |
2152 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1"; | |
2153 | |
2154 test_text = "#if _NO_XOPEN5\n" | |
2155 "extern size_t wcsftime(wchar_t *, " | |
2156 "__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, " | |
2157 "const struct tm *);"; | |
2158 }; | |
2159 | |
2160 /* | |
2161 * Fixing ISC fmod declaration | |
2162 */ | |
2163 fix = { | |
2164 hackname = isc_fmod; | |
2165 files = math.h; | |
2166 select = 'fmod\(double\)'; | |
2167 c_fix = format; | |
2168 c_fix_arg = "fmod(double, double)"; | |
2169 test_text = "extern double fmod(double);"; | |
2170 }; | |
2171 | |
2172 | |
2173 /* | |
2174 * On Interactive Unix 2.2, certain traditional Unix definitions | |
2175 * (notably getc and putc in stdio.h) are omitted if __STDC__ is | |
2176 * defined, not just if _POSIX_SOURCE is defined. This makes it | |
2177 * impossible to compile any nontrivial program except with -posix. | |
2178 */ | |
2179 fix = { | |
2180 hackname = isc_omits_with_stdc; | |
2181 | |
2182 files = "stdio.h"; | |
2183 files = "math.h"; | |
2184 files = "ctype.h"; | |
2185 files = "sys/limits.h"; | |
2186 files = "sys/fcntl.h"; | |
2187 files = "sys/dirent.h"; | |
2188 | |
2189 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)'; | |
2190 c_fix = format; | |
2191 c_fix_arg = '!defined(_POSIX_SOURCE)'; | |
2192 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */" | |
2193 "\nint foo;\n#endif"; | |
2194 }; | |
2195 | |
2196 | |
2197 /* | |
2198 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 | |
2199 * use / * * / to concatenate tokens. | |
2200 */ | |
2201 fix = { | |
2202 hackname = kandr_concat; | |
2203 files = "sparc/asm_linkage.h"; | |
2204 files = "sun*/asm_linkage.h"; | |
2205 files = "arm/as_support.h"; | |
2206 files = "arm/mc_type.h"; | |
2207 files = "arm/xcb.h"; | |
2208 files = "dev/chardefmac.h"; | |
2209 files = "dev/ps_irq.h"; | |
2210 files = "dev/screen.h"; | |
2211 files = "dev/scsi.h"; | |
2212 files = "sys/tty.h"; | |
2213 files = "Xm.acorn/XmP.h"; | |
2214 files = bsd43/bsd43_.h; | |
2215 select = '/\*\*/'; | |
2216 c_fix = format; | |
2217 c_fix_arg = '##'; | |
2218 test_text = "#define __CONCAT__(a,b) a/**/b"; | |
2219 }; | |
2220 | |
2221 | |
2222 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines | |
2223 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time | |
2224 * constant on recent versions of g++. | |
2225 */ | |
2226 fix = { | |
2227 hackname = linux_ia64_ucontext; | |
2228 files = "sys/ucontext.h"; | |
2229 mach = "ia64-*-linux*"; | |
2230 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)' | |
2231 '->sc_gr\[0\]\) - \(char \*\) 0\)'; | |
2232 c_fix = format; | |
2233 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)"; | |
2234 test_text = "# define _SC_GR0_OFFSET\t\\\\\n" | |
2235 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n"; | |
2236 }; | |
2237 | |
2238 | |
2239 /* | |
2240 * Remove header file warning from sys/time.h. Autoconf's | |
2241 * AC_HEADER_TIME recommends to include both sys/time.h and time.h | |
2242 * which causes warning on LynxOS. Remove the warning. | |
2243 */ | |
2244 fix = { | |
2245 hackname = lynxos_no_warning_in_sys_time_h; | |
2246 files = sys/time.h; | |
2247 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>"; | |
2248 c_fix = format; | |
2249 c_fix_arg = ""; | |
2250 test_text = "#warning Using <time.h> instead of <sys/time.h>"; | |
2251 }; | |
2252 | |
2253 | |
2254 /* | |
2255 * Add missing declaration for putenv. | |
2256 */ | |
2257 fix = { | |
2258 hackname = lynxos_missing_putenv; | |
2259 mach = '*-*-lynxos*'; | |
2260 files = stdlib.h; | |
2261 bypass = 'putenv[ \t]*\\('; | |
2262 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; | |
2263 c_fix = format; | |
2264 c_fix_arg = "%0\n" | |
2265 "extern int putenv _AP((char *));"; | |
2266 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; | |
2267 test_text = "extern char *getenv _AP((const char *));"; | |
2268 }; | |
2269 | |
2270 | |
2271 /* | |
2272 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_. | |
2273 * | |
2274 * On NetBSD, machine is a symbolic link to an architecture specific | |
2275 * directory name, so we can't match a specific file name here. | |
2276 */ | |
2277 fix = { | |
2278 hackname = machine_ansi_h_va_list; | |
2279 select = "define[ \t]+_BSD_VA_LIST_[ \t]"; | |
2280 bypass = '__builtin_va_list'; | |
2281 | |
2282 c_fix = format; | |
2283 c_fix_arg = "%1__builtin_va_list"; | |
2284 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*"; | |
2285 | |
2286 test_text = " # define _BSD_VA_LIST_\tchar**"; | |
2287 }; | |
2288 | |
2289 | |
2290 /* | |
2291 * Fix non-ansi machine name defines | |
2292 */ | |
2293 fix = { | |
2294 hackname = machine_name; | |
2295 c_test = machine_name; | |
2296 c_fix = machine_name; | |
2297 | |
2298 test_text = "/* MACH_DIFF: */\n" | |
2299 "#if defined( i386 ) || defined( sparc ) || defined( vax )" | |
2300 "\n/* no uniform test, so be careful :-) */"; | |
2301 }; | |
2302 | |
2303 | |
2304 /* | |
2305 * Some math.h files define struct exception (it's in the System V | |
2306 * Interface Definition), which conflicts with the class exception defined | |
2307 * in the C++ file std/stdexcept.h. We redefine it to __math_exception. | |
2308 * This is not a great fix, but I haven't been able to think of anything | |
2309 * better. Note that we have to put the #ifdef/#endif blocks at beginning | |
2310 * and end of file, because fixproto runs after us and may insert | |
2311 * additional references to struct exception. | |
2312 */ | |
2313 fix = { | |
2314 hackname = math_exception; | |
2315 files = math.h; | |
2316 select = "struct exception"; | |
2317 /* | |
2318 * This should be bypassed on __cplusplus, but some supposedly C++ C++ | |
2319 * aware headers, such as Solaris 8 and 9, don't wrap their struct | |
2320 * exception either. So currently we bypass only for glibc, based on a | |
2321 * comment in the fixed glibc header. Ick. | |
2322 */ | |
2323 bypass = 'We have a problem when using C\+\+|for C\+\+, ' | |
2324 '_[a-z0-9A-Z_]+_exception; for C, exception'; | |
2325 c_fix = wrap; | |
2326 | |
2327 c_fix_arg = "#ifdef __cplusplus\n" | |
2328 "#define exception __math_exception\n" | |
2329 "#endif\n"; | |
2330 | |
2331 c_fix_arg = "#ifdef __cplusplus\n" | |
2332 "#undef exception\n" | |
2333 "#endif\n"; | |
2334 | |
2335 test_text = "typedef struct exception t_math_exception;"; | |
2336 }; | |
2337 | |
2338 | |
2339 /* | |
2340 * This looks pretty broken to me. ``dbl_max_def'' will contain | |
2341 * "define DBL_MAX " at the start, when what we really want is just | |
2342 * the value portion. Can't figure out how to write a test case | |
2343 * for this either :-( | |
2344 */ | |
2345 fix = { | |
2346 hackname = math_huge_val_from_dbl_max; | |
2347 files = math.h; | |
2348 | |
2349 /* | |
2350 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined | |
2351 * in math.h, this fix applies. | |
2352 */ | |
2353 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX"; | |
2354 bypass = "define[ \t]+DBL_MAX"; | |
2355 | |
2356 shell = | |
2357 /* | |
2358 * See if we have a definition for DBL_MAX in float.h. | |
2359 * If we do, we will replace the one in math.h with that one. | |
2360 */ | |
2361 | |
2362 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " | |
2363 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n" | |
2364 | |
2365 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n" | |
2366 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/" | |
2367 "s@DBL_MAX@'\"$dbl_max_def@\"\n" | |
2368 "\telse cat\n" | |
2369 "\tfi"; | |
2370 | |
2371 test_text = | |
2372 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n" | |
2373 "#define HUGE_VAL DBL_MAX"; | |
2374 }; | |
2375 | |
2376 | |
2377 /* | |
2378 * nested comment | |
2379 */ | |
2380 fix = { | |
2381 hackname = nested_auth_des; | |
2382 files = rpc/rpc.h; | |
2383 select = '(/\*.*rpc/auth_des\.h>.*)/\*'; | |
2384 c_fix = format; | |
2385 c_fix_arg = "%1*/ /*"; | |
2386 test_text = "/*#include <rpc/auth_des.h> /* skip this */"; | |
2387 }; | |
2388 | |
2389 | |
2390 /* | |
2391 * Fixing nested comments in ISC <sys/limits.h> | |
2392 */ | |
2393 fix = { | |
2394 hackname = nested_sys_limits; | |
2395 files = sys/limits.h; | |
2396 select = CHILD_MAX; | |
2397 sed = "/CHILD_MAX/s,/\\* Max, Max,"; | |
2398 sed = "/OPEN_MAX/s,/\\* Max, Max,"; | |
2399 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n" | |
2400 "#define OPEN_MAX 20 /* Max, Max, ... */\n"; | |
2401 }; | |
2402 | |
2403 | |
2404 /* | |
2405 * Some versions of NetBSD don't expect the C99 inline semantics. | |
2406 */ | |
2407 fix = { | |
2408 hackname = netbsd_c99_inline_1; | |
2409 mach = "*-*-netbsd*"; | |
2410 files = signal.h; | |
2411 select = "extern __inline int"; | |
2412 | |
2413 c_fix = format; | |
2414 c_fix_arg = "extern\n" | |
2415 "#ifdef __GNUC_STDC_INLINE__\n" | |
2416 "__attribute__((__gnu_inline__))\n" | |
2417 "#endif\n" | |
2418 "__inline int"; | |
2419 | |
2420 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}"; | |
2421 }; | |
2422 | |
2423 | |
2424 fix = { | |
2425 hackname = netbsd_c99_inline_2; | |
2426 mach = "*-*-netbsd*"; | |
2427 files = signal.h; | |
2428 select = "#define _SIGINLINE extern __inline"; | |
2429 | |
2430 c_fix = format; | |
2431 c_fix_arg = <<- _EOArg_ | |
2432 #ifdef __GNUC_STDC_INLINE__ | |
2433 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline | |
2434 #else | |
2435 %0 | |
2436 #endif | |
2437 _EOArg_; | |
2438 | |
2439 test_text = "#define _SIGINLINE extern __inline"; | |
2440 }; | |
2441 | |
2442 | |
2443 /* | |
2444 * NetBSD has a semicolon after the ending '}' for some extern "C". | |
2445 */ | |
2446 fix = { | |
2447 hackname = netbsd_extra_semicolon; | |
2448 mach = "*-*-netbsd*"; | |
2449 files = sys/cdefs.h; | |
2450 select = "#define[ \t]*__END_DECLS[ \t]*};"; | |
2451 | |
2452 c_fix = format; | |
2453 c_fix_arg = "#define __END_DECLS }"; | |
2454 | |
2455 test_text = "#define __END_DECLS };"; | |
2456 }; | |
2457 | |
2458 | |
2459 /* | |
2460 * NeXT 3.2 adds const prefix to some math functions. | |
2461 * These conflict with the built-in functions. | |
2462 */ | |
2463 fix = { | |
2464 hackname = next_math_prefix; | |
2465 files = ansi/math.h; | |
2466 select = "^extern[ \t]+double[ \t]+__const__[ \t]"; | |
2467 | |
2468 c_fix = format; | |
2469 c_fix_arg = "extern double %1("; | |
2470 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\("; | |
2471 | |
2472 test_text = "extern\tdouble\t__const__\tmumble();"; | |
2473 }; | |
2474 | |
2475 | |
2476 /* | |
2477 * NeXT 3.2 uses the word "template" as a parameter for some | |
2478 * functions. GCC reports an invalid use of a reserved key word | |
2479 * with the built-in functions. | |
2480 */ | |
2481 fix = { | |
2482 hackname = next_template; | |
2483 files = bsd/libc.h; | |
2484 select = "[ \t]template\\)"; | |
2485 | |
2486 c_fix = format; | |
2487 c_fix_arg = "(%1)"; | |
2488 c_fix_arg = "\\(([^)]*)[ \t]template\\)"; | |
2489 test_text = "extern mumble( char * template); /* fix */"; | |
2490 }; | |
2491 | |
2492 | |
2493 /* | |
2494 * NeXT 3.2 includes the keyword volatile in the abort() and exit() | |
2495 * function prototypes. That conflicts with the built-in functions. | |
2496 */ | |
2497 fix = { | |
2498 hackname = next_volitile; | |
2499 files = ansi/stdlib.h; | |
2500 select = "^extern[ \t]+volatile[ \t]+void[ \t]"; | |
2501 | |
2502 c_fix = format; | |
2503 c_fix_arg = "extern void %1("; | |
2504 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\("; | |
2505 | |
2506 test_text = "extern\tvolatile\tvoid\tabort();"; | |
2507 }; | |
2508 | |
2509 | |
2510 /* | |
2511 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. | |
2512 * Note that version 3 of the NeXT system has wait.h in a different directory, | |
2513 * so that this code won't do anything. But wait.h in version 3 has a | |
2514 * conditional, so it doesn't need this fix. So everything is okay. | |
2515 */ | |
2516 fix = { | |
2517 hackname = next_wait_union; | |
2518 files = sys/wait.h; | |
2519 | |
2520 select = 'wait\(union wait'; | |
2521 c_fix = format; | |
2522 c_fix_arg = "wait(void"; | |
2523 test_text = "extern pid_d wait(union wait*);"; | |
2524 }; | |
2525 | |
2526 | |
2527 /* | |
2528 * a missing semi-colon at the end of the nodeent structure definition. | |
2529 */ | |
2530 fix = { | |
2531 hackname = nodeent_syntax; | |
2532 files = netdnet/dnetdb.h; | |
2533 select = "char[ \t]*\\*na_addr[ \t]*$"; | |
2534 c_fix = format; | |
2535 c_fix_arg = "%0;"; | |
2536 test_text = "char *na_addr\t"; | |
2537 }; | |
2538 | |
2539 /* | |
2540 * Fix OpenBSD's NULL definition. | |
2541 */ | |
2542 fix = { | |
2543 hackname = openbsd_null_definition; | |
2544 mach = "*-*-openbsd*"; | |
2545 files = locale.h, stddef.h, stdio.h, string.h, | |
2546 time.h, unistd.h, wchar.h, sys/param.h; | |
2547 select = "__GNUG__"; | |
2548 c_fix = format; | |
2549 c_fix_arg = "#ifndef NULL\n" | |
2550 "#ifdef __cplusplus\n" | |
2551 "#ifdef __GNUG__\n" | |
2552 "#define NULL\t__null\n" | |
2553 "#else\t /* ! __GNUG__ */\n" | |
2554 "#define NULL\t0L\n" | |
2555 "#endif\t /* __GNUG__ */\n" | |
2556 "#else\t /* ! __cplusplus */\n" | |
2557 "#define NULL\t((void *)0)\n" | |
2558 "#endif\t /* __cplusplus */\n" | |
2559 "#endif\t /* !NULL */"; | |
2560 | |
2561 c_fix_arg = "^#ifndef[ \t]*NULL\n" | |
2562 "^#ifdef[ \t]*__GNUG__\n" | |
2563 "^#define[ \t]*NULL[ \t]*__null\n" | |
2564 "^#else\n" | |
2565 "^#define[ \t]*NULL[ \t]*0L\n" | |
2566 "^#endif\n" | |
2567 "^#endif"; | |
2568 test_text = | |
2569 "#ifndef NULL\n" | |
2570 "#ifdef __GNUG__\n" | |
2571 "#define NULL __null\n" | |
2572 "#else\n" | |
2573 "#define NULL 0L\n" | |
2574 "#endif\n" | |
2575 "#endif\n"; | |
2576 }; | |
2577 | |
2578 /* | |
2579 * obstack.h used casts as lvalues. | |
2580 * | |
2581 * We need to change postincrements of casted pointers (which are | |
2582 * then dereferenced and assigned into) of the form | |
2583 * | |
2584 * *((TYPE*)PTRVAR)++ = (VALUE) | |
2585 * | |
2586 * into expressions like | |
2587 * | |
2588 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE))) | |
2589 * | |
2590 * which is correct for the cases used in obstack.h since PTRVAR is | |
2591 * of type char * and the value of the expression is not used. | |
2592 */ | |
2593 fix = { | |
2594 hackname = obstack_lvalue_cast; | |
2595 files = obstack.h; | |
2596 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)'; | |
2597 c_fix = format; | |
2598 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))"; | |
2599 test_text = "*((void **) (h)->next_free)++ = (aptr)"; | |
2600 }; | |
2601 | |
2602 /* | |
2603 * Fix OpenBSD's va_start define. | |
2604 */ | |
2605 fix = { | |
2606 hackname = openbsd_va_start; | |
2607 mach = "*-*-openbsd*"; | |
2608 files = stdarg.h; | |
2609 select = '__builtin_stdarg_start'; | |
2610 c_fix = format; | |
2611 c_fix_arg = __builtin_va_start; | |
2612 | |
2613 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)"; | |
2614 }; | |
2615 | |
2616 /* | |
2617 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by | |
2618 * defining regex.h related types. This causes libg++ build and usage | |
2619 * failures. Fixing this correctly requires checking and modifying 3 files. | |
2620 */ | |
2621 fix = { | |
2622 hackname = osf_namespace_a; | |
2623 files = reg_types.h; | |
2624 files = sys/lc_core.h; | |
2625 test = " -r reg_types.h"; | |
2626 test = " -r sys/lc_core.h"; | |
2627 test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
2628 test = " -z \"`grep __regex_t regex.h`\""; | |
2629 | |
2630 c_fix = format; | |
2631 c_fix_arg = "__%0"; | |
2632 c_fix_arg = "reg(ex|off|match)_t"; | |
2633 | |
2634 test_text = "`touch sys/lc_core.h`" | |
2635 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n" | |
2636 "extern regex_t re;\n" | |
2637 "extern regoff_t ro;\n" | |
2638 "extern regmatch_t rm;\n"; | |
2639 }; | |
2640 | |
2641 fix = { | |
2642 hackname = osf_namespace_c; | |
2643 files = regex.h; | |
2644 test = " -r reg_types.h"; | |
2645 test = " -r sys/lc_core.h"; | |
2646 test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
2647 test = " -z \"`grep __regex_t regex.h`\""; | |
2648 | |
2649 select = "#include <reg_types\.h>.*"; | |
2650 c_fix = format; | |
2651 c_fix_arg = "%0\n" | |
2652 "typedef __regex_t\tregex_t;\n" | |
2653 "typedef __regoff_t\tregoff_t;\n" | |
2654 "typedef __regmatch_t\tregmatch_t;"; | |
2655 | |
2656 test_text = "#include <reg_types.h>"; | |
2657 }; | |
2658 | |
2659 | |
2660 /* | |
2661 * Fix __page_size* declarations in pthread.h AIX 4.1.[34]. | |
2662 * The original ones fail if uninitialized externs are not common. | |
2663 * This is the default for all ANSI standard C++ compilers. | |
2664 */ | |
2665 fix = { | |
2666 hackname = pthread_page_size; | |
2667 files = pthread.h; | |
2668 select = "^int __page_size"; | |
2669 c_fix = format; | |
2670 c_fix_arg = "extern %0"; | |
2671 test_text = "int __page_size;"; | |
2672 }; | |
2673 | |
2674 /* | |
2675 * On broken glibc-2.3.3 systems an array of incomplete structures is | |
2676 * passed to __sigsetjmp. Fix that to take a pointer instead. | |
2677 */ | |
2678 fix = { | |
2679 hackname = pthread_incomplete_struct_argument; | |
2680 files = pthread.h; | |
2681 select = "struct __jmp_buf_tag"; | |
2682 c_fix = format; | |
2683 c_fix_arg = "%1 *%2%3"; | |
2684 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$"; | |
2685 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);"; | |
2686 }; | |
2687 | |
2688 /* | |
2689 * Fix return type of fread and fwrite on sysV68 | |
2690 */ | |
2691 fix = { | |
2692 hackname = read_ret_type; | |
2693 files = stdio.h; | |
2694 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)"; | |
2695 c_fix = format; | |
2696 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2"; | |
2697 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)"; | |
2698 | |
2699 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();"; | |
2700 }; | |
2701 | |
2702 | |
2703 /* | |
2704 * Fix casts as lvalues in glibc's <rpc/xdr.h>. | |
2705 */ | |
2706 fix = { | |
2707 hackname = rpc_xdr_lvalue_cast_a; | |
2708 files = rpc/xdr.h; | |
2709 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*"; | |
2710 c_fix = format; | |
2711 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))"; | |
2712 test_text = "#define IXDR_GET_LONG(buf) \\\\\n" | |
2713 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))"; | |
2714 }; | |
2715 | |
2716 | |
2717 fix = { | |
2718 hackname = rpc_xdr_lvalue_cast_b; | |
2719 files = rpc/xdr.h; | |
2720 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*"; | |
2721 c_fix = format; | |
2722 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))"; | |
2723 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n" | |
2724 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))"; | |
2725 }; | |
2726 | |
2727 | |
2728 /* | |
2729 * function class(double x) conflicts with C++ keyword on rs/6000 | |
2730 */ | |
2731 fix = { | |
2732 hackname = rs6000_double; | |
2733 files = math.h; | |
2734 select = '[^a-zA-Z_]class\('; | |
2735 | |
2736 c_fix = format; | |
2737 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; | |
2738 c_fix_arg = '^.*[^a-zA-Z_]class\(.*'; | |
2739 | |
2740 test_text = "extern int class();"; | |
2741 }; | |
2742 | |
2743 | |
2744 /* | |
2745 * Wrong fchmod prototype on RS/6000. | |
2746 */ | |
2747 fix = { | |
2748 hackname = rs6000_fchmod; | |
2749 files = sys/stat.h; | |
2750 select = 'fchmod\(char \*'; | |
2751 c_fix = format; | |
2752 c_fix_arg = "fchmod(int"; | |
2753 test_text = "extern int fchmod(char *, mode_t);"; | |
2754 }; | |
2755 | |
2756 | |
2757 /* | |
2758 * parameters conflict with C++ new on rs/6000 | |
2759 */ | |
2760 fix = { | |
2761 hackname = rs6000_param; | |
2762 files = "stdio.h"; | |
2763 files = "unistd.h"; | |
2764 | |
2765 select = 'rename\(const char \*old, const char \*new\)'; | |
2766 c_fix = format; | |
2767 c_fix_arg = 'rename(const char *_old, const char *_new)'; | |
2768 | |
2769 test_text = 'extern int rename(const char *old, const char *new);'; | |
2770 }; | |
2771 | |
2772 | |
2773 /* | |
2774 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler | |
2775 * __builtin_generic. We fix that usage to use the GCC equivalent. | |
2776 * It also has a plethora of inline functions that conflict with libstdc++. | |
2777 */ | |
2778 fix = { | |
2779 hackname = sco_math; | |
2780 files = math.h, '*/math.h'; | |
2781 select = "inline double abs"; | |
2782 bypass = "__GNUG__"; | |
2783 sed = "/#define.*__fp_class(a) \\\\/i\\\n" | |
2784 "#ifndef __GNUC__\n"; | |
2785 sed = | |
2786 "/.*__builtin_generic/a\\\n" | |
2787 "#else\\\n" | |
2788 "#define __fp_class(a) \\\\\\\n" | |
2789 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n" | |
2790 " __fpclassifyl(a), \\\\\\\n" | |
2791 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n" | |
2792 " __fpclassifyf(a),__fpclassify(a)))\\\n" | |
2793 "#endif"; | |
2794 | |
2795 sed = "/extern \"C\\+\\+\"/N;" | |
2796 "/inline double abs/i\\\n" | |
2797 "#ifndef __GNUC__\n"; | |
2798 sed = "/inline long double trunc/N;" | |
2799 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n" | |
2800 "#endif /* ! __GNUC__ */"; | |
2801 | |
2802 test_text = | |
2803 "#define __fp_class(a) \\\\\n" | |
2804 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n"; | |
2805 | |
2806 }; | |
2807 | |
2808 | |
2809 /* | |
2810 * Sun Solaris 10 defines several C99 math macros in terms of | |
2811 * builtins specific to the Studio compiler, in particular not | |
2812 * compatible with the GNU compiler. | |
2813 */ | |
2814 fix = { | |
2815 hackname = solaris_math_1; | |
2816 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2817 bypass = "__GNUC__"; | |
2818 files = iso/math_c99.h; | |
2819 c_fix = format; | |
2820 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())"; | |
2821 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)"; | |
2822 test_text = | |
2823 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2824 "#undef HUGE_VAL\n" | |
2825 "#define HUGE_VAL __builtin_huge_val\n" | |
2826 "#undef HUGE_VALF\n" | |
2827 "#define HUGE_VALF __builtin_huge_valf\n" | |
2828 "#undef HUGE_VALL\n" | |
2829 "#define HUGE_VALL __builtin_huge_vall"; | |
2830 }; | |
2831 | |
2832 fix = { | |
2833 hackname = solaris_math_2; | |
2834 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2835 bypass = "__GNUC__"; | |
2836 files = iso/math_c99.h; | |
2837 c_fix = format; | |
2838 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())"; | |
2839 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity"; | |
2840 test_text = | |
2841 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2842 "#undef INFINITY\n" | |
2843 "#define INFINITY __builtin_infinity"; | |
2844 }; | |
2845 | |
2846 fix = { | |
2847 hackname = solaris_math_3; | |
2848 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2849 bypass = "__GNUC__"; | |
2850 files = iso/math_c99.h; | |
2851 c_fix = format; | |
2852 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))"; | |
2853 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan"; | |
2854 test_text = | |
2855 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2856 "#undef NAN\n" | |
2857 "#define NAN __builtin_nan"; | |
2858 }; | |
2859 | |
2860 fix = { | |
2861 hackname = solaris_math_4; | |
2862 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2863 bypass = "__GNUC__"; | |
2864 files = iso/math_c99.h; | |
2865 c_fix = format; | |
2866 c_fix_arg = "#define\tfpclassify(x) \\\n" | |
2867 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))"; | |
2868 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)"; | |
2869 test_text = | |
2870 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2871 "#undef fpclassify\n" | |
2872 "#define fpclassify(x) __builtin_fpclassify(x)"; | |
2873 }; | |
2874 | |
2875 fix = { | |
2876 hackname = solaris_math_8; | |
2877 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2878 bypass = "__GNUC__"; | |
2879 files = iso/math_c99.h; | |
2880 c_fix = format; | |
2881 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n" | |
2882 "\t\t\t ? __builtin_signbitf(x) \\\n" | |
2883 "\t\t\t : sizeof(x) == sizeof(long double) \\\n" | |
2884 "\t\t\t ? __builtin_signbitl(x) \\\n" | |
2885 "\t\t\t : __builtin_signbit(x))"; | |
2886 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)"; | |
2887 test_text = | |
2888 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2889 "#undef signbit\n" | |
2890 "#define signbit(x) __builtin_signbit(x)"; | |
2891 }; | |
2892 | |
2893 fix = { | |
2894 hackname = solaris_math_9; | |
2895 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2896 bypass = "__GNUC__"; | |
2897 files = iso/math_c99.h; | |
2898 c_fix = format; | |
2899 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)"; | |
2900 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)"; | |
2901 test_text = | |
2902 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" | |
2903 "#undef isgreater\n" | |
2904 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n" | |
2905 "#undef isgreaterequal\n" | |
2906 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n" | |
2907 "#undef isless\n" | |
2908 "#define isless(x, y) ((x) __builtin_isless(y))\n" | |
2909 "#undef islessequal\n" | |
2910 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n" | |
2911 "#undef islessgreater\n" | |
2912 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n" | |
2913 "#undef isunordered\n" | |
2914 "#define isunordered(x, y) ((x) __builtin_isunordered(y))"; | |
2915 }; | |
2916 | |
2917 /* | |
2918 * On Solaris 11, if you do isinf(NaN) you'll get a floating point | |
2919 * exception. Provide an alternative using GCC's builtin. | |
2920 */ | |
2921 | |
2922 fix = { | |
2923 hackname = solaris_math_10; | |
2924 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2925 files = iso/math_c99.h; | |
2926 c_fix = format; | |
2927 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)"; | |
2928 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n" | |
2929 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n" | |
2930 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n" | |
2931 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)"; | |
2932 test_text = | |
2933 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n" | |
2934 "#undef isinf\n" | |
2935 "#define isinf(x) __extension__( \\\\\n" | |
2936 " { __typeof(x) __x_i = (x); \\\\\n" | |
2937 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n" | |
2938 " __x_i == (__typeof(__x_i)) (-INFINITY); })"; | |
2939 }; | |
2940 | |
2941 /* | |
2942 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing | |
2943 * "0" for the last field of the pthread_mutex_t structure, which is | |
2944 * of type upad64_t, which itself is typedef'd to int64_t, but with | |
2945 * __STDC__ defined (e.g. by -ansi) it is a union. So change the | |
2946 * initializer to "{0}" instead | |
2947 */ | |
2948 fix = { | |
2949 hackname = solaris_mutex_init_2; | |
2950 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2951 files = pthread.h; | |
2952 /* | |
2953 * On Solaris 10, this fix is unnecessary because upad64_t is | |
2954 * always defined correctly regardless of the definition of the | |
2955 * __STDC__ macro. The first "mach" pattern matches up to | |
2956 * solaris9. The second "mach" pattern will not match any two (or | |
2957 * more) digit solaris version, but it will match e.g. 2.5.1. | |
2958 */ | |
2959 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; | |
2960 c_fix = format; | |
2961 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
2962 "%0\n" | |
2963 "#else\n" | |
2964 "%1, {0}}%4\n" | |
2965 "#endif"; | |
2966 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+" | |
2967 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)" | |
2968 ",[ \t]*0\\}" "(|[ \t].*)$"; | |
2969 test_text = | |
2970 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
2971 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n" | |
2972 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n" | |
2973 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n" | |
2974 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n" | |
2975 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n" | |
2976 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}"; | |
2977 }; | |
2978 | |
2979 | |
2980 /* | |
2981 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some | |
2982 * fields of the pthread_rwlock_t structure, which are of type | |
2983 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ | |
2984 * defined (e.g. by -ansi) it is a union. So change the initializer | |
2985 * to "{0}" instead. | |
2986 */ | |
2987 fix = { | |
2988 hackname = solaris_rwlock_init_1; | |
2989 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
2990 files = pthread.h; | |
2991 mach = '*-*-solaris*'; | |
2992 c_fix = format; | |
2993 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
2994 "%0\n" | |
2995 "#else\n" | |
2996 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n" | |
2997 "#endif"; | |
2998 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)" | |
2999 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$"; | |
3000 | |
3001 test_text = | |
3002 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
3003 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}"; | |
3004 }; | |
3005 | |
3006 | |
3007 /* | |
3008 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a | |
3009 * structure. As such, it need two levels of brackets, but only | |
3010 * contains one. Wrap the macro definition in an extra layer. | |
3011 */ | |
3012 fix = { | |
3013 hackname = solaris_once_init_1; | |
3014 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3015 files = pthread.h; | |
3016 mach = '*-*-solaris*'; | |
3017 c_fix = format; | |
3018 c_fix_arg = "%1{%2}%3"; | |
3019 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$"; | |
3020 test_text = | |
3021 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n" | |
3022 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}"; | |
3023 }; | |
3024 | |
3025 | |
3026 /* | |
3027 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some | |
3028 * fields of the pthread_once_t structure, which are of type | |
3029 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ | |
3030 * defined (e.g. by -ansi) it is a union. So change the initializer | |
3031 * to "{0}" instead. This test relies on solaris_once_init_1. | |
3032 */ | |
3033 fix = { | |
3034 hackname = solaris_once_init_2; | |
3035 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; | |
3036 files = pthread.h; | |
3037 /* | |
3038 * On Solaris 10, this fix is unnecessary because upad64_t is | |
3039 * always defined correctly regardless of the definition of the | |
3040 * __STDC__ macro. The first "mach" pattern matches up to | |
3041 * solaris9. The second "mach" pattern will not match any two (or | |
3042 * more) digit solaris version, but it will match e.g. 2.5.1. | |
3043 */ | |
3044 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; | |
3045 c_fix = format; | |
3046 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" | |
3047 "%0\n" | |
3048 "#else\n" | |
3049 "%1{0}, {0}, {0}, {%3}%4\n" | |
3050 "#endif"; | |
3051 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)" | |
3052 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$"; | |
3053 test_text = | |
3054 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" | |
3055 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n"; | |
3056 }; | |
3057 | |
3058 | |
3059 /* | |
3060 * Solaris 2.8 has what appears to be some gross workaround for | |
3061 * some old version of their c++ compiler. G++ doesn't want it | |
3062 * either, but doesn't want to be tied to SunPRO version numbers. | |
3063 */ | |
3064 fix = { | |
3065 hackname = solaris_stdio_tag; | |
3066 files = stdio_tag.h; | |
3067 | |
3068 select = '__cplusplus < 54321L'; | |
3069 /* In Solaris 10, the code in stdio_tag.h is conditionalized on | |
3070 "!defined(__GNUC__)" so we no longer need to fix it. */ | |
3071 bypass = '__GNUC__'; | |
3072 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/'; | |
3073 | |
3074 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)"; | |
3075 }; | |
3076 | |
3077 | |
3078 /* | |
3079 * a missing semi-colon at the end of the statsswtch structure definition. | |
3080 */ | |
3081 fix = { | |
3082 hackname = statsswtch; | |
3083 files = rpcsvc/rstat.h; | |
3084 select = "boottime$"; | |
3085 c_fix = format; | |
3086 c_fix_arg = "boottime;"; | |
3087 test_text = "struct statswtch {\n int boottime\n};"; | |
3088 }; | |
3089 | |
3090 | |
3091 /* | |
3092 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list. | |
3093 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's | |
3094 * OK too. | |
3095 */ | |
3096 fix = { | |
3097 hackname = stdio_stdarg_h; | |
3098 files = stdio.h; | |
3099 bypass = "include.*(stdarg\.h|machine/ansi\.h)"; | |
3100 /* | |
3101 * On Solaris 10, this fix is unncessary; <stdio.h> includes | |
3102 * <iso/stdio_iso.h>, which includes <sys/va_list.h>. | |
3103 */ | |
3104 mach = '*-*-solaris2.1[0-9]*'; | |
3105 not_machine = true; | |
3106 | |
3107 c_fix = wrap; | |
3108 | |
3109 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n"; | |
3110 | |
3111 test_text = ""; | |
3112 }; | |
3113 | |
3114 | |
3115 /* | |
3116 * Don't use or define the name va_list in stdio.h. This is for | |
3117 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence | |
3118 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to | |
3119 * indicate that the header knows what it's doing -- under SUSv2, | |
3120 * stdio.h is required to define va_list, and we shouldn't break | |
3121 * that. On IRIX 6.5, internal/wchar_core.h used to get its | |
3122 * definition of va_list from stdio.h. Since this doesn't happen any | |
3123 * longer, use __gnuc_va_list there, too. | |
3124 */ | |
3125 fix = { | |
3126 hackname = stdio_va_list; | |
3127 files = stdio.h; | |
3128 files = internal/stdio_core.h; | |
3129 files = internal/wchar_core.h; | |
3130 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; | |
3131 /* | |
3132 * On Solaris 10, the definition in | |
3133 * <stdio.h> is guarded appropriately by the _XPG4 feature macro; | |
3134 * there is therefore no need for this fix there. | |
3135 */ | |
3136 mach = '*-*-solaris2.1[0-9]*'; | |
3137 not_machine = true; | |
3138 | |
3139 /* | |
3140 * Use __gnuc_va_list in arg types in place of va_list. | |
3141 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A | |
3142 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the | |
3143 * trailing parentheses and semicolon save all other systems from this. | |
3144 * Define __not_va_list__ (something harmless and unused) | |
3145 * instead of va_list. | |
3146 * Don't claim to have defined va_list. | |
3147 */ | |
3148 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" | |
3149 "s@(va_list)&@(__gnuc_va_list)\\&@\n" | |
3150 "s@ _VA_LIST_));@ __gnuc_va_list));@\n" | |
3151 "s@ __VA_LIST__));@ __gnuc_va_list));@\n" | |
3152 "s@ va_list@ __not_va_list__@\n" | |
3153 "s@\\*va_list@*__not_va_list__@\n" | |
3154 "s@ __va_list)@ __gnuc_va_list)@\n" | |
3155 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" | |
3156 "@typedef \\1 __not_va_list__;@\n" | |
3157 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" | |
3158 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" | |
3159 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" | |
3160 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" | |
3161 "s@VA_LIST@DUMMY_VA_LIST@\n" | |
3162 "s@_Va_LIST@_VA_LIST@"; | |
3163 test_text = "extern void mumble( va_list);"; | |
3164 }; | |
3165 | |
3166 | |
3167 /* | |
3168 * Fix headers that use va_list from stdio.h to use the updated | |
3169 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is | |
3170 * dealt with elsewhere. The presence of __gnuc_va_list, | |
3171 * __DJ_va_list, or _G_va_list is taken to indicate that the header | |
3172 * knows what it's doing. | |
3173 */ | |
3174 fix = { | |
3175 hackname = stdio_va_list_clients; | |
3176 files = com_err.h; | |
3177 files = cps.h; | |
3178 files = curses.h; | |
3179 files = krb5.h; | |
3180 files = lc_core.h; | |
3181 files = pfmt.h; | |
3182 files = wchar.h; | |
3183 files = curses_colr/curses.h; | |
3184 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; | |
3185 /* Don't fix, if we use va_list from stdarg.h, or if the use is | |
3186 otherwise protected. */ | |
3187 bypass = 'include <stdarg\.h>|#ifdef va_start'; | |
3188 | |
3189 /* | |
3190 * Use __gnuc_va_list in arg types in place of va_list. | |
3191 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A | |
3192 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the | |
3193 * trailing parentheses and semicolon save all other systems from this. | |
3194 * Define __not_va_list__ (something harmless and unused) | |
3195 * instead of va_list. | |
3196 * Don't claim to have defined va_list. | |
3197 */ | |
3198 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" | |
3199 "s@(va_list)&@(__gnuc_va_list)\\&@\n" | |
3200 "s@ _VA_LIST_));@ __gnuc_va_list));@\n" | |
3201 "s@ __VA_LIST__));@ __gnuc_va_list));@\n" | |
3202 "s@ va_list@ __not_va_list__@\n" | |
3203 "s@\\*va_list@*__not_va_list__@\n" | |
3204 "s@ __va_list)@ __gnuc_va_list)@\n" | |
3205 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" | |
3206 "@typedef \\1 __not_va_list__;@\n" | |
3207 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" | |
3208 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" | |
3209 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" | |
3210 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" | |
3211 "s@VA_LIST@DUMMY_VA_LIST@\n" | |
3212 "s@_Va_LIST@_VA_LIST@"; | |
3213 test_text = "extern void mumble( va_list);"; | |
3214 }; | |
3215 | |
3216 | |
3217 /* | |
3218 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0" | |
3219 * is "!defined( __STRICT_ANSI__ )" | |
3220 */ | |
3221 fix = { | |
3222 hackname = strict_ansi_not; | |
3223 select = "^([ \t]*#[ \t]*if.*)" | |
3224 "(!__STDC__" | |
3225 "|__STDC__[ \t]*==[ \t]*0" | |
3226 "|__STDC__[ \t]*!=[ \t]*1" | |
3227 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)"; | |
3228 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */ | |
3229 bypass = 'GNU and MIPS C compilers define __STDC__ differently'; | |
3230 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which | |
3231 is not defined by GCC, so it is safe. */ | |
3232 bypass = '__SCO_VERSION__.*__STDC__ != 1'; | |
3233 c_test = stdc_0_in_system_headers; | |
3234 | |
3235 c_fix = format; | |
3236 c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; | |
3237 | |
3238 test_text = "#if !__STDC__ \n" | |
3239 "#if __STDC__ == 0\n" | |
3240 "#if __STDC__ != 1\n" | |
3241 "#if __STDC__ - 0 == 0" | |
3242 "/* not std C */\nint foo;\n" | |
3243 "\n#end-end-end-end-if :-)"; | |
3244 }; | |
3245 | |
3246 /* | |
3247 * "__STDC__-0==0" | |
3248 * is "!defined( __STRICT_ANSI__ )" on continued #if-s | |
3249 */ | |
3250 fix = { | |
3251 hackname = strict_ansi_not_ctd; | |
3252 files = math.h, limits.h, stdio.h, signal.h, | |
3253 stdlib.h, sys/signal.h, time.h; | |
3254 /* | |
3255 * Starting at the beginning of a line, skip white space and | |
3256 * a leading "(" or "&&" or "||". One of those must be found. | |
3257 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&" | |
3258 * expression. If these are nested, then they must accumulate | |
3259 * because we won't match any closing parentheses. Finally, | |
3260 * after skipping over all that, we must then match our suspect | |
3261 * phrase: "__STDC__-0==0" with or without white space. | |
3262 */ | |
3263 select = "^([ \t]*" '(\(|&&|\|\|)' | |
3264 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*" | |
3265 "[ \t(]*)" | |
3266 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)"; | |
3267 c_test = stdc_0_in_system_headers; | |
3268 | |
3269 c_fix = format; | |
3270 c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; | |
3271 | |
3272 test_text = "#if 1 && \\\\\n" | |
3273 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n" | |
3274 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n" | |
3275 "|| __STDC__ - 0 == 0 ) /* not std C */\n" | |
3276 "int foo;\n#endif"; | |
3277 }; | |
3278 | |
3279 | |
3280 /* | |
3281 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1" | |
3282 * is "defined( __STRICT_ANSI__ )" | |
3283 */ | |
3284 fix = { | |
3285 hackname = strict_ansi_only; | |
3286 select = "^([ \t]*#[ \t]*if.*)" | |
3287 "(__STDC__[ \t]*!=[ \t]*0" | |
3288 "|__STDC__[ \t]*==[ \t]*1" | |
3289 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1" | |
3290 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)"; | |
3291 c_test = stdc_0_in_system_headers; | |
3292 | |
3293 c_fix = format; | |
3294 c_fix_arg = "%1 defined(__STRICT_ANSI__)"; | |
3295 | |
3296 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif"; | |
3297 }; | |
3298 | |
3299 | |
3300 /* | |
3301 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s | |
3302 * in prototype without previous definition. | |
3303 */ | |
3304 fix = { | |
3305 hackname = struct_file; | |
3306 files = rpc/xdr.h; | |
3307 select = '^.*xdrstdio_create.*struct __file_s'; | |
3308 c_fix = format; | |
3309 c_fix_arg = "struct __file_s;\n%0"; | |
3310 test_text = "extern void xdrstdio_create( struct __file_s* );"; | |
3311 }; | |
3312 | |
3313 | |
3314 /* | |
3315 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr | |
3316 * in prototype without previous definition. | |
3317 * | |
3318 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same | |
3319 * function, and does define it. | |
3320 */ | |
3321 fix = { | |
3322 hackname = struct_sockaddr; | |
3323 files = rpc/auth.h; | |
3324 select = "^.*authdes_create.*struct sockaddr[^_]"; | |
3325 bypass = "<sys/socket\.h>"; | |
3326 bypass = "struct sockaddr;\n"; | |
3327 c_fix = format; | |
3328 c_fix_arg = "struct sockaddr;\n%0"; | |
3329 test_text = "extern AUTH* authdes_create( struct sockaddr* );"; | |
3330 }; | |
3331 | |
3332 | |
3333 /* | |
3334 * Apply fix this to all OSs since this problem seems to effect | |
3335 * more than just SunOS. | |
3336 */ | |
3337 fix = { | |
3338 hackname = sun_auth_proto; | |
3339 files = rpc/auth.h; | |
3340 files = rpc/clnt.h; | |
3341 files = rpc/svc.h; | |
3342 files = rpc/xdr.h; | |
3343 bypass = "__cplusplus"; | |
3344 /* | |
3345 * Select those files containing '(*name)()'. | |
3346 */ | |
3347 select = '\(\*[a-z][a-z_]*\)\(\)'; | |
3348 | |
3349 c_fix = format; | |
3350 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n" | |
3351 "#else\n%1();%2\n#endif"; | |
3352 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)'; | |
3353 | |
3354 test_text = | |
3355 "struct auth_t {\n" | |
3356 " int (*name)(); /* C++ bad */\n" | |
3357 "};"; | |
3358 }; | |
3359 | |
3360 | |
3361 /* | |
3362 * Fix bogus #ifdef on SunOS 4.1. | |
3363 */ | |
3364 fix = { | |
3365 hackname = sun_bogus_ifdef; | |
3366 files = "hsfs/hsfs_spec.h"; | |
3367 files = "hsfs/iso_spec.h"; | |
3368 select = '#ifdef(.*\|\|.*)'; | |
3369 c_fix = format; | |
3370 c_fix_arg = "#if%1"; | |
3371 | |
3372 test_text = "#ifdef __i386__ || __vax__ || __sun4c__"; | |
3373 }; | |
3374 | |
3375 | |
3376 /* | |
3377 * Fix the CAT macro in SunOS memvar.h. | |
3378 */ | |
3379 fix = { | |
3380 hackname = sun_catmacro; | |
3381 files = pixrect/memvar.h; | |
3382 select = "^#define[ \t]+CAT\\(a,b\\).*"; | |
3383 c_fix = format; | |
3384 | |
3385 c_fix_arg = | |
3386 "#ifdef __STDC__\n" | |
3387 "# define CAT(a,b) a##b\n" | |
3388 "#else\n%0\n#endif"; | |
3389 | |
3390 test_text = | |
3391 "#define CAT(a,b)\ta/**/b"; | |
3392 }; | |
3393 | |
3394 | |
3395 /* | |
3396 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. | |
3397 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 | |
3398 */ | |
3399 fix = { | |
3400 hackname = sun_malloc; | |
3401 files = malloc.h; | |
3402 bypass = "_CLASSIC_ANSI_TYPES"; | |
3403 | |
3404 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g"; | |
3405 sed = "s/int[ \t][ \t]*free/void\tfree/g"; | |
3406 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g"; | |
3407 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g"; | |
3408 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g"; | |
3409 | |
3410 test_text = | |
3411 "typedef char *\tmalloc_t;\n" | |
3412 "int \tfree();\n" | |
3413 "char*\tmalloc();\n" | |
3414 "char*\tcalloc();\n" | |
3415 "char*\trealloc();"; | |
3416 }; | |
3417 | |
3418 | |
3419 /* | |
3420 * Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
3421 */ | |
3422 fix = { | |
3423 hackname = sun_rusers_semi; | |
3424 files = rpcsvc/rusers.h; | |
3425 select = "_cnt$"; | |
3426 sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; | |
3427 test_text = "struct mumble\n int _cnt\n};"; | |
3428 }; | |
3429 | |
3430 | |
3431 /* | |
3432 * signal.h on SunOS defines signal using (), | |
3433 * which causes trouble when compiling with g++ -pedantic. | |
3434 */ | |
3435 fix = { | |
3436 hackname = sun_signal; | |
3437 files = sys/signal.h; | |
3438 files = signal.h; | |
3439 select = "^void\t" '\(\*signal\(\)\)\(\);.*'; | |
3440 | |
3441 c_fix = format; | |
3442 c_fix_arg = | |
3443 "#ifdef __cplusplus\n" | |
3444 "void\t(*signal(...))(...);\n" | |
3445 "#else\n%0\n#endif"; | |
3446 | |
3447 test_text = "void\t(*signal())();"; | |
3448 }; | |
3449 | |
3450 | |
3451 /* | |
3452 * Correct the return type for strlen in strings.h in SunOS 4. | |
3453 */ | |
3454 fix = { | |
3455 hackname = sunos_strlen; | |
3456 files = strings.h; | |
3457 select = "int[ \t]*strlen\\(\\);(.*)"; | |
3458 c_fix = format; | |
3459 c_fix_arg = "__SIZE_TYPE__ strlen();%1"; | |
3460 test_text = " int\tstrlen(); /* string length */"; | |
3461 }; | |
3462 | |
3463 | |
3464 /* | |
3465 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> | |
3466 * that is visible to any ANSI compiler using this include. Simply | |
3467 * delete the lines that #define some string functions to internal forms. | |
3468 */ | |
3469 fix = { | |
3470 hackname = svr4_disable_opt; | |
3471 files = string.h; | |
3472 select = '#define.*__std_hdr_'; | |
3473 sed = '/#define.*__std_hdr_/d'; | |
3474 test_text = "#define strlen __std_hdr_strlen\n"; | |
3475 }; | |
3476 | |
3477 | |
3478 /* | |
3479 * Fix broken decl of getcwd present on some svr4 systems. | |
3480 */ | |
3481 fix = { | |
3482 hackname = svr4_getcwd; | |
3483 files = stdlib.h; | |
3484 files = unistd.h; | |
3485 files = prototypes.h; | |
3486 select = 'getcwd\(char \*, int\)'; | |
3487 | |
3488 c_fix = format; | |
3489 c_fix_arg = "getcwd(char *, size_t)"; | |
3490 | |
3491 test_text = "extern char* getcwd(char *, int);"; | |
3492 }; | |
3493 | |
3494 | |
3495 /* | |
3496 * Fix broken decl of profil present on some svr4 systems. | |
3497 */ | |
3498 fix = { | |
3499 hackname = svr4_profil; | |
3500 files = stdlib.h; | |
3501 files = unistd.h; | |
3502 | |
3503 select = | |
3504 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)'; | |
3505 /* The fix is wrong on IRIX 5/6 and creates a conflict with another | |
3506 prototype in <sys/profil.h>. */ | |
3507 bypass = 'Silicon Graphics'; | |
3508 c_fix = format; | |
3509 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)'; | |
3510 | |
3511 test_text = | |
3512 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);'; | |
3513 }; | |
3514 | |
3515 | |
3516 /* | |
3517 * Correct types for signal handler constants like SIG_DFL; they might be | |
3518 * void (*) (), and should be void (*) (int). C++ doesn't like the | |
3519 * old style. | |
3520 */ | |
3521 fix = { | |
3522 hackname = svr4_sighandler_type; | |
3523 files = sys/signal.h; | |
3524 select = 'void *\(\*\)\(\)'; | |
3525 c_fix = format; | |
3526 c_fix_arg = "void (*)(int)"; | |
3527 test_text = "#define SIG_DFL (void(*)())0\n" | |
3528 "#define SIG_IGN (void (*)())0\n"; | |
3529 }; | |
3530 | |
3531 | |
3532 /* | |
3533 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local | |
3534 * function 'getrnge' in <regexp.h> before they declare it. For these | |
3535 * systems add a 'static int' declaration of 'getrnge' into <regexp.h> | |
3536 * early on. | |
3537 * | |
3538 * 'getrnge' traditionally manipulates a file-scope global called 'size', | |
3539 * so put the declaration right after the declaration of 'size'. | |
3540 * | |
3541 * Don't do this if there is already a `static void getrnge' declaration | |
3542 * present, since this would cause a redeclaration error. Solaris 2.x has | |
3543 * such a declaration. | |
3544 */ | |
3545 fix = { | |
3546 hackname = svr4_undeclared_getrnge; | |
3547 files = regexp.h; | |
3548 select = "getrnge"; | |
3549 bypass = "static void getrnge"; | |
3550 c_fix = format; | |
3551 c_fix_arg = "%0\n" | |
3552 "static int getrnge ();"; | |
3553 c_fix_arg = "^static int[ \t]+size;"; | |
3554 test_text = "static int size;\n" | |
3555 "/* stuff which calls getrnge() */\n" | |
3556 "static getrnge()\n" | |
3557 "{}"; | |
3558 }; | |
3559 | |
3560 | |
3561 /* | |
3562 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} | |
3563 * in string.h on sysV68 | |
3564 * Correct the return type for strlen in string.h on Lynx. | |
3565 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. | |
3566 * Add missing const for strdup on OSF/1 V3.0. | |
3567 * On sysV88 layout is slightly different. | |
3568 */ | |
3569 fix = { | |
3570 hackname = sysv68_string; | |
3571 files = testing.h; | |
3572 files = string.h; | |
3573 bypass = "_CLASSIC_ANSI_TYPES"; | |
3574 | |
3575 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/"; | |
3576 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/"; | |
3577 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/"; | |
3578 | |
3579 sed = "/^extern char$/N"; | |
3580 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/"; | |
3581 | |
3582 sed = "/^extern int$/N"; | |
3583 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/"; | |
3584 | |
3585 sed = "/^\tstrncmp(),$/N"; | |
3586 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/' | |
3587 '\1;' "\\\nextern unsigned int\\\n\\2/"; | |
3588 | |
3589 test_text = | |
3590 "extern int strlen();\n" | |
3591 | |
3592 "extern int ffs(long);\n" | |
3593 | |
3594 "extern char\n" | |
3595 "\t*memccpy(),\n" | |
3596 "\tmemcpy();\n" | |
3597 | |
3598 "extern int\n" | |
3599 "\tstrcmp(),\n" | |
3600 "\tstrncmp(),\n" | |
3601 "\tstrlen(),\n" | |
3602 "\tstrspn();\n" | |
3603 | |
3604 "extern int\n" | |
3605 "\tstrlen(), strspn();"; | |
3606 }; | |
3607 | |
3608 | |
3609 /* | |
3610 * Fix return type of calloc, malloc, realloc, bsearch and exit | |
3611 */ | |
3612 fix = { | |
3613 hackname = sysz_stdlib_for_sun; | |
3614 files = stdlib.h; | |
3615 bypass = "_CLASSIC_ANSI_TYPES"; | |
3616 | |
3617 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\("; | |
3618 c_fix = format; | |
3619 c_fix_arg = "void *\t%1("; | |
3620 | |
3621 test_text = | |
3622 "extern char*\tcalloc(size_t);\n" | |
3623 "extern char*\tmalloc(size_t);\n" | |
3624 "extern char*\trealloc(void*,size_t);\n" | |
3625 "extern char*\tbsearch(void*,size_t,size_t);\n"; | |
3626 }; | |
3627 | |
3628 | |
3629 /* | |
3630 * __thread is now a keyword. | |
3631 */ | |
3632 fix = { | |
3633 hackname = thread_keyword; | |
3634 files = "pthread.h"; | |
3635 files = "bits/sigthread.h"; | |
3636 select = "([* ])__thread([,)])"; | |
3637 c_fix = format; | |
3638 c_fix_arg = "%1__thr%2"; | |
3639 | |
3640 test_text = | |
3641 "extern int pthread_create (pthread_t *__restrict __thread,\n" | |
3642 "extern int pthread_kill (pthread_t __thread, int __signo);\n" | |
3643 "extern int pthread_cancel (pthread_t __thread);"; | |
3644 }; | |
3645 | |
3646 /* | |
3647 * if the #if says _cplusplus, not the double underscore __cplusplus | |
3648 * that it should be | |
3649 */ | |
3650 fix = { | |
3651 hackname = tinfo_cplusplus; | |
3652 files = tinfo.h; | |
3653 select = "[ \t]_cplusplus"; | |
3654 | |
3655 c_fix = format; | |
3656 c_fix_arg = " __cplusplus"; | |
3657 test_text = "#ifdef _cplusplus\nint bogus;\n#endif"; | |
3658 }; | |
3659 | |
3660 | |
3661 /* | |
3662 * parameters not const on DECstation Ultrix V4.0 and OSF/1. | |
3663 */ | |
3664 fix = { | |
3665 hackname = ultrix_const; | |
3666 files = stdio.h; | |
3667 select = 'perror\( char \*'; | |
3668 | |
3669 c_fix = format; | |
3670 c_fix_arg = "%1 const %3 *__"; | |
3671 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)" | |
3672 "[ \t]+(char|void) \\*__"; | |
3673 | |
3674 test_text = | |
3675 "extern void perror( char *__s );\n" | |
3676 "extern int fputs( char *__s, FILE *);\n" | |
3677 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n" | |
3678 "extern int fscanf( FILE *__stream, char *__format, ...);\n" | |
3679 "extern int scanf( char *__format, ...);\n"; | |
3680 }; | |
3681 | |
3682 | |
3683 /* | |
3684 * parameters not const on DECstation Ultrix V4.0 and OSF/1. | |
3685 */ | |
3686 fix = { | |
3687 hackname = ultrix_const2; | |
3688 files = stdio.h; | |
3689 | |
3690 select = '\*fopen\( char \*'; | |
3691 c_fix = format; | |
3692 c_fix_arg = "%1( const char *%3, const char *"; | |
3693 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\(" | |
3694 "[ \t]*char[ \t]*\\*([^,]*)," | |
3695 "[ \t]*char[ \t]*\\*[ \t]*"; | |
3696 | |
3697 test_text = | |
3698 "extern FILE *fopen( char *__filename, char *__type );\n" | |
3699 "extern int sscanf( char *__s, char *__format, ...);\n" | |
3700 "extern FILE *popen(char *, char *);\n" | |
3701 "extern char *tempnam(char*,char*);\n"; | |
3702 }; | |
3703 | |
3704 | |
3705 /* | |
3706 * Fix definitions of macros used by va-i960.h in VxWorks header file. | |
3707 */ | |
3708 fix = { | |
3709 hackname = va_i960_macro; | |
3710 files = arch/i960/archI960.h; | |
3711 select = "__(vsiz|vali|vpad|alignof__)"; | |
3712 | |
3713 c_fix = format; | |
3714 c_fix_arg = "__vx%1"; | |
3715 | |
3716 test_text = | |
3717 "extern int __vsiz vsiz;\n" | |
3718 "extern int __vali vali;\n" | |
3719 "extern int __vpad vpad;\n" | |
3720 "#define __alignof__(x) ..."; | |
3721 }; | |
3722 | |
3723 | |
3724 /* | |
3725 * AIX and Interix headers define NULL to be cast to a void pointer, | |
3726 * which is illegal in ANSI C++. | |
3727 */ | |
3728 fix = { | |
3729 hackname = void_null; | |
3730 files = curses.h; | |
3731 files = dbm.h; | |
3732 files = locale.h; | |
3733 files = stdio.h; | |
3734 files = stdlib.h; | |
3735 files = string.h; | |
3736 files = time.h; | |
3737 files = unistd.h; | |
3738 files = sys/dir.h; | |
3739 files = sys/param.h; | |
3740 files = sys/types.h; | |
3741 /* avoid changing C++ friendly NULL */ | |
3742 bypass = __cplusplus; | |
3743 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)"; | |
3744 c_fix = format; | |
3745 c_fix_arg = "#define NULL 0"; | |
3746 test_text = "# define\tNULL \t((void *)0) /* typed NULL */"; | |
3747 }; | |
3748 | |
3749 | |
3750 /* | |
3751 * Make VxWorks header which is almost gcc ready fully gcc ready. | |
3752 */ | |
3753 fix = { | |
3754 hackname = vxworks_gcc_problem; | |
3755 files = types/vxTypesBase.h; | |
3756 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__"; | |
3757 | |
3758 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/" | |
3759 "#if 1/"; | |
3760 | |
3761 sed = "/[ \t]size_t/i\\\n" | |
3762 "#ifndef _GCC_SIZE_T\\\n" | |
3763 "#define _GCC_SIZE_T\n"; | |
3764 | |
3765 sed = "/[ \t]size_t/a\\\n" | |
3766 "#endif\n"; | |
3767 | |
3768 sed = "/[ \t]ptrdiff_t/i\\\n" | |
3769 "#ifndef _GCC_PTRDIFF_T\\\n" | |
3770 "#define _GCC_PTRDIFF_T\n"; | |
3771 | |
3772 sed = "/[ \t]ptrdiff_t/a\\\n" | |
3773 "#endif\n"; | |
3774 | |
3775 sed = "/[ \t]wchar_t/i\\\n" | |
3776 "#ifndef _GCC_WCHAR_T\\\n" | |
3777 "#define _GCC_WCHAR_T\n"; | |
3778 | |
3779 sed = "/[ \t]wchar_t/a\\\n" | |
3780 "#endif\n"; | |
3781 | |
3782 test_text = | |
3783 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n" | |
3784 "typedef unsigned int size_t;\n" | |
3785 "typedef long ptrdiff_t;\n" | |
3786 "typedef unsigned short wchar_t;\n" | |
3787 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n"; | |
3788 }; | |
3789 | |
3790 | |
3791 /* | |
3792 * Fix VxWorks <time.h> to not require including <vxTypes.h>. | |
3793 */ | |
3794 fix = { | |
3795 hackname = vxworks_needs_vxtypes; | |
3796 files = time.h; | |
3797 select = "uint_t([ \t]+_clocks_per_sec)"; | |
3798 c_fix = format; | |
3799 c_fix_arg = "unsigned int%1"; | |
3800 test_text = "uint_t\t_clocks_per_sec;"; | |
3801 }; | |
3802 | |
3803 | |
3804 /* | |
3805 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. | |
3806 */ | |
3807 fix = { | |
3808 hackname = vxworks_needs_vxworks; | |
3809 files = sys/stat.h; | |
3810 test = " -r types/vxTypesOld.h"; | |
3811 test = " -n \"`egrep '#include' $file`\""; | |
3812 test = " -n \"`egrep ULONG $file`\""; | |
3813 select = "#[ \t]define[ \t]+__INCstath"; | |
3814 | |
3815 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" | |
3816 "#include <types/vxTypesOld.h>\n"; | |
3817 | |
3818 test_text = "`touch types/vxTypesOld.h`" | |
3819 "#include </dev/null> /* ULONG */\n" | |
3820 "# define\t__INCstath <sys/stat.h>"; | |
3821 }; | |
3822 | |
3823 | |
3824 /* | |
3825 * Another bad dependency in VxWorks 5.2 <time.h>. | |
3826 */ | |
3827 fix = { | |
3828 hackname = vxworks_time; | |
3829 files = time.h; | |
3830 test = " -r vxWorks.h"; | |
3831 | |
3832 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*"; | |
3833 c_fix = format; | |
3834 | |
3835 c_fix_arg = | |
3836 "#ifndef __gcc_VOIDFUNCPTR_defined\n" | |
3837 "#ifdef __cplusplus\n" | |
3838 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n" | |
3839 "#else\n" | |
3840 "typedef void (*__gcc_VOIDFUNCPTR) ();\n" | |
3841 "#endif\n" | |
3842 "#define __gcc_VOIDFUNCPTR_defined\n" | |
3843 "#endif\n" | |
3844 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR"; | |
3845 | |
3846 test_text = "`touch vxWorks.h`" | |
3847 "#define VOIDFUNCPTR (void(*)())"; | |
3848 }; | |
3849 | |
3850 | |
3851 /* | |
3852 * There are several name conflicts with C++ reserved words in X11 header | |
3853 * files. These are fixed in some versions, so don't do the fixes if | |
3854 * we find __cplusplus in the file. These were found on the RS/6000. | |
3855 */ | |
3856 fix = { | |
3857 hackname = x11_class; | |
3858 files = X11/ShellP.h; | |
3859 bypass = __cplusplus; | |
3860 select = "^([ \t]*char \\*)class;(.*)"; | |
3861 c_fix = format; | |
3862 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n" | |
3863 "#else\n%1class;%2\n#endif"; | |
3864 test_text = | |
3865 "struct {\n" | |
3866 " char *class;\n" | |
3867 "} mumble;\n"; | |
3868 }; | |
3869 | |
3870 | |
3871 /* | |
3872 * class in Xm/BaseClassI.h | |
3873 */ | |
3874 fix = { | |
3875 hackname = x11_class_usage; | |
3876 files = Xm/BaseClassI.h; | |
3877 bypass = "__cplusplus"; | |
3878 | |
3879 select = " class\\)"; | |
3880 c_fix = format; | |
3881 c_fix_arg = " c_class)"; | |
3882 | |
3883 test_text = "extern mumble (int class);\n"; | |
3884 }; | |
3885 | |
3886 | |
3887 /* | |
3888 * new in Xm/Traversal.h | |
3889 */ | |
3890 fix = { | |
3891 hackname = x11_new; | |
3892 files = Xm/Traversal.h; | |
3893 bypass = __cplusplus; | |
3894 | |
3895 sed = "/Widget\told, new;/i\\\n" | |
3896 "#ifdef __cplusplus\\\n" | |
3897 "\tWidget\told, c_new;\\\n" | |
3898 "#else\n"; | |
3899 | |
3900 sed = "/Widget\told, new;/a\\\n" | |
3901 "#endif\n"; | |
3902 | |
3903 sed = "s/Widget new,/Widget c_new,/g"; | |
3904 test_text = | |
3905 "struct wedge {\n" | |
3906 " Widget\told, new; /* fixinc check FAILS ON BSD */\n" | |
3907 "};\nextern Wedged( Widget new, Widget old );"; | |
3908 }; | |
3909 | |
3910 | |
3911 /* | |
3912 * Incorrect sprintf declaration in X11/Xmu.h | |
3913 */ | |
3914 fix = { | |
3915 hackname = x11_sprintf; | |
3916 files = X11/Xmu.h; | |
3917 files = X11/Xmu/Xmu.h; | |
3918 select = "^extern char \\*\tsprintf\\(\\);$"; | |
3919 | |
3920 c_fix = format; | |
3921 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */"; | |
3922 | |
3923 test_text = "extern char *\tsprintf();"; | |
3924 }; | |
3925 | |
3926 /*EOF*/ |