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