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