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