Part 1 of the checkins for the SCO port update.
[gcc.git] / gcc / fixinc / inclhack.def
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 /*
24 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
25 */
26 fix = {
27 hackname = AAB_fd_zero_asm_posix_types_h;
28 files = asm/posix_types.h;
29 mach = 'i[34567]86-*-linux*';
30 bypass = '} while';
31
32 /*
33 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
34 * the start, so that if #include_next gets another instance of
35 * the wrapper, this will follow the #include_next chain until
36 * we arrive at the real <asm/posix_types.h>.
37 */
38 replace = <<- _EndOfHeader_
39 /* This file fixes a bug in the __FD_ZERO macro
40 for older versions of the Linux kernel. */
41 #ifndef _POSIX_TYPES_H_WRAPPER
42 #include <features.h>
43 #include_next <asm/posix_types.h>
44
45 #if defined(__FD_ZERO) && !defined(__GLIBC__)
46 #undef __FD_ZERO
47 #define __FD_ZERO(fdsetp) \
48 do { \
49 int __d0, __d1; \
50 __asm__ __volatile__("cld ; rep ; stosl" \
51 : "=&c" (__d0), "=&D" (__d1) \
52 : "a" (0), "0" (__FDSET_LONGS), \
53 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
54 } while (0)
55 #endif
56
57 #define _POSIX_TYPES_H_WRAPPER
58 #endif /* _POSIX_TYPES_H_WRAPPER */
59 _EndOfHeader_;
60 };
61
62
63 /*
64 * This fixes __FD_ZERO bug for glibc-1.x
65 */
66 fix = {
67 hackname = AAB_fd_zero_gnu_types_h;
68 files = gnu/types.h;
69 mach = 'i[34567]86-*-linux*';
70
71 /*
72 * Define _TYPES_H_WRAPPER at the end of the wrapper, not
73 * the start, so that if #include_next gets another instance of
74 * the wrapper, this will follow the #include_next chain until
75 * we arrive at the real <gnu/types.h>.
76 */
77 replace = <<- _EndOfHeader_
78 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
79 #ifndef _TYPES_H_WRAPPER
80 #include <features.h>
81 #include_next <gnu/types.h>
82
83 #if defined(__FD_ZERO) && !defined(__GLIBC__)
84 #undef __FD_ZERO
85 # define __FD_ZERO(fdsetp) \\
86 do { \\
87 int __d0, __d1; \\
88 __asm__ __volatile__("cld ; rep ; stosl" \\
89 : "=&c" (__d0), "=&D" (__d1) \\
90 : "a" (0), "0" (__FDSET_LONGS), \\
91 "1" ((__fd_set *) (fdsetp)) :"memory"); \\
92 } while (0)
93 #endif
94
95 #define _TYPES_H_WRAPPER
96 #endif /* _TYPES_H_WRAPPER */
97 _EndOfHeader_;
98 };
99
100
101 /*
102 * This fixes __FD_ZERO bug for glibc-2.0.x
103 */
104 fix = {
105 hackname = AAB_fd_zero_selectbits_h;
106 files = selectbits.h;
107 mach = 'i[34567]86-*-linux*';
108
109 /*
110 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
111 * the start, so that if #include_next gets another instance of
112 * the wrapper, this will follow the #include_next chain until
113 * we arrive at the real <selectbits.h>.
114 */
115 replace = <<- _EndOfHeader_
116 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
117 #ifndef _SELECTBITS_H_WRAPPER
118 #include <features.h>
119 #include_next <selectbits.h>
120
121 #if defined(__FD_ZERO) && defined(__GLIBC__) \\
122 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
123 && __GLIBC_MINOR__ == 0
124 #undef __FD_ZERO
125 #define __FD_ZERO(fdsetp) \\
126 do { \\
127 int __d0, __d1; \\
128 __asm__ __volatile__ ("cld; rep; stosl" \\
129 : "=&c" (__d0), "=&D" (__d1) \\
130 : "a" (0), "0" (sizeof (__fd_set) \\
131 / sizeof (__fd_mask)), \\
132 "1" ((__fd_mask *) (fdsetp)) \\
133 : "memory"); \\
134 } while (0)
135 #endif
136
137 #define _SELECTBITS_H_WRAPPER
138 #endif /* _SELECTBITS_H_WRAPPER */
139 _EndOfHeader_;
140 };
141
142
143 /*
144 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
145 * the same interface as <stdarg.h>. No idea why they couldn't have just
146 * used the standard header.
147 */
148 fix = {
149 hackname = AAB_solaris_sys_varargs_h;
150 files = "sys/varargs.h";
151 mach = '*-*-solaris*';
152 replace = <<- _EndOfHeader_
153 #ifdef __STDC__
154 #include <stdarg.h>
155 #else
156 #include <varargs.h>
157 #endif
158 _EndOfHeader_;
159 };
160
161
162 /*
163 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
164 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
165 * many other systems have similar text but correct versions of the file.
166 * To ensure only Sun's is fixed, we grep for a likely unique string.
167 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
168 */
169 fix = {
170 hackname = AAB_sun_memcpy;
171 files = memory.h;
172 select = "/\\*\t@\\(#\\)"
173 "(head/memory.h\t50.1\t "
174 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
175
176 replace = <<- _EndOfHeader_
177 /* This file was generated by fixincludes */
178 #ifndef __memory_h__
179 #define __memory_h__
180
181 #ifdef __STDC__
182 extern void *memccpy();
183 extern void *memchr();
184 extern void *memcpy();
185 extern void *memset();
186 #else
187 extern char *memccpy();
188 extern char *memchr();
189 extern char *memcpy();
190 extern char *memset();
191 #endif /* __STDC__ */
192
193 extern int memcmp();
194
195 #endif /* __memory_h__ */
196 _EndOfHeader;
197 };
198
199
200 /*
201 * Completely replace <sys/varargs.h> with a file that includes gcc's
202 * stdarg.h or varargs.h files as appropriate.
203 */
204 #ifdef SVR4
205 fix = {
206 hackname = AAB_svr4_no_varargs;
207 files = sys/varargs.h;
208 replace = "/* This file was generated by fixincludes. */\n"
209 "#ifndef _SYS_VARARGS_H\n"
210 "#define _SYS_VARARGS_H\n\n"
211
212 "#ifdef __STDC__\n"
213 "#include <stdarg.h>\n"
214 "#else\n"
215 "#include <varargs.h>\n"
216 "#endif\n\n"
217
218 "#endif /* _SYS_VARARGS_H */\n";
219 };
220 #endif
221
222
223 /*
224 * Completely replace <sys/byteorder.h>; with a file that implements gcc's
225 * optimized byteswapping.
226 */
227 fix = {
228 hackname = AAB_svr4_replace_byteorder;
229 mach = "*-*-sysv4*";
230 mach = "i[34567]86-*-sysv5*";
231 mach = "i[34567]86-*-sco3.2v5*";
232 mach = "i[34567]86-*-udk*";
233 mach = "i[34567]86-*-solaris2.[0-4]";
234 mach = "powerpcle-*-solaris2.[0-4]";
235 mach = "sparc-*-solaris2.[0-4]";
236 files = sys/byteorder.h;
237 replace = <<- _EndOfHeader_
238 #ifndef _SYS_BYTEORDER_H
239 #define _SYS_BYTEORDER_H
240
241 /* Functions to convert `short' and `long' quantities from host byte order
242 to (internet) network byte order (i.e. big-endian).
243
244 Written by Ron Guilmette (rfg@ncd.com).
245
246 This isn't actually used by GCC. It is installed by fixinc.svr4.
247
248 For big-endian machines these functions are essentially no-ops.
249
250 For little-endian machines, we define the functions using specialized
251 asm sequences in cases where doing so yields better code (e.g. i386). */
252
253 #if !defined (__GNUC__) && !defined (__GNUG__)
254 #error You lose! This file is only useful with GNU compilers.
255 #endif
256
257 #ifndef __BYTE_ORDER__
258 /* Byte order defines. These are as defined on UnixWare 1.1, but with
259 double underscores added at the front and back. */
260 #define __LITTLE_ENDIAN__ 1234
261 #define __BIG_ENDIAN__ 4321
262 #define __PDP_ENDIAN__ 3412
263 #endif
264
265 #ifdef __STDC__
266 static __inline__ unsigned long htonl (unsigned long);
267 static __inline__ unsigned short htons (unsigned int);
268 static __inline__ unsigned long ntohl (unsigned long);
269 static __inline__ unsigned short ntohs (unsigned int);
270 #endif /* defined (__STDC__) */
271
272 #if defined (__i386__)
273
274 #ifndef __BYTE_ORDER__
275 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
276 #endif
277
278 /* Convert a host long to a network long. */
279
280 /* We must use a new-style function definition, so that this will also
281 be valid for C++. */
282 static __inline__ unsigned long
283 htonl (unsigned long __arg)
284 {
285 register unsigned long __result;
286
287 __asm__ ("xchg%B0 %b0,%h0
288 ror%L0 $16,%0
289 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
290 return __result;
291 }
292
293 /* Convert a host short to a network short. */
294
295 static __inline__ unsigned short
296 htons (unsigned int __arg)
297 {
298 register unsigned short __result;
299
300 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
301 return __result;
302 }
303
304 #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
305
306 #ifndef __BYTE_ORDER__
307 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
308 #endif
309
310 /* For other little-endian machines, using C code is just as efficient as
311 using assembly code. */
312
313 /* Convert a host long to a network long. */
314
315 static __inline__ unsigned long
316 htonl (unsigned long __arg)
317 {
318 register unsigned long __result;
319
320 __result = (__arg >> 24) & 0x000000ff;
321 __result |= (__arg >> 8) & 0x0000ff00;
322 __result |= (__arg << 8) & 0x00ff0000;
323 __result |= (__arg << 24) & 0xff000000;
324 return __result;
325 }
326
327 /* Convert a host short to a network short. */
328
329 static __inline__ unsigned short
330 htons (unsigned int __arg)
331 {
332 register unsigned short __result;
333
334 __result = (__arg << 8) & 0xff00;
335 __result |= (__arg >> 8) & 0x00ff;
336 return __result;
337 }
338
339 #else /* must be a big-endian machine */
340
341 #ifndef __BYTE_ORDER__
342 #define __BYTE_ORDER__ __BIG_ENDIAN__
343 #endif
344
345 /* Convert a host long to a network long. */
346
347 static __inline__ unsigned long
348 htonl (unsigned long __arg)
349 {
350 return __arg;
351 }
352
353 /* Convert a host short to a network short. */
354
355 static __inline__ unsigned short
356 htons (unsigned int __arg)
357 {
358 return __arg;
359 }
360
361 #endif /* big-endian */
362
363 /* Convert a network long to a host long. */
364
365 static __inline__ unsigned long
366 ntohl (unsigned long __arg)
367 {
368 return htonl (__arg);
369 }
370
371 /* Convert a network short to a host short. */
372
373 static __inline__ unsigned short
374 ntohs (unsigned int __arg)
375 {
376 return htons (__arg);
377 }
378 #endif
379 _EndOfHeader_;
380 };
381
382 /*
383 * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file.
384 */
385 fix = {
386 hackname = AAB_ultrix_ansi_compat;
387 files = ansi_compat.h;
388 select = ULTRIX;
389 replace = "/* This file intentionally left blank. */\n";
390 };
391
392
393 /*
394 * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h.
395 * Replace limits.h with a file that includes sys/limits.h.
396 */
397 fix = {
398 hackname = AAB_ultrix_limits;
399 files = limits.h;
400 mach = "*-*-ultrix4.3";
401 replace = <<- _EndOfHeader_
402 #ifndef _LIMITS_INCLUDED
403 #define _LIMITS_INCLUDED
404 #include <sys/limits.h>
405 #endif /* _LIMITS_INCLUDED */
406 _EndOfHeader_;
407 };
408
409
410 /*
411 * The ULTRIX 4.3 version of memory.h duplicates definitions
412 * present in strings.h. Replace memory.h with a file that includes
413 * strings.h to prevent problems from multiple inclusion.
414 */
415 fix = {
416 hackname = AAB_ultrix_memory;
417 files = memory.h;
418 mach = "*-*-ultrix4.3";
419 replace = <<- _EndOfHeader_
420 #ifndef _MEMORY_INCLUDED
421 #define _MEMORY_INCLUDED
422 #include <strings.h>
423 #endif /* _MEMORY_INCLUDED */
424 _EndOfHeader_;
425 };
426
427
428 /*
429 * The Ultrix 4.3 file string.h is a symbolic link to strings.h.
430 * Replace string.h link with a file that includes strings.h to prevent
431 * problems from multiple inclusion.
432 */
433 fix = {
434 hackname = AAB_ultrix_string;
435 files = string.h;
436 mach = "*-*-ultrix4.3";
437 replace = <<- _EndOfHeader_
438 #ifndef _STRING_INCLUDED
439 #define _STRING_INCLUDED
440 #include <strings.h>
441 #endif /* _STRING_INCLUDED */
442 _EndOfHeader_;
443 };
444
445
446 /*
447 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
448 * which violates a requirement of ISO C.
449 */
450 fix = {
451 hackname = aix_pthread;
452 files = "pthread.h";
453 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
454 c_fix = format;
455 c_fix_arg = "%1 %2";
456 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
457 "{...init stuff...}";
458 };
459
460
461 /*
462 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
463 * in an otherwise harmless (and #ifed out) macro definition
464 */
465 fix = {
466 hackname = aix_sysmachine;
467 files = sys/machine.h;
468 select = "\\\\ +\n";
469 c_fix = format;
470 c_fix_arg = "\\\n";
471 test_text = "#define FOO \\\n"
472 " bar \\ \n baz \\ \n bat";
473 };
474
475
476 /*
477 * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the
478 * definition of struct rusage, so the prototype added by fixproto fails.
479 */
480 fix = {
481 hackname = aix_syswait;
482 files = sys/wait.h;
483 select = "^extern pid_t wait3\\(\\);\n";
484 select = "bos325,";
485 c_fix = format;
486 c_fix_arg = "struct rusage;\n%0";
487 test_text = "/* bos325, */\n"
488 "extern pid_t wait3();\n"
489 "\t/* pid_t wait3(int *, int, struct rusage *); */";
490 };
491
492
493 /*
494 * sys/signal.h on some versions of AIX uses volatile in the typedef of
495 * sig_atomic_t, which causes gcc to generate a warning about duplicate
496 * volatile when a sig_atomic_t variable is declared volatile, as
497 * required by ANSI C.
498 */
499 fix = {
500 hackname = aix_volatile;
501 files = sys/signal.h;
502 select = "typedef volatile int sig_atomic_t";
503 c_fix = format;
504 c_fix_arg = "typedef int sig_atomic_t";
505 test_text = "typedef volatile int sig_atomic_t;";
506 };
507
508
509 /*
510 * Fix __assert declaration in assert.h on Alpha OSF/1.
511 */
512 fix = {
513 hackname = alpha___assert;
514 files = "assert.h";
515 select = '__assert\(char \*, char \*, int\)';
516 c_fix = format;
517 c_fix_arg = "__assert(const char *, const char *, int)";
518 test_text = 'extern void __assert(char *, char *, int);';
519 };
520
521
522 /*
523 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
524 */
525 fix = {
526 hackname = alpha___extern_prefix;
527 files = sys/stat.h;
528 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
529
530 mach = "alpha*-dec-osf5*";
531 c_fix = format;
532 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
533
534 test_text = "# if defined(__DECC)";
535 };
536
537
538 /*
539 * Fix assert macro in assert.h on Alpha OSF/1.
540 * The superfluous int cast breaks C++.
541 */
542 fix = {
543 hackname = alpha_assert;
544 files = "assert.h";
545 select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)';
546 c_fix = format;
547 c_fix_arg = "%1(EX)";
548 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 : __assert(#EX, __FILE__, __LINE__))';
549 };
550
551
552 /*
553 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
554 */
555 fix = {
556 hackname = alpha_getopt;
557 files = "stdio.h";
558 files = "stdlib.h";
559 select = 'getopt\(int, char \*\[\], *char \*\)';
560 c_fix = format;
561 c_fix_arg = "getopt(int, char *const[], const char *)";
562 test_text = 'extern int getopt(int, char *[], char *);';
563 };
564
565
566 /*
567 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
568 */
569 fix = {
570 hackname = alpha_parens;
571 files = sym.h;
572 select = '#ifndef\(__mips64\)';
573 c_fix = format;
574 c_fix_arg = "#ifndef __mips64";
575 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
576 };
577
578
579 /*
580 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
581 */
582 fix = {
583 hackname = alpha_sbrk;
584 files = unistd.h;
585 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
586 c_fix = format;
587 c_fix_arg = "void *sbrk(";
588 test_text = "extern char* sbrk(ptrdiff_t increment);";
589 };
590
591
592 /*
593 * For C++, avoid any typedef or macro definition of bool,
594 * and use the built in type instead.
595 * HP/UX 10.20 also has it in curses_colr/curses.h.
596 */
597 fix = {
598 hackname = avoid_bool_define;
599 files = curses.h;
600 files = curses_colr/curses.h;
601 files = term.h;
602 files = tinfo.h;
603
604 select = "#[ \t]*define[ \t]+bool[ \t]";
605 bypass = "we must use the C\\+\\+ compiler's type";
606
607 c_fix = format;
608 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
609 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
610
611 test_text = "# define bool\t char \n";
612 };
613
614
615 fix = {
616 hackname = avoid_bool_type;
617 files = curses.h;
618 files = curses_colr/curses.h;
619 files = term.h;
620 files = tinfo.h;
621
622 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
623 bypass = "we must use the C\\+\\+ compiler's type";
624
625 c_fix = format;
626 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
627
628 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
629 };
630
631
632 /*
633 * For C++, avoid any typedef definition of wchar_t,
634 * and use the built in type instead.
635 */
636
637 fix = {
638 hackname = avoid_wchar_t_type;
639
640 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
641
642 c_fix = format;
643 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
644
645 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
646 };
647
648
649 /*
650 * Fix #defines under Alpha OSF/1:
651 * The following files contain '#pragma extern_prefix "_FOO"' followed by
652 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
653 * statements is to reduce namespace pollution. While these macros work
654 * properly in most cases, they don't allow you to take a pointer to the
655 * "something" being modified. To get around this limitation, change these
656 * statements to be of the form '#define something _FOOsomething'.
657 *
658 * sed ain't egrep, lesson 2463: sed can use self-referential
659 * regular expressions. In the substitute expression below,
660 * "\\1" and "\\2" refer to subexpressions found earlier in the
661 * same match. So, we continue to use sed. "extern_prefix" will
662 * be a rare match anyway...
663 */
664 fix = {
665 hackname = bad_lval;
666
667 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
668
669 files = libgen.h;
670 files = dirent.h;
671 files = ftw.h;
672 files = grp.h;
673 files = ndbm.h;
674 files = pthread.h;
675 files = pwd.h;
676 files = signal.h;
677 files = standards.h;
678 files = stdlib.h;
679 files = string.h;
680 files = stropts.h;
681 files = time.h;
682 files = unistd.h;
683
684 sed =
685 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
686 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
687
688 test_text = '#pragma extern_prefix "_FOO"'"\n"
689 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
690 "#define mumble _FOOmumble";
691 };
692
693
694 /*
695 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
696 */
697 fix = {
698 hackname = bad_struct_term;
699 files = curses.h;
700 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
701 c_fix = format;
702 c_fix_arg = "struct term;";
703
704 test_text = 'typedef struct term;';
705 };
706
707
708 /*
709 * Fix one other error in this file:
710 * a mismatched quote not inside a C comment.
711 */
712 fix = {
713 hackname = badquote;
714 files = sundev/vuid_event.h;
715 select = "doesn't";
716 c_fix = format;
717 c_fix_arg = "does not";
718
719 test_text = "/* doesn't have matched single quotes */";
720 };
721
722
723 /*
724 * Various systems derived from BSD4.4 contain a macro definition
725 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
726 * Known to be fixed in FreeBSD 5 system headers.
727 */
728 fix = {
729 hackname = bsd_stdio_attrs_conflict;
730 mach = *-*-*bsd*;
731 mach = *-*-*darwin*;
732 files = stdio.h;
733 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
734 c_fix = format;
735 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
736 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
737 'int vfscanf(FILE *, const char *, __builtin_va_list) '
738 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
739 test_text = '#define vfscanf __svfscanf';
740 };
741
742
743 /*
744 * check for broken assert.h that needs stdio.h
745 */
746 fix = {
747 hackname = broken_assert_stdio;
748 files = assert.h;
749 select = stderr;
750 bypass = "include.*stdio\\.h";
751 c_fix = wrap;
752 c_fix_arg = "#include <stdio.h>\n";
753 test_text = "extern FILE* stderr;";
754 };
755
756
757 /*
758 * check for broken assert.h that needs stdlib.h
759 */
760 fix = {
761 hackname = broken_assert_stdlib;
762 files = assert.h;
763 select = 'exit *\(|abort *\(';
764 bypass = "include.*stdlib\\.h";
765 c_fix = wrap;
766 c_fix_arg = "#ifdef __cplusplus\n"
767 "#include <stdlib.h>\n"
768 "#endif\n";
769 test_text = "extern void exit ( int );";
770 };
771
772
773 /*
774 * Remove `extern double cabs' declarations from math.h.
775 * This conflicts with C99. Discovered on AIX.
776 * SunOS4 has its cabs() declaration followed by a comment which
777 * terminates on the following line.
778 */
779 fix = {
780 hackname = broken_cabs;
781 files = "math.h";
782 select = '^extern[ \t]+double[ \t]+cabs';
783
784 c_fix = format;
785 c_fix_arg = "";
786 c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);";
787
788 test_text = "#ifdef __STDC__\n"
789 "extern double cabs(struct dbl_hypot);\n"
790 "#else\n"
791 "extern double cabs();\n"
792 "#endif\n"
793 "extern double cabs(); /* This is a comment\n"
794 " and it ends here. */";
795 };
796
797
798 /*
799 * Fix various macros used to define ioctl numbers.
800 * The traditional syntax was:
801 *
802 * #define _CTRL(n, x) (('n'<<8)+x)
803 * #define TCTRLCFOO _CTRL(T, 1)
804 *
805 * but this does not work with the C standard, which disallows macro
806 * expansion inside strings. We have to rewrite it thus:
807 *
808 * #define _CTRL(n, x) ((n<<8)+x)
809 * #define TCTRLCFOO _CTRL('T', 1)
810 *
811 * The select expressions match too much, but the c_fix code is cautious.
812 *
813 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
814 */
815 fix = {
816 hackname = ctrl_quotes_def;
817 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
818 c_fix = char_macro_def;
819 c_fix_arg = "CTRL";
820
821 /*
822 * This is two tests in order to ensure that the "CTRL(c)" can
823 * be selected in isolation from the multi-arg format
824 */
825 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
826 test_text = "#define _CTRL(c) ('c'&037)";
827 };
828
829 fix = {
830 hackname = ctrl_quotes_use;
831 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
832 c_fix = char_macro_use;
833 c_fix_arg = "CTRL";
834 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
835 };
836
837
838 /*
839 * sys/mman.h on HP/UX is not C++ ready,
840 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
841 *
842 * rpc/types.h on OSF1/2.0 is not C++ ready,
843 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
844 *
845 * The problem is the declaration of malloc.
846 */
847 fix = {
848 hackname = cxx_unready;
849 files = sys/mman.h;
850 files = rpc/types.h;
851 select = '[^#]+malloc.*;'; /* Catch any form of declaration
852 not within a macro. */
853 bypass = '"C"|__BEGIN_DECLS';
854
855 c_fix = wrap;
856 c_fix_arg = "#ifdef __cplusplus\n"
857 "extern \"C\" {\n"
858 "#endif\n";
859 c_fix_arg = "#ifdef __cplusplus\n"
860 "}\n"
861 "#endif\n";
862 test_text = "extern void* malloc( size_t );";
863 };
864
865
866 /*
867 * Fix <c_asm.h> on Digital UNIX V4.0:
868 * It contains a prototype for a DEC C internal asm() function,
869 * clashing with gcc's asm keyword. So protect this with __DECC.
870 */
871 fix = {
872 hackname = dec_intern_asm;
873 files = c_asm.h;
874 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
875 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
876 "#endif\n";
877 test_text =
878 "float fasm {\n"
879 " ... asm stuff ...\n"
880 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
881 };
882
883
884 /*
885 * Fix typo in <wchar.h> on DJGPP 2.03.
886 */
887 fix = {
888 hackname = djgpp_wchar_h;
889 file = wchar.h;
890 select = "__DJ_wint_t";
891 bypass = "sys/djtypes.h";
892 c_fix = format;
893 c_fix_arg = "%0\n#include <sys/djtypes.h>";
894 c_fix_arg = "#include <stddef.h>";
895 test_text = "#include <stddef.h>\n"
896 "extern __DJ_wint_t x;\n";
897 };
898
899
900 /*
901 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
902 */
903 fix = {
904 hackname = ecd_cursor;
905 files = "sunwindow/win_lock.h";
906 files = "sunwindow/win_cursor.h";
907 select = 'ecd\.cursor';
908 c_fix = format;
909 c_fix_arg = 'ecd_cursor';
910
911 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
912 };
913
914
915 /*
916 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
917 * neither the existence of GCC 3 nor its exact feature set yet break
918 * (by design?) when __GNUC__ is set beyond 2.
919 */
920 fix = {
921 hackname = freebsd_gcc3_breakage;
922 mach = *-*-freebsd*;
923 files = sys/cdefs.h;
924 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
925 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
926 c_fix = format;
927 c_fix_arg = '%0 || __GNUC__ >= 3';
928 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
929 };
930
931
932 /*
933 * Fix these files to use the same types that we think they should.
934 */
935 fix = {
936 hackname = gnu_types;
937 files = "sys/types.h";
938 files = "stdlib.h";
939 files = "sys/stdtypes.h";
940 files = "stddef.h";
941 files = "memory.h";
942 files = "unistd.h";
943 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
944 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
945 c_fix = gnu_type;
946
947 test_text = "typedef long int ptrdiff_t; /* long int */\n"
948 "typedef uint_t size_t; /* uint_t */\n"
949 "typedef ushort_t wchar_t; /* ushort_t */";
950 };
951
952
953 /*
954 * Fix HP & Sony's use of "../machine/xxx.h"
955 * to refer to: <machine/xxx.h>
956 */
957 fix = {
958 hackname = hp_inline;
959 files = sys/spinlock.h;
960 files = machine/machparam.h;
961 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
962
963 c_fix = format;
964 c_fix_arg = "%1<machine/%2.h>";
965
966 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
967 '([a-z]+)\.h"';
968
969 test_text = ' # include "../machine/mumble.h"';
970 };
971
972
973 /*
974 * Check for (...) in C++ code in HP/UX sys/file.h.
975 */
976 fix = {
977 hackname = hp_sysfile;
978 files = sys/file.h;
979 select = "HPUX_SOURCE";
980
981 c_fix = format;
982 c_fix_arg = "(struct file *, ...)";
983 c_fix_arg = '\(\.\.\.\)';
984
985 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
986 };
987
988
989 /*
990 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
991 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
992 */
993 fix = {
994 hackname = hpux10_cpp_pow_inline;
995 files = fixinc-test-limits.h, math.h;
996 select = <<- END_POW_INLINE
997 ^# +ifdef +__cplusplus
998 +}
999 +inline +double +pow\(double +__d,int +__expon\) +{
1000 [ ]+return +pow\(__d,\(double\)__expon\);
1001 +}
1002 +extern +"C" +{
1003 #else
1004 # +endif
1005 END_POW_INLINE;
1006
1007 c_fix = format;
1008 c_fix_arg = "";
1009
1010 test_text =
1011 "# ifdef __cplusplus\n"
1012 " }\n"
1013 " inline double pow(double __d,int __expon) {\n"
1014 "\t return pow(__d,(double)__expon);\n"
1015 " }\n"
1016 ' extern "C"' " {\n"
1017 "#else\n"
1018 "# endif";
1019 };
1020
1021 fix = {
1022 hackname = hpux11_cpp_pow_inline;
1023 files = math.h;
1024 select = " +inline double pow\\(double d,int expon\\) {\n"
1025 " +return pow\\(d, \\(double\\)expon\\);\n"
1026 " +}\n";
1027 c_fix = format;
1028 c_fix_arg = "";
1029
1030 test_text =
1031 " inline double pow(double d,int expon) {\n"
1032 " return pow(d, (double)expon);\n"
1033 " }\n";
1034 };
1035
1036
1037 /*
1038 * Fix hpux 10.X missing ctype declarations 1
1039 */
1040 fix = {
1041 hackname = hpux10_ctype_declarations1;
1042 files = ctype.h;
1043 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1044 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1045 c_fix = format;
1046 c_fix_arg = "#ifdef _PROTOTYPES\n"
1047 "extern int __tolower(int);\n"
1048 "extern int __toupper(int);\n"
1049 "#else /* NOT _PROTOTYPES */\n"
1050 "extern int __tolower();\n"
1051 "extern int __toupper();\n"
1052 "#endif /* _PROTOTYPES */\n\n"
1053 "%0\n";
1054
1055 test_text = "# define _toupper(__c) __toupper(__c)\n";
1056 };
1057
1058
1059 /*
1060 * Fix hpux 10.X missing ctype declarations 2
1061 */
1062 fix = {
1063 hackname = hpux10_ctype_declarations2;
1064 files = ctype.h;
1065 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1066 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1067 c_fix = format;
1068 c_fix_arg = "%0\n\n"
1069 "#ifdef _PROTOTYPES\n"
1070 " extern int _isalnum(int);\n"
1071 " extern int _isalpha(int);\n"
1072 " extern int _iscntrl(int);\n"
1073 " extern int _isdigit(int);\n"
1074 " extern int _isgraph(int);\n"
1075 " extern int _islower(int);\n"
1076 " extern int _isprint(int);\n"
1077 " extern int _ispunct(int);\n"
1078 " extern int _isspace(int);\n"
1079 " extern int _isupper(int);\n"
1080 " extern int _isxdigit(int);\n"
1081 "# else /* not _PROTOTYPES */\n"
1082 " extern int _isalnum();\n"
1083 " extern int _isalpha();\n"
1084 " extern int _iscntrl();\n"
1085 " extern int _isdigit();\n"
1086 " extern int _isgraph();\n"
1087 " extern int _islower();\n"
1088 " extern int _isprint();\n"
1089 " extern int _ispunct();\n"
1090 " extern int _isspace();\n"
1091 " extern int _isupper();\n"
1092 " extern int _isxdigit();\n"
1093 "#endif /* _PROTOTYPES */\n";
1094
1095 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1096 " extern unsigned int *__SB_masks;\n";
1097 };
1098
1099
1100 /*
1101 * Make sure hpux defines abs in header.
1102 */
1103 fix = {
1104 hackname = hpux11_abs;
1105 mach = ia64-hp-hpux11*;
1106 files = stdlib.h;
1107 select = "ifndef _MATH_INCLUDED";
1108 c_fix = format;
1109 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1110 // sed = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/";
1111 test_text = "#ifndef _MATH_INCLUDED";
1112 };
1113
1114
1115 /*
1116 * Keep HP-UX 11 from stomping on C++ math namespace
1117 * with defines for fabsf.
1118 */
1119 fix = {
1120 hackname = hpux11_fabsf;
1121 files = math.h;
1122 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1123 bypass = "__cplusplus";
1124
1125 c_fix = format;
1126 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1127
1128 test_text =
1129 "#ifdef _PA_RISC\n"
1130 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1131 "#endif";
1132 };
1133
1134
1135 /*
1136 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1137 * being defined by having it define _hpux_size_t instead.
1138 */
1139 fix = {
1140 hackname = hpux11_size_t;
1141 mach = "*-hp-hpux11*";
1142 select = "__size_t";
1143
1144 c_fix = format;
1145 c_fix_arg = "_hpux_size_t";
1146
1147 test_text =
1148 "#define __size_t size_t\n"
1149 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1150 };
1151
1152
1153 /*
1154 * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
1155 * of UINT32_C has undefined behavior according to ISO/ANSI:
1156 * the arguments to __CONCAT__ are not macro expanded before the
1157 * concatination happens so the trailing ')' in the first argument
1158 * is concatinated with the 'l' in the second argument creating an
1159 * invalid pp token. The behavior of invalid pp tokens is undefined.
1160 * GCC does not handle these invalid tokens the way the HP compiler does.
1161 * This problem will potentially occur anytime macros are used in the
1162 * arguments to __CONCAT__. A general solution to this problem would be to
1163 * insert another layer of macro between __CONCAT__ and its use
1164 * in UINT32_C. An example of this solution can be found in the C standard.
1165 * A more specific solution, the one used here, is to change the UINT32_C
1166 * macro to not used macros in the arguments to __CONCAT__.
1167 */
1168 fix = {
1169 hackname = hpux11_uint32_c;
1170 files = inttypes.h;
1171 select = "^#define UINT32_C\\(__c\\)[ \t]*"
1172 "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
1173 c_fix = format;
1174 c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
1175 test_text =
1176 "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
1177 "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
1178 };
1179
1180
1181 /*
1182 * Fix hpux 11.00 broken vsnprintf declaration
1183 */
1184 fix = {
1185 hackname = hpux11_vsnprintf;
1186 files = stdio.h;
1187 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
1188 'const char \*,) __va__list\);';
1189 c_fix = format;
1190 c_fix_arg = "%1 __va_list);";
1191
1192 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1193 ' __va__list);';
1194 };
1195
1196
1197 /*
1198 * get rid of bogus inline definitions in HP-UX 8.0
1199 */
1200 fix = {
1201 hackname = hpux8_bogus_inlines;
1202 files = math.h;
1203 select = inline;
1204 sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
1205 "@extern \"C\" int abs(int);@";
1206 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
1207 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
1208 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1209 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1210 "inline double sqr(double v) { return v**0.5; }";
1211 };
1212
1213
1214 /*
1215 * Fix hpux broken ctype macros
1216 */
1217 fix = {
1218 hackname = hpux_ctype_macros;
1219 files = ctype.h;
1220 select = '((: |\()__SB_masks \? )'
1221 '(__SB_masks\[__(alnum|c)\] & _IS)';
1222 c_fix = format;
1223 c_fix_arg = "%1(int)%3";
1224
1225 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1226 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1227 };
1228
1229
1230 /*
1231 * HP-UX long_double
1232 */
1233 fix = {
1234 hackname = hpux_long_double;
1235 files = stdlib.h;
1236 select = "extern[ \t]long_double[ \t]strtold";
1237 bypass = "long_double_t";
1238 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
1239 sed = "s/long_double/long double/g";
1240
1241 test_text = "# ifndef _LONG_DOUBLE\n"
1242 "# define _LONG_DOUBLE\n"
1243 " typedef struct {\n"
1244 " unsigned int word1, word2, word3, word4;\n"
1245 " } long_double;\n"
1246 "# endif /* _LONG_DOUBLE */\n"
1247 "extern long_double strtold(const char *, char **);\n";
1248 };
1249
1250
1251 /*
1252 * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
1253 */
1254 fix = {
1255 hackname = hpux_maxint;
1256 files = sys/param.h;
1257 files = values.h;
1258 select = "^#[ \t]*define[ \t]+MAXINT[ \t]";
1259 bypass = "^#[ \t]*ifndef[ \t]+MAXINT";
1260 test =
1261 "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\"";
1262
1263 c_fix = format;
1264 c_fix_arg = "#ifndef MAXINT\n%0\n#endif";
1265 c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*";
1266
1267 test_text = '#define MAXINT 0x7FFFFFFF';
1268 };
1269
1270
1271 /*
1272 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
1273 */
1274 fix = {
1275 hackname = hpux_systime;
1276 files = sys/time.h;
1277 select = "^extern struct sigevent;";
1278
1279 c_fix = format;
1280 c_fix_arg = "struct sigevent;";
1281
1282 test_text = 'extern struct sigevent;';
1283 };
1284
1285
1286 /*
1287 * Fix return type of abort and free
1288 */
1289 fix = {
1290 hackname = int_abort_free_and_exit;
1291 files = stdlib.h;
1292 select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
1293
1294 c_fix = format;
1295 c_fix_arg = "void\t%1(";
1296
1297 test_text = "extern int abort(int);\n"
1298 "extern int free(void*);\n"
1299 "extern int exit(void*);";
1300 };
1301
1302
1303 /*
1304 * Fix various macros used to define ioctl numbers.
1305 * The traditional syntax was:
1306 *
1307 * #define _IO(n, x) (('n'<<8)+x)
1308 * #define TIOCFOO _IO(T, 1)
1309 *
1310 * but this does not work with the C standard, which disallows macro
1311 * expansion inside strings. We have to rewrite it thus:
1312 *
1313 * #define _IO(n, x) ((n<<8)+x)
1314 * #define TIOCFOO _IO('T', 1)
1315 *
1316 * The select expressions match too much, but the c_fix code is cautious.
1317 *
1318 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
1319 */
1320 fix = {
1321 hackname = io_quotes_def;
1322 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
1323 c_fix = char_macro_def;
1324 c_fix_arg = "IO";
1325 test_text =
1326 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
1327 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
1328 "#define _IO(x,y) ('x'<<8|y)";
1329 test_text =
1330 "#define XX_IO(x) ('x'<<8|256)";
1331 };
1332
1333 fix = {
1334 hackname = io_quotes_use;
1335 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
1336 "\\( *[^,']";
1337 c_fix = char_macro_use;
1338 c_fix_arg = "IO";
1339 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
1340 "#define TIOCFOO \\\\\n"
1341 "BSD43__IOWR(T, 1) /* Some are multi-line */";
1342 };
1343
1344
1345 /*
1346 * Check for missing ';' in struct
1347 */
1348 fix = {
1349 hackname = ip_missing_semi;
1350 files = netinet/ip.h;
1351 select = "}$";
1352 sed = "/^struct/,/^};/s/}$/};/";
1353 test_text=
1354 "struct mumble {\n"
1355 " union {\n"
1356 " int x;\n"
1357 " }\n"
1358 "}; /* mumbled struct */\n";
1359 };
1360
1361
1362 /*
1363 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
1364 * __restrict as restrict iff __c99. This is wrong for C++, which
1365 * needs many C99 features, but only supports __restrict.
1366 */
1367 fix = {
1368 hackname = irix___restrict;
1369 files = internal/sgimacros.h;
1370 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
1371
1372 mach = "mips-sgi-irix6.5";
1373 c_fix = format;
1374 c_fix_arg = "%1"
1375 "# ifndef __cplusplus\n%2\n# endif";
1376
1377 test_text = "#ifdef __c99\n# define __restrict restrict";
1378 };
1379
1380 /*
1381 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
1382 * that causes the assembly preprocessor to complain about an
1383 * unterminated character constant.
1384 */
1385 fix = {
1386 hackname = irix_asm_apostrophe;
1387 files = sys/asm.h;
1388
1389 select = "^[ \t]*#.*[Ww]e're";
1390 c_fix = format;
1391 c_fix_arg = "%1 are";
1392 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
1393 test_text = "\t# and we're on vacation";
1394 };
1395
1396
1397 /*
1398 * Non-traditional "const" declaration in Irix's limits.h.
1399 */
1400 fix = {
1401 hackname = irix_limits_const;
1402 files = fixinc-test-limits.h, limits.h;
1403 select = "^extern const ";
1404 c_fix = format;
1405 c_fix_arg = "extern __const ";
1406 test_text = "extern const char limit; /* test limits */";
1407 };
1408
1409
1410 /*
1411 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
1412 * Various socket function prototypes use different types instead,
1413 * depending on the API in use (BSD, XPG4/5), but the socklen_t
1414 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
1415 * IRIX 6.5.19).
1416 */
1417 fix = {
1418 hackname = irix_socklen_t;
1419 files = sys/socket.h;
1420 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
1421
1422 mach = "mips-sgi-irix6.5";
1423 c_fix = format;
1424 c_fix_arg = "%1"
1425 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
1426 "typedef int socklen_t;\n"
1427 "#else\n"
1428 "%2\n"
1429 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
1430
1431 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
1432 };
1433
1434 /*
1435 * IRIX 5.x's stdio.h declares some functions that take a va_list as
1436 * taking char *. However, GCC uses void * for va_list, so
1437 * calling vfprintf with a va_list fails in C++. */
1438 fix = {
1439 hackname = irix_stdio_va_list;
1440 files = stdio.h;
1441
1442 select = '(printf\(.*), /\* va_list \*/ char \*';
1443 c_fix = format;
1444 c_fix_arg = "%1, __gnuc_va_list";
1445 test_text =
1446 "extern int printf( const char *, /* va_list */ char * );";
1447 };
1448
1449
1450 /*
1451 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
1452 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
1453 */
1454 fix = {
1455 hackname = irix_wcsftime;
1456 files = internal/wchar_core.h;
1457 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
1458
1459 mach = "mips-sgi-irix6.5";
1460 c_fix = format;
1461 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
1462
1463 test_text = "#if _NO_XOPEN5\n"
1464 "extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
1465 };
1466
1467 /*
1468 * Fixing ISC fmod declaration
1469 */
1470 fix = {
1471 hackname = isc_fmod;
1472 files = math.h;
1473 select = 'fmod\(double\)';
1474 c_fix = format;
1475 c_fix_arg = "fmod(double, double)";
1476 test_text = "extern double fmod(double);";
1477 };
1478
1479
1480 /*
1481 * On Interactive Unix 2.2, certain traditional Unix definitions
1482 * (notably getc and putc in stdio.h) are omitted if __STDC__ is
1483 * defined, not just if _POSIX_SOURCE is defined. This makes it
1484 * impossible to compile any nontrivial program except with -posix.
1485 */
1486 fix = {
1487 hackname = isc_omits_with_stdc;
1488
1489 files = "stdio.h";
1490 files = "math.h";
1491 files = "ctype.h";
1492 files = "sys/limits.h";
1493 files = "sys/fcntl.h";
1494 files = "sys/dirent.h";
1495
1496 select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)';
1497 c_fix = format;
1498 c_fix_arg = '!defined(_POSIX_SOURCE)';
1499 test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */"
1500 "\nint foo;\n#endif";
1501 };
1502
1503
1504 /*
1505 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
1506 * use / * * / to concatenate tokens.
1507 */
1508 fix = {
1509 hackname = kandr_concat;
1510 files = "sparc/asm_linkage.h";
1511 files = "sun3/asm_linkage.h";
1512 files = "sun3x/asm_linkage.h";
1513 files = "sun4/asm_linkage.h";
1514 files = "sun4c/asm_linkage.h";
1515 files = "sun4m/asm_linkage.h";
1516 files = "sun4c/debug/asm_linkage.h";
1517 files = "sun4m/debug/asm_linkage.h";
1518 files = "arm/as_support.h";
1519 files = "arm/mc_type.h";
1520 files = "arm/xcb.h";
1521 files = "dev/chardefmac.h";
1522 files = "dev/ps_irq.h";
1523 files = "dev/screen.h";
1524 files = "dev/scsi.h";
1525 files = "sys/tty.h";
1526 files = "Xm.acorn/XmP.h";
1527 files = bsd43/bsd43_.h;
1528 select = '/\*\*/';
1529 c_fix = format;
1530 c_fix_arg = '##';
1531 test_text = "#define __CONCAT__(a,b) a/**/b";
1532 };
1533
1534
1535 /*
1536 * Fix libc1 _G_va_list definition, used in declarations of several
1537 * more-or-less standard functions, for example vasprintf.
1538 */
1539 fix = {
1540 hackname = libc1_G_va_list;
1541 files = _G_config.h;
1542 mach = '*-*-linux*libc1';
1543 select = 'typedef void \* _G_va_list;';
1544 c_fix = format;
1545 c_fix_arg = "typedef __builtin_va_list _G_va_list;";
1546 test_text = 'typedef void * _G_va_list;';
1547 };
1548
1549
1550 /*
1551 * GNU libc1 string.h does not prototype memcpy and memcmp for gcc
1552 * versions > 1. This fix will open up the declaration for all
1553 * versions of GCC and for g++.
1554 */
1555 fix = {
1556 hackname = libc1_ifdefd_memx;
1557
1558 /* The string.h result is overwritten by AAB_ultrix_string when doing
1559 "make check" and will fail. Therefore, we add the following kludgery
1560 to insert the test_text into the special testing header. :-} */
1561 files = testing.h;
1562 files = string.h;
1563
1564 c_fix = format;
1565 select = "' is a built-in function for gcc 2\\.x\\. \\*/";
1566 bypass = __cplusplus;
1567 c_fix_arg = "%1";
1568 c_fix_arg =
1569 '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n"
1570 '#if defined\(__STDC__\) && __GNUC__ < 2' "\n"
1571 "(/\\* .* \\*/\n"
1572 "extern [a-z_]+ mem.*(\n[^#].*)*;)\n"
1573 "#endif";
1574
1575 test_text =
1576 "/* \\`memcpy' is a built-in function for gcc 2.x. */\n"
1577 "#if defined(__STDC__) && __GNUC__ < 2\n"
1578 "/* Copy N bytes of SRC to DEST. */\n"
1579 "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n"
1580 " size_t __n));\n"
1581 "#endif";
1582 };
1583
1584
1585 /*
1586 * In limits.h, put #ifndefs around things that are supposed to be defined
1587 * in float.h to avoid redefinition errors if float.h is included first.
1588 * On HP/UX this patch does not work, because on HP/UX limits.h uses
1589 * multi line comments and the inserted #endif winds up inside the
1590 * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1591 * we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1592 * are there, and we do not add them ourselves.
1593 *
1594 * QNX Software Systems also guards the defines, but doesn't define
1595 * FLT_MIN. Therefore, bypass the fix for *either* guarded FLT_MIN
1596 * or guarded FLT_MAX.
1597 */
1598 fix = {
1599 hackname = limits_ifndefs;
1600 files = "sys/limits.h";
1601 files = "limits.h";
1602 bypass = "ifndef[ \t]+FLT_(MIN|MAX)";
1603
1604 c_fix = format;
1605 c_fix_arg = "#ifndef %1\n%0\n#endif";
1606 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
1607 "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
1608 test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */";
1609 };
1610
1611
1612 /*
1613 * Delete the '#define void int' line from curses.h on Lynx
1614 */
1615 fix = {
1616 hackname = lynx_void_int;
1617 files = curses.h;
1618 select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*";
1619 c_fix = format;
1620 c_fix_arg = "";
1621 test_text = "# define\tvoid\tint \t/* curses foiled again */";
1622 };
1623
1624
1625 /*
1626 * Fix fcntl prototype in fcntl.h on LynxOS.
1627 */
1628 fix = {
1629 hackname = lynxos_fcntl_proto;
1630 files = fcntl.h;
1631 select = "fcntl[ \t]*" '\(int, int, int\)';
1632 c_fix = format;
1633 c_fix_arg = '%1...)';
1634 c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)';
1635 test_text = "extern int fcntl(int, int, int);";
1636 };
1637
1638
1639 /*
1640 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
1641 *
1642 * On NetBSD, machine is a symbolic link to an architecture specific
1643 * directory name, so we can't match a specific file name here.
1644 */
1645 fix = {
1646 hackname = machine_ansi_h_va_list;
1647 select = "define[ \t]+_BSD_VA_LIST_[ \t]";
1648 bypass = '__builtin_va_list';
1649
1650 c_fix = format;
1651 c_fix_arg = "%1__builtin_va_list";
1652 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
1653
1654 test_text = " # define _BSD_VA_LIST_\tchar**";
1655 };
1656
1657
1658 /*
1659 * Fix non-ansi machine name defines
1660 */
1661 fix = {
1662 hackname = machine_name;
1663 c_test = machine_name;
1664 c_fix = machine_name;
1665
1666 test_text = "/* MACH_DIFF: */\n"
1667 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
1668 "\n/* no uniform test, so be careful :-) */";
1669 };
1670
1671
1672 /*
1673 * Some math.h files define struct exception, which conflicts with
1674 * the class exception defined in the C++ file std/stdexcept.h. We
1675 * redefine it to __math_exception. This is not a great fix, but I
1676 * haven't been able to think of anything better.
1677 * Note that we have to put the #ifdef/#endif blocks at beginning
1678 * and end of file, because fixproto runs after us and may insert
1679 * additional references to struct exception.
1680 */
1681 fix = {
1682 hackname = math_exception;
1683 files = math.h;
1684 select = "struct exception";
1685 bypass = 'We have a problem when using C\+\+';
1686 c_fix = wrap;
1687
1688 c_fix_arg = "#ifdef __cplusplus\n"
1689 "#define exception __math_exception\n"
1690 "#endif\n";
1691
1692 c_fix_arg = "#ifdef __cplusplus\n"
1693 "#undef exception\n"
1694 "#endif\n";
1695
1696 test_text = "typedef struct exception t_math_exception;";
1697 };
1698
1699
1700 /*
1701 * This looks pretty broken to me. ``dbl_max_def'' will contain
1702 * "define DBL_MAX " at the start, when what we really want is just
1703 * the value portion. Can't figure out how to write a test case
1704 * for this either :-(
1705 */
1706 fix = {
1707 hackname = math_huge_val_from_dbl_max;
1708 files = math.h;
1709
1710 /*
1711 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
1712 * in math.h, this fix applies.
1713 */
1714 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
1715 bypass = "define[ \t]+DBL_MAX";
1716
1717 shell =
1718 /*
1719 * See if we have a definition for DBL_MAX in float.h.
1720 * If we do, we will replace the one in math.h with that one.
1721 */
1722
1723 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
1724 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
1725
1726 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
1727 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
1728 "s@DBL_MAX@'\"$dbl_max_def@\"\n"
1729 "\telse cat\n"
1730 "\tfi";
1731
1732 test_text =
1733 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
1734 "#define HUGE_VAL DBL_MAX";
1735 };
1736
1737
1738 /*
1739 * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
1740 */
1741 fix = {
1742 hackname = math_huge_val_ifndef;
1743 files = math.h;
1744 files = math/math.h;
1745 select = "define[ \t]+HUGE_VAL";
1746
1747 c_fix = format;
1748 c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
1749 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
1750
1751 test_text = "# define\tHUGE_VAL 3.4e+40";
1752 };
1753
1754
1755 /*
1756 * nested comment
1757 */
1758 fix = {
1759 hackname = nested_auth_des;
1760 files = rpc/rpc.h;
1761 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
1762 c_fix = format;
1763 c_fix_arg = "%1*/ /*";
1764 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
1765 };
1766
1767
1768 /*
1769 * Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
1770 */
1771 fix = {
1772 hackname = nested_motorola;
1773 mach = "m68k-motorola-sysv*";
1774 files = sys/limits.h;
1775 files = limits.h;
1776 select = "max # bytes atomic in write|error value returned by Math lib";
1777
1778 sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*"
1779 "/\\* max # bytes atomic in write to a\\)$@\\1 */@";
1780 sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)"
1781 "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@";
1782
1783 test_text =
1784 "#undef PIPE_BUF /* max # bytes atomic in write to a\n"
1785 "\t\t/* PIPE */\n"
1786 "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/";
1787 };
1788
1789
1790 /*
1791 * Fixing nested comments in ISC <sys/limits.h>
1792 */
1793 fix = {
1794 hackname = nested_sys_limits;
1795 files = sys/limits.h;
1796 select = CHILD_MAX;
1797 sed = "/CHILD_MAX/s,/\\* Max, Max,";
1798 sed = "/OPEN_MAX/s,/\\* Max, Max,";
1799 test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n"
1800 "#define OPEN_MAX 20 /* Max, Max, ... */\n";
1801 };
1802
1803
1804 /*
1805 * NetBSD has a semicolon after the ending '}' for some extern "C".
1806 */
1807 fix = {
1808 hackname = netbsd_extra_semicolon;
1809 mach = *-*-netbsd*;
1810 files = sys/cdefs.h;
1811 select = "#define[ \t]*__END_DECLS[ \t]*};";
1812
1813 c_fix = format;
1814 c_fix_arg = "#define __END_DECLS }";
1815
1816 test_text = "#define __END_DECLS };";
1817 };
1818
1819
1820 /*
1821 * NeXT 3.2 adds const prefix to some math functions.
1822 * These conflict with the built-in functions.
1823 */
1824 fix = {
1825 hackname = next_math_prefix;
1826 files = ansi/math.h;
1827 select = "^extern[ \t]+double[ \t]+__const__[ \t]";
1828
1829 c_fix = format;
1830 c_fix_arg = "extern double %1(";
1831 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
1832
1833 test_text = "extern\tdouble\t__const__\tmumble();";
1834 };
1835
1836
1837 /*
1838 * NeXT 3.2 uses the word "template" as a parameter for some
1839 * functions. GCC reports an invalid use of a reserved key word
1840 * with the built-in functions.
1841 */
1842 fix = {
1843 hackname = next_template;
1844 files = bsd/libc.h;
1845 select = "[ \t]template\\)";
1846
1847 c_fix = format;
1848 c_fix_arg = "(%1)";
1849 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
1850 test_text = "extern mumble( char * template); /* fix */";
1851 };
1852
1853
1854 /*
1855 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
1856 * function prototypes. That conflicts with the built-in functions.
1857 */
1858 fix = {
1859 hackname = next_volitile;
1860 files = ansi/stdlib.h;
1861 select = "^extern[ \t]+volatile[ \t]+void[ \t]";
1862
1863 c_fix = format;
1864 c_fix_arg = "extern void %1(";
1865 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
1866
1867 test_text = "extern\tvolatile\tvoid\tabort();";
1868 };
1869
1870
1871 /*
1872 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1873 * Note that version 3 of the NeXT system has wait.h in a different directory,
1874 * so that this code won't do anything. But wait.h in version 3 has a
1875 * conditional, so it doesn't need this fix. So everything is okay.
1876 */
1877 fix = {
1878 hackname = next_wait_union;
1879 files = sys/wait.h;
1880
1881 select = 'wait\(union wait';
1882 c_fix = format;
1883 c_fix_arg = "wait(void";
1884 test_text = "extern pid_d wait(union wait*);";
1885 };
1886
1887
1888 /*
1889 * a missing semi-colon at the end of the nodeent structure definition.
1890 */
1891 fix = {
1892 hackname = nodeent_syntax;
1893 files = netdnet/dnetdb.h;
1894 select = "char[ \t]*\\*na_addr[ \t]*$";
1895 c_fix = format;
1896 c_fix_arg = "%0;";
1897 test_text = "char *na_addr\t";
1898 };
1899
1900
1901 /*
1902 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
1903 * defining regex.h related types. This causes libg++ build and usage
1904 * failures. Fixing this correctly requires checking and modifying 3 files.
1905 */
1906 fix = {
1907 hackname = osf_namespace_a;
1908 files = reg_types.h;
1909 files = sys/lc_core.h;
1910 test = " -r reg_types.h";
1911 test = " -r sys/lc_core.h";
1912 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1913 test = " -z \"`grep __regex_t regex.h`\"";
1914
1915 c_fix = format;
1916 c_fix_arg = "__%0";
1917 c_fix_arg = "reg(ex|off|match)_t";
1918
1919 test_text = "`touch sys/lc_core.h`"
1920 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
1921 "extern regex_t re;\n"
1922 "extern regoff_t ro;\n"
1923 "extern regmatch_t rm;\n";
1924 };
1925
1926 fix = {
1927 hackname = osf_namespace_c;
1928 files = regex.h;
1929 test = " -r reg_types.h";
1930 test = " -r sys/lc_core.h";
1931 test = " -n \"`grep '} regex_t;' reg_types.h`\"";
1932 test = " -z \"`grep __regex_t regex.h`\"";
1933
1934 select = "#include <reg_types\.h>.*";
1935 c_fix = format;
1936 c_fix_arg = "%0\n"
1937 "typedef __regex_t\tregex_t;\n"
1938 "typedef __regoff_t\tregoff_t;\n"
1939 "typedef __regmatch_t\tregmatch_t;";
1940
1941 test_text = "#include <reg_types.h>";
1942 };
1943
1944
1945 /*
1946 * Fix __page_size* declarations in pthread.h AIX 4.1.[34].
1947 * The original ones fail if uninitialized externs are not common.
1948 * This is the default for all ANSI standard C++ compilers.
1949 */
1950 fix = {
1951 hackname = pthread_page_size;
1952 files = pthread.h;
1953 select = "^int __page_size";
1954 c_fix = format;
1955 c_fix_arg = "extern %0";
1956 test_text = "int __page_size;";
1957 };
1958
1959
1960 /*
1961 * Fix return type of fread and fwrite on sysV68
1962 */
1963 fix = {
1964 hackname = read_ret_type;
1965 files = stdio.h;
1966 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
1967 c_fix = format;
1968 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
1969 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
1970
1971 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
1972 };
1973
1974
1975 /*
1976 * function class(double x) conflicts with C++ keyword on rs/6000
1977 */
1978 fix = {
1979 hackname = rs6000_double;
1980 files = math.h;
1981 select = '[^a-zA-Z_]class\(';
1982
1983 c_fix = format;
1984 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1985 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
1986
1987 test_text = "extern int class();";
1988 };
1989
1990
1991 /*
1992 * Wrong fchmod prototype on RS/6000.
1993 */
1994 fix = {
1995 hackname = rs6000_fchmod;
1996 files = sys/stat.h;
1997 select = 'fchmod\(char \*';
1998 c_fix = format;
1999 c_fix_arg = "fchmod(int";
2000 test_text = "extern int fchmod(char *, mode_t);";
2001 };
2002
2003
2004 /*
2005 * parameters conflict with C++ new on rs/6000
2006 */
2007 fix = {
2008 hackname = rs6000_param;
2009 files = "stdio.h";
2010 files = "unistd.h";
2011
2012 select = 'rename\(const char \*old, const char \*new\)';
2013 c_fix = format;
2014 c_fix_arg = 'rename(const char *_old, const char *_new)';
2015
2016 test_text = 'extern int rename(const char *old, const char *new);';
2017 };
2018
2019 /*
2020 * On OpenServer and on UnixWare 7, <math.h> uses the native compiler
2021 * __builtin_generic. We fix that usage to use the GCC equivalent.
2022 * It also has a plethora of inline functions that conflict with libstdc++.
2023 */
2024 fix = {
2025 hackname = sco_math;
2026 files = math.h;
2027 files = ansi/math.h;
2028 files = posix/math.h;
2029 files = xpg4/math.h;
2030 files = xpg4v2/math.h;
2031 files = xpg4plus/math.h;
2032 files = ods_30_compat/math.h;
2033 files = oldstyle/math.h;
2034 select = "inline double abs";
2035 sed = "/#define.*__fp_class(a) \\\\/i\\\n"
2036 "#ifndef __GNUC__\n";
2037 sed =
2038 "/.*__builtin_generic/a\\\n"
2039 "#else\\\n"
2040 "#define __fp_class(a) \\\\\\\n"
2041 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n"
2042 " __fpclassifyl(a), \\\\\\\n"
2043 " __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n"
2044 " __fpclassifyf(a),__fpclassify(a)))\\\n"
2045 "#endif";
2046
2047 sed = "/extern \"C\\+\\+\"/N;"
2048 "/inline double abs/i\\\n"
2049 "#ifndef __GNUC__\n";
2050 sed = "/inline long double trunc/N;"
2051 "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n"
2052 "#endif /* ! __GNUC__ */";
2053
2054 test_text =
2055 "#define __fp_class(a) \\\\\n"
2056 " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n";
2057
2058 };
2059
2060 /*
2061 * On SCO OpenServer prior to 5.0.7UP1, <sys/regset.h> and <ieeefp.h>
2062 * have a clash on struct _fpstate and struct fpstate.
2063 */
2064 fix = {
2065 hackname = sco_regset;
2066 files = sys/regset.h;
2067 mach = "*-*-sco3.2v5*";
2068 select = "(struct[ \t]+.*)fpstate";
2069 c_fix = format;
2070 c_fix_arg = "%1rsfpstate";
2071
2072 test_text =
2073 "union u_fps {\n"
2074 " struct\tfpstate\n"
2075 " {\n"
2076 " int whatever;\n"
2077 " }\n"
2078 "};\n"
2079 "union _u_fps {\n"
2080 " struct _fpstate\n"
2081 " {\n"
2082 " int whatever;\n"
2083 " }\n"
2084 "};\n";
2085 };
2086
2087 /*
2088 * The static functions lstat() and fchmod() in <sys/stat.h>
2089 * cause G++ grief since they're not wrapped in "if __cplusplus".
2090 *
2091 * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains
2092 * tiny static wrappers that aren't C++ safe.
2093 */
2094 fix = {
2095 hackname = sco_static_func;
2096 files = sys/stat.h;
2097 mach = "i?86-*-sco3.2*";
2098 select = "^static int";
2099
2100 sed = "/^static int/i\\\n"
2101 "#if __cplusplus\\\n"
2102 "extern \"C\" {\\\n"
2103 "#endif /* __cplusplus */";
2104
2105 sed = "/^}$/a\\\n"
2106 "#if __cplusplus\\\n"
2107 " }\\\n"
2108 "#endif /* __cplusplus */";
2109
2110 test_text =
2111 "#ifdef __STDC__\n"
2112 "static int\tstat(const char *__f, struct stat *__p) {\n"
2113 "\treturn __stat32(__f, __p);\n"
2114 "}\n\n# else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n"
2115
2116 "static int\tstat(__f, __p)\n"
2117 "\tchar *__f;\n"
2118 "\tstruct stat *__p;\n"
2119 "{\n"
2120 "\treturn __stat32(__f, __p);\n"
2121 "}\n"
2122 "#endif";
2123 };
2124
2125
2126 /*
2127 * Fix prototype declaration of utime in sys/times.h.
2128 * In 3.2v4.0 the const is missing.
2129 */
2130 fix = {
2131 hackname = sco_utime;
2132 files = sys/times.h;
2133 mach = "i?86-*-sco3.2v4*";
2134
2135 select = '\(const char \*, struct utimbuf \*\);';
2136 c_fix = format;
2137 c_fix_arg = '(const char *, const struct utimbuf *);';
2138
2139 test_text = "extern int utime(const char *, struct utimbuf *);";
2140 };
2141
2142
2143 /*
2144 * Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
2145 * incorrectly, so we replace them with versions that correspond to
2146 * the definition. We also explicitly name this fix "1" and the next
2147 * fix "2" because this one does not deal with the last field. This
2148 * fix needs to run before the next.
2149 */
2150 fix = {
2151 hackname = solaris_mutex_init_1;
2152 select = '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI";
2153 files = pthread.h;
2154 sed = "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n"
2155 "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/";
2156 test_text =
2157 '#ident "@(#)pthread.h 1.16 97/05/05 SMI"'"\n"
2158 "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n"
2159 "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n";
2160 };
2161
2162
2163 /*
2164 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
2165 * "0" for the last field of the pthread_mutex_t structure, which is
2166 * of type upad64_t, which itself is typedef'd to int64_t, but with
2167 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
2168 * initializer to "{0}" instead
2169 */
2170 fix = {
2171 hackname = solaris_mutex_init_2;
2172 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
2173 files = pthread.h;
2174 c_fix = format;
2175 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
2176 "%0\n"
2177 "#else\n"
2178 "%1, {0}}%3\n"
2179 "#endif";
2180 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+{.*)"
2181 ",[ \t]*0}" "(|[ \t].*)$";
2182 test_text =
2183 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
2184 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
2185 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
2186 "#define PTHREAD_RWLOCK_INITIALIZER\t"
2187 "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
2188 };
2189
2190
2191 /*
2192 * Solaris 2.8 has what appears to be some gross workaround for
2193 * some old version of their c++ compiler. G++ doesn't want it
2194 * either, but doesn't want to be tied to SunPRO version numbers.
2195 */
2196 fix = {
2197 hackname = solaris_stdio_tag;
2198 files = stdio_tag.h;
2199
2200 select = '__cplusplus < 54321L';
2201 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
2202
2203 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
2204 };
2205
2206 /*
2207 * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h>
2208 * functions, breaking their prototypes if that file is included afterwards.
2209 * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6
2210 * and up.
2211 */
2212 fix = {
2213 hackname = solaris_widec;
2214 files = widec.h;
2215 mach = '*-*-solaris2.[0-5]*';
2216 bypass = "include.*wchar\\.h";
2217 select = "#include <euc.h>";
2218 c_fix = format;
2219 c_fix_arg = "%0\n#include <wchar.h>";
2220 test_text = "#include <euc.h>";
2221 };
2222
2223
2224 /*
2225 * Add a `static' declaration of `getrnge' into <regexp.h>.
2226 *
2227 * Don't do this if there is already a `static void getrnge' declaration
2228 * present, since this would cause a redeclaration error. Solaris 2.x has
2229 * such a declaration.
2230 */
2231 #ifdef SVR4
2232 fix = {
2233 hackname = static_getrnge;
2234 files = regexp.h;
2235 bypass = "static void getrnge";
2236 sed = "/^static int[ \t]*size;/c\\\n"
2237 "static int size ;\\\n\\\n"
2238 "static int getrnge ();";
2239 };
2240 #endif
2241
2242
2243 /*
2244 * a missing semi-colon at the end of the statsswtch structure definition.
2245 */
2246 fix = {
2247 hackname = statsswtch;
2248 files = rpcsvc/rstat.h;
2249 select = "boottime$";
2250 c_fix = format;
2251 c_fix_arg = "boottime;";
2252 test_text = "struct statswtch {\n int boottime\n};";
2253 };
2254
2255
2256 /*
2257 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
2258 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
2259 * OK too.
2260 */
2261 fix = {
2262 hackname = stdio_stdarg_h;
2263 files = stdio.h;
2264 bypass = "include.*(stdarg\.h|machine/ansi\.h)";
2265
2266 c_fix = wrap;
2267
2268 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
2269
2270 test_text = "";
2271 };
2272
2273
2274 /*
2275 * Don't use or define the name va_list in stdio.h.
2276 * This is for ANSI and also to interoperate properly with gcc's varargs.h.
2277 * Note _BSD_VA_LIST_ is dealt with elsewhere.
2278 */
2279 fix = {
2280 hackname = stdio_va_list;
2281 files = stdio.h;
2282 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list';
2283
2284 /*
2285 * Use __gnuc_va_list in arg types in place of va_list.
2286 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
2287 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
2288 * trailing parentheses and semicolon save all other systems from this.
2289 * Define __not_va_list__ (something harmless and unused)
2290 * instead of va_list.
2291 * Don't claim to have defined va_list.
2292 */
2293 sed = "s@ va_list @ __gnuc_va_list @\n"
2294 "s@ va_list)@ __gnuc_va_list)@\n"
2295 "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
2296 "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
2297 "s@ va_list@ __not_va_list__@\n"
2298 "s@\\*va_list@*__not_va_list__@\n"
2299 "s@ __va_list)@ __gnuc_va_list)@\n"
2300 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
2301 "@typedef \\1 __not_va_list__;@\n"
2302 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
2303 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
2304 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
2305 "s@VA_LIST@DUMMY_VA_LIST@\n"
2306 "s@_Va_LIST@_VA_LIST@";
2307 test_text = "extern void mumble( va_list);";
2308 };
2309
2310
2311 /*
2312 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
2313 * is "!defined( __STRICT_ANSI__ )"
2314 */
2315 fix = {
2316 hackname = strict_ansi_not;
2317 select = "^([ \t]*#[ \t]*if.*)"
2318 "(!__STDC__"
2319 "|__STDC__[ \t]*==[ \t]*0"
2320 "|__STDC__[ \t]*!=[ \t]*1"
2321 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
2322 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
2323 bypass = 'GNU and MIPS C compilers define __STDC__ differently';
2324 c_test = stdc_0_in_system_headers;
2325
2326 c_fix = format;
2327 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2328
2329 test_text = "#if !__STDC__ \n"
2330 "#if __STDC__ == 0\n"
2331 "#if __STDC__ != 1\n"
2332 "#if __STDC__ - 0 == 0"
2333 "/* not std C */\nint foo;\n"
2334 "\n#end-end-end-end-if :-)";
2335 };
2336
2337 /*
2338 * "__STDC__-0==0"
2339 * is "!defined( __STRICT_ANSI__ )" on continued #if-s
2340 */
2341 fix = {
2342 hackname = strict_ansi_not_ctd;
2343 files = math.h, limits.h, stdio.h, signal.h,
2344 stdlib.h, sys/signal.h, time.h;
2345 /*
2346 * Starting at the beginning of a line, skip white space and
2347 * a leading "(" or "&&" or "||". One of those must be found.
2348 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
2349 * expression. If these are nested, then they must accumulate
2350 * because we won't match any closing parentheses. Finally,
2351 * after skipping over all that, we must then match our suspect
2352 * phrase: "__STDC__-0==0" with or without white space.
2353 */
2354 select = "^([ \t]*" '(\(|&&|\|\|)'
2355 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
2356 "[ \t(]*)"
2357 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
2358 c_test = stdc_0_in_system_headers;
2359
2360 c_fix = format;
2361 c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
2362
2363 test_text = "#if 1 && \\\\\n"
2364 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
2365 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
2366 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
2367 "int foo;\n#endif";
2368 };
2369
2370
2371 /*
2372 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
2373 * is "defined( __STRICT_ANSI__ )"
2374 */
2375 fix = {
2376 hackname = strict_ansi_only;
2377 select = "^([ \t]*#[ \t]*if.*)"
2378 "(__STDC__[ \t]*!=[ \t]*0"
2379 "|__STDC__[ \t]*==[ \t]*1"
2380 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
2381 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
2382 c_test = stdc_0_in_system_headers;
2383
2384 c_fix = format;
2385 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
2386
2387 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
2388 };
2389
2390
2391 /*
2392 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
2393 * in prototype without previous definition.
2394 */
2395 fix = {
2396 hackname = struct_file;
2397 files = rpc/xdr.h;
2398 select = '^.*xdrstdio_create.*struct __file_s';
2399 c_fix = format;
2400 c_fix_arg = "struct __file_s;\n%0";
2401 test_text = "extern void xdrstdio_create( struct __file_s* );";
2402 };
2403
2404
2405 /*
2406 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
2407 * in prototype without previous definition.
2408 */
2409 fix = {
2410 hackname = struct_sockaddr;
2411 files = rpc/auth.h;
2412 select = "^.*authdes_create.*struct sockaddr";
2413 bypass = "<sys/socket\.h>";
2414 c_fix = format;
2415 c_fix_arg = "struct sockaddr;\n%0";
2416 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
2417 };
2418
2419
2420 /*
2421 * Apply fix this to all OSs since this problem seems to effect
2422 * more than just SunOS.
2423 */
2424 fix = {
2425 hackname = sun_auth_proto;
2426 files = rpc/auth.h;
2427 files = rpc/clnt.h;
2428 files = rpc/svc.h;
2429 files = rpc/xdr.h;
2430 /*
2431 * Select those files containing '(*name)()'.
2432 */
2433 select = '\(\*[a-z][a-z_]*\)\(\)';
2434
2435 c_fix = format;
2436 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
2437 "#else\n%1();%2\n#endif";
2438 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
2439
2440 test_text =
2441 "struct auth_t {\n"
2442 " int (*name)(); /* C++ bad */\n"
2443 "};";
2444 };
2445
2446
2447 /*
2448 * Fix bogus #ifdef on SunOS 4.1.
2449 */
2450 fix = {
2451 hackname = sun_bogus_ifdef;
2452 files = "hsfs/hsfs_spec.h";
2453 files = "hsfs/iso_spec.h";
2454 select = '#ifdef(.*\|\|.*)';
2455 c_fix = format;
2456 c_fix_arg = "#if%1";
2457
2458 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
2459 };
2460
2461
2462 /*
2463 * Fix the CAT macro in SunOS memvar.h.
2464 */
2465 fix = {
2466 hackname = sun_catmacro;
2467 files = pixrect/memvar.h;
2468 select = "^#define[ \t]+CAT\\(a,b\\).*";
2469 c_fix = format;
2470
2471 c_fix_arg =
2472 "#ifdef __STDC__\n"
2473 "# define CAT(a,b) a##b\n"
2474 "#else\n%0\n#endif";
2475
2476 test_text =
2477 "#define CAT(a,b)\ta/**/b";
2478 };
2479
2480
2481 /*
2482 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
2483 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
2484 */
2485 fix = {
2486 hackname = sun_malloc;
2487 files = malloc.h;
2488
2489 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
2490 sed = "s/int[ \t][ \t]*free/void\tfree/g";
2491 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
2492 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
2493 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
2494
2495 test_text =
2496 "typedef char *\tmalloc_t;\n"
2497 "int \tfree();\n"
2498 "char*\tmalloc();\n"
2499 "char*\tcalloc();\n"
2500 "char*\trealloc();";
2501 };
2502
2503
2504 /*
2505 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
2506 */
2507 fix = {
2508 hackname = sun_rusers_semi;
2509 files = rpcsvc/rusers.h;
2510 select = "_cnt$";
2511 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
2512 test_text = "struct mumble\n int _cnt\n};";
2513 };
2514
2515
2516 /*
2517 * signal.h on SunOS defines signal using (),
2518 * which causes trouble when compiling with g++ -pedantic.
2519 */
2520 fix = {
2521 hackname = sun_signal;
2522 files = sys/signal.h;
2523 files = signal.h;
2524 select = "^void\t" '\(\*signal\(\)\)\(\);.*';
2525
2526 c_fix = format;
2527 c_fix_arg =
2528 "#ifdef __cplusplus\n"
2529 "void\t(*signal(...))(...);\n"
2530 "#else\n%0\n#endif";
2531
2532 test_text = "void\t(*signal())();";
2533 };
2534
2535
2536 /*
2537 * math.h on SunOS 4 puts the declaration of matherr before the definition
2538 * of struct exception, so the prototype (added by fixproto) causes havoc.
2539 */
2540 fix = {
2541 hackname = sunos_matherr_decl;
2542 files = math.h;
2543
2544 /* If matherr has a prototype already, the header needs no fix. */
2545 bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)';
2546 select = matherr;
2547
2548 c_fix = wrap;
2549 c_fix_arg = "struct exception;\n";
2550
2551 test_text = "extern int matherr();";
2552 };
2553
2554
2555 /*
2556 * Correct the return type for strlen in strings.h in SunOS 4.
2557 */
2558 fix = {
2559 hackname = sunos_strlen;
2560 files = strings.h;
2561 select = "int[ \t]*strlen\\(\\);(.*)";
2562 c_fix = format;
2563 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
2564 test_text = " int\tstrlen(); /* string length */";
2565 };
2566
2567
2568 /*
2569 * Solaris math.h and floatingpoint.h define __P without protection,
2570 * which conflicts with the fixproto definition. The fixproto
2571 * definition and the Solaris definition are used the same way.
2572 */
2573 fix = {
2574 hackname = svr4__p;
2575 files = math.h;
2576 files = floatingpoint.h;
2577 select = "^#define[ \t]+__P.*";
2578 c_fix = format;
2579 c_fix_arg = "#ifndef __P\n%0\n#endif";
2580
2581 test_text = "#define __P(a) a";
2582 };
2583
2584
2585 /*
2586 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
2587 * that is visible to any ANSI compiler using this include. Simply
2588 * delete the lines that #define some string functions to internal forms.
2589 */
2590 fix = {
2591 hackname = svr4_disable_opt;
2592 files = string.h;
2593 select = '#define.*__std_hdr_';
2594 sed = '/#define.*__std_hdr_/d';
2595 test_text = "#define strlen __std_hdr_strlen\n";
2596 };
2597
2598 /*
2599 * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
2600 * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h
2601 * but we still "hijack" it and redirect it to the GNU byteorder.h..
2602 */
2603 #ifdef SVR5
2604 fix = {
2605 hackname = svr4_endian;
2606 files = sys/endian.h;
2607 #ifdef LATER
2608 /*
2609 * since we emit our own sys/byteorder.h,
2610 * this fix can never be applied to that file.
2611 */
2612 files = sys/byteorder.h;
2613 #endif
2614 bypass = '__GNUC__';
2615
2616 sed = "/#\tifdef\t__STDC__/i\\\n"
2617 "# if !defined (__GNUC__) && !defined (__GNUG__)\n";
2618
2619 sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /";
2620
2621 sed = "/# include\t<sys\\/byteorder.h>/i\\\n"
2622 "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n";
2623 };
2624 #endif /* SVR5 */
2625
2626
2627 /*
2628 * Remove useless extern keyword from struct forward declarations
2629 * in <sys/stream.h> and <sys/strsubr.h>
2630 */
2631 #ifdef SVR4
2632 fix = {
2633 hackname = svr4_extern_struct;
2634 files = sys/stream.h;
2635 files = sys/strsubr.h;
2636 select = 'extern struct [a-z_]*;';
2637 sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/';
2638 };
2639 #endif
2640
2641 /*
2642 * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4
2643 * systems the file <ftw.h> contains extern declarations of these
2644 * functions followed by explicitly `static' definitions of these
2645 * functions... and that's not allowed according to ANSI C. (Note
2646 * however that on Solaris, this header file glitch has been pre-fixed by
2647 * Sun. In the Solaris version of <ftw.h> there are no static
2648 * definitions of any function so we don't need to do any of this stuff
2649 * when on Solaris.
2650 */
2651 #ifdef SVR4
2652 #ifndef SOLARIS
2653 fix = {
2654 hackname = svr4_ftw;
2655 files = ftw.h;
2656 select = '^extern int ftw\(const';
2657
2658 sed = '/^extern int ftw(const/i' "\\\n"
2659 "#if !defined(_STYPES)\\\n"
2660 "static\\\n"
2661 "#else\\\n"
2662 "extern\\\n"
2663 "#endif";
2664 sed = 's/extern \(int ftw(const.*\)$/\1/';
2665 sed = "/^extern int nftw/i\\\n"
2666 "#if defined(_STYPES)\\\n"
2667 "static\\\n"
2668 "#else\\\n"
2669 "extern\\\n"
2670 "#endif";
2671 sed = 's/extern \(int nftw.*\)$/\1/';
2672 sed = "/^extern int ftw(),/c\\\n"
2673 "#if !defined(_STYPES)\\\n"
2674 "static\\\n"
2675 "#else\\\n"
2676 "extern\\\n"
2677 "#endif\\\n"
2678 " int ftw();\\\n"
2679 "#if defined(_STYPES)\\\n"
2680 "static\\\n"
2681 "#else\\\n"
2682 "extern\\\n"
2683 "#endif\\\n"
2684 " int nftw();";
2685 };
2686 #endif
2687 #endif
2688
2689
2690 /*
2691 * Fix broken decl of getcwd present on some svr4 systems.
2692 */
2693 fix = {
2694 hackname = svr4_getcwd;
2695 files = stdlib.h;
2696 files = unistd.h;
2697 files = prototypes.h;
2698 select = 'getcwd\(char \*, int\)';
2699
2700 c_fix = format;
2701 c_fix_arg = "getcwd(char *, size_t)";
2702
2703 test_text = "extern char* getcwd(char *, int);";
2704 };
2705
2706
2707 /*
2708 * set ifdef _KERNEL
2709 */
2710 #ifdef SVR4
2711 fix = {
2712 hackname = svr4_kernel;
2713 files = fs/rfs/rf_cache.h;
2714 files = sys/erec.h;
2715 files = sys/err.h;
2716 files = sys/char.h;
2717 files = sys/getpages.h;
2718 files = sys/map.h;
2719 files = sys/cmn_err.h;
2720 files = sys/kdebugger.h;
2721 bypass = '_KERNEL';
2722 c_fix = wrap;
2723
2724 c_fix_arg = "#ifdef _KERNEL\n";
2725 c_fix_arg = "#endif /* _KERNEL */\n";
2726 test_text = "";
2727 };
2728 #endif
2729
2730 /*
2731 * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
2732 * tend to conflict with the compiler's own definition of this symbol. (We
2733 * will use the compiler's definition.)
2734 * Likewise __sparc, for Solaris, and __i860, and a few others
2735 * (guessing it is necessary for all of them).
2736 */
2737 #ifdef SVR4
2738 fix = {
2739 hackname = svr4_mach_defines;
2740 files = ieeefp.h;
2741 select = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]";
2742 sed = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d";
2743 };
2744 #endif
2745
2746
2747 /*
2748 * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
2749 * They are declared as non-static then immediately redeclared as static.
2750 */
2751 #ifdef SVR5
2752 fix = {
2753 hackname = svr4_mkdev;
2754 files = sys/mkdev.h;
2755 select = '^static';
2756
2757 sed = "/^dev_t makedev(/s/^/static /";
2758 sed = "/^major_t major(/s/^/static /";
2759 sed = "/^minor_t minor(/s/^/static /";
2760 };
2761 #endif /* SVR5 */
2762
2763
2764 /*
2765 * Fix reference to NC_NPI_RAW in <sys/netcspace.h>.
2766 * Also fix types of array initializers.
2767 */
2768 #ifdef SVR4
2769 fix = {
2770 hackname = svr4_netcspace;
2771 files = sys/netcspace.h;
2772 select = 'NC_NPI_RAW';
2773 sed = 's/NC_NPI_RAW/NC_TPI_RAW/g';
2774 sed = 's/NC_/(unsigned long) NC_/';
2775 };
2776 #endif
2777
2778 /*
2779 * Fix reference to NMSZ in <sys/adv.h>.
2780 */
2781 #ifdef SVR4
2782 fix = {
2783 hackname = svr4_nmsz;
2784 files = sys/adv.h;
2785 select = '\[NMSZ\]';
2786 sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g';
2787 };
2788 #endif
2789
2790
2791 /*
2792 * Fix broken decl of profil present on some svr4 systems.
2793 */
2794 fix = {
2795 hackname = svr4_profil;
2796 files = stdlib.h;
2797 files = unistd.h;
2798
2799 select =
2800 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
2801 c_fix = format;
2802 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
2803
2804 test_text =
2805 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
2806 };
2807
2808
2809 /*
2810 * Convert functions to prototype form, and fix arg names in <sys/stat.h>.
2811 */
2812 #ifdef SVR4
2813 fix = {
2814 hackname = svr4_proto_form;
2815 files = sys/stat.h;
2816 select = 'const extern';
2817
2818 sed = "/^stat([ \t]*[^c]/ {\nN\nN\n"
2819 "s/(.*)\\n/( /\n"
2820 "s/;\\n/, /\n"
2821 "s/;$/)/\n" "}";
2822
2823 sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n"
2824 "s/(.*)\\n/( /\n"
2825 "s/;\\n/, /\n"
2826 "s/;$/)/\n" "}";
2827
2828 sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n"
2829 "s/(.*)\\n/( /\n"
2830 "s/;\\n/, /\n"
2831 "s/;$/)/\n" "}";
2832
2833 sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n"
2834 "s/(.*)\\n/( /\n"
2835 "s/;\\n/, /g\n"
2836 "s/;$/)/\n" "}";
2837
2838 sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g";
2839 sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g";
2840 sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g";
2841 sed = "1,$s/ret\\([^u]\\)/__ret\\1/g";
2842 sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g";
2843 sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g";
2844 };
2845 #endif
2846
2847 /*
2848 * Add a prototyped declaration of mmap to <sys/mman.h>.
2849 */
2850 #ifdef SVR4
2851 fix = {
2852 hackname = svr4_proto_mmap;
2853 files = sys/mman.h;
2854 select = '^extern caddr_t mmap();$';
2855 sed = '/^extern caddr_t mmap();$/c' "\\\n"
2856 "#ifdef __STDC__\\\n"
2857 "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n"
2858 "#else /* !defined(__STDC__) */\\\n"
2859 "extern caddr_t mmap ();\\\n"
2860 "#endif /* !defined(__STDC__) */\\\n";
2861 };
2862 #endif
2863
2864 /*
2865 * Add a #define of _SIGACTION_ into <sys/signal.h>.
2866 */
2867 #ifdef SVR4
2868 fix = {
2869 hackname = svr4_sigaction;
2870 files = sys/signal.h;
2871 sed = "/^struct sigaction {/i\\\n"
2872 "#define _SIGACTION_";
2873 sed = 's/(void *(\*)())/(void (*)(int))/';
2874 };
2875 #endif
2876
2877 /*
2878 * Put storage class at start of decl, to avoid warning.
2879 */
2880 #ifdef SVR4
2881 fix = {
2882 hackname = svr4_storage_class;
2883 files = rpc/types.h;
2884 select = 'const extern';
2885 sed = 's/const extern/extern const/g';
2886 };
2887 #endif
2888
2889
2890 /*
2891 * Like svr4_mach_defines, but with newfangled syntax.
2892 * Source lines are of #define __i386 #machine(i386). Delete them.
2893 */
2894 #ifdef SVR5
2895 fix = {
2896 hackname = svr5_mach_defines;
2897 files = ieeefp.h;
2898 select = "#define[ \t]*__i386.*\(i386\)";
2899 sed = "/#define[ \t]*__i386.*/d";
2900 };
2901 #endif /* SVR5 */
2902
2903
2904 /*
2905 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2906 * in string.h on sysV68
2907 * Correct the return type for strlen in string.h on Lynx.
2908 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2909 * Add missing const for strdup on OSF/1 V3.0.
2910 * On sysV88 layout is slightly different.
2911 */
2912 fix = {
2913 hackname = sysv68_string;
2914 files = testing.h;
2915 files = string.h;
2916
2917 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
2918 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
2919 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
2920
2921 sed = "/^extern char$/N";
2922 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
2923
2924 sed = "/^extern int$/N";
2925 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
2926
2927 sed = "/^\tstrncmp(),$/N";
2928 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
2929 '\1;' "\\\nextern unsigned int\\\n\\2/";
2930
2931 test_text =
2932 "extern int strlen();\n"
2933
2934 "extern int ffs(long);\n"
2935
2936 "extern char\n"
2937 "\t*memccpy(),\n"
2938 "\tmemcpy();\n"
2939
2940 "extern int\n"
2941 "\tstrcmp(),\n"
2942 "\tstrncmp(),\n"
2943 "\tstrlen(),\n"
2944 "\tstrspn();\n"
2945
2946 "extern int\n"
2947 "\tstrlen(), strspn();";
2948 };
2949
2950
2951 /*
2952 * Fix return type of calloc, malloc, realloc, bsearch and exit
2953 */
2954 fix = {
2955 hackname = sysz_stdlib_for_sun;
2956 files = stdlib.h;
2957
2958 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
2959 c_fix = format;
2960 c_fix_arg = "void *\t%1(";
2961
2962 test_text =
2963 "extern char*\tcalloc(size_t);\n"
2964 "extern char*\tmalloc(size_t);\n"
2965 "extern char*\trealloc(void*,size_t);\n"
2966 "extern char*\tbsearch(void*,size_t,size_t);\n";
2967 };
2968
2969
2970 /*
2971 * __thread is now a keyword.
2972 */
2973 fix = {
2974 hackname = thread_keyword;
2975 files = "pthread.h";
2976 files = "bits/sigthread.h";
2977 select = "([* ])__thread([,)])";
2978 c_fix = format;
2979 c_fix_arg = "%1__thr%2";
2980
2981 test_text =
2982 "extern int pthread_create (pthread_t *__restrict __thread,\n"
2983 "extern int pthread_kill (pthread_t __thread, int __signo);\n"
2984 "extern int pthread_cancel (pthread_t __thread);";
2985 };
2986
2987 /*
2988 * if the #if says _cplusplus, not the double underscore __cplusplus
2989 * that it should be
2990 */
2991 fix = {
2992 hackname = tinfo_cplusplus;
2993 files = tinfo.h;
2994 select = "[ \t]_cplusplus";
2995
2996 c_fix = format;
2997 c_fix_arg = " __cplusplus";
2998 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
2999 };
3000
3001
3002 /*
3003 * function parameter to atexit is missing "void" on VAX Ultrix 4.3.
3004 */
3005 fix = {
3006 hackname = ultrix_atexit_param;
3007 files = stdlib.h;
3008 select = 'atexit\(.*\(\)';
3009
3010 c_fix = format;
3011 c_fix_arg = "atexit( void (*__func)( void )";
3012
3013 test_text = "int atexit( void (*__func)() );\n";
3014 };
3015
3016
3017 /*
3018 * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
3019 */
3020 fix = {
3021 hackname = ultrix_atof_param;
3022 files = math.h;
3023 select = "atof\\([ \t]*char";
3024
3025 c_fix = format;
3026 c_fix_arg = "atof(const char";
3027
3028 test_text = "extern double atof( char *__nptr);\n";
3029 };
3030
3031
3032 /*
3033 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3034 */
3035 fix = {
3036 hackname = ultrix_const;
3037 files = stdio.h;
3038 select = 'perror\( char \*';
3039
3040 c_fix = format;
3041 c_fix_arg = "%1 const %3 *__";
3042 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
3043 "[ \t]+(char|void) \\*__";
3044
3045 test_text =
3046 "extern void perror( char *__s );\n"
3047 "extern int fputs( char *__s, FILE *);\n"
3048 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
3049 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
3050 "extern int scanf( char *__format, ...);\n";
3051 };
3052
3053
3054 /*
3055 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
3056 */
3057 fix = {
3058 hackname = ultrix_const2;
3059 files = stdio.h;
3060
3061 select = '\*fopen\( char \*';
3062 c_fix = format;
3063 c_fix_arg = "%1( const char *%3, const char *";
3064 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
3065 "[ \t]*char[ \t]*\\*([^,]*),"
3066 "[ \t]*char[ \t]*\\*[ \t]*";
3067
3068 test_text =
3069 "extern FILE *fopen( char *__filename, char *__type );\n"
3070 "extern int sscanf( char *__s, char *__format, ...);\n"
3071 "extern FILE *popen(char *, char *);\n"
3072 "extern char *tempnam(char*,char*);\n";
3073 };
3074
3075
3076 /*
3077 * Ultrix V4.[35] puts the declaration of uname before the definition
3078 * of struct utsname, so the prototype (added by fixproto) causes havoc.
3079 */
3080 fix = {
3081 hackname = ultrix_fix_fixproto;
3082 files = sys/utsname.h;
3083 select = ULTRIX;
3084
3085 c_fix = format;
3086 c_fix_arg = "struct utsname;\n%0";
3087 c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);";
3088
3089 test_text =
3090 "/* ULTRIX's uname */\nextern\tint\tuname();";
3091 };
3092
3093
3094 /*
3095 * Check for bad #ifdef line (in Ultrix 4.1)
3096 */
3097 fix = {
3098 hackname = ultrix_ifdef;
3099 select = "^#ifdef KERNEL[ \t]+&&";
3100 files = sys/file.h;
3101
3102 c_fix = format;
3103 c_fix_arg = "#if defined(KERNEL) &&";
3104
3105 test_text =
3106 "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif";
3107 };
3108
3109
3110 /*
3111 * Strip "|| CC$gfloat" from Ultrix math headers.
3112 */
3113 fix = {
3114 hackname = ultrix_math_ifdef;
3115 files = sys/limits.h;
3116 files = float.h;
3117 files = math.h;
3118 select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+";
3119 c_fix = format;
3120 c_fix_arg = "%1";
3121
3122 test_text = '#if defined(__GFLOAT) || CC\$gfloat';
3123 };
3124
3125
3126 /*
3127 * Avoid nested comments on Ultrix 4.3.
3128 */
3129 fix = {
3130 hackname = ultrix_nested_ioctl;
3131 files = sys/ioctl.h;
3132 select = "^/\\* #define SIOCSCREEN";
3133 sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@";
3134 test_text =
3135 "/* #define SIOCSCREENON _IOWR('i', 49, int)"
3136 "/* screend, net/gw_screen.h */\n";
3137 };
3138
3139
3140 fix = {
3141 hackname = ultrix_nested_svc;
3142 files = rpc/svc.h;
3143 select = "^ \\*[ \t]*int protocol; */\\*";
3144 sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@";
3145 test_text =
3146 " *\tint protocol; /* like TCP or UDP\n";
3147 };
3148
3149
3150 /*
3151 * Add missing prototype for lstat and define for S_ISLNK
3152 * in Ultrix V4.3 sys/stat.h.
3153 */
3154 fix = {
3155 hackname = ultrix_stat;
3156 files = sys/stat.h;
3157 select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)";
3158 sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n"
3159 "\\\n"
3160 "/* macro to test for symbolic link */\\\n"
3161 "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n"
3162 "\n";
3163 sed = "/^[ \t]*fstat(),$/a\\\n"
3164 "\tlstat(),\n";
3165 test_text =
3166 "@(#)stat.h 6.1 (ULTRIX)\n"
3167 "#define S_IFPORT S_IFIFO\n"
3168 "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */";
3169 };
3170
3171
3172 /*
3173 * Check for superfluous `static' (in Ultrix 4.2)
3174 * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
3175 */
3176 fix = {
3177 hackname = ultrix_static;
3178 files = machine/cpu.h;
3179 select = '#include "r[34]_cpu';
3180 sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/";
3181 sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/';
3182 sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/';
3183 test_text =
3184 "static struct tlb_pid_state {\n"
3185 "#include \"r3_cpu.h\"\n";
3186 };
3187
3188
3189 /*
3190 * Add once-only latch to Ultrix V4.3 strings.h.
3191 */
3192 fix = {
3193 hackname = ultrix_strings;
3194 files = strings.h;
3195 select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)";
3196 c_fix = wrap;
3197 test_text =
3198 "@(#)strings.h 6.1 (ULTRIX)\n";
3199 };
3200
3201
3202 /*
3203 * Fix multiple defines for NULL. Sometimes, we stumble into \r\n
3204 * terminated lines, so accommodate these. Test both ways.
3205 */
3206 fix = {
3207 hackname = undefine_null;
3208 select = "^#[ \t]*define[ \t]+NULL[ \t]";
3209 bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
3210
3211 c_fix = format;
3212 c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
3213 c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
3214
3215 test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
3216 };
3217
3218 /*
3219 * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict"
3220 * which must be replaced by __restrict__ for GCC.
3221 */
3222 fix = {
3223 hackname = unicosmk_restrict;
3224 files = stdio.h;
3225 files = stdlib.h;
3226 files = wchar.h;
3227 mach = "*-*-unicosmk*";
3228 select = "(\\*[ \t]*)restrict([ \t]+)";
3229
3230 c_fix = format;
3231 c_fix_arg = "%1__restrict__%2";
3232
3233 test_text = "void f (char * restrict x);";
3234 };
3235
3236 /*
3237 * If arpa/inet.h prototypes are incompatible with the ones we just
3238 * installed in <sys/byteorder.h>, just remove the protos.
3239 * Because of this close association, this patch must be applied only
3240 * on those systems where the replacement byteorder header is installed.
3241 */
3242 fix = {
3243 hackname = uw7_byteorder_fix;
3244 files = arpa/inet.h;
3245 select = "in_port_t";
3246 test = "-f sys/byteorder.h";
3247 #ifndef SVR5
3248 mach = "*-*-sysv4*";
3249 mach = "i?86-*-sysv5*";
3250 mach = "i?86-*-udk*";
3251 mach = "i?86-*-solaris2.[0-4]";
3252 mach = "powerpcle-*-solaris2.[0-4]";
3253 mach = "sparc-*-solaris2.[0-4]";
3254 #endif /* SVR5 */
3255
3256 c_fix = format;
3257 c_fix_arg = "";
3258 c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;";
3259
3260 test_text = "extern in_port_t\thtons __P((in_port_t));\n"
3261 "extern in_port_t\tntohs __P((in_port_t));"
3262 "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n"
3263 "echo '/* DUMMY */' >> sys/byteorder.h`";
3264 };
3265
3266
3267 /*
3268 * Fix definitions of macros used by va-i960.h in VxWorks header file.
3269 */
3270 fix = {
3271 hackname = va_i960_macro;
3272 files = arch/i960/archI960.h;
3273 select = "__(vsiz|vali|vpad|alignof__)";
3274
3275 c_fix = format;
3276 c_fix_arg = "__vx%1";
3277
3278 test_text =
3279 "extern int __vsiz vsiz;\n"
3280 "extern int __vali vali;\n"
3281 "extern int __vpad vpad;\n"
3282 "#define __alignof__(x) ...";
3283 };
3284
3285
3286 /*
3287 * AIX headers define NULL to be cast to a void pointer,
3288 * which is illegal in ANSI C++.
3289 */
3290 fix = {
3291 hackname = void_null;
3292 files = curses.h;
3293 files = dbm.h;
3294 files = locale.h;
3295 files = stdio.h;
3296 files = stdlib.h;
3297 files = string.h;
3298 files = time.h;
3299 files = unistd.h;
3300 files = sys/dir.h;
3301 files = sys/param.h;
3302 files = sys/types.h;
3303 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
3304 c_fix = format;
3305 c_fix_arg = "#define NULL 0";
3306 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
3307 };
3308
3309
3310 /*
3311 * Make VxWorks header which is almost gcc ready fully gcc ready.
3312 */
3313 fix = {
3314 hackname = vxworks_gcc_problem;
3315 files = types/vxTypesBase.h;
3316 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
3317
3318 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
3319 "#if 1/";
3320
3321 sed = "/[ \t]size_t/i\\\n"
3322 "#ifndef _GCC_SIZE_T\\\n"
3323 "#define _GCC_SIZE_T\n";
3324
3325 sed = "/[ \t]size_t/a\\\n"
3326 "#endif\n";
3327
3328 sed = "/[ \t]ptrdiff_t/i\\\n"
3329 "#ifndef _GCC_PTRDIFF_T\\\n"
3330 "#define _GCC_PTRDIFF_T\n";
3331
3332 sed = "/[ \t]ptrdiff_t/a\\\n"
3333 "#endif\n";
3334
3335 sed = "/[ \t]wchar_t/i\\\n"
3336 "#ifndef _GCC_WCHAR_T\\\n"
3337 "#define _GCC_WCHAR_T\n";
3338
3339 sed = "/[ \t]wchar_t/a\\\n"
3340 "#endif\n";
3341
3342 test_text =
3343 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
3344 "typedef unsigned int size_t;\n"
3345 "typedef long ptrdiff_t;\n"
3346 "typedef unsigned short wchar_t;\n"
3347 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
3348 };
3349
3350
3351 /*
3352 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
3353 */
3354 fix = {
3355 hackname = vxworks_needs_vxtypes;
3356 files = time.h;
3357 select = "uint_t([ \t]+_clocks_per_sec)";
3358 c_fix = format;
3359 c_fix_arg = "unsigned int%1";
3360 test_text = "uint_t\t_clocks_per_sec;";
3361 };
3362
3363
3364 /*
3365 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
3366 */
3367 fix = {
3368 hackname = vxworks_needs_vxworks;
3369 files = sys/stat.h;
3370 test = " -r types/vxTypesOld.h";
3371 test = " -n \"`egrep '#include' $file`\"";
3372 test = " -n \"`egrep ULONG $file`\"";
3373 select = "#[ \t]define[ \t]+__INCstath";
3374
3375 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
3376 "#include <types/vxTypesOld.h>\n";
3377
3378 test_text = "`touch types/vxTypesOld.h`"
3379 "#include </dev/null> /* ULONG */\n"
3380 "# define\t__INCstath <sys/stat.h>";
3381 };
3382
3383
3384 /*
3385 * Another bad dependency in VxWorks 5.2 <time.h>.
3386 */
3387 fix = {
3388 hackname = vxworks_time;
3389 files = time.h;
3390 test = " -r vxWorks.h";
3391
3392 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
3393 c_fix = format;
3394
3395 c_fix_arg =
3396 "#ifndef __gcc_VOIDFUNCPTR_defined\n"
3397 "#ifdef __cplusplus\n"
3398 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
3399 "#else\n"
3400 "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
3401 "#endif\n"
3402 "#define __gcc_VOIDFUNCPTR_defined\n"
3403 "#endif\n"
3404 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
3405
3406 test_text = "`touch vxWorks.h`"
3407 "#define VOIDFUNCPTR (void(*)())";
3408 };
3409
3410
3411 /*
3412 * WindISS math.h headers include bogus extern declarations of
3413 * numerous math functions that conflict with libstdc++-v3.
3414 */
3415 fix = {
3416 hackname = windiss_math1;
3417 files = math.h;
3418 mach = "*-*-windiss";
3419 sed = "s|inline long double cosl.*|#ifndef __GNUC__|";
3420
3421 test_text = "inline long double cosl(long double);";
3422 };
3423
3424 fix = {
3425 hackname = windiss_math2;
3426 files = math.h;
3427 mach = "*-*-windiss";
3428 sed = "s|/\\* long double declarations \\*/|"
3429 "#endif /* __GNUC__ */|";
3430
3431 test_text = "/* long double declarations */";
3432 };
3433
3434 /*
3435 * WindISS headers include "diab/va_list.h" instead of "stdarg.h"
3436 */
3437 fix = {
3438 select = '(#include.*)diab/va_list.h';
3439 hackname = windiss_valist;
3440 sed = "s|diab/va_list.h|stdarg.h|";
3441 mach = "*-*-windiss";
3442
3443 test_text = "#include <diab/va_list.h>";
3444 };
3445
3446 /*
3447 * There are several name conflicts with C++ reserved words in X11 header
3448 * files. These are fixed in some versions, so don't do the fixes if
3449 * we find __cplusplus in the file. These were found on the RS/6000.
3450 */
3451 fix = {
3452 hackname = x11_class;
3453 files = X11/ShellP.h;
3454 bypass = __cplusplus;
3455 select = "^([ \t]*char \\*)class;(.*)";
3456 c_fix = format;
3457 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
3458 "#else\n%1class;%2\n#endif";
3459 test_text =
3460 "struct {\n"
3461 " char *class;\n"
3462 "} mumble;\n";
3463 };
3464
3465
3466 /*
3467 * class in Xm/BaseClassI.h
3468 */
3469 fix = {
3470 hackname = x11_class_usage;
3471 files = Xm/BaseClassI.h;
3472 bypass = "__cplusplus";
3473
3474 select = " class\\)";
3475 c_fix = format;
3476 c_fix_arg = " c_class)";
3477
3478 test_text = "extern mumble (int class);\n";
3479 };
3480
3481
3482 /*
3483 * new in Xm/Traversal.h
3484 */
3485 fix = {
3486 hackname = x11_new;
3487 files = Xm/Traversal.h;
3488 bypass = __cplusplus;
3489
3490 sed = "/Widget\told, new;/i\\\n"
3491 "#ifdef __cplusplus\\\n"
3492 "\tWidget\told, c_new;\\\n"
3493 "#else\n";
3494
3495 sed = "/Widget\told, new;/a\\\n"
3496 "#endif\n";
3497
3498 sed = "s/Widget new,/Widget c_new,/g";
3499 test_text =
3500 "struct wedge {\n"
3501 " Widget\told, new; /* fixinc check FAILS ON BSD */\n"
3502 "};\nextern Wedged( Widget new, Widget old );";
3503 };
3504
3505
3506 /*
3507 * Incorrect sprintf declaration in X11/Xmu.h
3508 */
3509 fix = {
3510 hackname = x11_sprintf;
3511 files = X11/Xmu.h;
3512 files = X11/Xmu/Xmu.h;
3513 select = "^extern char \\*\tsprintf\\(\\);$";
3514
3515 c_fix = format;
3516 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
3517
3518 test_text = "extern char *\tsprintf();";
3519 };
3520
3521 /*EOF*/