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