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