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/* On AIX when _LARGE_FILES is defined stdio.h defines fopen to 24 * fopen64 etc. and this causes problems when building with g++ 25 * because cstdio udefs everything from stdio.h, leaving us with 26 * ::fopen has not been declared errors. This fixes stdio.h to 27 * undef those defines and use __asm__ to alias the symbols if 28 * building with g++ and -D_LARGE_FILES 29 */ 30fix = { 31 hackname = AAB_aix_stdio; 32 files = stdio.h; 33 select = "define fopen fopen64"; 34 mach = "*-*-aix*"; 35 test-text = ''; /* no way to test */ 36 37 c_fix = wrap; 38 39 c_fix_arg = ""; 40 41 c_fix_arg = <<- _EOArg_ 42 43 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus 44 #define __need__aix_stdio_h_fix 45 #ifdef __need__aix_stdio_h_fix 46 #undef fseeko 47 #undef ftello 48 #undef fgetpos 49 #undef fsetpos 50 #undef fopen 51 #undef freopen 52 /* Alias the symbols using asm */ 53 extern "C" { 54 extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64"); 55 extern FILE *fopen(const char *, const char *) __asm__("fopen64"); 56 extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64"); 57 extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64"); 58 extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64"); 59 extern off64_t ftello(FILE *) __asm__("ftello64"); 60 } 61 #endif 62 #endif 63 64 _EOArg_; 65}; 66 67 68/* On AIX when _LARGE_FILES is defined fcntl.h defines open to 69 * open64 and creat to creat64. This fixes fcntl.h to 70 * undef those defines and use __asm__ to alias the symbols if 71 * building with g++ and -D_LARGE_FILES 72 */ 73fix = { 74 hackname = AAB_aix_fcntl; 75 files = fcntl.h; 76 select = "define open[ \t]open64"; 77 mach = "*-*-aix*"; 78 test-text = ''; /* no way to test */ 79 80 c_fix = wrap; 81 82 c_fix_arg = ""; 83 84 c_fix_arg = <<- _EOArg_ 85 86 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus 87 #define __need__aix_fcntl_h_fix 88 #ifdef __need__aix_fcntl_h_fix 89 #undef open 90 #undef creat 91 #undef openat 92 /* Alias the symbols using asm */ 93 extern "C" { 94 extern int open(const char *, int, ...) __asm__("open64"); 95 extern int creat(const char *, mode_t) __asm__("creat64"); 96 #if (_XOPEN_SOURCE >= 700) 97 extern int openat(int, const char *, int, ...) __asm__("open64at"); 98 #endif 99 } 100 #endif 101 #endif 102 103 _EOArg_; 104}; 105 106 107/* 108 * On Mac OS 10.3.9, the 'long double' functions are available in 109 * libSystem, but are not prototyped in math.h. 110 */ 111fix = { 112 hackname = AAB_darwin7_9_long_double_funcs; 113 mach = "*-*-darwin7.9*"; 114 files = architecture/ppc/math.h; 115 bypass = "powl"; 116 replace = <<- _EndOfHeader_ 117 /* This file prototypes the long double functions available on Mac OS 118 10.3.9. */ 119 #ifndef __MATH__ 120 # undef __APPLE_CC__ 121 # define __APPLE_CC__ 1345 122 # include_next <architecture/ppc/math.h> 123 # undef __APPLE_CC__ 124 # define __APPLE_CC__ 1 125 # ifndef __LIBMLDBL_COMPAT 126 # ifdef __LONG_DOUBLE_128__ 127 # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128") 128 # else 129 # define __LIBMLDBL_COMPAT(sym) 130 # endif /* __LONG_DOUBLE_128__ */ 131 # endif /* __LIBMLDBL_COMPAT */ 132 # ifdef __cplusplus 133 extern "C" { 134 # endif 135 extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl); 136 extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl); 137 extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl); 138 extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l); 139 extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl); 140 extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl); 141 extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl); 142 extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl); 143 extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl); 144 extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl); 145 extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl); 146 extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl); 147 extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl); 148 extern long double expl( long double ) __LIBMLDBL_COMPAT(expl); 149 extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l); 150 extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l); 151 extern long double logl( long double ) __LIBMLDBL_COMPAT(logl); 152 extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l); 153 extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l); 154 extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl); 155 extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl); 156 extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl); 157 extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl); 158 extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl); 159 extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl); 160 extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl); 161 extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl); 162 extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl); 163 extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl); 164 extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl); 165 extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl); 166 extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl); 167 extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl); 168 extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl); 169 extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal); 170 extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal); 171 extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill); 172 extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl); 173 extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl); 174 extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl); 175 extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl); 176 extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl); 177 extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl); 178 extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl); 179 extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl); 180 extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl); 181 extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl); 182 extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl); 183 extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol); 184 extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl); 185 extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl); 186 extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl); 187 extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl); 188 extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml); 189 extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl); 190 extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl); 191 extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal); 192 # ifdef __cplusplus 193 } 194 # endif 195 #endif /* __MATH__ */ 196 _EndOfHeader_; 197}; 198 199/* 200 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n) 201 */ 202fix = { 203 hackname = AAB_fd_zero_asm_posix_types_h; 204 files = asm/posix_types.h; 205 mach = 'i[34567]86-*-linux*'; 206 bypass = '} while'; 207 bypass = 'x86_64'; 208 bypass = 'posix_types_64'; 209 210 /* 211 * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not 212 * the start, so that if #include_next gets another instance of 213 * the wrapper, this will follow the #include_next chain until 214 * we arrive at the real <asm/posix_types.h>. 215 */ 216 replace = <<- _EndOfHeader_ 217 /* This file fixes a bug in the __FD_ZERO macro 218 for older versions of the Linux kernel. */ 219 #ifndef _POSIX_TYPES_H_WRAPPER 220 #include <features.h> 221 #include_next <asm/posix_types.h> 222 223 #if defined(__FD_ZERO) && !defined(__GLIBC__) 224 #undef __FD_ZERO 225 #define __FD_ZERO(fdsetp) \ 226 do { \ 227 int __d0, __d1; \ 228 __asm__ __volatile__("cld ; rep ; stosl" \ 229 : "=&c" (__d0), "=&D" (__d1) \ 230 : "a" (0), "0" (__FDSET_LONGS), \ 231 "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \ 232 } while (0) 233 #endif 234 235 #define _POSIX_TYPES_H_WRAPPER 236 #endif /* _POSIX_TYPES_H_WRAPPER */ 237 _EndOfHeader_; 238}; 239 240 241/* 242 * This fixes __FD_ZERO bug for glibc-1.x 243 */ 244fix = { 245 hackname = AAB_fd_zero_gnu_types_h; 246 files = gnu/types.h; 247 mach = 'i[34567]86-*-linux*'; 248 249 /* 250 * Define _TYPES_H_WRAPPER at the end of the wrapper, not 251 * the start, so that if #include_next gets another instance of 252 * the wrapper, this will follow the #include_next chain until 253 * we arrive at the real <gnu/types.h>. 254 */ 255 replace = <<- _EndOfHeader_ 256 /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ 257 #ifndef _TYPES_H_WRAPPER 258 #include <features.h> 259 #include_next <gnu/types.h> 260 261 #if defined(__FD_ZERO) && !defined(__GLIBC__) 262 #undef __FD_ZERO 263 # define __FD_ZERO(fdsetp) \ 264 do { \ 265 int __d0, __d1; \ 266 __asm__ __volatile__("cld ; rep ; stosl" \ 267 : "=&c" (__d0), "=&D" (__d1) \ 268 : "a" (0), "0" (__FDSET_LONGS), \ 269 "1" ((__fd_set *) (fdsetp)) :"memory"); \ 270 } while (0) 271 #endif 272 273 #define _TYPES_H_WRAPPER 274 #endif /* _TYPES_H_WRAPPER */ 275 _EndOfHeader_; 276}; 277 278 279/* 280 * This fixes __FD_ZERO bug for glibc-2.0.x 281 */ 282fix = { 283 hackname = AAB_fd_zero_selectbits_h; 284 files = selectbits.h; 285 mach = 'i[34567]86-*-linux*'; 286 287 /* 288 * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not 289 * the start, so that if #include_next gets another instance of 290 * the wrapper, this will follow the #include_next chain until 291 * we arrive at the real <selectbits.h>. 292 */ 293 replace = <<- _EndOfHeader_ 294 /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ 295 #ifndef _SELECTBITS_H_WRAPPER 296 #include <features.h> 297 #include_next <selectbits.h> 298 299 #if defined(__FD_ZERO) && defined(__GLIBC__) \\ 300 && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\ 301 && __GLIBC_MINOR__ == 0 302 #undef __FD_ZERO 303 #define __FD_ZERO(fdsetp) \\ 304 do { \\ 305 int __d0, __d1; \\ 306 __asm__ __volatile__ ("cld; rep; stosl" \\ 307 : "=&c" (__d0), "=&D" (__d1) \\ 308 : "a" (0), "0" (sizeof (__fd_set) \\ 309 / sizeof (__fd_mask)), \\ 310 "1" ((__fd_mask *) (fdsetp)) \\ 311 : "memory"); \\ 312 } while (0) 313 #endif 314 315 #define _SELECTBITS_H_WRAPPER 316 #endif /* _SELECTBITS_H_WRAPPER */ 317 _EndOfHeader_; 318}; 319 320 321/* 322 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing 323 * the same interface as <stdarg.h>. No idea why they couldn't have just 324 * used the standard header. 325 */ 326fix = { 327 hackname = AAB_solaris_sys_varargs_h; 328 files = "sys/varargs.h"; 329 mach = '*-*-solaris*'; 330 replace = <<- _EndOfHeader_ 331 #ifdef __STDC__ 332 #include <stdarg.h> 333 #else 334 #include <varargs.h> 335 #endif 336 _EndOfHeader_; 337}; 338 339 340/* 341 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin 342 * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because 343 * many other systems have similar text but correct versions of the file. 344 * To ensure only Sun's is fixed, we grep for a likely unique string. 345 * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) 346 */ 347fix = { 348 hackname = AAB_sun_memcpy; 349 files = memory.h; 350 select = "/\\*\t@\\(#\\)" 351 "(head/memory.h\t50.1\t " 352 "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/"; 353 354 replace = <<- _EndOfHeader_ 355 /* This file was generated by fixincludes */ 356 #ifndef __memory_h__ 357 #define __memory_h__ 358 359 #ifdef __STDC__ 360 extern void *memccpy(); 361 extern void *memchr(); 362 extern void *memcpy(); 363 extern void *memset(); 364 #else 365 extern char *memccpy(); 366 extern char *memchr(); 367 extern char *memcpy(); 368 extern char *memset(); 369 #endif /* __STDC__ */ 370 371 extern int memcmp(); 372 373 #endif /* __memory_h__ */ 374 _EndOfHeader_; 375}; 376 377/* 378 * Fix assert.h on VxWorks: 379 */ 380fix = { 381 hackname = AAB_vxworks_assert; 382 files = assert.h; 383 mach = "*-*-vxworks*"; 384 385 replace = <<- _EndOfHeader_ 386 #ifndef _ASSERT_H 387 #define _ASSERT_H 388 389 #ifdef assert 390 #undef assert 391 #endif 392 393 #if defined(__STDC__) || defined(__cplusplus) 394 extern void __assert (const char*); 395 #else 396 extern void __assert (); 397 #endif 398 399 #ifdef NDEBUG 400 #define assert(ign) ((void)0) 401 #else 402 403 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str) 404 #define ASSERT_STRINGIFY_HELPER(str) #str 405 406 #define assert(test) ((void) \ 407 ((test) ? ((void)0) : \ 408 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \ 409 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n"))) 410 411 #endif 412 413 #endif 414 _EndOfHeader_; 415}; 416 417/* 418 * Add needed include to regs.h (NOT the gcc header) on VxWorks 419 */ 420 421fix = { 422 hackname = AAB_vxworks_regs_vxtypes; 423 files = regs.h; 424 mach = "*-*-vxworks*"; 425 426 replace = <<- _EndOfHeader_ 427 #ifndef _REGS_H 428 #define _REGS_H 429 #include <types/vxTypesOld.h> 430 #include_next <arch/../regs.h> 431 #endif 432 _EndOfHeader_; 433}; 434 435/* 436 * Make VxWorks stdint.h a bit more compliant - add typedefs 437 */ 438fix = { 439 hackname = AAB_vxworks_stdint; 440 files = stdint.h; 441 mach = "*-*-vxworks*"; 442 443 replace = <<- _EndOfHeader_ 444 #ifndef _STDINT_H 445 #define _STDINT_H 446 /* get int*_t, uint*_t */ 447 #include <types/vxTypes.h> 448 449 /* get legacy vxworks types for compatibility */ 450 #include <types/vxTypesOld.h> 451 452 typedef long intptr_t; 453 typedef unsigned long uintptr_t; 454 455 typedef int64_t intmax_t; 456 typedef uint64_t uintmax_t; 457 458 typedef int8_t int_least8_t; 459 typedef int16_t int_least16_t; 460 typedef int32_t int_least32_t; 461 typedef int64_t int_least64_t; 462 463 typedef uint8_t uint_least8_t; 464 typedef uint16_t uint_least16_t; 465 typedef uint32_t uint_least32_t; 466 typedef uint64_t uint_least64_t; 467 468 typedef int8_t int_fast8_t; 469 typedef int int_fast16_t; 470 typedef int32_t int_fast32_t; 471 typedef int64_t int_fast64_t; 472 473 typedef uint8_t uint_fast8_t; 474 typedef unsigned int uint_fast16_t; 475 typedef uint32_t uint_fast32_t; 476 typedef uint64_t uint_fast64_t; 477 478 /* Ranges */ 479 #define UINT8_MAX (~(uint8_t)0) 480 #define UINT8_MIN 0 481 #define UINT16_MAX (~(uint16_t)0) 482 #define UINT16_MIN 0 483 #define UINT32_MAX (~(uint32_t)0) 484 #define UINT32_MIN 0 485 #define UINT64_MAX (~(uint64_t)0) 486 #define UINT64_MIN 0 487 488 #define UINTPTR_MAX (~(uintptr_t)0) 489 #define UINTPTR_MIN 0 490 491 /* Need to do int_fast16_t as well, as type 492 size may be architecture dependent */ 493 #define UINT_FAST16_MAX (~(uint_fast16_t)0) 494 #define UINT_FAST16_MAX 0 495 496 #define INT8_MAX (UINT8_MAX>>1) 497 #define INT8_MIN (INT8_MAX+1) 498 #define INT16_MAX (UINT16_MAX>>1) 499 #define INT16_MIN (INT16_MAX+1) 500 #define INT32_MAX (UINT32_MAX>>1) 501 #define INT32_MIN (INT32_MAX+1) 502 #define INT64_MAX (UINT64_MAX>>1) 503 #define INT64_MIN (INT64_MAX+1) 504 505 #define INTPTR_MAX (UINTPTR_MAX>>1) 506 #define INTPTR_MIN (INTPTR_MAX+1) 507 508 #define INT_FAST16_MAX (UINT_FAST16_MAX>>1) 509 #define INT_FAST16_MIN (INT_FAST16_MAX+1) 510 511 /* now define equiv. constants */ 512 #define UINT_FAST8_MAX UINT8_MAX 513 #define UINT_FAST8_MIN UINT_FAST8_MIN 514 #define INT_FAST8_MAX INT8_MAX 515 #define INT_FAST8_MIN INT8_MIN 516 #define UINT_FAST32_MAX UINT32_MAX 517 #define UINT_FAST32_MIN UINT32_MIN 518 #define INT_FAST32_MAX INT32_MAX 519 #define INT_FAST32_MIN INT32_MIN 520 #define UINT_FAST64_MAX UINT64_MAX 521 #define UINT_FAST64_MIN UINT64_MIN 522 #define INT_FAST64_MAX INT64_MAX 523 #define INT_FAST64_MIN INT64_MIN 524 525 #define UINT_LEAST8_MAX UINT8_MAX 526 #define UINT_LEAST8_MIN UINT8_MIN 527 #define INT_LEAST8_MAX INT8_MAX 528 #define INT_LEAST8_MIN INT8_MIN 529 #define UINT_LEAST16_MAX UINT16_MAX 530 #define UINT_LEAST16_MIN UINT16_MIN 531 #define INT_LEAST16_MAX INT16_MAX 532 #define INT_LEAST16_MIN INT16_MIN 533 #define UINT_LEAST32_MAX UINT32_MAX 534 #define UINT_LEAST32_MIN UINT32_MIN 535 #define INT_LEAST32_MAX INT32_MAX 536 #define INT_LEAST32_MIN INT32_MIN 537 #define UINT_LEAST64_MAX UINT64_MAX 538 #define UINT_LEAST64_MIN UINT64_MIN 539 #define INT_LEAST64_MAX INT64_MAX 540 #define INT_LEAST64_MIN INT64_MIN 541 542 #define UINTMAX_MAX UINT64_MAX 543 #define UINTMAX_MIN UINT64_MIN 544 #define INTMAX_MAX INT64_MAX 545 #define INTMAX_MIN INT64_MIN 546 547 #endif 548 _EndOfHeader_; 549}; 550 551/* 552 * This hack makes makes unistd.h more POSIX-compliant on VxWorks 553 */ 554fix = { 555 hackname = AAB_vxworks_unistd; 556 files = unistd.h; 557 mach = "*-*-vxworks*"; 558 559 replace = <<- _EndOfHeader_ 560 #ifndef _UNISTD_H 561 #define _UNISTD_H 562 #include_next <unistd.h> 563 #include <ioLib.h> 564 #ifndef STDIN_FILENO 565 #define STDIN_FILENO 0 566 #endif 567 #ifndef STDOUT_FILENO 568 #define STDOUT_FILENO 1 569 #endif 570 #ifndef STDERR_FILENO 571 #define STDERR_FILENO 2 572 #endif 573 #endif /* _UNISTD_H */ 574 _EndOfHeader_; 575}; 576 577 578/* 579 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I, 580 * which only is provided by AIX xlc C99. 581 */ 582fix = { 583 hackname = aix_complex; 584 mach = "*-*-aix*"; 585 files = complex.h; 586 select = "#define[ \t]_Complex_I[ \t]__I"; 587 c_fix = format; 588 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; 589 test_text = "#define _Complex_I __I\n"; 590}; 591 592/* 593 * malloc.h on AIX6 uses XLC++ specific builtin syntax 594 */ 595fix = { 596 hackname = aix_malloc; 597 mach = "*-*-aix*"; 598 files = "malloc.h"; 599 select = "#ifdef __cplusplus"; 600 c_fix = format; 601 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))"; 602 test_text = "#ifdef __cplusplus"; 603}; 604 605/* 606 * net/if_arp.h defines a variable fc_softc instead of adding a 607 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1 608 */ 609fix = { 610 hackname = aix_net_if_arp; 611 mach = "*-*-aix*"; 612 files = "net/if_arp.h"; 613 select = "^struct fc_softc \\{"; 614 c_fix = format; 615 c_fix_arg = "typedef struct _fc_softc {"; 616 test_text = "struct fc_softc {\n int a;\n};"; 617}; 618 619/* 620 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER, 621 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough 622 * braces. 623 */ 624fix = { 625 hackname = aix_once_init_1; 626 mach = "*-*-aix*"; 627 files = "pthread.h"; 628 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n" 629 "\\{ \\\\\n"; 630 c_fix = format; 631 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n" 632 "{{ \\\n"; 633 test_text = "#define PTHREAD_ONCE_INIT \\\\\n" 634 "{ \\\\\n"; 635}; 636 637fix = { 638 hackname = aix_once_init_2; 639 mach = "*-*-aix*"; 640 files = "pthread.h"; 641 select = "[ \t]0 \\\\\n" 642 "\\}\n"; 643 c_fix = format; 644 c_fix_arg = " 0 \\\n" 645 "}}\n"; 646 test_text = " 0 \\\\\n" 647 "}\n"; 648}; 649 650fix = { 651 hackname = aix_mutex_initializer_1; 652 mach = "*-*-aix*"; 653 files = "pthread.h"; 654 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n" 655 "\\{ \\\\\n"; 656 c_fix = format; 657 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n" 658 "{{ \\\n"; 659 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n" 660 "{ \\\\\n"; 661}; 662 663fix = { 664 hackname = aix_cond_initializer_1; 665 mach = "*-*-aix*"; 666 files = "pthread.h"; 667 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n" 668 "\\{ \\\\\n"; 669 c_fix = format; 670 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n" 671 "{{ \\\n"; 672 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n" 673 "{ \\\\\n"; 674}; 675 676fix = { 677 hackname = aix_rwlock_initializer_1; 678 mach = "*-*-aix*"; 679 files = "pthread.h"; 680 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n" 681 "\\{ \\\\\n"; 682 c_fix = format; 683 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n" 684 "{{ \\\n"; 685 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n" 686 "{ \\\\\n"; 687}; 688 689/* 690 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace 691 * which violates a requirement of ISO C. 692 */ 693fix = { 694 hackname = aix_pthread; 695 files = "pthread.h"; 696 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])"; 697 c_fix = format; 698 c_fix_arg = "%1 %2"; 699 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n" 700 "{...init stuff...}"; 701}; 702 703 704/* 705 * AIX stdint.h fixes. 706 */ 707fix = { 708 hackname = aix_stdint_1; 709 mach = "*-*-aix*"; 710 files = stdint-aix.h, stdint.h; 711 select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n" 712 "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)"; 713 c_fix = format; 714 c_fix_arg = "#define UINT8_MAX (255)\n" 715 "#define UINT16_MAX (65535)"; 716 test_text = "#define UINT8_MAX (255U)\n" 717 "#define UINT16_MAX (65535U)"; 718}; 719 720 721fix = { 722 hackname = aix_stdint_2; 723 mach = "*-*-aix*"; 724 files = stdint-aix.h, stdint.h; 725 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n" 726 "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n" 727 "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n" 728 "#else\n" 729 "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n" 730 "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n" 731 "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX"; 732 c_fix = format; 733 c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n" 734 "#define INTPTR_MAX 9223372036854775807L\n" 735 "#define UINTPTR_MAX 18446744073709551615UL\n" 736 "#else\n" 737 "#define INTPTR_MIN (-INTPTR_MAX-1)\n" 738 "#define INTPTR_MAX 2147483647L\n" 739 "#define UINTPTR_MAX 4294967295UL"; 740 test_text = "#define INTPTR_MIN INT64_MIN\n" 741 "#define INTPTR_MAX INT64_MAX\n" 742 "#define UINTPTR_MAX UINT64_MAX\n" 743 "#else\n" 744 "#define INTPTR_MIN INT32_MIN\n" 745 "#define INTPTR_MAX INT32_MAX\n" 746 "#define UINTPTR_MAX UINT32_MAX"; 747}; 748 749 750fix = { 751 hackname = aix_stdint_3; 752 mach = "*-*-aix*"; 753 files = stdint-aix.h, stdint.h; 754 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n" 755 "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n" 756 "#else\n" 757 "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n" 758 "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX"; 759 c_fix = format; 760 c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n" 761 "#define PTRDIFF_MAX 9223372036854775807L\n" 762 "#else\n" 763 "#define PTRDIFF_MIN (-2147483647L - 1)\n" 764 "#define PTRDIFF_MAX 2147483647L"; 765 test_text = "#define PTRDIFF_MIN INT64_MIN\n" 766 "#define PTRDIFF_MAX INT64_MAX\n" 767 "#else\n" 768 "#define PTRDIFF_MIN INT32_MIN\n" 769 "#define PTRDIFF_MAX INT32_MAX"; 770}; 771 772 773fix = { 774 hackname = aix_stdint_4; 775 mach = "*-*-aix*"; 776 files = stdint-aix.h, stdint.h; 777 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n" 778 "#else\n" 779 "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX"; 780 c_fix = format; 781 c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n" 782 "#else\n" 783 "#define SIZE_MAX 4294967295UL"; 784 test_text = "#define SIZE_MAX UINT64_MAX\n" 785 "#else\n" 786 "#define SIZE_MAX UINT32_MAX"; 787}; 788 789 790fix = { 791 hackname = aix_stdint_5; 792 mach = "*-*-aix*"; 793 files = stdint-aix.h, stdint.h; 794 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n" 795 "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)"; 796 c_fix = format; 797 c_fix_arg = "#define UINT8_C(c) c\n" 798 "#define UINT16_C(c) c"; 799 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n" 800 "#define UINT16_C(c) __CONCAT__(c,U)"; 801}; 802 803 804/* 805 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline 806 * in an otherwise harmless (and #ifed out) macro definition 807 */ 808fix = { 809 hackname = aix_sysmachine; 810 files = sys/machine.h; 811 select = "\\\\ +\n"; 812 c_fix = format; 813 c_fix_arg = "\\\n"; 814 test_text = "#define FOO \\\n" 815 " bar \\ \n baz \\ \n bat"; 816}; 817 818 819/* 820 * sys/wait.h on AIX 5.2 defines macros that have both signed and 821 * unsigned types in conditional expressions. 822 */ 823fix = { 824 hackname = aix_syswait_2; 825 files = sys/wait.h; 826 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)'; 827 c_fix = format; 828 c_fix_arg = "? (int)%1"; 829 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)"; 830}; 831 832 833/* 834 * sys/signal.h on some versions of AIX uses volatile in the typedef of 835 * sig_atomic_t, which causes gcc to generate a warning about duplicate 836 * volatile when a sig_atomic_t variable is declared volatile, as 837 * required by ANSI C. 838 */ 839fix = { 840 hackname = aix_volatile; 841 files = sys/signal.h; 842 select = "typedef volatile int sig_atomic_t"; 843 c_fix = format; 844 c_fix_arg = "typedef int sig_atomic_t"; 845 test_text = "typedef volatile int sig_atomic_t;"; 846}; 847 848 849/* 850 * Fix __assert declaration in assert.h on Alpha OSF/1. 851 */ 852fix = { 853 hackname = alpha___assert; 854 files = "assert.h"; 855 select = '__assert\(char \*, char \*, int\)'; 856 c_fix = format; 857 c_fix_arg = "__assert(const char *, const char *, int)"; 858 test_text = 'extern void __assert(char *, char *, int);'; 859}; 860 861 862/* 863 * Fix assert macro in assert.h on Alpha OSF/1. 864 * The superfluous int cast breaks C++. 865 */ 866fix = { 867 hackname = alpha_assert; 868 files = "assert.h"; 869 select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)'; 870 c_fix = format; 871 c_fix_arg = "%1(EX)"; 872 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 ' 873 ': __assert(#EX, __FILE__, __LINE__))'; 874}; 875 876 877/* 878 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. 879 */ 880fix = { 881 hackname = alpha_getopt; 882 files = "stdio.h"; 883 files = "stdlib.h"; 884 select = 'getopt\(int, char \*\[\], *char \*\)'; 885 c_fix = format; 886 c_fix_arg = "getopt(int, char *const[], const char *)"; 887 test_text = 'extern int getopt(int, char *[], char *);'; 888}; 889 890 891/* 892 * Fix missing semicolon on Alpha OSF/4 in <net/if.h> 893 */ 894fix = { 895 hackname = alpha_if_semicolon; 896 files = net/if.h; 897 select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*"; 898 c_fix = format; 899 c_fix_arg = "struct sockaddr vmif_paddr;\t/*"; 900 test_text = ' struct sockaddr vmif_paddr /* protocol address */'; 901}; 902 903 904/* 905 * Remove erroneous parentheses in sym.h on Alpha OSF/1. 906 */ 907fix = { 908 hackname = alpha_parens; 909 files = sym.h; 910 select = '#ifndef\(__mips64\)'; 911 c_fix = format; 912 c_fix_arg = "#ifndef __mips64"; 913 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif"; 914}; 915 916 917/* 918 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 919 * And OpenBSD. 920 */ 921fix = { 922 hackname = alpha_sbrk; 923 files = unistd.h; 924 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; 925 c_fix = format; 926 c_fix_arg = "void *sbrk("; 927 test_text = "extern char* sbrk(ptrdiff_t increment);"; 928}; 929 930 931/* 932 * For C++, avoid any typedef or macro definition of bool, 933 * and use the built in type instead. 934 * HP/UX 10.20 also has it in curses_colr/curses.h. 935 */ 936fix = { 937 hackname = avoid_bool_define; 938 files = curses.h; 939 files = curses_colr/curses.h; 940 files = term.h; 941 files = tinfo.h; 942 943 select = "#[ \t]*define[ \t]+bool[ \t]"; 944 bypass = "__cplusplus"; 945 946 c_fix = format; 947 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 948 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*"; 949 950 test_text = "# define bool\t char \n"; 951}; 952 953 954fix = { 955 hackname = avoid_bool_type; 956 files = curses.h; 957 files = curses_colr/curses.h; 958 files = term.h; 959 files = tinfo.h; 960 961 select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;"; 962 bypass = "__cplusplus"; 963 964 c_fix = format; 965 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 966 967 test_text = "typedef unsigned int\tbool \t; /* bool\n type */"; 968}; 969 970 971/* 972 * For C++, avoid any typedef definition of wchar_t, 973 * and use the built in type instead. 974 * Don't do this for headers that are smart enough to do the right 975 * thing (recent [n]curses.h and Xlib.h). 976 * Don't do it for <linux/nls.h> which is never used from C++ anyway, 977 * and will be broken by the edit. 978 */ 979 980fix = { 981 hackname = avoid_wchar_t_type; 982 983 select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;"; 984 bypass = "__cplusplus"; 985 bypass = "_LINUX_NLS_H"; 986 bypass = "XFree86: xc/lib/X11/Xlib\\.h"; 987 988 c_fix = format; 989 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 990 991 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */"; 992}; 993 994 995/* 996 * Fix `typedef struct term;' on hppa1.1-hp-hpux9. 997 */ 998fix = { 999 hackname = bad_struct_term; 1000 files = curses.h; 1001 select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;"; 1002 c_fix = format; 1003 c_fix_arg = "struct term;"; 1004 1005 test_text = 'typedef struct term;'; 1006}; 1007 1008 1009/* 1010 * Fix one other error in this file: 1011 * a mismatched quote not inside a C comment. 1012 */ 1013fix = { 1014 hackname = badquote; 1015 files = sundev/vuid_event.h; 1016 select = "doesn't"; 1017 c_fix = format; 1018 c_fix_arg = "does not"; 1019 1020 test_text = "/* doesn't have matched single quotes */"; 1021}; 1022 1023 1024/* 1025 * check for broken assert.h that needs stdio.h 1026 */ 1027fix = { 1028 hackname = broken_assert_stdio; 1029 files = assert.h; 1030 select = stderr; 1031 bypass = "include.*stdio\\.h"; 1032 c_fix = wrap; 1033 c_fix_arg = "#include <stdio.h>\n"; 1034 test_text = "extern FILE* stderr;"; 1035}; 1036 1037 1038/* 1039 * check for broken assert.h that needs stdlib.h 1040 */ 1041fix = { 1042 hackname = broken_assert_stdlib; 1043 files = assert.h; 1044 select = 'exit *\(|abort *\('; 1045 bypass = "include.*stdlib\\.h"; 1046 c_fix = wrap; 1047 c_fix_arg = "#ifdef __cplusplus\n" 1048 "#include <stdlib.h>\n" 1049 "#endif\n"; 1050 test_text = "extern void exit ( int );"; 1051}; 1052 1053/* 1054 * Remove `extern double cabs' declarations from math.h. 1055 * This conflicts with C99. Discovered on AIX. 1056 * Darwin hides its broken cabs in architecture-specific subdirs. 1057 */ 1058fix = { 1059 hackname = broken_cabs; 1060 files = math.h, "architecture/*/math.h"; 1061 select = "^extern[ \t]+double[ \t]+cabs"; 1062 1063 sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//"; 1064 sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//"; 1065 1066 test_text = "#ifdef __STDC__\n" 1067 "extern double cabs(struct dbl_hypot);\n" 1068 "#else\n" 1069 "extern double cabs();\n" 1070 "#endif\n" 1071 "extern double cabs ( _Complex z );"; 1072}; 1073 1074 1075/* 1076 * Fixup Darwin's broken check for __builtin_nanf. 1077 */ 1078fix = { 1079 hackname = broken_nan; 1080 /* 1081 * It is tempting to omit the first "files" entry. Do not. 1082 * The testing machinery will take the first "files" entry as the name 1083 * of a test file to play with. It would be a nuisance to have a directory 1084 * with the name "*". 1085 */ 1086 files = "architecture/ppc/math.h"; 1087 files = "architecture/*/math.h"; 1088 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)'; 1089 bypass = "powl"; 1090 c_fix = format; 1091 c_fix_arg = "#if 1"; 1092 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; 1093}; 1094 1095 1096/* 1097 * Various systems derived from BSD4.4 contain a macro definition 1098 * for vfscanf that interacts badly with requirements of builtin-attrs.def. 1099 * Known to be fixed in FreeBSD 5 system headers. 1100 */ 1101fix = { 1102 hackname = bsd_stdio_attrs_conflict; 1103 mach = "*-*-*bsd*"; 1104 mach = "*-*-*darwin*"; 1105 files = stdio.h; 1106 select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$"; 1107 c_fix = format; 1108 c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n" 1109 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n" 1110 'int vfscanf(FILE *, const char *, __builtin_va_list) ' 1111 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");'; 1112 test_text = '#define vfscanf __svfscanf'; 1113}; 1114 1115/* 1116 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests 1117 * that it conforms to ISO/IEC 14882:2011. It currently does 1118 * not support the [[noreturn]] procedure attribute. 1119 * When it does, this hack should be removed. 1120 * SEE: gcc.gnu.org/bugzilla/show_bug.cgi?id=51776 1121 */ 1122fix = { 1123 hackname = cdef_cplusplus; 1124 files = sys/cdefs.h; 1125 select = '\[\[noreturn\]\]'; 1126 c_fix = format; 1127 c_fix_arg = '__attribute__((__noreturn__))'; 1128 test_text = "#define _Noreturn [[noreturn]]"; 1129}; 1130 1131/* 1132 * Fix various macros used to define ioctl numbers. 1133 * The traditional syntax was: 1134 * 1135 * #define _CTRL(n, x) (('n'<<8)+x) 1136 * #define TCTRLCFOO _CTRL(T, 1) 1137 * 1138 * but this does not work with the C standard, which disallows macro 1139 * expansion inside strings. We have to rewrite it thus: 1140 * 1141 * #define _CTRL(n, x) ((n<<8)+x) 1142 * #define TCTRLCFOO _CTRL('T', 1) 1143 * 1144 * The select expressions match too much, but the c_fix code is cautious. 1145 * 1146 * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ... 1147 */ 1148fix = { 1149 hackname = ctrl_quotes_def; 1150 select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]"; 1151 c_fix = char_macro_def; 1152 c_fix_arg = "CTRL"; 1153 1154 /* 1155 * This is two tests in order to ensure that the "CTRL(c)" can 1156 * be selected in isolation from the multi-arg format 1157 */ 1158 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"; 1159 test_text = "#define _CTRL(c) ('c'&037)"; 1160}; 1161 1162/* 1163 * Fix various macros used to define ioctl numbers. 1164 */ 1165fix = { 1166 hackname = ctrl_quotes_use; 1167 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']"; 1168 c_fix = char_macro_use; 1169 c_fix_arg = "CTRL"; 1170 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)"; 1171}; 1172 1173 1174/* 1175 * sys/mman.h on HP/UX is not C++ ready, 1176 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. 1177 * 1178 * rpc/types.h on OSF1/2.0 is not C++ ready, 1179 * even though NO_IMPLICIT_EXTERN_C is defined for the alpha. 1180 * 1181 * The problem is the declaration of malloc. 1182 */ 1183fix = { 1184 hackname = cxx_unready; 1185 files = sys/mman.h; 1186 files = rpc/types.h; 1187 select = '[^#]+malloc.*;'; /* Catch any form of declaration 1188 not within a macro. */ 1189 bypass = '"C"|__BEGIN_DECLS'; 1190 1191 c_fix = wrap; 1192 c_fix_arg = "#ifdef __cplusplus\n" 1193 "extern \"C\" {\n" 1194 "#endif\n"; 1195 c_fix_arg = "#ifdef __cplusplus\n" 1196 "}\n" 1197 "#endif\n"; 1198 test_text = "extern void* malloc( size_t );"; 1199}; 1200 1201/* 1202 * For the AAB_darwin7_9_long_double_funcs fix to be useful, 1203 * you have to not use "" includes. 1204 */ 1205fix = { 1206 hackname = darwin_9_long_double_funcs_2; 1207 mach = "*-*-darwin7.9*"; 1208 files = math.h; 1209 select = '#include[ \t]+\"'; 1210 c_fix = format; 1211 c_fix_arg = "%1<%2.h>"; 1212 1213 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"'; 1214 1215 test_text = '#include "architecture/ppc/math.h"'; 1216}; 1217 1218 1219/* 1220 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded 1221 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded. 1222 */ 1223fix = { 1224 hackname = darwin_externc; 1225 mach = "*-*-darwin*"; 1226 files = mach-o/swap.h; 1227 files = mach/mach_time.h; 1228 files = mach/mach_traps.h; 1229 files = mach/message.h; 1230 files = mach/mig.h; 1231 files = mach/semaphore.h; 1232 bypass = "extern \"C\""; 1233 bypass = "__BEGIN_DECLS"; 1234 c_fix = wrap; 1235 c_fix_arg = "#ifdef __cplusplus\n" 1236 "extern \"C\" {\n" 1237 "#endif\n"; 1238 c_fix_arg = "#ifdef __cplusplus\n" 1239 "}\n" 1240 "#endif\n"; 1241 test_text = "extern void swap_fat_header();\n"; 1242}; 1243 1244 1245/* 1246 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of 1247 * bad __GNUC__ tests. 1248 */ 1249 1250fix = { 1251 hackname = darwin_gcc4_breakage; 1252 mach = "*-*-darwin*"; 1253 files = AvailabilityMacros.h; 1254 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)"; 1255 c_fix = format; 1256 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))"; 1257 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && " 1258 "(__GNUC_MINOR__ >= 1)\n"; 1259}; 1260 1261 1262/* 1263 * __private_extern__ doesn't exist in FSF GCC. Even if it did, 1264 * why would you ever put it in a system header file? 1265 */ 1266fix = { 1267 hackname = darwin_private_extern; 1268 mach = "*-*-darwin*"; 1269 files = mach-o/dyld.h; 1270 select = "__private_extern__ [a-z_]+ _dyld_"; 1271 c_fix = format; 1272 c_fix_arg = "extern"; 1273 c_fix_arg = "__private_extern__"; 1274 test_text = "__private_extern__ int _dyld_func_lookup(\n" 1275 "const char *dyld_func_name,\n" 1276 "unsigned long *address);\n"; 1277}; 1278 1279 1280/* 1281 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to 1282 * unsigned constants. 1283 */ 1284fix = { 1285 hackname = darwin_stdint_1; 1286 mach = "*-*-darwin*"; 1287 files = stdint-darwin.h, stdint.h; 1288 c_fix = format; 1289 c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv"; 1290 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n" 1291 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)"; 1292 test_text = "#define UINT8_C(v) (v ## U)\n" 1293 "#define UINT16_C(v) (v ## U)"; 1294}; 1295 1296 1297/* 1298 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX 1299 * with wrong types. 1300 */ 1301fix = { 1302 hackname = darwin_stdint_2; 1303 mach = "*-*-darwin*"; 1304 files = stdint-darwin.h, stdint.h; 1305 c_fix = format; 1306 c_fix_arg = "#if __WORDSIZE == 64\n" 1307 "#define INTPTR_MAX 9223372036854775807L\n" 1308 "#define INTPTR_MIN (-INTPTR_MAX-1)\n" 1309 "#else\n" 1310 "#define INTPTR_MAX 2147483647L\n" 1311 "#define INTPTR_MIN (-INTPTR_MAX-1)\n" 1312 "#endif"; 1313 select = "#if __WORDSIZE == 64\n" 1314 "#define INTPTR_MIN[ \t]+INT64_MIN\n" 1315 "#define INTPTR_MAX[ \t]+INT64_MAX\n" 1316 "#else\n" 1317 "#define INTPTR_MIN[ \t]+INT32_MIN\n" 1318 "#define INTPTR_MAX[ \t]+INT32_MAX\n" 1319 "#endif"; 1320 test_text = "#if __WORDSIZE == 64\n" 1321 "#define INTPTR_MIN INT64_MIN\n" 1322 "#define INTPTR_MAX INT64_MAX\n" 1323 "#else\n" 1324 "#define INTPTR_MIN INT32_MIN\n" 1325 "#define INTPTR_MAX INT32_MAX\n" 1326 "#endif"; 1327}; 1328 1329 1330/* 1331 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type. 1332 */ 1333fix = { 1334 hackname = darwin_stdint_3; 1335 mach = "*-*-darwin*"; 1336 files = stdint-darwin.h, stdint.h; 1337 c_fix = format; 1338 c_fix_arg = "#if __WORDSIZE == 64\n" 1339 "#define UINTPTR_MAX 18446744073709551615UL\n" 1340 "#else\n" 1341 "#define UINTPTR_MAX 4294967295UL\n" 1342 "#endif"; 1343 select = "#if __WORDSIZE == 64\n" 1344 "#define UINTPTR_MAX[ \t]+UINT64_MAX\n" 1345 "#else\n" 1346 "#define UINTPTR_MAX[ \t]+UINT32_MAX\n" 1347 "#endif"; 1348 test_text = "#if __WORDSIZE == 64\n" 1349 "#define UINTPTR_MAX UINT64_MAX\n" 1350 "#else\n" 1351 "#define UINTPTR_MAX UINT32_MAX\n" 1352 "#endif"; 1353}; 1354 1355 1356/* 1357 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type. 1358 */ 1359fix = { 1360 hackname = darwin_stdint_4; 1361 mach = "*-*-darwin*"; 1362 files = stdint-darwin.h, stdint.h; 1363 c_fix = format; 1364 c_fix_arg = "#if __WORDSIZE == 64\n" 1365 "#define SIZE_MAX 18446744073709551615UL\n" 1366 "#else\n" 1367 "#define SIZE_MAX 4294967295UL\n" 1368 "#endif"; 1369 select = "#if __WORDSIZE == 64\n" 1370 "#define SIZE_MAX[ \t]+UINT64_MAX\n" 1371 "#else\n" 1372 "#define SIZE_MAX[ \t]+UINT32_MAX\n" 1373 "#endif"; 1374 test_text = "#if __WORDSIZE == 64\n" 1375 "#define SIZE_MAX UINT64_MAX\n" 1376 "#else\n" 1377 "#define SIZE_MAX UINT32_MAX\n" 1378 "#endif"; 1379}; 1380 1381 1382/* 1383 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX} 1384 * with a wrong type. 1385 */ 1386fix = { 1387 hackname = darwin_stdint_5; 1388 mach = "*-*-darwin*"; 1389 files = stdint-darwin.h, stdint.h; 1390 c_fix = format; 1391 c_fix_arg = "#if __WORDSIZE == 64\n" 1392 "#define INTMAX_MIN (-9223372036854775807L - 1)\n" 1393 "#define INTMAX_MAX 9223372036854775807L\n" 1394 "#define UINTMAX_MAX 18446744073709551615UL\n" 1395 "#else\n" 1396 "#define INTMAX_MIN (-9223372036854775807LL - 1)\n" 1397 "#define INTMAX_MAX 9223372036854775807LL\n" 1398 "#define UINTMAX_MAX 18446744073709551615ULL\n" 1399 "#endif"; 1400 select = "#define INTMAX_MIN[ \t]+INT64_MIN\n" 1401 "#define INTMAX_MAX[ \t]+INT64_MAX\n" 1402 "\n" 1403 "#define UINTMAX_MAX[ \t]+UINT64_MAX"; 1404 test_text = "#define INTMAX_MIN INT64_MIN\n" 1405 "#define INTMAX_MAX INT64_MAX\n" 1406 "\n" 1407 "#define UINTMAX_MAX UINT64_MAX"; 1408}; 1409 1410 1411/* 1412 * Darwin headers have a stdint.h that defines {U,}INTMAX_C 1413 * with a wrong type. 1414 */ 1415fix = { 1416 hackname = darwin_stdint_6; 1417 mach = "*-*-darwin*"; 1418 files = stdint-darwin.h, stdint.h; 1419 c_fix = format; 1420 c_fix_arg = "#if __WORDSIZE == 64\n" 1421 "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n" 1422 "#define PTRDIFF_MAX 9223372036854775807L\n" 1423 "#else\n" 1424 "#define PTRDIFF_MIN (-2147483647 - 1)\n" 1425 "#define PTRDIFF_MAX 2147483647\n" 1426 "#endif"; 1427 select = "#if __WORDSIZE == 64\n" 1428 "#define PTRDIFF_MIN[ \t]+INT64_MIN\n" 1429 "#define PTRDIFF_MAX[ \t]+INT64_MAX\n" 1430 "#else\n" 1431 "#define PTRDIFF_MIN[ \t]+INT32_MIN\n" 1432 "#define PTRDIFF_MAX[ \t]+INT32_MAX\n" 1433 "#endif"; 1434 test_text = "#if __WORDSIZE == 64\n" 1435 "#define PTRDIFF_MIN INT64_MIN\n" 1436 "#define PTRDIFF_MAX INT64_MAX\n" 1437 "#else\n" 1438 "#define PTRDIFF_MIN INT32_MIN\n" 1439 "#define PTRDIFF_MAX INT32_MAX\n" 1440 "#endif"; 1441}; 1442 1443 1444/* 1445 * Darwin headers have a stdint.h that defines {U,}INTMAX_C 1446 * with a wrong type. 1447 */ 1448fix = { 1449 hackname = darwin_stdint_7; 1450 mach = "*-*-darwin*"; 1451 files = stdint-darwin.h, stdint.h; 1452 c_fix = format; 1453 c_fix_arg = "#if __WORDSIZE == 64\n" 1454 "#define INTMAX_C(v) (v ## L)\n" 1455 "#define UINTMAX_C(v) (v ## UL)\n" 1456 "#else\n" 1457 "#define INTMAX_C(v) (v ## LL)\n" 1458 "#define UINTMAX_C(v) (v ## ULL)\n" 1459 "#endif"; 1460 select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n" 1461 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)"; 1462 test_text = "#define INTMAX_C(v) (v ## LL)\n" 1463 "#define UINTMAX_C(v) (v ## ULL)"; 1464}; 1465 1466 1467/* 1468 * Fix <c_asm.h> on Digital UNIX V4.0: 1469 * It contains a prototype for a DEC C internal asm() function, 1470 * clashing with gcc's asm keyword. So protect this with __DECC. 1471 */ 1472fix = { 1473 hackname = dec_intern_asm; 1474 files = c_asm.h; 1475 sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; 1476 sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" 1477 "#endif\n"; 1478 test_text = 1479 "float fasm {\n" 1480 " ... asm stuff ...\n" 1481 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/"; 1482}; 1483 1484 1485/* 1486 * Fix typo in <wchar.h> on DJGPP 2.03. 1487 */ 1488fix = { 1489 hackname = djgpp_wchar_h; 1490 file = wchar.h; 1491 select = "__DJ_wint_t"; 1492 bypass = "sys/djtypes.h"; 1493 c_fix = format; 1494 c_fix_arg = "%0\n#include <sys/djtypes.h>"; 1495 c_fix_arg = "#include <stddef.h>"; 1496 test_text = "#include <stddef.h>\n" 1497 "extern __DJ_wint_t x;\n"; 1498}; 1499 1500 1501/* 1502 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. 1503 */ 1504fix = { 1505 hackname = ecd_cursor; 1506 files = "sunwindow/win_lock.h"; 1507 files = "sunwindow/win_cursor.h"; 1508 select = 'ecd\.cursor'; 1509 c_fix = format; 1510 c_fix_arg = 'ecd_cursor'; 1511 1512 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */"; 1513}; 1514 1515 1516/* 1517 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume 1518 * neither the existence of GCC 3 nor its exact feature set yet break 1519 * (by design?) when __GNUC__ is set beyond 2. 1520 */ 1521fix = { 1522 hackname = freebsd_gcc3_breakage; 1523 mach = "*-*-freebsd*"; 1524 files = sys/cdefs.h; 1525 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'; 1526 bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)'; 1527 c_fix = format; 1528 c_fix_arg = '%0 || __GNUC__ >= 3'; 1529 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7'; 1530}; 1531 1532 1533/* 1534 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume 1535 * neither the existence of GCC 4 nor its exact feature set yet break 1536 * (by design?) when __GNUC__ is set beyond 3. 1537 */ 1538fix = { 1539 hackname = freebsd_gcc4_breakage; 1540 mach = "*-*-freebsd*"; 1541 files = sys/cdefs.h; 1542 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$'; 1543 c_fix = format; 1544 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3'; 1545 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3'; 1546}; 1547 1548 1549/* 1550 * Some versions of glibc don't expect the C99 inline semantics. 1551 */ 1552fix = { 1553 hackname = glibc_c99_inline_1; 1554 files = features.h, '*/features.h'; 1555 select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$"; 1556 c_fix = format; 1557 c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)"; 1558 test_text = <<-EOT 1559 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ 1560 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ 1561 # define __USE_EXTERN_INLINES 1 1562 #endif 1563 EOT; 1564}; 1565 1566 1567/* 1568 * Similar, but a version that didn't have __NO_INLINE__ 1569 */ 1570fix = { 1571 hackname = glibc_c99_inline_1a; 1572 files = features.h, '*/features.h'; 1573 select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n" 1574 "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)"; 1575 c_fix = format; 1576 c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2"; 1577 test_text = <<-EOT 1578 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ 1579 # define __USE_EXTERN_INLINES 1 1580 #endif 1581 EOT; 1582}; 1583 1584 1585/* 1586 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately 1587 * there are many glibc headers which do not respect __USE_EXTERN_INLINES. 1588 * The remaining glibc_c99_inline_* fixes deal with some of those headers. 1589 */ 1590fix = { 1591 hackname = glibc_c99_inline_2; 1592 files = sys/stat.h, '*/sys/stat.h'; 1593 select = "extern __inline__ int"; 1594 sed = "s/extern int \\(stat\\)/" 1595 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1596 "__inline__ int \\1/"; 1597 sed = "s/extern int \\([lf]stat\\)/" 1598 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1599 "__inline__ int \\1/"; 1600 sed = "s/extern int \\(mknod\\)/" 1601 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1602 "__inline__ int \\1/"; 1603 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/" 1604 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1605 "__inline__ int __REDIRECT\\1 (\\2/"; 1606 sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/" 1607 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1608 "__inline__ int __REDIRECT\\1 (\\2/"; 1609 sed = "s/^extern __inline__ int/" 1610 "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n" 1611 "__inline__ int/"; 1612 test_text = <<-EOT 1613 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); 1614 extern __inline__ int 1615 __NTH (fstat64 (int __fd, struct stat64 *__statbuf)) 1616 {} 1617 EOT; 1618}; 1619 1620 1621fix = { 1622 hackname = glibc_c99_inline_3; 1623 files = bits/string2.h, '*/bits/string2.h'; 1624 select = "extern __inline"; 1625 bypass = "__extern_inline|__GNU_STDC_INLINE__"; 1626 c_fix = format; 1627 c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)"; 1628 c_fix_arg = "^# ifdef __cplusplus$"; 1629 test_text = <<-EOT 1630 # ifdef __cplusplus 1631 # define __STRING_INLINE inline 1632 # else 1633 # define __STRING_INLINE extern __inline 1634 # endif 1635 EOT; 1636}; 1637 1638 1639fix = { 1640 hackname = glibc_c99_inline_4; 1641 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h'; 1642 bypass = "__extern_inline|__gnu_inline__"; 1643 select = "(^| )extern __inline"; 1644 c_fix = format; 1645 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))"; 1646 test_text = <<-EOT 1647 __extension__ extern __inline unsigned int 1648 extern __inline unsigned int 1649 EOT; 1650}; 1651 1652 1653/* glibc-2.3.5 defines pthread mutex initializers incorrectly, 1654 * so we replace them with versions that correspond to the 1655 * definition. 1656 */ 1657fix = { 1658 hackname = glibc_mutex_init; 1659 files = pthread.h; 1660 select = '\{ *\{ *0, *\} *\}'; 1661 sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n" 1662 "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}"; 1663 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" 1664 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/"; 1665 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" 1666 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/"; 1667 sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_" 1668 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/"; 1669 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" 1670 "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/"; 1671 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" 1672 "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/"; 1673 sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_" 1674 "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/"; 1675 sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/" 1676 "N;s/^[ \t]*#[ \t]*" 1677 "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n" 1678 "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n" 1679 "# \\1\\\n" 1680 " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n" 1681 "# else\\\n" 1682 "# \\1\\\n" 1683 " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n" 1684 "# endif/"; 1685 sed = "s/{ \\(0, 0, 0, 0, 0, 0, " 1686 "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/"; 1687 sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/" 1688 "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/"; 1689 1690 test_text = <<- _EOText_ 1691 #define PTHREAD_MUTEX_INITIALIZER \\ 1692 { { 0, } } 1693 #ifdef __USE_GNU 1694 # if __WORDSIZE == 64 1695 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ 1696 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } 1697 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ 1698 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } 1699 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ 1700 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } 1701 # else 1702 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\ 1703 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } } 1704 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\ 1705 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } } 1706 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\ 1707 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } } 1708 # endif 1709 #endif 1710 # define PTHREAD_RWLOCK_INITIALIZER \\ 1711 { { 0, } } 1712 # ifdef __USE_GNU 1713 # if __WORDSIZE == 64 1714 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ 1715 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ 1716 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } 1717 # else 1718 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\ 1719 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } 1720 # endif 1721 # endif 1722 #define PTHREAD_COND_INITIALIZER { { 0, } } 1723 _EOText_; 1724}; 1725 1726 1727/* glibc versions before 2.5 have a version of stdint.h that defines 1728 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc 1729 versions with stdint.h based on those glibc versions. */ 1730fix = { 1731 hackname = glibc_stdint; 1732 files = stdint.h; 1733 select = "GNU C Library"; 1734 c_fix = format; 1735 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc"; 1736 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U"; 1737 test_text = "/* This file is part of the GNU C Library. */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U"; 1738}; 1739 1740 1741/* Some versions of glibc have a version of bits/string2.h that 1742 produces "value computed is not used" warnings from strncpy; fix 1743 this definition by using __builtin_strncpy instead as in newer 1744 versions. */ 1745fix = { 1746 hackname = glibc_strncpy; 1747 files = bits/string2.h; 1748 bypass = "__builtin_strncpy"; 1749 c_fix = format; 1750 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)"; 1751 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*"; 1752 test_text = <<-EOT 1753 # define strncpy(dest, src, n) \ 1754 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\ 1755 ? (strlen (src) + 1 >= ((size_t) (n)) \\ 1756 ? (char *) memcpy (dest, src, n) \\ 1757 : strncpy (dest, src, n)) \\ 1758 : strncpy (dest, src, n))) 1759 EOT; 1760 1761}; 1762 1763/* glibc's tgmath.h relies on an expression that is not an integer 1764 constant expression being treated as it was by GCC 4.4 and 1765 earlier. */ 1766fix = { 1767 hackname = glibc_tgmath; 1768 files = tgmath.h; 1769 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)'; 1770 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type"; 1771 c_fix = format; 1772 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))"; 1773 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))"; 1774}; 1775 1776/* 1777 * Fix these files to use the types we think they should for 1778 * ptrdiff_t, size_t, and wchar_t. 1779 * 1780 * This defines the types in terms of macros predefined by our 'cpp'. 1781 * This is supposedly necessary for glibc's handling of these types. 1782 * It's probably not necessary for anyone else, but it doesn't hurt. 1783 */ 1784fix = { 1785 hackname = gnu_types; 1786 files = "sys/types.h"; 1787 files = "stdlib.h"; 1788 files = "sys/stdtypes.h"; 1789 files = "stddef.h"; 1790 files = "memory.h"; 1791 files = "unistd.h"; 1792 bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T'; 1793 select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;"; 1794 c_fix = gnu_type; 1795 /* The Solaris 10 headers already define these types correctly. */ 1796 mach = '*-*-solaris2.1[0-9]*'; 1797 not_machine = true; 1798 1799 test_text = "typedef long int ptrdiff_t; /* long int */\n" 1800 "typedef uint_t size_t; /* uint_t */\n" 1801 "typedef ushort_t wchar_t; /* ushort_t */"; 1802}; 1803 1804 1805/* 1806 * Fix HP & Sony's use of "../machine/xxx.h" 1807 * to refer to: <machine/xxx.h> 1808 */ 1809fix = { 1810 hackname = hp_inline; 1811 files = sys/spinlock.h; 1812 files = machine/machparam.h; 1813 select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/'; 1814 1815 c_fix = format; 1816 c_fix_arg = "%1<machine/%2.h>"; 1817 1818 c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/' 1819 '([a-z]+)\.h"'; 1820 1821 test_text = ' # include "../machine/mumble.h"'; 1822}; 1823 1824 1825/* 1826 * Check for (...) in C++ code in HP/UX sys/file.h. 1827 */ 1828fix = { 1829 hackname = hp_sysfile; 1830 files = sys/file.h; 1831 select = "HPUX_SOURCE"; 1832 1833 c_fix = format; 1834 c_fix_arg = "(struct file *, ...)"; 1835 c_fix_arg = '\(\.\.\.\)'; 1836 1837 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */"; 1838}; 1839 1840 1841/* 1842 * Un-Hide a series of five FP defines from post-1999 compliance GCC: 1843 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN 1844 */ 1845fix = { 1846 hackname = hppa_hpux_fp_macros; 1847 mach = "hppa*-hp-hpux11*"; 1848 files = math.h; 1849 select = "#[ \t]*define[ \t]*FP_NORMAL.*\n" 1850 "#[ \t]*define[ \t]*FP_ZERO.*\n" 1851 "#[ \t]*define[ \t]*FP_INFINITE.*\n" 1852 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n" 1853 "#[ \t]*define[ \t]*FP_NAN.*\n"; 1854 c_fix = format; 1855 c_fix_arg = <<- _EOFix_ 1856 #endif /* _INCLUDE_HPUX_SOURCE */ 1857 1858 #if defined(_INCLUDE_HPUX_SOURCE) || \ 1859 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) 1860 %0#endif 1861 1862 #ifdef _INCLUDE_HPUX_SOURCE 1863 1864 _EOFix_; 1865 1866 test_text = 1867 "# define FP_NORMAL 0\n" 1868 "# define FP_ZERO 1\n" 1869 "# define FP_INFINITE 2\n" 1870 "# define FP_SUBNORMAL 3\n" 1871 "# define FP_NAN 4\n"; 1872}; 1873 1874 1875/* 1876 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11 1877 * math.h to prevent clash with define in c_std/bits/std_cmath.h. 1878 */ 1879fix = { 1880 hackname = hpux10_cpp_pow_inline; 1881 files = fixinc-test-limits.h, math.h; 1882 select = <<- END_POW_INLINE 1883 ^# +ifdef +__cplusplus 1884 +\} 1885 +inline +double +pow\(double +__d,int +__expon\) +\{ 1886 [ ]+return +pow\(__d,\(double\)__expon\); 1887 +\} 1888 +extern +"C" +\{ 1889 #else 1890 # +endif 1891 END_POW_INLINE; 1892 1893 c_fix = format; 1894 c_fix_arg = ""; 1895 1896 test_text = 1897 "# ifdef __cplusplus\n" 1898 " }\n" 1899 " inline double pow(double __d,int __expon) {\n" 1900 "\t return pow(__d,(double)__expon);\n" 1901 " }\n" 1902 ' extern "C"' " {\n" 1903 "#else\n" 1904 "# endif"; 1905}; 1906 1907fix = { 1908 hackname = hpux11_cpp_pow_inline; 1909 files = math.h; 1910 select = " +inline double pow\\(double d,int expon\\) \\{\n" 1911 " +return pow\\(d, \\(double\\)expon\\);\n" 1912 " +\\}\n"; 1913 c_fix = format; 1914 c_fix_arg = ""; 1915 1916 test_text = 1917 " inline double pow(double d,int expon) {\n" 1918 " return pow(d, (double)expon);\n" 1919 " }\n"; 1920}; 1921 1922 1923/* 1924 * Fix hpux 10.X missing ctype declarations 1 1925 */ 1926fix = { 1927 hackname = hpux10_ctype_declarations1; 1928 files = ctype.h; 1929 select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)"; 1930 bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\("; 1931 c_fix = format; 1932 c_fix_arg = "#ifdef _PROTOTYPES\n" 1933 "extern int __tolower(int);\n" 1934 "extern int __toupper(int);\n" 1935 "#else /* NOT _PROTOTYPES */\n" 1936 "extern int __tolower();\n" 1937 "extern int __toupper();\n" 1938 "#endif /* _PROTOTYPES */\n\n" 1939 "%0\n"; 1940 1941 test_text = "# define _toupper(__c) __toupper(__c)\n"; 1942}; 1943 1944 1945/* 1946 * Fix hpux 10.X missing ctype declarations 2 1947 */ 1948fix = { 1949 hackname = hpux10_ctype_declarations2; 1950 files = ctype.h; 1951 select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)"; 1952 bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\("; 1953 c_fix = format; 1954 c_fix_arg = "%0\n\n" 1955 "#ifdef _PROTOTYPES\n" 1956 " extern int _isalnum(int);\n" 1957 " extern int _isalpha(int);\n" 1958 " extern int _iscntrl(int);\n" 1959 " extern int _isdigit(int);\n" 1960 " extern int _isgraph(int);\n" 1961 " extern int _islower(int);\n" 1962 " extern int _isprint(int);\n" 1963 " extern int _ispunct(int);\n" 1964 " extern int _isspace(int);\n" 1965 " extern int _isupper(int);\n" 1966 " extern int _isxdigit(int);\n" 1967 "# else /* not _PROTOTYPES */\n" 1968 " extern int _isalnum();\n" 1969 " extern int _isalpha();\n" 1970 " extern int _iscntrl();\n" 1971 " extern int _isdigit();\n" 1972 " extern int _isgraph();\n" 1973 " extern int _islower();\n" 1974 " extern int _isprint();\n" 1975 " extern int _ispunct();\n" 1976 " extern int _isspace();\n" 1977 " extern int _isupper();\n" 1978 " extern int _isxdigit();\n" 1979 "#endif /* _PROTOTYPES */\n"; 1980 1981 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n" 1982 " extern unsigned int *__SB_masks;\n"; 1983}; 1984 1985 1986/* 1987 * Fix hpux 10.X missing stdio declarations 1988 */ 1989fix = { 1990 hackname = hpux10_stdio_declarations; 1991 files = stdio.h; 1992 select = "^#[ \t]*define _iob[ \t]*__iob"; 1993 bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\("; 1994 c_fix = format; 1995 c_fix_arg = "%0\n\n" 1996 "# if defined(__STDC__) || defined(__cplusplus)\n" 1997 " extern int snprintf(char *, size_t, const char *, ...);\n" 1998 " extern int vsnprintf(char *, size_t, const char *, __va_list);\n" 1999 "# else /* not __STDC__) || __cplusplus */\n" 2000 " extern int snprintf();\n" 2001 " extern int vsnprintf();\n" 2002 "# endif /* __STDC__) || __cplusplus */\n"; 2003 2004 test_text = "# define _iob __iob\n"; 2005}; 2006 2007 2008/* 2009 * Make sure hpux defines abs in header. 2010 */ 2011fix = { 2012 hackname = hpux11_abs; 2013 mach = "*-hp-hpux11*"; 2014 files = stdlib.h; 2015 select = "ifndef _MATH_INCLUDED"; 2016 c_fix = format; 2017 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)"; 2018 test_text = "#ifndef _MATH_INCLUDED"; 2019}; 2020 2021 2022/* 2023 * Keep HP-UX 11 from stomping on C++ math namespace 2024 * with defines for fabsf. 2025 */ 2026fix = { 2027 hackname = hpux11_fabsf; 2028 files = math.h; 2029 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*"; 2030 bypass = "__cplusplus"; 2031 2032 c_fix = format; 2033 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 2034 2035 test_text = 2036 "#ifdef _PA_RISC\n" 2037 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n" 2038 "#endif"; 2039}; 2040 2041 2042/* 2043 * Fix C99 constant in __POINTER_SET define. 2044 */ 2045fix = { 2046 hackname = hpux11_pthread_const; 2047 mach = "*-hp-hpux11.[0-3]*"; 2048 files = sys/pthread.h; 2049 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)"; 2050 2051 c_fix = format; 2052 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)"; 2053 test_text = "#define __POINTER_SET\t\t((void *) 1LL)"; 2054}; 2055 2056 2057/* 2058 * Prevent HP-UX 11 from defining __size_t and preventing size_t from 2059 * being defined by having it define _hpux_size_t instead. 2060 */ 2061fix = { 2062 hackname = hpux11_size_t; 2063 mach = "*-hp-hpux11*"; 2064 select = "__size_t"; 2065 2066 c_fix = format; 2067 c_fix_arg = "_hpux_size_t"; 2068 2069 test_text = 2070 "#define __size_t size_t\n" 2071 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n"; 2072}; 2073 2074 2075/* 2076 * Fix hpux 11.00 broken snprintf declaration 2077 * (third argument is char *, needs to be const char * to prevent 2078 * spurious warnings with -Wwrite-strings or in C++). 2079 */ 2080fix = { 2081 hackname = hpux11_snprintf; 2082 files = stdio.h; 2083 select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)' 2084 ' *(char *\*, *\.\.\.\);)'; 2085 c_fix = format; 2086 c_fix_arg = '%1 const %3'; 2087 2088 test_text = "extern int snprintf(char *, size_t, char *, ...);\n" 2089 "extern int snprintf(char *, __size_t, char *, ...);\n" 2090 "extern int snprintf(char *, _hpux_size_t, char *, ...);"; 2091}; 2092 2093/* 2094 * Fix hpux 11.00 broken vsnprintf declaration 2095 */ 2096fix = { 2097 hackname = hpux11_vsnprintf; 2098 files = stdio.h; 2099 select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, ' 2100 'const char \*,) __va__list\);'; 2101 c_fix = format; 2102 c_fix_arg = "%1 __va_list);"; 2103 2104 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,' 2105 ' __va__list);'; 2106}; 2107 2108 2109/* 2110 * get rid of bogus inline definitions in HP-UX 8.0 2111 */ 2112fix = { 2113 hackname = hpux8_bogus_inlines; 2114 files = math.h; 2115 select = inline; 2116 bypass = "__GNUG__"; 2117 sed = "s@inline int abs(int [a-z][a-z]*) {.*}" 2118 "@extern \"C\" int abs(int);@"; 2119 sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@"; 2120 sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@"; 2121 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; 2122 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n" 2123 "inline double sqr(double v) { return v**0.5; }"; 2124}; 2125 2126 2127/* 2128 * Fix hpux broken ctype macros 2129 */ 2130fix = { 2131 hackname = hpux_ctype_macros; 2132 files = ctype.h; 2133 select = '((: |\()__SB_masks \? )' 2134 '(__SB_masks\[__(alnum|c)\] & _IS)'; 2135 c_fix = format; 2136 c_fix_arg = "%1(int)%3"; 2137 2138 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n" 2139 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n"; 2140}; 2141 2142 2143/* 2144 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc. 2145 */ 2146fix = { 2147 hackname = hpux_htonl; 2148 files = netinet/in.h; 2149 select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n" 2150 "(/\\*\n" 2151 " \\* Macros for number representation conversion\\.\n" 2152 " \\*/\n" 2153 "#ifndef ntohl)"; 2154 c_fix = format; 2155 c_fix_arg = "#if 1\n%1"; 2156 2157 test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n" 2158 "/*\n" 2159 " * Macros for number representation conversion.\n" 2160 " */\n" 2161 "#ifndef ntohl\n" 2162 "#define ntohl(x) (x)\n" 2163 "#define ntohs(x) (x)\n" 2164 "#define htonl(x) (x)\n" 2165 "#define htons(x) (x)\n" 2166 "#endif\n" 2167 "#endif /* ! _XOPEN_SOURCE_EXTENDED */"; 2168}; 2169 2170 2171/* 2172 * HP-UX long_double 2173 */ 2174fix = { 2175 hackname = hpux_long_double; 2176 mach = "*-*-hpux10*"; 2177 mach = "*-*-hpux11.[012]*"; 2178 files = stdlib.h; 2179 select = "extern[ \t]long_double[ \t]strtold"; 2180 bypass = "long_double_t"; 2181 sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D"; 2182 sed = "s/long_double/long double/g"; 2183 2184 test_text = "# ifndef _LONG_DOUBLE\n" 2185 "# define _LONG_DOUBLE\n" 2186 " typedef struct {\n" 2187 " unsigned int word1, word2, word3, word4;\n" 2188 " } long_double;\n" 2189 "# endif /* _LONG_DOUBLE */\n" 2190 "extern long_double strtold(const char *, char **);\n"; 2191}; 2192 2193 /* 2194 * We cannot use the above rule on 11.31 because it removes the strtold 2195 * definition. ia64 is OK with no hack, PA needs some help. 2196 */ 2197fix = { 2198 hackname = hpux_long_double_2; 2199 mach = "hppa*-*-hpux11.3*"; 2200 files = stdlib.h; 2201 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)"; 2202 c_fix = format; 2203 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)"; 2204 2205 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n"; 2206}; 2207 2208/* 2209 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl 2210 */ 2211fix = { 2212 hackname = hpux_systime; 2213 files = sys/time.h; 2214 select = "^extern struct sigevent;"; 2215 2216 c_fix = format; 2217 c_fix_arg = "struct sigevent;"; 2218 2219 test_text = 'extern struct sigevent;'; 2220}; 2221 2222 2223/* 2224 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown 2225 * type and mpinfou is only defined when _KERNEL is set. 2226 */ 2227fix = { 2228 hackname = hpux_spu_info; 2229 mach = "*-hp-hpux*"; 2230 /* 2231 * It is tempting to omit the first "files" entry. Do not. 2232 * The testing machinery will take the first "files" entry as the name 2233 * of a test file to play with. It would be a nuisance to have a directory 2234 * with the name "*". 2235 */ 2236 files = "ia64/sys/getppdp.h"; 2237 files = "*/sys/getppdp.h"; 2238 select = "^.*extern.*spu_info.*"; 2239 2240 c_fix = format; 2241 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif"; 2242 2243 test_text = "extern union mpinfou spu_info[];"; 2244}; 2245 2246fix = { 2247 hackname = hpux11_extern_sendfile; 2248 mach = "*-hp-hpux11.[12]*"; 2249 files = sys/socket.h; 2250 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n"; 2251 c_fix = format; 2252 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; 2253 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; 2254}; 2255 2256fix = { 2257 hackname = hpux11_extern_sendpath; 2258 mach = "*-hp-hpux11.[12]*"; 2259 files = sys/socket.h; 2260 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n"; 2261 c_fix = format; 2262 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n"; 2263 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n"; 2264}; 2265 2266fix = { 2267 hackname = hpux_extern_errno; 2268 mach = "*-hp-hpux10.*"; 2269 mach = "*-hp-hpux11.[0-2]*"; 2270 files = errno.h; 2271 select = "^[ \t]*extern int errno;$"; 2272 c_fix = format; 2273 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif"; 2274 test_text = " extern int errno;\n"; 2275}; 2276 2277 2278/* 2279 * Add missing braces to pthread initializer defines. 2280 */ 2281fix = { 2282 hackname = hpux_pthread_initializers; 2283 mach = "*-hp-hpux11.[0-3]*"; 2284 files = sys/pthread.h; 2285 sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\" 2286 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@"; 2287 sed = "s@^[ \t]*1,[ \t]*\\\\" 2288 "@\t{ 1, 0 }@"; 2289 sed = "/^[ \t]*0$/d"; 2290 sed = "s@__PTHREAD_MUTEX_VALID, 0" 2291 "@{ __PTHREAD_MUTEX_VALID, 0 }@"; 2292 sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\" 2293 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@"; 2294 sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" 2295 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; 2296 sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\" 2297 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@"; 2298 sed = "s@^[ \t]*0, 0[ \t]*\\\\" 2299 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@"; 2300 sed = "s@__PTHREAD_COND_VALID, 0" 2301 "@{ __PTHREAD_COND_VALID, 0 }@"; 2302 sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\" 2303 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@"; 2304 sed = "s@__PTHREAD_RWLOCK_VALID, 0" 2305 "@{ __PTHREAD_RWLOCK_VALID, 0 }@"; 2306 sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\" 2307 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@"; 2308 sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\" 2309 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@"; 2310 test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n" 2311 "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n" 2312 "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n" 2313 "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n" 2314 "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n" 2315 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n" 2316 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n" 2317 "}\n"; 2318}; 2319 2320fix = { 2321 hackname = hpux_c99_intptr; 2322 mach = "*-hp-hpux11.3*"; 2323 files = stdint-hpux11.h, stdint.h; 2324 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@"; 2325 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; 2326 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@"; 2327 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@"; 2328 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@"; 2329 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@"; 2330 test_text = "#define PTRDIFF_MAX INT32_MAX\n" 2331 "#define PTRDIFF_MIN INT32_MIN\n" 2332 "#define INTPTR_MAX INT32_MAX\n" 2333 "#define INTPTR_MIN INT32_MIN\n" 2334 "#define UINTPTR_MAX UINT32_MAX\n" 2335 "#define SIZE_MAX UINT32_MAX\n"; 2336}; 2337 2338/* 2339 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31. 2340 */ 2341 2342fix = { 2343 hackname = hpux_c99_inttypes; 2344 mach = "*-hp-hpux11.[23]*"; 2345 files = inttypes.h; 2346 files = stdint-hpux11.h, stdint.h; 2347 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@"; 2348 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@"; 2349 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@"; 2350 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@"; 2351 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n" 2352 "#define UINT16_C(__c) __CONCAT_U__(__c)\n" 2353 "#define INT32_C(__c) __CONCAT__(__c,l)\n" 2354 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n"; 2355}; 2356 2357fix = { 2358 hackname = hpux_c99_inttypes2; 2359 mach = "*-hp-hpux11.2*"; 2360 files = stdint-hpux11.h, stdint.h; 2361 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@"; 2362 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@"; 2363 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@"; 2364 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@"; 2365 test_text = "# define INT8_C(__c) ((signed char)(__c))\n" 2366 "# define UINT8_C(__c) ((unsigned char)(__c))\n" 2367 "# define INT16_C(__c) ((short)(__c))\n" 2368 "# define UINT16_C(__c) ((unsigned short)(__c))\n"; 2369}; 2370 2371fix = { 2372 hackname = hpux_stdint_least_fast; 2373 mach = "*-hp-hpux11.2*"; 2374 files = stdint-hpux11.h, stdint.h; 2375 select = 2376 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX"; 2377 c_fix = format; 2378 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__"; 2379 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n" 2380 "# define UINT_LEAST64_MAX ULLONG_MAX\n"; 2381 _EOFix_; 2382}; 2383 2384fix = { 2385 hackname = hpux_inttype_int8_t; 2386 mach = "*-hp-hpux1[01].*"; 2387 files = sys/_inttypes.h; 2388 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*"; 2389 c_fix = format; 2390 c_fix_arg = "typedef signed char int%18_t;"; 2391 test_text = "typedef char int_least8_t;\n" 2392 "typedef char int8_t;\n"; 2393}; 2394 2395fix = { 2396 hackname = hpux_imaginary_i; 2397 mach = "ia64-hp-hpux11.*"; 2398 files = complex.h; 2399 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*"; 2400 c_fix = format; 2401 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; 2402 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n"; 2403}; 2404 2405/* 2406 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant 2407 */ 2408fix = { 2409 hackname = huge_val_hex; 2410 files = bits/huge_val.h; 2411 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*"; 2412 bypass = "__builtin_huge_val"; 2413 2414 c_fix = format; 2415 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n"; 2416 2417 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)"; 2418}; 2419 2420 2421/* 2422 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant 2423 */ 2424fix = { 2425 hackname = huge_valf_hex; 2426 files = bits/huge_val.h; 2427 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*"; 2428 bypass = "__builtin_huge_valf"; 2429 2430 c_fix = format; 2431 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n"; 2432 2433 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)"; 2434}; 2435 2436 2437/* 2438 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant 2439 */ 2440fix = { 2441 hackname = huge_vall_hex; 2442 files = bits/huge_val.h; 2443 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*"; 2444 bypass = "__builtin_huge_vall"; 2445 2446 c_fix = format; 2447 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n"; 2448 2449 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)"; 2450}; 2451 2452 2453/* 2454 * Fix return type of abort and free 2455 */ 2456fix = { 2457 hackname = int_abort_free_and_exit; 2458 files = stdlib.h; 2459 select = "int[ \t]+(abort|free|exit)[ \t]*\\("; 2460 bypass = "_CLASSIC_ANSI_TYPES"; 2461 2462 c_fix = format; 2463 c_fix_arg = "void\t%1("; 2464 2465 test_text = "extern int abort(int);\n" 2466 "extern int free(void*);\n" 2467 "extern int exit(void*);"; 2468}; 2469 2470 2471/* 2472 * Fix various macros used to define ioctl numbers. 2473 * The traditional syntax was: 2474 * 2475 * #define _IO(n, x) (('n'<<8)+x) 2476 * #define TIOCFOO _IO(T, 1) 2477 * 2478 * but this does not work with the C standard, which disallows macro 2479 * expansion inside strings. We have to rewrite it thus: 2480 * 2481 * #define _IO(n, x) ((n<<8)+x) 2482 * #define TIOCFOO _IO('T', 1) 2483 * 2484 * The select expressions match too much, but the c_fix code is cautious. 2485 * 2486 * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes. 2487 */ 2488fix = { 2489 hackname = io_quotes_def; 2490 select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]"; 2491 c_fix = char_macro_def; 2492 c_fix_arg = "IO"; 2493 test_text = 2494 "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n" 2495 "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n" 2496 "#define _IO(x,y) ('x'<<8|y)"; 2497 test_text = 2498 "#define XX_IO(x) ('x'<<8|256)"; 2499}; 2500 2501/* 2502 * Fix the usage of the ioctl macro numbers. 2503 */ 2504fix = { 2505 hackname = io_quotes_use; 2506 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*" 2507 "\\( *[^,']"; 2508 c_fix = char_macro_use; 2509 c_fix_arg = "IO"; 2510 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n" 2511 "#define TIOCFOO \\\\\n" 2512 "BSD43__IOWR(T, 1) /* Some are multi-line */"; 2513}; 2514 2515 2516/* 2517 * Check for missing ';' in struct 2518 */ 2519fix = { 2520 hackname = ip_missing_semi; 2521 files = netinet/ip.h; 2522 select = "}$"; 2523 sed = "/^struct/,/^};/s/}$/};/"; 2524 test_text= 2525 "struct mumble {\n" 2526 " union {\n" 2527 " int x;\n" 2528 " }\n" 2529 "}; /* mumbled struct */\n"; 2530}; 2531 2532 2533/* 2534 * Non-traditional "const" declaration in Irix's limits.h. 2535 */ 2536fix = { 2537 hackname = irix_limits_const; 2538 files = fixinc-test-limits.h, limits.h; 2539 select = "^extern const "; 2540 c_fix = format; 2541 c_fix_arg = "extern __const "; 2542 test_text = "extern const char limit; /* test limits */"; 2543}; 2544 2545 2546/* 2547 * IRIX 5.x's stdio.h declares some functions that take a va_list as 2548 * taking char *. However, GCC uses void * for va_list, so 2549 * calling vfprintf with a va_list fails in C++. */ 2550fix = { 2551 hackname = irix_stdio_va_list; 2552 files = stdio.h; 2553 2554 select = '/\* va_list \*/ char \*'; 2555 c_fix = format; 2556 c_fix_arg = "__gnuc_va_list"; 2557 test_text = 2558 "extern int printf( const char *, /* va_list */ char * );"; 2559}; 2560 2561 2562/* 2563 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 2564 * use / * * / to concatenate tokens. 2565 */ 2566fix = { 2567 hackname = kandr_concat; 2568 files = "sparc/asm_linkage.h"; 2569 files = "sun*/asm_linkage.h"; 2570 files = "arm/as_support.h"; 2571 files = "arm/mc_type.h"; 2572 files = "arm/xcb.h"; 2573 files = "dev/chardefmac.h"; 2574 files = "dev/ps_irq.h"; 2575 files = "dev/screen.h"; 2576 files = "dev/scsi.h"; 2577 files = "sys/tty.h"; 2578 files = "Xm.acorn/XmP.h"; 2579 files = bsd43/bsd43_.h; 2580 select = '/\*\*/'; 2581 c_fix = format; 2582 c_fix_arg = '##'; 2583 test_text = "#define __CONCAT__(a,b) a/**/b"; 2584}; 2585 2586 2587/* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines 2588 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time 2589 * constant on recent versions of g++. 2590 */ 2591fix = { 2592 hackname = linux_ia64_ucontext; 2593 files = "sys/ucontext.h"; 2594 mach = "ia64-*-linux*"; 2595 select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)' 2596 '->sc_gr\[0\]\) - \(char \*\) 0\)'; 2597 c_fix = format; 2598 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)"; 2599 test_text = "# define _SC_GR0_OFFSET\t\\\\\n" 2600 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n"; 2601}; 2602 2603 2604/* 2605 * Remove header file warning from sys/time.h. Autoconf's 2606 * AC_HEADER_TIME recommends to include both sys/time.h and time.h 2607 * which causes warning on LynxOS. Remove the warning. 2608 */ 2609fix = { 2610 hackname = lynxos_no_warning_in_sys_time_h; 2611 files = sys/time.h; 2612 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>"; 2613 c_fix = format; 2614 c_fix_arg = ""; 2615 test_text = "#warning Using <time.h> instead of <sys/time.h>"; 2616}; 2617 2618 2619/* 2620 * Add missing declaration for putenv. 2621 */ 2622fix = { 2623 hackname = lynxos_missing_putenv; 2624 mach = '*-*-lynxos*'; 2625 files = stdlib.h; 2626 bypass = 'putenv[ \t]*\\('; 2627 select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; 2628 c_fix = format; 2629 c_fix_arg = "%0\n" 2630 "extern int putenv _AP((char *));"; 2631 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; 2632 test_text = "extern char *getenv _AP((const char *));"; 2633}; 2634 2635 2636/* 2637 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_. 2638 * 2639 * On NetBSD, machine is a symbolic link to an architecture specific 2640 * directory name, so we can't match a specific file name here. 2641 */ 2642fix = { 2643 hackname = machine_ansi_h_va_list; 2644 select = "define[ \t]+_BSD_VA_LIST_[ \t]"; 2645 bypass = '__builtin_va_list'; 2646 2647 c_fix = format; 2648 c_fix_arg = "%1__builtin_va_list"; 2649 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*"; 2650 2651 test_text = " # define _BSD_VA_LIST_\tchar**"; 2652}; 2653 2654 2655/* 2656 * Fix non-ansi machine name defines 2657 */ 2658fix = { 2659 hackname = machine_name; 2660 c_test = machine_name; 2661 c_fix = machine_name; 2662 2663 test_text = "/* MACH_DIFF: */\n" 2664 "#if defined( i386 ) || defined( sparc ) || defined( vax )" 2665 "\n/* no uniform test, so be careful :-) */"; 2666}; 2667 2668 2669/* 2670 * Some math.h files define struct exception (it's in the System V 2671 * Interface Definition), which conflicts with the class exception defined 2672 * in the C++ file std/stdexcept.h. We redefine it to __math_exception. 2673 * This is not a great fix, but I haven't been able to think of anything 2674 * better. 2675 */ 2676fix = { 2677 hackname = math_exception; 2678 files = math.h; 2679 select = "struct exception"; 2680 /* 2681 * This should be bypassed on __cplusplus, but some supposedly C++ 2682 * aware headers, such as Solaris 8 and 9, don't wrap their struct 2683 * exception either. So currently we bypass only for glibc, based on a 2684 * comment in the fixed glibc header. Ick. 2685 */ 2686 bypass = 'We have a problem when using C\+\+|for C\+\+, ' 2687 '_[a-z0-9A-Z_]+_exception; for C, exception'; 2688 c_fix = wrap; 2689 2690 c_fix_arg = "#ifdef __cplusplus\n" 2691 "#define exception __math_exception\n" 2692 "#endif\n"; 2693 2694 c_fix_arg = "#ifdef __cplusplus\n" 2695 "#undef exception\n" 2696 "#endif\n"; 2697 2698 test_text = "typedef struct exception t_math_exception;"; 2699}; 2700 2701 2702/* 2703 * This looks pretty broken to me. ``dbl_max_def'' will contain 2704 * "define DBL_MAX " at the start, when what we really want is just 2705 * the value portion. Can't figure out how to write a test case 2706 * for this either :-( 2707 */ 2708fix = { 2709 hackname = math_huge_val_from_dbl_max; 2710 files = math.h; 2711 2712 /* 2713 * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined 2714 * in math.h, this fix applies. 2715 */ 2716 select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX"; 2717 bypass = "define[ \t]+DBL_MAX"; 2718 2719 shell = 2720 /* 2721 * See if we have a definition for DBL_MAX in float.h. 2722 * If we do, we will replace the one in math.h with that one. 2723 */ 2724 2725 "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " 2726 "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n" 2727 2728 "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n" 2729 "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/" 2730 "s@DBL_MAX@'\"$dbl_max_def@\"\n" 2731 "\telse cat\n" 2732 "\tfi"; 2733 2734 test_text = 2735 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n" 2736 "#define HUGE_VAL DBL_MAX"; 2737}; 2738 2739 2740/* 2741 * nested comment 2742 */ 2743fix = { 2744 hackname = nested_auth_des; 2745 files = rpc/rpc.h; 2746 select = '(/\*.*rpc/auth_des\.h>.*)/\*'; 2747 c_fix = format; 2748 c_fix_arg = "%1*/ /*"; 2749 test_text = "/*#include <rpc/auth_des.h> /* skip this */"; 2750}; 2751 2752 2753/* 2754 * Some versions of NetBSD don't expect the C99 inline semantics. 2755 */ 2756fix = { 2757 hackname = netbsd_c99_inline_1; 2758 mach = "*-*-netbsd*"; 2759 files = signal.h; 2760 select = "extern __inline int"; 2761 2762 c_fix = format; 2763 c_fix_arg = "extern\n" 2764 "#ifdef __GNUC_STDC_INLINE__\n" 2765 "__attribute__((__gnu_inline__))\n" 2766 "#endif\n" 2767 "__inline int"; 2768 2769 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}"; 2770}; 2771 2772 2773fix = { 2774 hackname = netbsd_c99_inline_2; 2775 mach = "*-*-netbsd*"; 2776 files = signal.h; 2777 select = "#define _SIGINLINE extern __inline"; 2778 2779 c_fix = format; 2780 c_fix_arg = <<- _EOArg_ 2781 #ifdef __GNUC_STDC_INLINE__ 2782 #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline 2783 #else 2784 %0 2785 #endif 2786 _EOArg_; 2787 2788 test_text = "#define _SIGINLINE extern __inline"; 2789}; 2790 2791 2792/* 2793 * NetBSD has a semicolon after the ending '}' for some extern "C". 2794 */ 2795fix = { 2796 hackname = netbsd_extra_semicolon; 2797 mach = "*-*-netbsd*"; 2798 files = sys/cdefs.h; 2799 select = "#define[ \t]*__END_DECLS[ \t]*};"; 2800 2801 c_fix = format; 2802 c_fix_arg = "#define __END_DECLS }"; 2803 2804 test_text = "#define __END_DECLS };"; 2805}; 2806 2807 2808/* newlib's stdint.h has several failures to conform to C99. The fix 2809 for these removed a comment that can be matched to identify unfixed 2810 versions. */ 2811fix = { 2812 hackname = newlib_stdint_1; 2813 files = stdint-newlib.h, stdint.h; 2814 select = "@todo - Add support for wint_t types"; 2815 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@"; 2816 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@"; 2817 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@"; 2818 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@"; 2819 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@"; 2820 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@"; 2821 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@'; 2822 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@'; 2823 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@'; 2824 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@"; 2825 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; 2826 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@"; 2827 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@"; 2828 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@"; 2829 test_text = "/* @todo - Add support for wint_t types. */\n" 2830 "#define INT32_MIN (-2147483647-1)\n" 2831 "#define INT32_MAX 2147483647\n" 2832 "#define UINT32_MAX 4294967295U\n" 2833 "#define INT_LEAST32_MIN (-2147483647-1)\n" 2834 "#define INT_LEAST32_MAX 2147483647\n" 2835 "#define UINT_LEAST32_MAX 4294967295U\n" 2836 "#define INT_FAST8_MIN INT8_MIN\n" 2837 "#define INT_FAST8_MAX INT8_MAX\n" 2838 "#define UINT_FAST8_MAX UINT8_MAX\n" 2839 "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n" 2840 "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n" 2841 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n" 2842 "#define UINT8_C(x) x##U\n" 2843 "#define UINT16_C(x) x##U"; 2844}; 2845 2846 2847fix = { 2848 hackname = newlib_stdint_2; 2849 files = stdint-newlib.h, stdint.h; 2850 select = "@todo - Add support for wint_t types"; 2851 c_fix = format; 2852 c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n" 2853 "#define INTMAX_MIN (-INTMAX_MAX - 1)\n" 2854 "#define UINTMAX_MAX __UINTMAX_MAX__\n" 2855 "#define WCHAR_MAX __WCHAR_MAX__\n" 2856 "#define WCHAR_MIN __WCHAR_MIN__\n" 2857 "#define WINT_MAX __WINT_MAX__\n" 2858 "#define WINT_MIN __WINT_MIN__\n\n" 2859 "%0"; 2860 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/'; 2861 test_text = "/* @todo - Add support for wint_t types. */\n" 2862 "/** Macros for minimum-width integer constant expressions */"; 2863}; 2864 2865 2866/* 2867 * NeXT 3.2 adds const prefix to some math functions. 2868 * These conflict with the built-in functions. 2869 */ 2870fix = { 2871 hackname = next_math_prefix; 2872 files = ansi/math.h; 2873 select = "^extern[ \t]+double[ \t]+__const__[ \t]"; 2874 2875 c_fix = format; 2876 c_fix_arg = "extern double %1("; 2877 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\("; 2878 2879 test_text = "extern\tdouble\t__const__\tmumble();"; 2880}; 2881 2882 2883/* 2884 * NeXT 3.2 uses the word "template" as a parameter for some 2885 * functions. GCC reports an invalid use of a reserved key word 2886 * with the built-in functions. 2887 */ 2888fix = { 2889 hackname = next_template; 2890 files = bsd/libc.h; 2891 select = "[ \t]template\\)"; 2892 2893 c_fix = format; 2894 c_fix_arg = "(%1)"; 2895 c_fix_arg = "\\(([^)]*)[ \t]template\\)"; 2896 test_text = "extern mumble( char * template); /* fix */"; 2897}; 2898 2899 2900/* 2901 * NeXT 3.2 includes the keyword volatile in the abort() and exit() 2902 * function prototypes. That conflicts with the built-in functions. 2903 */ 2904fix = { 2905 hackname = next_volitile; 2906 files = ansi/stdlib.h; 2907 select = "^extern[ \t]+volatile[ \t]+void[ \t]"; 2908 2909 c_fix = format; 2910 c_fix_arg = "extern void %1("; 2911 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\("; 2912 2913 test_text = "extern\tvolatile\tvoid\tabort();"; 2914}; 2915 2916 2917/* 2918 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. 2919 * Note that version 3 of the NeXT system has wait.h in a different directory, 2920 * so that this code won't do anything. But wait.h in version 3 has a 2921 * conditional, so it doesn't need this fix. So everything is okay. 2922 */ 2923fix = { 2924 hackname = next_wait_union; 2925 files = sys/wait.h; 2926 2927 select = 'wait\(union wait'; 2928 c_fix = format; 2929 c_fix_arg = "wait(void"; 2930 test_text = "extern pid_d wait(union wait*);"; 2931}; 2932 2933 2934/* 2935 * a missing semi-colon at the end of the nodeent structure definition. 2936 */ 2937fix = { 2938 hackname = nodeent_syntax; 2939 files = netdnet/dnetdb.h; 2940 select = "char[ \t]*\\*na_addr[ \t]*$"; 2941 c_fix = format; 2942 c_fix_arg = "%0;"; 2943 test_text = "char *na_addr\t"; 2944}; 2945 2946/* 2947 * Fix OpenBSD's NULL definition. 2948 */ 2949fix = { 2950 hackname = openbsd_null_definition; 2951 mach = "*-*-openbsd*"; 2952 files = locale.h, stddef.h, stdio.h, string.h, 2953 time.h, unistd.h, wchar.h, sys/param.h; 2954 select = "__GNUG__"; 2955 c_fix = format; 2956 c_fix_arg = "#ifndef NULL\n" 2957 "#ifdef __cplusplus\n" 2958 "#ifdef __GNUG__\n" 2959 "#define NULL\t__null\n" 2960 "#else\t /* ! __GNUG__ */\n" 2961 "#define NULL\t0L\n" 2962 "#endif\t /* __GNUG__ */\n" 2963 "#else\t /* ! __cplusplus */\n" 2964 "#define NULL\t((void *)0)\n" 2965 "#endif\t /* __cplusplus */\n" 2966 "#endif\t /* !NULL */"; 2967 2968 c_fix_arg = "^#ifndef[ \t]*NULL\n" 2969 "^#ifdef[ \t]*__GNUG__\n" 2970 "^#define[ \t]*NULL[ \t]*__null\n" 2971 "^#else\n" 2972 "^#define[ \t]*NULL[ \t]*0L\n" 2973 "^#endif\n" 2974 "^#endif"; 2975 test_text = 2976 "#ifndef NULL\n" 2977 "#ifdef __GNUG__\n" 2978 "#define NULL __null\n" 2979 "#else\n" 2980 "#define NULL 0L\n" 2981 "#endif\n" 2982 "#endif\n"; 2983}; 2984 2985/* 2986 * obstack.h used casts as lvalues. 2987 * 2988 * We need to change postincrements of casted pointers (which are 2989 * then dereferenced and assigned into) of the form 2990 * 2991 * *((TYPE*)PTRVAR)++ = (VALUE) 2992 * 2993 * into expressions like 2994 * 2995 * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE))) 2996 * 2997 * which is correct for the cases used in obstack.h since PTRVAR is 2998 * of type char * and the value of the expression is not used. 2999 */ 3000fix = { 3001 hackname = obstack_lvalue_cast; 3002 files = obstack.h; 3003 select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)'; 3004 c_fix = format; 3005 c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))"; 3006 test_text = "*((void **) (h)->next_free)++ = (aptr)"; 3007}; 3008 3009/* 3010 * Fix OpenBSD's va_start define. 3011 */ 3012fix = { 3013 hackname = openbsd_va_start; 3014 mach = "*-*-openbsd*"; 3015 files = stdarg.h; 3016 select = '__builtin_stdarg_start'; 3017 c_fix = format; 3018 c_fix_arg = __builtin_va_start; 3019 3020 test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)"; 3021}; 3022 3023/* 3024 * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by 3025 * defining regex.h related types. This causes libg++ build and usage 3026 * failures. Fixing this correctly requires checking and modifying 3 files. 3027 */ 3028fix = { 3029 hackname = osf_namespace_a; 3030 files = reg_types.h; 3031 files = sys/lc_core.h; 3032 test = " -r reg_types.h"; 3033 test = " -r sys/lc_core.h"; 3034 test = " -n \"`grep '} regex_t;' reg_types.h`\""; 3035 test = " -z \"`grep __regex_t regex.h`\""; 3036 3037 c_fix = format; 3038 c_fix_arg = "__%0"; 3039 c_fix_arg = "reg(ex|off|match)_t"; 3040 3041 test_text = "`touch sys/lc_core.h`" 3042 "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n" 3043 "extern regex_t re;\n" 3044 "extern regoff_t ro;\n" 3045 "extern regmatch_t rm;\n"; 3046}; 3047 3048fix = { 3049 hackname = osf_namespace_c; 3050 files = regex.h; 3051 test = " -r reg_types.h"; 3052 test = " -r sys/lc_core.h"; 3053 test = " -n \"`grep '} regex_t;' reg_types.h`\""; 3054 test = " -z \"`grep __regex_t regex.h`\""; 3055 3056 select = "#include <reg_types\.h>.*"; 3057 c_fix = format; 3058 c_fix_arg = "%0\n" 3059 "typedef __regex_t\tregex_t;\n" 3060 "typedef __regoff_t\tregoff_t;\n" 3061 "typedef __regmatch_t\tregmatch_t;"; 3062 3063 test_text = "#include <reg_types.h>"; 3064}; 3065 3066 3067/* 3068 * On broken glibc-2.3.3 systems an array of incomplete structures is 3069 * passed to __sigsetjmp. Fix that to take a pointer instead. 3070 */ 3071fix = { 3072 hackname = pthread_incomplete_struct_argument; 3073 files = pthread.h; 3074 select = "struct __jmp_buf_tag"; 3075 c_fix = format; 3076 c_fix_arg = "%1 *%2%3"; 3077 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$"; 3078 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);"; 3079}; 3080 3081/* 3082 * Fix return type of fread and fwrite on sysV68 3083 */ 3084fix = { 3085 hackname = read_ret_type; 3086 files = stdio.h; 3087 select = "extern int\t.*, fread\\(\\), fwrite\\(\\)"; 3088 c_fix = format; 3089 c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2"; 3090 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)"; 3091 3092 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();"; 3093}; 3094 3095 3096/* 3097 * Fix casts as lvalues in glibc's <rpc/xdr.h>. 3098 */ 3099fix = { 3100 hackname = rpc_xdr_lvalue_cast_a; 3101 files = rpc/xdr.h; 3102 select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*"; 3103 c_fix = format; 3104 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))"; 3105 test_text = "#define IXDR_GET_LONG(buf) \\\\\n" 3106 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))"; 3107}; 3108 3109 3110fix = { 3111 hackname = rpc_xdr_lvalue_cast_b; 3112 files = rpc/xdr.h; 3113 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*"; 3114 c_fix = format; 3115 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))"; 3116 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n" 3117 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))"; 3118}; 3119 3120 3121/* 3122 * function class(double x) conflicts with C++ keyword on rs/6000 3123 */ 3124fix = { 3125 hackname = rs6000_double; 3126 files = math.h; 3127 select = '[^a-zA-Z_]class\('; 3128 3129 c_fix = format; 3130 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 3131 c_fix_arg = '^.*[^a-zA-Z_]class\(.*'; 3132 3133 test_text = "extern int class();"; 3134}; 3135 3136 3137/* 3138 * Wrong fchmod prototype on RS/6000. 3139 */ 3140fix = { 3141 hackname = rs6000_fchmod; 3142 files = sys/stat.h; 3143 select = 'fchmod\(char \*'; 3144 c_fix = format; 3145 c_fix_arg = "fchmod(int"; 3146 test_text = "extern int fchmod(char *, mode_t);"; 3147}; 3148 3149 3150/* 3151 * parameters conflict with C++ new on rs/6000 3152 */ 3153fix = { 3154 hackname = rs6000_param; 3155 files = "stdio.h"; 3156 files = "unistd.h"; 3157 3158 select = 'rename\(const char \*old, const char \*new\)'; 3159 c_fix = format; 3160 c_fix_arg = 'rename(const char *_old, const char *_new)'; 3161 3162 test_text = 'extern int rename(const char *old, const char *new);'; 3163}; 3164 3165 3166/* 3167 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict 3168 * for C99. This is wrong for C++, which needs many C99 features, but 3169 * only supports __restrict. 3170 */ 3171fix = { 3172 hackname = solaris___restrict; 3173 files = sys/feature_tests.h; 3174 select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict"; 3175 mach = "*-*-solaris2*"; 3176 c_fix = format; 3177 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n" 3178 "#else\n%0\n#endif"; 3179 test_text = "#define _RESTRICT_KYWD restrict"; 3180}; 3181 3182 3183/* 3184 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of 3185 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I 3186 * and imaginary definitions which are not supported by GCC. 3187 */ 3188fix = { 3189 hackname = solaris_complex; 3190 mach = "*-*-solaris2.*"; 3191 files = complex.h; 3192 select = "#define[ \t]_Complex_I[ \t]_Complex_I"; 3193 sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/" 3194 "#define\t_Complex_I\t(__extension__ 1.0iF)/"; 3195 sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d"; 3196 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d"; 3197 sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/"; 3198 test_text = "#define _Complex_I _Complex_I\n" 3199 "#define complex _Complex\n" 3200 "#define _Imaginary_I _Imaginary_I\n" 3201 "#define imaginary _Imaginary\n" 3202 "#undef I\n" 3203 "#define I _Imaginary_I"; 3204}; 3205 3206 3207/* 3208 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in 3209 * extern "C" instead so libstdc++ can use it. 3210 */ 3211fix = { 3212 hackname = solaris_complex_cxx; 3213 mach = "*-*-solaris2.*"; 3214 files = complex.h; 3215 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n" 3216 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif"; 3217 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n" 3218 "#ifdef\t__cplusplus\\\n}\\\n#endif"; 3219 test_text = "#if !defined(__cplusplus)\n" 3220 "#endif /* !defined(__cplusplus) */"; 3221}; 3222 3223 3224/* 3225 * g++ rejects functions declared with both C and C++ linkage. 3226 */ 3227fix = { 3228 hackname = solaris_cxx_linkage; 3229 mach = '*-*-solaris2*'; 3230 files = "iso/stdlib_iso.h"; 3231 select = "(#if __cplusplus >= 199711L)\n" 3232 "(extern \"C\\+\\+\" \\{\n)" 3233 "(.*(bsearch|qsort).*)"; 3234 c_fix = format; 3235 c_fix_arg = "%1 && !__GNUG__\n%2%3"; 3236 3237 test_text = 3238 "#if __cplusplus >= 199711L\n" 3239 "extern \"C++\" {\n" 3240 " void *bsearch(const void *, const void *, size_t, size_t,"; 3241}; 3242 3243 3244/* 3245 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with 3246 * _STRICT_STDC, but uses it. 3247 */ 3248fix = { 3249 hackname = solaris_getc_strict_stdc; 3250 mach = "*-*-solaris2*"; 3251 files = "iso/stdio_iso.h"; 3252 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)"; 3253 c_fix = format; 3254 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2"; 3255 3256 test_text = 3257 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)"; 3258}; 3259 3260 3261/* 3262 * Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn. 3263 */ 3264fix = { 3265 hackname = solaris_longjmp_noreturn; 3266 mach = "*-*-solaris2*"; 3267 files = "iso/setjmp_iso.h"; 3268 bypass = "__NORETURN"; 3269 select = "(.*longjmp\\(jmp_buf.*[^)]+\\));"; 3270 c_fix = format; 3271 c_fix_arg = "%1 __attribute__ ((__noreturn__));"; 3272 3273 test_text = "extern void longjmp(jmp_buf, int);"; 3274}; 3275 3276 3277/* 3278 * Sun Solaris 10 defines several C99 math macros in terms of 3279 * builtins specific to the Studio compiler, in particular not 3280 * compatible with the GNU compiler. 3281 */ 3282fix = { 3283 hackname = solaris_math_1; 3284 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3285 bypass = "__GNUC__"; 3286 files = iso/math_c99.h; 3287 c_fix = format; 3288 c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())"; 3289 c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)"; 3290 test_text = 3291 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3292 "#undef HUGE_VAL\n" 3293 "#define HUGE_VAL __builtin_huge_val\n" 3294 "#undef HUGE_VALF\n" 3295 "#define HUGE_VALF __builtin_huge_valf\n" 3296 "#undef HUGE_VALL\n" 3297 "#define HUGE_VALL __builtin_huge_vall"; 3298}; 3299 3300fix = { 3301 hackname = solaris_math_2; 3302 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3303 bypass = "__GNUC__"; 3304 files = iso/math_c99.h; 3305 c_fix = format; 3306 c_fix_arg = "#define\tINFINITY\t(__builtin_inff())"; 3307 c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity"; 3308 test_text = 3309 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3310 "#undef INFINITY\n" 3311 "#define INFINITY __builtin_infinity"; 3312}; 3313 3314fix = { 3315 hackname = solaris_math_3; 3316 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3317 bypass = "__GNUC__"; 3318 files = iso/math_c99.h; 3319 c_fix = format; 3320 c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))"; 3321 c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan"; 3322 test_text = 3323 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3324 "#undef NAN\n" 3325 "#define NAN __builtin_nan"; 3326}; 3327 3328fix = { 3329 hackname = solaris_math_4; 3330 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3331 bypass = "__GNUC__"; 3332 files = iso/math_c99.h; 3333 c_fix = format; 3334 c_fix_arg = "#define\tfpclassify(x) \\\n" 3335 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))"; 3336 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)"; 3337 test_text = 3338 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3339 "#undef fpclassify\n" 3340 "#define fpclassify(x) __builtin_fpclassify(x)"; 3341}; 3342 3343fix = { 3344 hackname = solaris_math_8; 3345 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI"; 3346 bypass = "__GNUC__"; 3347 files = iso/math_c99.h; 3348 c_fix = format; 3349 c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n" 3350 "\t\t\t ? __builtin_signbitf(x) \\\n" 3351 "\t\t\t : sizeof(x) == sizeof(long double) \\\n" 3352 "\t\t\t ? __builtin_signbitl(x) \\\n" 3353 "\t\t\t : __builtin_signbit(x))"; 3354 c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)"; 3355 test_text = <<- _EOText_ 3356 #ident "@(#)math_c99.h 1.9 04/11/01 SMI" 3357 #undef signbit 3358 #define signbit(x) __builtin_signbit(x) 3359 _EOText_; 3360}; 3361 3362fix = { 3363 hackname = solaris_math_9; 3364 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3365 bypass = "__GNUC__"; 3366 files = iso/math_c99.h; 3367 c_fix = format; 3368 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)"; 3369 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)"; 3370 test_text = 3371 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3372 "#undef isgreater\n" 3373 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n" 3374 "#undef isgreaterequal\n" 3375 "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n" 3376 "#undef isless\n" 3377 "#define isless(x, y) ((x) __builtin_isless(y))\n" 3378 "#undef islessequal\n" 3379 "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n" 3380 "#undef islessgreater\n" 3381 "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n" 3382 "#undef isunordered\n" 3383 "#define isunordered(x, y) ((x) __builtin_isunordered(y))"; 3384}; 3385 3386/* 3387 * On Solaris 11, if you do isinf(NaN) you'll get a floating point 3388 * exception. Provide an alternative using GCC's builtin. 3389 */ 3390 3391fix = { 3392 hackname = solaris_math_10; 3393 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3394 files = iso/math_c99.h; 3395 c_fix = format; 3396 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)"; 3397 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n" 3398 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n" 3399 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n" 3400 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)"; 3401 test_text = 3402 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n" 3403 "#undef isinf\n" 3404 "#define isinf(x) __extension__( \\\\\n" 3405 " { __typeof(x) __x_i = (x); \\\\\n" 3406 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n" 3407 " __x_i == (__typeof(__x_i)) (-INFINITY); })"; 3408}; 3409 3410/* 3411 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing 3412 * "0" for the last field of the pthread_mutex_t structure, which is 3413 * of type upad64_t, which itself is typedef'd to int64_t, but with 3414 * __STDC__ defined (e.g. by -ansi) it is a union. So change the 3415 * initializer to "{0}" instead 3416 */ 3417fix = { 3418 hackname = solaris_mutex_init_2; 3419 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3420 files = pthread.h; 3421 /* 3422 * On Solaris 10, this fix is unnecessary because upad64_t is 3423 * always defined correctly regardless of the definition of the 3424 * __STDC__ macro. The first "mach" pattern matches up to 3425 * solaris9. The second "mach" pattern will not match any two (or 3426 * more) digit solaris version, but it will match e.g. 2.5.1. 3427 */ 3428 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; 3429 c_fix = format; 3430 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 3431 "%0\n" 3432 "#else\n" 3433 "%1, {0}}%4\n" 3434 "#endif"; 3435 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+" 3436 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)" 3437 ",[ \t]*0\\}" "(|[ \t].*)$"; 3438 test_text = 3439 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 3440 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n" 3441 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n" 3442 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n" 3443 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n" 3444 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n" 3445 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}"; 3446}; 3447 3448 3449/* 3450 * The pow overloads with int were removed in C++ 2011 DR 550. 3451 */ 3452fix = { 3453 hackname = solaris_pow_int_overload; 3454 mach = '*-*-solaris2*'; 3455 files = "iso/math_iso.h"; 3456 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)" 3457 " *\\{[^{}]*\n[^{}]*\\}"; 3458 c_fix = format; 3459 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif"; 3460 3461 test_text = 3462 " inline long double pow(long double __X, int __Y) { return\n" 3463 " __powl(__X, (long double) (__Y)); }"; 3464}; 3465 3466 3467/* 3468 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some 3469 * fields of the pthread_rwlock_t structure, which are of type 3470 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ 3471 * defined (e.g. by -ansi) it is a union. So change the initializer 3472 * to "{0}" instead. 3473 */ 3474fix = { 3475 hackname = solaris_rwlock_init_1; 3476 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3477 files = pthread.h; 3478 mach = '*-*-solaris*'; 3479 c_fix = format; 3480 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 3481 "%0\n" 3482 "#else\n" 3483 "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n" 3484 "#endif"; 3485 c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)" 3486 "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$"; 3487 3488 test_text = 3489 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 3490 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}"; 3491}; 3492 3493 3494/* 3495 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a 3496 * structure. As such, it need two levels of brackets, but only 3497 * contains one. Wrap the macro definition in an extra layer. 3498 */ 3499fix = { 3500 hackname = solaris_once_init_1; 3501 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3502 files = pthread.h; 3503 mach = '*-*-solaris*'; 3504 c_fix = format; 3505 c_fix_arg = "%1{%2}%3"; 3506 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$"; 3507 test_text = 3508 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n" 3509 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}"; 3510}; 3511 3512 3513/* 3514 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some 3515 * fields of the pthread_once_t structure, which are of type 3516 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ 3517 * defined (e.g. by -ansi) it is a union. So change the initializer 3518 * to "{0}" instead. This test relies on solaris_once_init_1. 3519 */ 3520fix = { 3521 hackname = solaris_once_init_2; 3522 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3523 files = pthread.h; 3524 /* 3525 * On Solaris 10, this fix is unnecessary because upad64_t is 3526 * always defined correctly regardless of the definition of the 3527 * __STDC__ macro. The first "mach" pattern matches up to 3528 * solaris9. The second "mach" pattern will not match any two (or 3529 * more) digit solaris version, but it will match e.g. 2.5.1. 3530 */ 3531 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*'; 3532 c_fix = format; 3533 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 3534 "%0\n" 3535 "#else\n" 3536 "%1{0}, {0}, {0}, {%3}%4\n" 3537 "#endif"; 3538 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)" 3539 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$"; 3540 test_text = 3541 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 3542 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n"; 3543}; 3544 3545 3546/* 3547 * Sun Solaris 2 has a version of sys/int_const.h that defines 3548 * UINT8_C and UINT16_C to unsigned constants. 3549 */ 3550fix = { 3551 hackname = solaris_int_const; 3552 files = sys/int_const.h; 3553 mach = '*-*-solaris2*'; 3554 c_fix = format; 3555 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n" 3556 "%1\n" 3557 "#define\tUINT16_C(c)\t(c)"; 3558 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n" 3559 "(/\*.*\*/)\n" 3560 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*"; 3561 test_text = 3562 "#define UINT8_C(c) __CONCAT__(c,u)\n" 3563 "/* CSTYLED */\n" 3564 "#define UINT16_C(c) __CONCAT__(c,u)"; 3565}; 3566 3567 3568/* 3569 * Sun Solaris 2 has a version of sys/int_limits.h that defines 3570 * UINT8_MAX and UINT16_MAX to unsigned constants. 3571 */ 3572fix = { 3573 hackname = solaris_int_limits_1; 3574 files = sys/int_limits.h; 3575 mach = '*-*-solaris2*'; 3576 c_fix = format; 3577 c_fix_arg = "#define\tUINT8_MAX\t(255)\n" 3578 "#define\tUINT16_MAX\t(65535)"; 3579 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n" 3580 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)"; 3581 test_text = 3582 "#define UINT8_MAX (255U)\n" 3583 "#define UINT16_MAX (65535U)"; 3584}; 3585 3586 3587/* 3588 * Sun Solaris 2 has a version of sys/int_limits.h that defines 3589 * INT_FAST16 limits to wrong values for sys/int_types.h. 3590 */ 3591fix = { 3592 hackname = solaris_int_limits_2; 3593 files = sys/int_limits.h; 3594 mach = '*-*-solaris2*'; 3595 c_fix = format; 3596 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2"; 3597 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*"; 3598 test_text = 3599 "#define INT_FAST16_MAX INT16_MAX\n" 3600 "#define UINT_FAST16_MAX UINT16_MAX\n" 3601 "#define INT_FAST16_MIN INT16_MIN"; 3602}; 3603 3604 3605/* 3606 * Sun Solaris 2 has a version of sys/int_limits.h that defines 3607 * SIZE_MAX as unsigned long. 3608 */ 3609fix = { 3610 hackname = solaris_int_limits_3; 3611 files = sys/int_limits.h; 3612 mach = '*-*-solaris2*'; 3613 c_fix = format; 3614 c_fix_arg = "#define\tSIZE_MAX\t4294967295U"; 3615 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL"; 3616 test_text = 3617 "#define SIZE_MAX 4294967295UL"; 3618}; 3619 3620 3621/* 3622 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use 3623 * of Standard C99 64-bit types in 32-bit mode. 3624 */ 3625fix = { 3626 hackname = solaris_int_types; 3627 select = "__STDC__ - 0 == 0"; 3628 bypass = "_LONGLONG_TYPE"; 3629 files = sys/int_types.h; 3630 c_fix = format; 3631 c_fix_arg = 3632 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))"; 3633 test_text = 3634 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 3635 "typedef long long int64_t;\n" 3636 "#endif\n\n" 3637 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n" 3638 "typedef int64_t intmax_t;\n" 3639 "#endif"; 3640}; 3641 3642 3643/* 3644 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the 3645 * posix_spawn declarations, which doesn't work with C++. 3646 */ 3647fix = { 3648 hackname = solaris_posix_spawn_restrict; 3649 files = spawn.h; 3650 mach = '*-*-solaris2*'; 3651 c_fix = format; 3652 c_fix_arg = "%1*_RESTRICT_KYWD %2%3"; 3653 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)"; 3654 test_text = 3655 "char *const argv[_RESTRICT_KYWD],\n" 3656 "char *const envp[_RESTRICT_KYWD]);"; 3657}; 3658 3659 3660/* 3661 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and 3662 * std::__flsbuf, but <iso/stdio_iso.h> uses them. 3663 */ 3664fix = { 3665 hackname = solaris_std___filbuf; 3666 files = stdio.h; 3667 mach = '*-*-solaris2*'; 3668 bypass = "using std::__filbuf"; 3669 select = "(using std::perror;\n)(#endif)"; 3670 c_fix = format; 3671 c_fix_arg = "%1#ifndef _LP64\n" 3672 "using std::__filbuf;\n" 3673 "using std::__flsbuf;\n" 3674 "#endif\n%2"; 3675 3676 test_text = "using std::perror;\n" 3677 "#endif"; 3678}; 3679 3680 3681/* 3682 * Sun Solaris 8 has what appears to be some gross workaround for 3683 * some old version of their c++ compiler. G++ doesn't want it 3684 * either, but doesn't want to be tied to SunPRO version numbers. 3685 */ 3686fix = { 3687 hackname = solaris_stdio_tag; 3688 files = stdio_tag.h; 3689 3690 select = '__cplusplus < 54321L'; 3691 /* In Solaris 10, the code in stdio_tag.h is conditionalized on 3692 "!defined(__GNUC__)" so we no longer need to fix it. */ 3693 bypass = '__GNUC__'; 3694 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/'; 3695 3696 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)"; 3697}; 3698 3699 3700/* 3701 * On Solaris 9, __va_list needs to become a typedef for 3702 * __builtin_va_list to make -Wmissing-format-attribute work. 3703 */ 3704fix = { 3705 hackname = solaris_sys_va_list; 3706 files = sys/va_list.h; 3707 mach = '*-*-solaris2.9'; 3708 select = "#if.*__STDC__.*\n" 3709 "typedef void \\*__va_list;\n" 3710 "#else\n" 3711 "typedef char \\*__va_list;\n" 3712 "#endif"; 3713 3714 c_fix = format; 3715 c_fix_arg = "#ifdef __GNUC__\n" 3716 "typedef __builtin_va_list __va_list;\n" 3717 "#else\n" 3718 "%0\n" 3719 "#endif"; 3720 test_text = "#if defined(__STDC__) && !defined(__ia64)\n" 3721 "typedef void *__va_list;\n" 3722 "#else\n" 3723 "typedef char *__va_list;\n" 3724 "#endif"; 3725}; 3726 3727 3728/* 3729 * a missing semi-colon at the end of the statsswtch structure definition. 3730 */ 3731fix = { 3732 hackname = statsswtch; 3733 files = rpcsvc/rstat.h; 3734 select = "boottime$"; 3735 c_fix = format; 3736 c_fix_arg = "boottime;"; 3737 test_text = "struct statswtch {\n int boottime\n};"; 3738}; 3739 3740 3741/* 3742 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list. 3743 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's 3744 * OK too. 3745 */ 3746fix = { 3747 hackname = stdio_stdarg_h; 3748 files = stdio.h; 3749 bypass = "include.*(stdarg\.h|machine/ansi\.h)"; 3750 /* 3751 * On Solaris 10, this fix is unncessary; <stdio.h> includes 3752 * <iso/stdio_iso.h>, which includes <sys/va_list.h>. 3753 */ 3754 mach = '*-*-solaris2.1[0-9]*'; 3755 not_machine = true; 3756 3757 c_fix = wrap; 3758 3759 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n"; 3760 3761 test_text = ""; 3762}; 3763 3764 3765/* 3766 * Don't use or define the name va_list in stdio.h. This is for 3767 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence 3768 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to 3769 * indicate that the header knows what it's doing -- under SUSv2, 3770 * stdio.h is required to define va_list, and we shouldn't break 3771 * that. 3772 */ 3773fix = { 3774 hackname = stdio_va_list; 3775 files = stdio.h; 3776 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; 3777 /* 3778 * On Solaris 10, the definition in 3779 * <stdio.h> is guarded appropriately by the _XPG4 feature macro; 3780 * there is therefore no need for this fix there. 3781 */ 3782 mach = '*-*-solaris2.1[0-9]*'; 3783 not_machine = true; 3784 3785 /* 3786 * Use __gnuc_va_list in arg types in place of va_list. 3787 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A 3788 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the 3789 * trailing parentheses and semicolon save all other systems from this. 3790 * Define __not_va_list__ (something harmless and unused) 3791 * instead of va_list. 3792 * Don't claim to have defined va_list. 3793 */ 3794 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" 3795 "s@(va_list)&@(__gnuc_va_list)\\&@\n" 3796 "s@ _VA_LIST_));@ __gnuc_va_list));@\n" 3797 "s@ __VA_LIST__));@ __gnuc_va_list));@\n" 3798 "s@ va_list@ __not_va_list__@\n" 3799 "s@\\*va_list@*__not_va_list__@\n" 3800 "s@ __va_list)@ __gnuc_va_list)@\n" 3801 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" 3802 "@typedef \\1 __not_va_list__;@\n" 3803 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" 3804 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" 3805 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" 3806 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" 3807 "s@VA_LIST@DUMMY_VA_LIST@\n" 3808 "s@_Va_LIST@_VA_LIST@"; 3809 test_text = "extern void mumble( va_list);"; 3810}; 3811 3812 3813/* 3814 * Fix headers that use va_list from stdio.h to use the updated 3815 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is 3816 * dealt with elsewhere. The presence of __gnuc_va_list, 3817 * __DJ_va_list, or _G_va_list is taken to indicate that the header 3818 * knows what it's doing. 3819 */ 3820fix = { 3821 hackname = stdio_va_list_clients; 3822 files = com_err.h; 3823 files = cps.h; 3824 files = curses.h; 3825 files = krb5.h; 3826 files = lc_core.h; 3827 files = pfmt.h; 3828 files = wchar.h; 3829 files = curses_colr/curses.h; 3830 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; 3831 /* Don't fix, if we use va_list from stdarg.h, or if the use is 3832 otherwise protected. */ 3833 bypass = 'include <stdarg\.h>|#ifdef va_start'; 3834 3835 /* 3836 * Use __gnuc_va_list in arg types in place of va_list. 3837 * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A 3838 * use __gnuc_va_list instead of __VA_LIST__. We're hoping the 3839 * trailing parentheses and semicolon save all other systems from this. 3840 * Define __not_va_list__ (something harmless and unused) 3841 * instead of va_list. 3842 * Don't claim to have defined va_list. 3843 */ 3844 sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n" 3845 "s@(va_list)&@(__gnuc_va_list)\\&@\n" 3846 "s@ _VA_LIST_));@ __gnuc_va_list));@\n" 3847 "s@ __VA_LIST__));@ __gnuc_va_list));@\n" 3848 "s@ va_list@ __not_va_list__@\n" 3849 "s@\\*va_list@*__not_va_list__@\n" 3850 "s@ __va_list)@ __gnuc_va_list)@\n" 3851 "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" 3852 "@typedef \\1 __not_va_list__;@\n" 3853 "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" 3854 "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" 3855 "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n" 3856 "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" 3857 "s@VA_LIST@DUMMY_VA_LIST@\n" 3858 "s@_Va_LIST@_VA_LIST@"; 3859 test_text = "extern void mumble( va_list);"; 3860}; 3861 3862 3863/* 3864 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0" 3865 * is "!defined( __STRICT_ANSI__ )" 3866 */ 3867fix = { 3868 hackname = strict_ansi_not; 3869 select = "^([ \t]*#[ \t]*if.*)" 3870 "(!__STDC__" 3871 "|__STDC__[ \t]*==[ \t]*0" 3872 "|__STDC__[ \t]*!=[ \t]*1" 3873 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)"; 3874 /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */ 3875 bypass = 'GNU and MIPS C compilers define __STDC__ differently'; 3876 /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which 3877 is not defined by GCC, so it is safe. */ 3878 bypass = '__SCO_VERSION__.*__STDC__ != 1'; 3879 c_test = stdc_0_in_system_headers; 3880 3881 c_fix = format; 3882 c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; 3883 3884 test_text = "#if !__STDC__ \n" 3885 "#if __STDC__ == 0\n" 3886 "#if __STDC__ != 1\n" 3887 "#if __STDC__ - 0 == 0" 3888 "/* not std C */\nint foo;\n" 3889 "\n#end-end-end-end-if :-)"; 3890}; 3891 3892/* 3893 * "__STDC__-0==0" 3894 * is "!defined( __STRICT_ANSI__ )" on continued #if-s 3895 */ 3896fix = { 3897 hackname = strict_ansi_not_ctd; 3898 files = math.h, limits.h, stdio.h, signal.h, 3899 stdlib.h, sys/signal.h, time.h; 3900 /* 3901 * Starting at the beginning of a line, skip white space and 3902 * a leading "(" or "&&" or "||". One of those must be found. 3903 * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&" 3904 * expression. If these are nested, then they must accumulate 3905 * because we won't match any closing parentheses. Finally, 3906 * after skipping over all that, we must then match our suspect 3907 * phrase: "__STDC__-0==0" with or without white space. 3908 */ 3909 select = "^([ \t]*" '(\(|&&|\|\|)' 3910 "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*" 3911 "[ \t(]*)" 3912 "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)"; 3913 c_test = stdc_0_in_system_headers; 3914 3915 c_fix = format; 3916 c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; 3917 3918 test_text = "#if 1 && \\\\\n" 3919 "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n" 3920 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n" 3921 "|| __STDC__ - 0 == 0 ) /* not std C */\n" 3922 "int foo;\n#endif"; 3923}; 3924 3925 3926/* 3927 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1" 3928 * is "defined( __STRICT_ANSI__ )" 3929 */ 3930fix = { 3931 hackname = strict_ansi_only; 3932 select = "^([ \t]*#[ \t]*if.*)" 3933 "(__STDC__[ \t]*!=[ \t]*0" 3934 "|__STDC__[ \t]*==[ \t]*1" 3935 "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1" 3936 "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)"; 3937 c_test = stdc_0_in_system_headers; 3938 3939 c_fix = format; 3940 c_fix_arg = "%1 defined(__STRICT_ANSI__)"; 3941 3942 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif"; 3943}; 3944 3945 3946/* 3947 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s 3948 * in prototype without previous definition. 3949 */ 3950fix = { 3951 hackname = struct_file; 3952 files = rpc/xdr.h; 3953 select = '^.*xdrstdio_create.*struct __file_s'; 3954 c_fix = format; 3955 c_fix_arg = "struct __file_s;\n%0"; 3956 test_text = "extern void xdrstdio_create( struct __file_s* );"; 3957}; 3958 3959 3960/* 3961 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr 3962 * in prototype without previous definition. 3963 * 3964 * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same 3965 * function, and does define it. 3966 */ 3967fix = { 3968 hackname = struct_sockaddr; 3969 files = rpc/auth.h; 3970 select = "^.*authdes_create.*struct sockaddr[^_]"; 3971 bypass = "<sys/socket\.h>"; 3972 bypass = "struct sockaddr;\n"; 3973 c_fix = format; 3974 c_fix_arg = "struct sockaddr;\n%0"; 3975 test_text = "extern AUTH* authdes_create( struct sockaddr* );"; 3976}; 3977 3978 3979/* 3980 * Apply fix this to all OSs since this problem seems to effect 3981 * more than just SunOS. 3982 */ 3983fix = { 3984 hackname = sun_auth_proto; 3985 files = rpc/auth.h; 3986 files = rpc/clnt.h; 3987 files = rpc/svc.h; 3988 files = rpc/xdr.h; 3989 bypass = "__cplusplus"; 3990 /* 3991 * Select those files containing '(*name)()'. 3992 */ 3993 select = '\(\*[a-z][a-z_]*\)\(\)'; 3994 3995 c_fix = format; 3996 c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n" 3997 "#else\n%1();%2\n#endif"; 3998 c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)'; 3999 4000 test_text = 4001 "struct auth_t {\n" 4002 " int (*name)(); /* C++ bad */\n" 4003 "};"; 4004}; 4005 4006 4007/* 4008 * Fix bogus #ifdef on SunOS 4.1. 4009 */ 4010fix = { 4011 hackname = sun_bogus_ifdef; 4012 files = "hsfs/hsfs_spec.h"; 4013 files = "hsfs/iso_spec.h"; 4014 select = '#ifdef(.*\|\|.*)'; 4015 c_fix = format; 4016 c_fix_arg = "#if%1"; 4017 4018 test_text = "#ifdef __i386__ || __vax__ || __sun4c__"; 4019}; 4020 4021 4022/* 4023 * Fix the CAT macro in SunOS memvar.h. 4024 */ 4025fix = { 4026 hackname = sun_catmacro; 4027 files = pixrect/memvar.h; 4028 select = "^#define[ \t]+CAT\\(a,b\\).*"; 4029 c_fix = format; 4030 4031 c_fix_arg = 4032 "#ifdef __STDC__\n" 4033 "# define CAT(a,b) a##b\n" 4034 "#else\n%0\n#endif"; 4035 4036 test_text = 4037 "#define CAT(a,b)\ta/**/b"; 4038}; 4039 4040 4041/* 4042 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. 4043 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 4044 */ 4045fix = { 4046 hackname = sun_malloc; 4047 files = malloc.h; 4048 bypass = "_CLASSIC_ANSI_TYPES"; 4049 4050 sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g"; 4051 sed = "s/int[ \t][ \t]*free/void\tfree/g"; 4052 sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g"; 4053 sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g"; 4054 sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g"; 4055 4056 test_text = 4057 "typedef char *\tmalloc_t;\n" 4058 "int \tfree();\n" 4059 "char*\tmalloc();\n" 4060 "char*\tcalloc();\n" 4061 "char*\trealloc();"; 4062}; 4063 4064 4065/* 4066 * Check for yet more missing ';' in struct (in SunOS 4.0.x) 4067 */ 4068fix = { 4069 hackname = sun_rusers_semi; 4070 files = rpcsvc/rusers.h; 4071 select = "_cnt$"; 4072 sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; 4073 test_text = "struct mumble\n int _cnt\n};"; 4074}; 4075 4076 4077/* 4078 * signal.h on SunOS defines signal using (), 4079 * which causes trouble when compiling with g++ -pedantic. 4080 */ 4081fix = { 4082 hackname = sun_signal; 4083 files = sys/signal.h; 4084 files = signal.h; 4085 select = "^void\t" '\(\*signal\(\)\)\(\);.*'; 4086 4087 c_fix = format; 4088 c_fix_arg = 4089 "#ifdef __cplusplus\n" 4090 "void\t(*signal(...))(...);\n" 4091 "#else\n%0\n#endif"; 4092 4093 test_text = "void\t(*signal())();"; 4094}; 4095 4096 4097/* 4098 * Correct the return type for strlen in strings.h in SunOS 4. 4099 */ 4100fix = { 4101 hackname = sunos_strlen; 4102 files = strings.h; 4103 select = "int[ \t]*strlen\\(\\);(.*)"; 4104 c_fix = format; 4105 c_fix_arg = "__SIZE_TYPE__ strlen();%1"; 4106 test_text = " int\tstrlen(); /* string length */"; 4107}; 4108 4109 4110/* 4111 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> 4112 * that is visible to any ANSI compiler using this include. Simply 4113 * delete the lines that #define some string functions to internal forms. 4114 */ 4115fix = { 4116 hackname = svr4_disable_opt; 4117 files = string.h; 4118 select = '#define.*__std_hdr_'; 4119 sed = '/#define.*__std_hdr_/d'; 4120 test_text = "#define strlen __std_hdr_strlen\n"; 4121}; 4122 4123 4124/* 4125 * Fix broken decl of getcwd present on some svr4 systems. 4126 */ 4127fix = { 4128 hackname = svr4_getcwd; 4129 files = stdlib.h; 4130 files = unistd.h; 4131 files = prototypes.h; 4132 select = 'getcwd\(char \*, int\)'; 4133 4134 c_fix = format; 4135 c_fix_arg = "getcwd(char *, size_t)"; 4136 4137 test_text = "extern char* getcwd(char *, int);"; 4138}; 4139 4140 4141/* 4142 * Fix broken decl of profil present on some svr4 systems. 4143 */ 4144fix = { 4145 hackname = svr4_profil; 4146 files = stdlib.h; 4147 files = unistd.h; 4148 4149 select = 4150 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)'; 4151 c_fix = format; 4152 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)'; 4153 4154 test_text = 4155 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);'; 4156}; 4157 4158 4159/* 4160 * Correct types for signal handler constants like SIG_DFL; they might be 4161 * void (*) (), and should be void (*) (int). C++ doesn't like the 4162 * old style. 4163 */ 4164fix = { 4165 hackname = svr4_sighandler_type; 4166 files = sys/signal.h; 4167 select = 'void *\(\*\)\(\)'; 4168 c_fix = format; 4169 c_fix_arg = "void (*)(int)"; 4170 test_text = "#define SIG_DFL (void(*)())0\n" 4171 "#define SIG_IGN (void (*)())0\n"; 4172}; 4173 4174 4175/* 4176 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local 4177 * function 'getrnge' in <regexp.h> before they declare it. For these 4178 * systems add a 'static int' declaration of 'getrnge' into <regexp.h> 4179 * early on. 4180 * 4181 * 'getrnge' traditionally manipulates a file-scope global called 'size', 4182 * so put the declaration right after the declaration of 'size'. 4183 * 4184 * Don't do this if there is already a `static void getrnge' declaration 4185 * present, since this would cause a redeclaration error. Solaris 2.x has 4186 * such a declaration. 4187 */ 4188fix = { 4189 hackname = svr4_undeclared_getrnge; 4190 files = regexp.h; 4191 select = "getrnge"; 4192 bypass = "static void getrnge"; 4193 c_fix = format; 4194 c_fix_arg = "%0\n" 4195 "static int getrnge ();"; 4196 c_fix_arg = "^static int[ \t]+size;"; 4197 test_text = "static int size;\n" 4198 "/* stuff which calls getrnge() */\n" 4199 "static getrnge()\n" 4200 "{}"; 4201}; 4202 4203 4204/* 4205 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} 4206 * in string.h on sysV68 4207 * Correct the return type for strlen in string.h on Lynx. 4208 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. 4209 * Add missing const for strdup on OSF/1 V3.0. 4210 * On sysV88 layout is slightly different. 4211 */ 4212fix = { 4213 hackname = sysv68_string; 4214 files = testing.h; 4215 files = string.h; 4216 bypass = "_CLASSIC_ANSI_TYPES"; 4217 4218 sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/"; 4219 sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/"; 4220 sed = "s/strdup(char \\*s1);/strdup(const char *s1);/"; 4221 4222 sed = "/^extern char$/N"; 4223 sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/"; 4224 4225 sed = "/^extern int$/N"; 4226 sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/"; 4227 4228 sed = "/^\tstrncmp(),$/N"; 4229 sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/' 4230 '\1;' "\\\nextern unsigned int\\\n\\2/"; 4231 4232 test_text = 4233 "extern int strlen();\n" 4234 4235 "extern int ffs(long);\n" 4236 4237 "extern char\n" 4238 "\t*memccpy(),\n" 4239 "\tmemcpy();\n" 4240 4241 "extern int\n" 4242 "\tstrcmp(),\n" 4243 "\tstrncmp(),\n" 4244 "\tstrlen(),\n" 4245 "\tstrspn();\n" 4246 4247 "extern int\n" 4248 "\tstrlen(), strspn();"; 4249}; 4250 4251 4252/* 4253 * Fix return type of calloc, malloc, realloc, bsearch and exit 4254 */ 4255fix = { 4256 hackname = sysz_stdlib_for_sun; 4257 files = stdlib.h; 4258 bypass = "_CLASSIC_ANSI_TYPES"; 4259 4260 select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\("; 4261 c_fix = format; 4262 c_fix_arg = "void *\t%1("; 4263 4264 test_text = 4265 "extern char*\tcalloc(size_t);\n" 4266 "extern char*\tmalloc(size_t);\n" 4267 "extern char*\trealloc(void*,size_t);\n" 4268 "extern char*\tbsearch(void*,size_t,size_t);\n"; 4269}; 4270 4271 4272/* 4273 * __thread is now a keyword. 4274 */ 4275fix = { 4276 hackname = thread_keyword; 4277 files = "pthread.h"; 4278 files = "bits/sigthread.h"; 4279 select = "([* ])__thread([,)])"; 4280 c_fix = format; 4281 c_fix_arg = "%1__thr%2"; 4282 4283 test_text = 4284 "extern int pthread_create (pthread_t *__restrict __thread,\n" 4285 "extern int pthread_kill (pthread_t __thread, int __signo);\n" 4286 "extern int pthread_cancel (pthread_t __thread);"; 4287}; 4288 4289/* 4290 * if the #if says _cplusplus, not the double underscore __cplusplus 4291 * that it should be 4292 */ 4293fix = { 4294 hackname = tinfo_cplusplus; 4295 files = tinfo.h; 4296 select = "[ \t]_cplusplus"; 4297 4298 c_fix = format; 4299 c_fix_arg = " __cplusplus"; 4300 test_text = "#ifdef _cplusplus\nint bogus;\n#endif"; 4301}; 4302 4303 4304/* 4305 * parameters not const on DECstation Ultrix V4.0 and OSF/1. 4306 */ 4307fix = { 4308 hackname = ultrix_const; 4309 files = stdio.h; 4310 select = 'perror\( char \*'; 4311 4312 c_fix = format; 4313 c_fix_arg = "%1 const %3 *__"; 4314 c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)" 4315 "[ \t]+(char|void) \\*__"; 4316 4317 test_text = 4318 "extern void perror( char *__s );\n" 4319 "extern int fputs( char *__s, FILE *);\n" 4320 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n" 4321 "extern int fscanf( FILE *__stream, char *__format, ...);\n" 4322 "extern int scanf( char *__format, ...);\n"; 4323}; 4324 4325 4326/* 4327 * parameters not const on DECstation Ultrix V4.0 and OSF/1. 4328 */ 4329fix = { 4330 hackname = ultrix_const2; 4331 files = stdio.h; 4332 4333 select = '\*fopen\( char \*'; 4334 c_fix = format; 4335 c_fix_arg = "%1( const char *%3, const char *"; 4336 c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\(" 4337 "[ \t]*char[ \t]*\\*([^,]*)," 4338 "[ \t]*char[ \t]*\\*[ \t]*"; 4339 4340 test_text = 4341 "extern FILE *fopen( char *__filename, char *__type );\n" 4342 "extern int sscanf( char *__s, char *__format, ...);\n" 4343 "extern FILE *popen(char *, char *);\n" 4344 "extern char *tempnam(char*,char*);\n"; 4345}; 4346 4347 4348/* 4349 * Fix definitions of macros used by va-i960.h in VxWorks header file. 4350 */ 4351fix = { 4352 hackname = va_i960_macro; 4353 files = arch/i960/archI960.h; 4354 select = "__(vsiz|vali|vpad|alignof__)"; 4355 4356 c_fix = format; 4357 c_fix_arg = "__vx%1"; 4358 4359 test_text = 4360 "extern int __vsiz vsiz;\n" 4361 "extern int __vali vali;\n" 4362 "extern int __vpad vpad;\n" 4363 "#define __alignof__(x) ..."; 4364}; 4365 4366 4367/* 4368 * Define __CAN_USE_EXTERN_PREFIX on vms. 4369 */ 4370fix = { 4371 hackname = vms_define_can_use_extern_prefix; 4372 files = "rtldef/decc$types.h"; 4373 select = "#[ \t]*else\n" 4374 "#[ \t]*if defined\\(__DECCXX\\)\n" 4375 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n"; 4376 mach = "*-*-*vms*"; 4377 c_fix = format; 4378 4379 c_fix_arg = "%0" 4380 "# elif defined (__GNUC__)\n" 4381 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"; 4382 4383 test_text = "# else\n" 4384 "# if defined(__DECCXX)\n" 4385 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n" 4386 "# endif\n" 4387 "# endif\n"; 4388}; 4389 4390/* 4391 * On VMS, use pragma extern_model instead of VAX-C keywords. 4392 */ 4393fix = { 4394 hackname = vms_use_pragma_extern_model; 4395 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n" 4396 "# pragma extern_model __save\n"; 4397 mach = "*-*-*vms*"; 4398 c_fix = format; 4399 4400 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n" 4401 "# pragma extern_model __save\n"; 4402 4403 test_text = "#if defined(__DECC) || defined(__DECCXX)\n" 4404 "# pragma extern_model __save\n" 4405 "# pragma extern_model strict_refdef\n" 4406 " extern struct x zz$yy;\n" 4407 "# pragma extern_model __restore\n" 4408 "#endif\n"; 4409}; 4410 4411/* 4412 * On VMS, disable the use of dec-c string builtins 4413 */ 4414fix = { 4415 hackname = vms_disable_decc_string_builtins; 4416 select = "#if !defined\\(__VAX\\)\n"; 4417 mach = "*-*-*vms*"; 4418 files = "rtldef/string.h"; 4419 c_fix = format; 4420 4421 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n"; 4422 4423 test_text = "#if !defined(__VAX)\n"; 4424}; 4425 4426/* 4427 * On VMS, change <resource.h> to <sys/resource.h> to avoid a 4428 * conflict while building gcc. Likewise for <builtins.h> 4429 */ 4430fix = { 4431 hackname = vms_use_quoted_include; 4432 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>"; 4433 mach = "*-*-*vms*"; 4434 files = rtldef/wait.h, starlet_c/pthread.h; 4435 c_fix = format; 4436 4437 c_fix_arg = '%1<sys/%2.h>'; 4438 4439 test_text = "# include <resource.h>"; 4440}; 4441 4442/* 4443 * On VMS, add missing braces around sigset_t constants. 4444 */ 4445fix = { 4446 hackname = vms_add_missing_braces; 4447 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)"; 4448 mach = "*-*-*vms*"; 4449 files = "rtldef/signal.h"; 4450 c_fix = format; 4451 4452 c_fix_arg = '%1 {%2} '; 4453 4454 test_text = "static const __sigset_t _SIG_EMPTY_SET = " 4455 "{0x00000000, 0x00000000},\n" 4456 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n"; 4457}; 4458 4459/* 4460 * On VMS, fix incompatible redeclaration of hostalias. 4461 */ 4462fix = { 4463 hackname = vms_do_not_redeclare_hostalias; 4464 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n" 4465 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)"; 4466 mach = "*-*-*vms*"; 4467 files = "rtldef/resolv.h"; 4468 c_fix = format; 4469 4470 c_fix_arg = "%1\n" 4471 "/* %2 */"; 4472 4473 test_text = "void fp_nquery (const u_char *, int, FILE *);\n" 4474 "__char_ptr32 hostalias (const char *);\n"; 4475}; 4476 4477/* 4478 * On VMS, some DEC-C builtins are directly used. 4479 */ 4480fix = { 4481 hackname = vms_decc_builtin; 4482 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)"; 4483 mach = "*-*-*vms*"; 4484 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h, 4485 rtldef/socket.h; 4486 sed = "s@__MEMSET@memset@"; 4487 sed = "s@__MEMMOVE@memmove@"; 4488 sed = "s@__MEMCPY@memcpy@"; 4489 sed = "s@__STRLEN@strlen@"; 4490 sed = "s@__STRCPY@strcpy@"; 4491 4492 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n"; 4493}; 4494 4495/* 4496 * On VMS, do not declare getopt and al if pointers are 64 bit. 4497 */ 4498fix = { 4499 hackname = vms_no_64bit_getopt; 4500 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n"; 4501 /* select = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */ 4502 mach = "*-*-*vms*"; 4503 files = rtldef/stdio.h, rtldef/unistd.h; 4504 c_fix = format; 4505 4506 c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */\n" 4507 "%0" 4508 "#endif\n"; 4509 4510 test_text = "int getopt (int, char * const [], const char *);"; 4511}; 4512 4513/* 4514 * On VMS, forward declare structure before referencing them in prototypes. 4515 */ 4516fix = { 4517 hackname = vms_forward_declare_struct; 4518 select = "(/\\* forward decls for C\\+\\+ \\*/\n)" 4519 "#ifdef __cplusplus\n"; 4520 mach = "*-*-*vms*"; 4521 files = rtldef/if.h; 4522 c_fix = format; 4523 4524 c_fix_arg = "%1" 4525 "#if defined (__cplusplus) || defined (__GNUC__)\n"; 4526 4527 test_text = "/* forward decls for C++ */\n" 4528 "#ifdef __cplusplus\n" 4529 "struct foo;\n" 4530 "#endif\n"; 4531}; 4532 4533/* 4534 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions 4535 * which is not yet fully supported by gcc. 4536 */ 4537fix = { 4538 hackname = vms_use_fast_setjmp; 4539 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)"; 4540 mach = "*-*-*vms*"; 4541 files = rtldef/setjmp.h; 4542 c_fix = format; 4543 4544 c_fix_arg = "%0 defined (__GNUC__) ||"; 4545 4546 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)"; 4547}; 4548 4549/* 4550 * AIX and Interix headers define NULL to be cast to a void pointer, 4551 * which is illegal in ANSI C++. 4552 */ 4553fix = { 4554 hackname = void_null; 4555 files = curses.h; 4556 files = dbm.h; 4557 files = locale.h; 4558 files = stdio.h; 4559 files = stdlib.h; 4560 files = string.h; 4561 files = time.h; 4562 files = unistd.h; 4563 files = sys/dir.h; 4564 files = sys/param.h; 4565 files = sys/types.h; 4566 /* avoid changing C++ friendly NULL */ 4567 bypass = __cplusplus; 4568 bypass = __null; 4569 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)"; 4570 c_fix = format; 4571 c_fix_arg = "#define NULL 0"; 4572 test_text = "# define\tNULL \t((void *)0) /* typed NULL */"; 4573}; 4574 4575 4576/* 4577 * Make VxWorks header which is almost gcc ready fully gcc ready. 4578 */ 4579fix = { 4580 hackname = vxworks_gcc_problem; 4581 files = types/vxTypesBase.h; 4582 select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__"; 4583 4584 sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/" 4585 "#if 1/"; 4586 4587 sed = "/[ \t]size_t/i\\\n" 4588 "#ifndef _GCC_SIZE_T\\\n" 4589 "#define _GCC_SIZE_T\n"; 4590 4591 sed = "/[ \t]size_t/a\\\n" 4592 "#endif\n"; 4593 4594 sed = "/[ \t]ptrdiff_t/i\\\n" 4595 "#ifndef _GCC_PTRDIFF_T\\\n" 4596 "#define _GCC_PTRDIFF_T\n"; 4597 4598 sed = "/[ \t]ptrdiff_t/a\\\n" 4599 "#endif\n"; 4600 4601 sed = "/[ \t]wchar_t/i\\\n" 4602 "#ifndef _GCC_WCHAR_T\\\n" 4603 "#define _GCC_WCHAR_T\n"; 4604 4605 sed = "/[ \t]wchar_t/a\\\n" 4606 "#endif\n"; 4607 4608 test_text = 4609 "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n" 4610 "typedef unsigned int size_t;\n" 4611 "typedef long ptrdiff_t;\n" 4612 "typedef unsigned short wchar_t;\n" 4613 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n"; 4614}; 4615 4616/* 4617 * Wrap VxWorks ioctl to keep everything pretty 4618 */ 4619fix = { 4620 hackname = vxworks_ioctl_macro; 4621 files = ioLib.h; 4622 mach = "*-*-vxworks*"; 4623 4624 c_fix = format; 4625 c_fix_arg = "%0\n" 4626 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n"; 4627 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);"; 4628 4629 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;"; 4630}; 4631 4632/* 4633 * Wrap VxWorks mkdir to be posix compliant 4634 */ 4635fix = { 4636 hackname = vxworks_mkdir_macro; 4637 files = sys/stat.h; 4638 mach = "*-*-vxworks*"; 4639 4640 c_fix = format; 4641 c_fix_arg = "%0\n" 4642 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n"; 4643 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*" 4644 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */ 4645 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */ 4646 "\\)[\t ]*;"; 4647 4648 test_text = "extern STATUS mkdir (const char * _qwerty) ;"; 4649}; 4650 4651 4652/* 4653 * Fix VxWorks <time.h> to not require including <vxTypes.h>. 4654 */ 4655fix = { 4656 hackname = vxworks_needs_vxtypes; 4657 files = time.h; 4658 select = "uint_t([ \t]+_clocks_per_sec)"; 4659 c_fix = format; 4660 c_fix_arg = "unsigned int%1"; 4661 test_text = "uint_t\t_clocks_per_sec;"; 4662}; 4663 4664 4665/* 4666 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. 4667 */ 4668fix = { 4669 hackname = vxworks_needs_vxworks; 4670 files = sys/stat.h; 4671 test = " -r types/vxTypesOld.h"; 4672 test = " -n \"`egrep '#include' $file`\""; 4673 test = " -n \"`egrep ULONG $file`\""; 4674 select = "#[ \t]define[ \t]+__INCstath"; 4675 4676 sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" 4677 "#include <types/vxTypesOld.h>\n"; 4678 4679 test_text = "`touch types/vxTypesOld.h`" 4680 "#include </dev/null> /* ULONG */\n" 4681 "# define\t__INCstath <sys/stat.h>"; 4682}; 4683 4684/* 4685 * Make it so VxWorks does not include gcc/regs.h accidentally 4686 */ 4687fix = { 4688 hackname = vxworks_regs; 4689 mach = "*-*-vxworks*"; 4690 4691 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]"; 4692 c_fix = format; 4693 c_fix_arg = "#include <arch/../regs.h>"; 4694 4695 test_text = "#include <regs.h>\n"; 4696}; 4697 4698 4699/* 4700 * Another bad dependency in VxWorks 5.2 <time.h>. 4701 */ 4702fix = { 4703 hackname = vxworks_time; 4704 files = time.h; 4705 test = " -r vxWorks.h"; 4706 4707 select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*"; 4708 c_fix = format; 4709 4710 c_fix_arg = 4711 "#ifndef __gcc_VOIDFUNCPTR_defined\n" 4712 "#ifdef __cplusplus\n" 4713 "typedef void (*__gcc_VOIDFUNCPTR) (...);\n" 4714 "#else\n" 4715 "typedef void (*__gcc_VOIDFUNCPTR) ();\n" 4716 "#endif\n" 4717 "#define __gcc_VOIDFUNCPTR_defined\n" 4718 "#endif\n" 4719 "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR"; 4720 4721 test_text = "`touch vxWorks.h`" 4722 "#define VOIDFUNCPTR (void(*)())"; 4723}; 4724 4725/* 4726 * This hack makes write const-correct on VxWorks 4727 */ 4728fix = { 4729 hackname = vxworks_write_const; 4730 files = ioLib.h; 4731 mach = "*-*-vxworks*"; 4732 4733 c_fix = format; 4734 c_fix_arg = "extern int write (int, const char*, size_t);"; 4735 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\(" 4736 "[\t ]*int[\t ]*," 4737 "[\t ]*char[\t ]*\\*[\t ]*," 4738 "[\t ]*size_t[\t ]*\\)[\t ]*;"; 4739 4740 test_text = "extern int write ( int , char * , size_t ) ;"; 4741}; 4742 4743/* 4744 * There are several name conflicts with C++ reserved words in X11 header 4745 * files. These are fixed in some versions, so don't do the fixes if 4746 * we find __cplusplus in the file. These were found on the RS/6000. 4747 */ 4748fix = { 4749 hackname = x11_class; 4750 files = X11/ShellP.h; 4751 bypass = __cplusplus; 4752 select = "^([ \t]*char \\*)class;(.*)"; 4753 c_fix = format; 4754 c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n" 4755 "#else\n%1class;%2\n#endif"; 4756 test_text = 4757 "struct {\n" 4758 " char *class;\n" 4759 "} mumble;\n"; 4760}; 4761 4762 4763/* 4764 * class in Xm/BaseClassI.h 4765 */ 4766fix = { 4767 hackname = x11_class_usage; 4768 files = Xm/BaseClassI.h; 4769 bypass = "__cplusplus"; 4770 4771 select = " class\\)"; 4772 c_fix = format; 4773 c_fix_arg = " c_class)"; 4774 4775 test_text = "extern mumble (int class);\n"; 4776}; 4777 4778 4779/* 4780 * new in Xm/Traversal.h 4781 */ 4782fix = { 4783 hackname = x11_new; 4784 files = Xm/Traversal.h; 4785 bypass = __cplusplus; 4786 4787 sed = "/Widget\told, new;/i\\\n" 4788 "#ifdef __cplusplus\\\n" 4789 "\\\tWidget\told, c_new;\\\n" 4790 "#else\n"; 4791 4792 sed = "/Widget\told, new;/a\\\n" 4793 "#endif\n"; 4794 4795 sed = "s/Widget new,/Widget c_new,/g"; 4796 test_text = 4797 "struct wedge {\n" 4798 " Widget\told, new;\n" 4799 "};\nextern Wedged( Widget new, Widget old );"; 4800}; 4801 4802 4803/* 4804 * Incorrect sprintf declaration in X11/Xmu.h 4805 */ 4806fix = { 4807 hackname = x11_sprintf; 4808 files = X11/Xmu.h; 4809 files = X11/Xmu/Xmu.h; 4810 select = "^extern char \\*\tsprintf\\(\\);$"; 4811 4812 c_fix = format; 4813 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */"; 4814 4815 test_text = "extern char *\tsprintf();"; 4816}; 4817 4818/* 4819 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64 4820 * that fails when compiling for SSE-less 32-bit x86. 4821 */ 4822fix = { 4823 hackname = feraiseexcept_nosse_invalid; 4824 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*'; 4825 files = bits/fenv.h; 4826 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : " 4827 ": \"x\" \\(__f\\)\\);$"; 4828 bypass = "\"fdiv .*; fwait\""; 4829 4830 c_fix = format; 4831 c_fix_arg = <<- _EOText_ 4832 # ifdef __SSE_MATH__ 4833 %0 4834 # else 4835 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait" 4836 %1 : "=t" (__f) : "0" (__f)); 4837 # endif 4838 _EOText_; 4839 4840 test_text = <<- _EOText_ 4841 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f)); 4842 _EOText_; 4843}; 4844fix = { 4845 hackname = feraiseexcept_nosse_divbyzero; 4846 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*'; 4847 files = bits/fenv.h; 4848 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : " 4849 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$"; 4850 bypass = "\"fdivp .*; fwait\""; 4851 4852 c_fix = format; 4853 c_fix_arg = <<- _EOText_ 4854 # ifdef __SSE_MATH__ 4855 %0 4856 # else 4857 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait" 4858 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)"); 4859 # endif 4860 _EOText_; 4861 4862 test_text = <<- _EOText_ 4863 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g)); 4864 _EOText_; 4865}; 4866 4867/*EOF*/ 4868