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