1 /* Get common system includes and various definitions and declarations based 2 on autoconf macros. 3 Copyright (C) 1998-2015 Free Software Foundation, Inc. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it under 8 the terms of the GNU General Public License as published by the Free 9 Software Foundation; either version 3, or (at your option) any later 10 version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 22 #ifndef GCC_SYSTEM_H 23 #define GCC_SYSTEM_H 24 25 /* Define this so that inttypes.h defines the PRI?64 macros even 26 when compiling with a C++ compiler. Define it here so in the 27 event inttypes.h gets pulled in by another header it is already 28 defined. */ 29 #define __STDC_FORMAT_MACROS 30 31 /* We must include stdarg.h before stdio.h. */ 32 #include <stdarg.h> 33 34 #ifndef va_copy 35 # ifdef __va_copy 36 # define va_copy(d,s) __va_copy (d, s) 37 # else 38 # define va_copy(d,s) ((d) = (s)) 39 # endif 40 #endif 41 42 #ifdef HAVE_STDDEF_H 43 # include <stddef.h> 44 #endif 45 46 #ifndef GENERATOR_FILE 47 #ifdef __cplusplus 48 # include <cstdio> 49 #endif 50 #endif 51 52 #include <stdio.h> 53 54 /* Define a generic NULL if one hasn't already been defined. */ 55 #ifndef NULL 56 #define NULL 0 57 #endif 58 59 /* Use the unlocked open routines from libiberty. */ 60 61 /* Some of these are #define on some systems, e.g. on AIX to redirect 62 the names to 64bit capable functions for LARGE_FILES support. These 63 redefs are pointless here so we can override them. */ 64 65 #undef fopen 66 #undef freopen 67 68 #define fopen(PATH, MODE) fopen_unlocked (PATH, MODE) 69 #define fdopen(FILDES, MODE) fdopen_unlocked (FILDES, MODE) 70 #define freopen(PATH, MODE, STREAM) freopen_unlocked (PATH, MODE, STREAM) 71 72 /* The compiler is not a multi-threaded application and therefore we 73 do not have to use the locking functions. In fact, using the locking 74 functions can cause the compiler to be significantly slower under 75 I/O bound conditions (such as -g -O0 on very large source files). 76 77 HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio 78 code is multi-thread safe by default. If it is set to 0, then do 79 not worry about using the _unlocked functions. 80 81 fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are 82 extensions and need to be prototyped by hand (since we do not 83 define _GNU_SOURCE). */ 84 85 #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED 86 87 # ifdef HAVE_PUTC_UNLOCKED 88 # undef putc 89 # define putc(C, Stream) putc_unlocked (C, Stream) 90 # endif 91 # ifdef HAVE_PUTCHAR_UNLOCKED 92 # undef putchar 93 # define putchar(C) putchar_unlocked (C) 94 # endif 95 # ifdef HAVE_GETC_UNLOCKED 96 # undef getc 97 # define getc(Stream) getc_unlocked (Stream) 98 # endif 99 # ifdef HAVE_GETCHAR_UNLOCKED 100 # undef getchar 101 # define getchar() getchar_unlocked () 102 # endif 103 # ifdef HAVE_FPUTC_UNLOCKED 104 # undef fputc 105 # define fputc(C, Stream) fputc_unlocked (C, Stream) 106 # endif 107 108 #ifdef __cplusplus 109 extern "C" { 110 #endif 111 112 # ifdef HAVE_CLEARERR_UNLOCKED 113 # undef clearerr 114 # define clearerr(Stream) clearerr_unlocked (Stream) 115 # if defined (HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED 116 extern void clearerr_unlocked (FILE *); 117 # endif 118 # endif 119 # ifdef HAVE_FEOF_UNLOCKED 120 # undef feof 121 # define feof(Stream) feof_unlocked (Stream) 122 # if defined (HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED 123 extern int feof_unlocked (FILE *); 124 # endif 125 # endif 126 # ifdef HAVE_FILENO_UNLOCKED 127 # undef fileno 128 # define fileno(Stream) fileno_unlocked (Stream) 129 # if defined (HAVE_DECL_FILENO_UNLOCKED) && !HAVE_DECL_FILENO_UNLOCKED 130 extern int fileno_unlocked (FILE *); 131 # endif 132 # endif 133 # ifdef HAVE_FFLUSH_UNLOCKED 134 # undef fflush 135 # define fflush(Stream) fflush_unlocked (Stream) 136 # if defined (HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED 137 extern int fflush_unlocked (FILE *); 138 # endif 139 # endif 140 # ifdef HAVE_FGETC_UNLOCKED 141 # undef fgetc 142 # define fgetc(Stream) fgetc_unlocked (Stream) 143 # if defined (HAVE_DECL_FGETC_UNLOCKED) && !HAVE_DECL_FGETC_UNLOCKED 144 extern int fgetc_unlocked (FILE *); 145 # endif 146 # endif 147 # ifdef HAVE_FGETS_UNLOCKED 148 # undef fgets 149 # define fgets(S, n, Stream) fgets_unlocked (S, n, Stream) 150 # if defined (HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED 151 extern char *fgets_unlocked (char *, int, FILE *); 152 # endif 153 # endif 154 # ifdef HAVE_FPUTS_UNLOCKED 155 # undef fputs 156 # define fputs(String, Stream) fputs_unlocked (String, Stream) 157 # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED 158 extern int fputs_unlocked (const char *, FILE *); 159 # endif 160 # endif 161 # ifdef HAVE_FERROR_UNLOCKED 162 # undef ferror 163 # define ferror(Stream) ferror_unlocked (Stream) 164 # if defined (HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED 165 extern int ferror_unlocked (FILE *); 166 # endif 167 # endif 168 # ifdef HAVE_FREAD_UNLOCKED 169 # undef fread 170 # define fread(Ptr, Size, N, Stream) fread_unlocked (Ptr, Size, N, Stream) 171 # if defined (HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED 172 extern size_t fread_unlocked (void *, size_t, size_t, FILE *); 173 # endif 174 # endif 175 # ifdef HAVE_FWRITE_UNLOCKED 176 # undef fwrite 177 # define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream) 178 # if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED 179 extern size_t fwrite_unlocked (const void *, size_t, size_t, FILE *); 180 # endif 181 # endif 182 # ifdef HAVE_FPRINTF_UNLOCKED 183 # undef fprintf 184 /* We can't use a function-like macro here because we don't know if 185 we have varargs macros. */ 186 # define fprintf fprintf_unlocked 187 # if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED 188 extern int fprintf_unlocked (FILE *, const char *, ...); 189 # endif 190 # endif 191 192 #ifdef __cplusplus 193 } 194 #endif 195 196 #endif 197 198 /* ??? Glibc's fwrite/fread_unlocked macros cause 199 "warning: signed and unsigned type in conditional expression". */ 200 #undef fread_unlocked 201 #undef fwrite_unlocked 202 203 /* Include <string> before "safe-ctype.h" to avoid GCC poisoning 204 the ctype macros through safe-ctype.h */ 205 206 #ifdef __cplusplus 207 # include <string> 208 #endif 209 210 /* There are an extraordinary number of issues with <ctype.h>. 211 The last straw is that it varies with the locale. Use libiberty's 212 replacement instead. */ 213 #include "safe-ctype.h" 214 215 #include <sys/types.h> 216 217 #include <errno.h> 218 219 #if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO 220 extern int errno; 221 #endif 222 223 #ifndef GENERATOR_FILE 224 #ifdef __cplusplus 225 # ifdef INCLUDE_LIST 226 # include <list> 227 # endif 228 # ifdef INCLUDE_MAP 229 # include <map> 230 # endif 231 # ifdef INCLUDE_SET 232 # include <set> 233 # endif 234 # ifdef INCLUDE_VECTOR 235 # include <vector> 236 # endif 237 # include <algorithm> 238 # include <cstring> 239 # include <new> 240 # include <utility> 241 #endif 242 #endif 243 244 /* Some of glibc's string inlines cause warnings. Plus we'd rather 245 rely on (and therefore test) GCC's string builtins. */ 246 #define __NO_STRING_INLINES 247 248 #ifdef STRING_WITH_STRINGS 249 # include <string.h> 250 # include <strings.h> 251 #else 252 # ifdef HAVE_STRING_H 253 # include <string.h> 254 # else 255 # ifdef HAVE_STRINGS_H 256 # include <strings.h> 257 # endif 258 # endif 259 #endif 260 261 #ifdef HAVE_STDLIB_H 262 # include <stdlib.h> 263 #endif 264 265 /* When compiling C++ we need to include <cstdlib> as well as <stdlib.h> so 266 that it is processed before we poison "malloc"; otherwise, if a source 267 file uses a standard library header that includes <cstdlib>, we will get 268 an error about 'using std::malloc'. */ 269 #ifdef __cplusplus 270 #include <cstdlib> 271 #endif 272 273 /* Undef vec_free from AIX stdlib.h header which conflicts with vec.h. */ 274 #undef vec_free 275 276 /* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and 277 FATAL_EXIT_CODE to EXIT_SUCCESS and EXIT_FAILURE respectively, 278 or 0 and 1 if those macros are not defined. */ 279 #ifndef SUCCESS_EXIT_CODE 280 # ifdef EXIT_SUCCESS 281 # define SUCCESS_EXIT_CODE EXIT_SUCCESS 282 # else 283 # define SUCCESS_EXIT_CODE 0 284 # endif 285 #endif 286 287 #ifndef FATAL_EXIT_CODE 288 # ifdef EXIT_FAILURE 289 # define FATAL_EXIT_CODE EXIT_FAILURE 290 # else 291 # define FATAL_EXIT_CODE 1 292 # endif 293 #endif 294 295 #define ICE_EXIT_CODE 4 296 297 #ifdef HAVE_UNISTD_H 298 # include <unistd.h> 299 #endif 300 301 #ifdef HAVE_SYS_PARAM_H 302 # include <sys/param.h> 303 /* We use these identifiers later and they appear in some vendor param.h's. */ 304 # undef PREFETCH 305 # undef m_slot 306 #endif 307 308 #if HAVE_LIMITS_H 309 # include <limits.h> 310 #endif 311 312 /* A macro to determine whether a VALUE lies inclusively within a 313 certain range without evaluating the VALUE more than once. This 314 macro won't warn if the VALUE is unsigned and the LOWER bound is 315 zero, as it would e.g. with "VALUE >= 0 && ...". Note the LOWER 316 bound *is* evaluated twice, and LOWER must not be greater than 317 UPPER. However the bounds themselves can be either positive or 318 negative. */ 319 #define IN_RANGE(VALUE, LOWER, UPPER) \ 320 ((unsigned HOST_WIDE_INT) (VALUE) - (unsigned HOST_WIDE_INT) (LOWER) \ 321 <= (unsigned HOST_WIDE_INT) (UPPER) - (unsigned HOST_WIDE_INT) (LOWER)) 322 323 /* Infrastructure for defining missing _MAX and _MIN macros. Note that 324 macros defined with these cannot be used in #if. */ 325 326 /* The extra casts work around common compiler bugs. */ 327 #define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 328 /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. 329 It is necessary at least when t == time_t. */ 330 #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ 331 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) 332 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) 333 334 /* Use that infrastructure to provide a few constants. */ 335 #ifndef UCHAR_MAX 336 # define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char) 337 #endif 338 339 #ifdef TIME_WITH_SYS_TIME 340 # include <sys/time.h> 341 # include <time.h> 342 #else 343 # if HAVE_SYS_TIME_H 344 # include <sys/time.h> 345 # else 346 # ifdef HAVE_TIME_H 347 # include <time.h> 348 # endif 349 # endif 350 #endif 351 352 #ifdef HAVE_FCNTL_H 353 # include <fcntl.h> 354 #else 355 # ifdef HAVE_SYS_FILE_H 356 # include <sys/file.h> 357 # endif 358 #endif 359 360 #ifndef SEEK_SET 361 # define SEEK_SET 0 362 # define SEEK_CUR 1 363 # define SEEK_END 2 364 #endif 365 #ifndef F_OK 366 # define F_OK 0 367 # define X_OK 1 368 # define W_OK 2 369 # define R_OK 4 370 #endif 371 #ifndef O_RDONLY 372 # define O_RDONLY 0 373 #endif 374 #ifndef O_WRONLY 375 # define O_WRONLY 1 376 #endif 377 #ifndef O_BINARY 378 # define O_BINARY 0 379 #endif 380 381 /* Some systems define these in, e.g., param.h. We undefine these names 382 here to avoid the warnings. We prefer to use our definitions since we 383 know they are correct. */ 384 385 #undef MIN 386 #undef MAX 387 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) 388 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) 389 390 /* Returns the least number N such that N * Y >= X. */ 391 #define CEIL(x,y) (((x) + (y) - 1) / (y)) 392 393 #ifdef HAVE_SYS_WAIT_H 394 #include <sys/wait.h> 395 #endif 396 397 #ifndef WIFSIGNALED 398 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) 399 #endif 400 #ifndef WTERMSIG 401 #define WTERMSIG(S) ((S) & 0x7f) 402 #endif 403 #ifndef WIFEXITED 404 #define WIFEXITED(S) (((S) & 0xff) == 0) 405 #endif 406 #ifndef WEXITSTATUS 407 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8) 408 #endif 409 #ifndef WSTOPSIG 410 #define WSTOPSIG WEXITSTATUS 411 #endif 412 #ifndef WCOREDUMP 413 #define WCOREDUMP(S) ((S) & WCOREFLG) 414 #endif 415 #ifndef WCOREFLG 416 #define WCOREFLG 0200 417 #endif 418 419 #include <signal.h> 420 #if !defined (SIGCHLD) && defined (SIGCLD) 421 # define SIGCHLD SIGCLD 422 #endif 423 424 #ifdef HAVE_SYS_MMAN_H 425 # include <sys/mman.h> 426 #endif 427 428 #ifndef MAP_FAILED 429 # define MAP_FAILED ((void *)-1) 430 #endif 431 432 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) 433 # define MAP_ANONYMOUS MAP_ANON 434 #endif 435 436 #ifdef HAVE_SYS_RESOURCE_H 437 # include <sys/resource.h> 438 #endif 439 440 #ifdef HAVE_SYS_TIMES_H 441 # include <sys/times.h> 442 #endif 443 444 /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they 445 are defined to 0 then we must provide the relevant declaration 446 here. These checks will be in the undefined state while configure 447 is running so be careful to test "defined (HAVE_DECL_*)". */ 448 449 #ifdef __cplusplus 450 extern "C" { 451 #endif 452 453 #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF 454 extern double atof (const char *); 455 #endif 456 457 #if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL 458 extern long atol (const char *); 459 #endif 460 461 #if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE 462 extern void free (void *); 463 #endif 464 465 #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD 466 extern char *getcwd (char *, size_t); 467 #endif 468 469 #if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV 470 extern char *getenv (const char *); 471 #endif 472 473 #if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT 474 extern int getopt (int, char * const *, const char *); 475 #endif 476 477 #if defined (HAVE_DECL_GETPAGESIZE) && !HAVE_DECL_GETPAGESIZE 478 extern int getpagesize (void); 479 #endif 480 481 #if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD 482 extern char *getwd (char *); 483 #endif 484 485 #if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK 486 extern void *sbrk (int); 487 #endif 488 489 #if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR 490 extern char *strstr (const char *, const char *); 491 #endif 492 493 #if defined (HAVE_DECL_STPCPY) && !HAVE_DECL_STPCPY 494 extern char *stpcpy (char *, const char *); 495 #endif 496 497 #ifdef __cplusplus 498 } 499 #endif 500 501 #ifdef HAVE_MALLOC_H 502 #include <malloc.h> 503 #endif 504 505 #ifdef __cplusplus 506 extern "C" { 507 #endif 508 509 #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC 510 extern void *malloc (size_t); 511 #endif 512 513 #if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC 514 extern void *calloc (size_t, size_t); 515 #endif 516 517 #if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC 518 extern void *realloc (void *, size_t); 519 #endif 520 521 #ifdef __cplusplus 522 } 523 #endif 524 525 #ifdef HAVE_STDINT_H 526 #include <stdint.h> 527 #endif 528 529 #ifdef HAVE_INTTYPES_H 530 #include <inttypes.h> 531 #endif 532 533 #ifdef __cplusplus 534 extern "C" { 535 #endif 536 537 /* If the system doesn't provide strsignal, we get it defined in 538 libiberty but no declaration is supplied. */ 539 #if !defined (HAVE_STRSIGNAL) \ 540 || (defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL) 541 # ifndef strsignal 542 extern const char *strsignal (int); 543 # endif 544 #endif 545 546 #ifdef HAVE_GETRLIMIT 547 # if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT 548 # ifndef getrlimit 549 struct rlimit; 550 extern int getrlimit (int, struct rlimit *); 551 # endif 552 # endif 553 #endif 554 555 #ifdef HAVE_SETRLIMIT 556 # if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT 557 # ifndef setrlimit 558 struct rlimit; 559 extern int setrlimit (int, const struct rlimit *); 560 # endif 561 # endif 562 #endif 563 564 #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT 565 extern void abort (void); 566 #endif 567 568 #if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF 569 extern int snprintf (char *, size_t, const char *, ...); 570 #endif 571 572 #if defined (HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF 573 extern int vsnprintf (char *, size_t, const char *, va_list); 574 #endif 575 576 #ifdef __cplusplus 577 } 578 #endif 579 580 /* 1 if we have C99 designated initializers. */ 581 #if !defined(HAVE_DESIGNATED_INITIALIZERS) 582 #define HAVE_DESIGNATED_INITIALIZERS \ 583 (((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)) \ 584 && !defined(__cplusplus)) 585 #endif 586 587 #if !defined(HAVE_DESIGNATED_UNION_INITIALIZERS) 588 #define HAVE_DESIGNATED_UNION_INITIALIZERS \ 589 (((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)) \ 590 && (!defined(__cplusplus) || (GCC_VERSION >= 4007))) 591 #endif 592 593 #if HAVE_SYS_STAT_H 594 # include <sys/stat.h> 595 #endif 596 597 /* Test if something is a normal file. */ 598 #ifndef S_ISREG 599 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 600 #endif 601 602 /* Test if something is a directory. */ 603 #ifndef S_ISDIR 604 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 605 #endif 606 607 /* Test if something is a character special file. */ 608 #ifndef S_ISCHR 609 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 610 #endif 611 612 /* Test if something is a block special file. */ 613 #ifndef S_ISBLK 614 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 615 #endif 616 617 /* Test if something is a socket. */ 618 #ifndef S_ISSOCK 619 # ifdef S_IFSOCK 620 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 621 # else 622 # define S_ISSOCK(m) 0 623 # endif 624 #endif 625 626 /* Test if something is a FIFO. */ 627 #ifndef S_ISFIFO 628 # ifdef S_IFIFO 629 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 630 # else 631 # define S_ISFIFO(m) 0 632 # endif 633 #endif 634 635 /* Define well known filenos if the system does not define them. */ 636 #ifndef STDIN_FILENO 637 # define STDIN_FILENO 0 638 #endif 639 #ifndef STDOUT_FILENO 640 # define STDOUT_FILENO 1 641 #endif 642 #ifndef STDERR_FILENO 643 # define STDERR_FILENO 2 644 #endif 645 646 /* Some systems have mkdir that takes a single argument. */ 647 #ifdef MKDIR_TAKES_ONE_ARG 648 # define mkdir(a,b) mkdir (a) 649 #endif 650 651 #ifndef HAVE_KILL 652 # define kill(p,s) raise (s) 653 #endif 654 655 /* Provide a way to print an address via printf. */ 656 #ifndef HOST_PTR_PRINTF 657 #define HOST_PTR_PRINTF "%p" 658 #endif /* ! HOST_PTR_PRINTF */ 659 660 /* By default, colon separates directories in a path. */ 661 #ifndef PATH_SEPARATOR 662 #define PATH_SEPARATOR ':' 663 #endif 664 665 /* Filename handling macros. */ 666 #include "filenames.h" 667 668 /* These should be phased out in favor of IS_DIR_SEPARATOR, where possible. */ 669 #ifndef DIR_SEPARATOR 670 # define DIR_SEPARATOR '/' 671 # ifdef HAVE_DOS_BASED_FILE_SYSTEM 672 # define DIR_SEPARATOR_2 '\\' 673 # endif 674 #endif 675 676 #if defined (ENABLE_PLUGIN) && defined (HAVE_DLFCN_H) 677 /* If plugin support is enabled, we could use libdl. */ 678 #include <dlfcn.h> 679 #endif 680 681 /* Do not introduce a gmp.h dependency on the build system. */ 682 #ifndef GENERATOR_FILE 683 #include <gmp.h> 684 #endif 685 686 /* Get libiberty declarations. */ 687 #include "libiberty.h" 688 689 #undef FFS /* Some systems predefine this symbol; don't let it interfere. */ 690 #undef FLOAT /* Likewise. */ 691 #undef ABS /* Likewise. */ 692 #undef PC /* Likewise. */ 693 694 /* Provide a default for the HOST_BIT_BUCKET. 695 This suffices for POSIX-like hosts. */ 696 697 #ifndef HOST_BIT_BUCKET 698 #define HOST_BIT_BUCKET "/dev/null" 699 #endif 700 701 #ifndef offsetof 702 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) 703 #endif 704 705 /* Various error reporting routines want to use __FUNCTION__. */ 706 #if (GCC_VERSION < 2007) 707 #ifndef __FUNCTION__ 708 #define __FUNCTION__ "?" 709 #endif /* ! __FUNCTION__ */ 710 #endif 711 712 /* __builtin_expect(A, B) evaluates to A, but notifies the compiler that 713 the most likely value of A is B. This feature was added at some point 714 between 2.95 and 3.0. Let's use 3.0 as the lower bound for now. */ 715 #if (GCC_VERSION < 3000) 716 #define __builtin_expect(a, b) (a) 717 #endif 718 719 /* Redefine abort to report an internal error w/o coredump, and 720 reporting the location of the error in the source file. */ 721 extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; 722 #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) 723 724 /* Use gcc_assert(EXPR) to test invariants. */ 725 #if ENABLE_ASSERT_CHECKING 726 #define gcc_assert(EXPR) \ 727 ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0)) 728 #elif (GCC_VERSION >= 4005) 729 #define gcc_assert(EXPR) \ 730 ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0)) 731 #else 732 /* Include EXPR, so that unused variable warnings do not occur. */ 733 #define gcc_assert(EXPR) ((void)(0 && (EXPR))) 734 #endif 735 736 #ifdef ENABLE_CHECKING 737 #define gcc_checking_assert(EXPR) gcc_assert (EXPR) 738 #else 739 #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR))) 740 #endif 741 742 /* Use gcc_unreachable() to mark unreachable locations (like an 743 unreachable default case of a switch. Do not use gcc_assert(0). */ 744 #if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING 745 #define gcc_unreachable() __builtin_unreachable () 746 #else 747 #define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__)) 748 #endif 749 750 #if GCC_VERSION >= 3001 751 #define STATIC_CONSTANT_P(X) (__builtin_constant_p (X) && (X)) 752 #else 753 #define STATIC_CONSTANT_P(X) (false && (X)) 754 #endif 755 756 /* Until we can use C++11's static_assert. */ 757 #define STATIC_ASSERT(X) \ 758 typedef int assertion1[(X) ? 1 : -1] ATTRIBUTE_UNUSED 759 760 /* Provide a fake boolean type. We make no attempt to use the 761 C99 _Bool, as it may not be available in the bootstrap compiler, 762 and even if it is, it is liable to be buggy. 763 This must be after all inclusion of system headers, as some of 764 them will mess us up. */ 765 766 #undef TRUE 767 #undef FALSE 768 769 #ifdef __cplusplus 770 /* Obsolete. */ 771 # define TRUE true 772 # define FALSE false 773 #else /* !__cplusplus */ 774 # undef bool 775 # undef true 776 # undef false 777 778 # define bool unsigned char 779 # define true 1 780 # define false 0 781 782 /* Obsolete. */ 783 # define TRUE true 784 # define FALSE false 785 #endif /* !__cplusplus */ 786 787 /* Some compilers do not allow the use of unsigned char in bitfields. */ 788 #define BOOL_BITFIELD unsigned int 789 790 /* As the last action in this file, we poison the identifiers that 791 shouldn't be used. Note, luckily gcc-3.0's token-based integrated 792 preprocessor won't trip on poisoned identifiers that arrive from 793 the expansion of macros. E.g. #define strrchr rindex, won't error 794 if rindex is poisoned after this directive is issued and later on 795 strrchr is called. 796 797 Note: We define bypass macros for the few cases where we really 798 want to use the libc memory allocation routines. Otherwise we 799 insist you use the "x" versions from libiberty. */ 800 801 #define really_call_malloc malloc 802 #define really_call_calloc calloc 803 #define really_call_realloc realloc 804 805 #if defined(FLEX_SCANNER) || defined(YYBISON) || defined(YYBYACC) 806 /* Flex and bison use malloc and realloc. Yuk. Note that this means 807 really_call_* cannot be used in a .l or .y file. */ 808 #define malloc xmalloc 809 #define realloc xrealloc 810 #endif 811 812 #if (GCC_VERSION >= 3000) 813 814 /* Note autoconf checks for prototype declarations and includes 815 system.h while doing so. Only poison these tokens if actually 816 compiling gcc, so that the autoconf declaration tests for malloc 817 etc don't spuriously fail. */ 818 #ifdef IN_GCC 819 #undef calloc 820 #undef strdup 821 #pragma GCC poison calloc strdup 822 823 #if !defined(FLEX_SCANNER) && !defined(YYBISON) 824 #undef malloc 825 #undef realloc 826 #pragma GCC poison malloc realloc 827 #endif 828 829 /* The %m format should be used when GCC's main diagnostic functions 830 supporting %m are available, and xstrerror from libiberty 831 otherwise. */ 832 #undef strerror 833 #pragma GCC poison strerror 834 835 /* loc_t is defined on some systems and too inviting for some 836 programmers to avoid. */ 837 #undef loc_t 838 #pragma GCC poison loc_t 839 840 /* Old target macros that have moved to the target hooks structure. */ 841 #pragma GCC poison ASM_OPEN_PAREN ASM_CLOSE_PAREN \ 842 FUNCTION_PROLOGUE FUNCTION_EPILOGUE \ 843 FUNCTION_END_PROLOGUE FUNCTION_BEGIN_EPILOGUE \ 844 DECL_MACHINE_ATTRIBUTES COMP_TYPE_ATTRIBUTES INSERT_ATTRIBUTES \ 845 VALID_MACHINE_DECL_ATTRIBUTE VALID_MACHINE_TYPE_ATTRIBUTE \ 846 SET_DEFAULT_TYPE_ATTRIBUTES SET_DEFAULT_DECL_ATTRIBUTES \ 847 MERGE_MACHINE_TYPE_ATTRIBUTES MERGE_MACHINE_DECL_ATTRIBUTES \ 848 MD_INIT_BUILTINS MD_EXPAND_BUILTIN ASM_OUTPUT_CONSTRUCTOR \ 849 ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \ 850 WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \ 851 ENCODE_SECTION_INFO STRIP_NAME_ENCODING ASM_GLOBALIZE_LABEL \ 852 ASM_OUTPUT_MI_THUNK CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS \ 853 ADDRESS_COST MACHINE_DEPENDENT_REORG ASM_FILE_START ASM_FILE_END \ 854 ASM_SIMPLIFY_DWARF_ADDR INIT_TARGET_OPTABS INIT_SUBTARGET_OPTABS \ 855 INIT_GOFAST_OPTABS MULSI3_LIBCALL MULDI3_LIBCALL DIVSI3_LIBCALL \ 856 DIVDI3_LIBCALL UDIVSI3_LIBCALL UDIVDI3_LIBCALL MODSI3_LIBCALL \ 857 MODDI3_LIBCALL UMODSI3_LIBCALL UMODDI3_LIBCALL BUILD_VA_LIST_TYPE \ 858 PRETEND_OUTGOING_VARARGS_NAMED STRUCT_VALUE_INCOMING_REGNUM \ 859 ASM_OUTPUT_SECTION_NAME PROMOTE_FUNCTION_ARGS PROMOTE_FUNCTION_MODE \ 860 STRUCT_VALUE_INCOMING STRICT_ARGUMENT_NAMING \ 861 PROMOTE_FUNCTION_RETURN PROMOTE_PROTOTYPES STRUCT_VALUE_REGNUM \ 862 SETUP_INCOMING_VARARGS EXPAND_BUILTIN_SAVEREGS \ 863 DEFAULT_SHORT_ENUMS SPLIT_COMPLEX_ARGS MD_ASM_CLOBBERS \ 864 HANDLE_PRAGMA_REDEFINE_EXTNAME HANDLE_PRAGMA_EXTERN_PREFIX \ 865 MUST_PASS_IN_STACK FUNCTION_ARG_PASS_BY_REFERENCE \ 866 VECTOR_MODE_SUPPORTED_P TARGET_SUPPORTS_HIDDEN \ 867 FUNCTION_ARG_PARTIAL_NREGS ASM_OUTPUT_DWARF_DTPREL \ 868 ALLOCATE_INITIAL_VALUE LEGITIMIZE_ADDRESS FRAME_POINTER_REQUIRED \ 869 CAN_ELIMINATE TRAMPOLINE_TEMPLATE INITIALIZE_TRAMPOLINE \ 870 TRAMPOLINE_ADJUST_ADDRESS STATIC_CHAIN STATIC_CHAIN_INCOMING \ 871 RETURN_POPS_ARGS UNITS_PER_SIMD_WORD OVERRIDE_OPTIONS \ 872 OPTIMIZATION_OPTIONS CLASS_LIKELY_SPILLED_P \ 873 USING_SJLJ_EXCEPTIONS TARGET_UNWIND_INFO \ 874 LABEL_ALIGN_MAX_SKIP LOOP_ALIGN_MAX_SKIP \ 875 LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP JUMP_ALIGN_MAX_SKIP \ 876 CAN_DEBUG_WITHOUT_FP UNLIKELY_EXECUTED_TEXT_SECTION_NAME \ 877 HOT_TEXT_SECTION_NAME LEGITIMATE_CONSTANT_P ALWAYS_STRIP_DOTDOT \ 878 OUTPUT_ADDR_CONST_EXTRA SMALL_REGISTER_CLASSES ASM_OUTPUT_IDENT \ 879 ASM_BYTE_OP MEMBER_TYPE_FORCES_BLK LIBGCC2_HAS_SF_MODE \ 880 LIBGCC2_HAS_DF_MODE LIBGCC2_HAS_XF_MODE LIBGCC2_HAS_TF_MODE \ 881 CLEAR_BY_PIECES_P MOVE_BY_PIECES_P SET_BY_PIECES_P \ 882 STORE_BY_PIECES_P 883 884 /* Target macros only used for code built for the target, that have 885 moved to libgcc-tm.h or have never been present elsewhere. */ 886 #pragma GCC poison DECLARE_LIBRARY_RENAMES LIBGCC2_GNU_PREFIX \ 887 MD_UNWIND_SUPPORT MD_FROB_UPDATE_CONTEXT ENABLE_EXECUTE_STACK \ 888 REG_VALUE_IN_UNWIND_CONTEXT ASSUME_EXTENDED_UNWIND_CONTEXT 889 890 /* Other obsolete target macros, or macros that used to be in target 891 headers and were not used, and may be obsolete or may never have 892 been used. */ 893 #pragma GCC poison INT_ASM_OP ASM_OUTPUT_EH_REGION_BEG CPP_PREDEFINES \ 894 ASM_OUTPUT_EH_REGION_END ASM_OUTPUT_LABELREF_AS_INT SMALL_STACK \ 895 DOESNT_NEED_UNWINDER EH_TABLE_LOOKUP OBJC_SELECTORS_WITHOUT_LABELS \ 896 OMIT_EH_TABLE EASY_DIV_EXPR IMPLICIT_FIX_EXPR \ 897 LONGJMP_RESTORE_FROM_STACK MAX_INT_TYPE_SIZE ASM_IDENTIFY_GCC \ 898 STDC_VALUE TRAMPOLINE_ALIGN ASM_IDENTIFY_GCC_AFTER_SOURCE \ 899 SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET DWARF_LINE_MIN_INSTR_LENGTH \ 900 TRADITIONAL_RETURN_FLOAT NO_BUILTIN_SIZE_TYPE \ 901 NO_BUILTIN_PTRDIFF_TYPE NO_BUILTIN_WCHAR_TYPE NO_BUILTIN_WINT_TYPE \ 902 BLOCK_PROFILER BLOCK_PROFILER_CODE FUNCTION_BLOCK_PROFILER \ 903 FUNCTION_BLOCK_PROFILER_EXIT MACHINE_STATE_SAVE \ 904 MACHINE_STATE_RESTORE SCCS_DIRECTIVE SECTION_ASM_OP BYTEORDER \ 905 ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL HOST_WORDS_BIG_ENDIAN \ 906 OBJC_PROLOGUE ALLOCATE_TRAMPOLINE HANDLE_PRAGMA ROUND_TYPE_SIZE \ 907 ROUND_TYPE_SIZE_UNIT CONST_SECTION_ASM_OP CRT_GET_RFIB_TEXT \ 908 DBX_LBRAC_FIRST DBX_OUTPUT_ENUM DBX_OUTPUT_SOURCE_FILENAME \ 909 DBX_WORKING_DIRECTORY INSN_CACHE_DEPTH INSN_CACHE_SIZE \ 910 INSN_CACHE_LINE_WIDTH INIT_SECTION_PREAMBLE NEED_ATEXIT ON_EXIT \ 911 EXIT_BODY OBJECT_FORMAT_ROSE MULTIBYTE_CHARS MAP_CHARACTER \ 912 LIBGCC_NEEDS_DOUBLE FINAL_PRESCAN_LABEL DEFAULT_CALLER_SAVES \ 913 LOAD_ARGS_REVERSED MAX_INTEGER_COMPUTATION_MODE \ 914 CONVERT_HARD_REGISTER_TO_SSA_P ASM_OUTPUT_MAIN_SOURCE_FILENAME \ 915 FIRST_INSN_ADDRESS TEXT_SECTION SHARED_BSS_SECTION_ASM_OP \ 916 PROMOTED_MODE EXPAND_BUILTIN_VA_END \ 917 LINKER_DOES_NOT_WORK_WITH_DWARF2 FUNCTION_ARG_KEEP_AS_REFERENCE \ 918 GIV_SORT_CRITERION MAX_LONG_TYPE_SIZE MAX_LONG_DOUBLE_TYPE_SIZE \ 919 MAX_WCHAR_TYPE_SIZE SHARED_SECTION_ASM_OP INTEGRATE_THRESHOLD \ 920 FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE \ 921 TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE \ 922 DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE \ 923 SUNOS4_SHARED_LIBRARIES PROMOTE_FOR_CALL_ONLY \ 924 SPACE_AFTER_L_OPTION NO_RECURSIVE_FUNCTION_CSE \ 925 DEFAULT_MAIN_RETURN TARGET_MEM_FUNCTIONS EXPAND_BUILTIN_VA_ARG \ 926 COLLECT_PARSE_FLAG DWARF2_GENERATE_TEXT_SECTION_LABEL WINNING_GDB \ 927 ASM_OUTPUT_FILENAME ASM_OUTPUT_SOURCE_LINE FILE_NAME_JOINER \ 928 GDB_INV_REF_REGPARM_STABS_LETTER DBX_MEMPARM_STABS_LETTER \ 929 PUT_SDB_SRC_FILE STABS_GCC_MARKER DBX_OUTPUT_FUNCTION_END \ 930 DBX_OUTPUT_GCC_MARKER DBX_FINISH_SYMBOL SDB_GENERATE_FAKE \ 931 NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE \ 932 CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0 \ 933 TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT \ 934 LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE \ 935 TARGET_OPTIONS TARGET_SWITCHES EXTRA_CC_MODES FINALIZE_PIC \ 936 PREDICATE_CODES SPECIAL_MODE_PREDICATES UNALIGNED_WORD_ASM_OP \ 937 EXTRA_SECTIONS EXTRA_SECTION_FUNCTIONS READONLY_DATA_SECTION \ 938 TARGET_ASM_EXCEPTION_SECTION TARGET_ASM_EH_FRAME_SECTION \ 939 SMALL_ARG_MAX ASM_OUTPUT_SHARED_BSS ASM_OUTPUT_SHARED_COMMON \ 940 ASM_OUTPUT_SHARED_LOCAL ASM_MAKE_LABEL_LINKONCE \ 941 STACK_CHECK_PROBE_INTERVAL STACK_CHECK_PROBE_LOAD \ 942 ORDER_REGS_FOR_LOCAL_ALLOC FUNCTION_OUTGOING_VALUE \ 943 ASM_DECLARE_CONSTANT_NAME MODIFY_TARGET_NAME SWITCHES_NEED_SPACES \ 944 SWITCH_CURTAILS_COMPILATION SWITCH_TAKES_ARG WORD_SWITCH_TAKES_ARG \ 945 TARGET_OPTION_TRANSLATE_TABLE HANDLE_PRAGMA_PACK_PUSH_POP \ 946 HANDLE_SYSV_PRAGMA HANDLE_PRAGMA_WEAK CONDITIONAL_REGISTER_USAGE \ 947 FUNCTION_ARG_BOUNDARY MUST_USE_SJLJ_EXCEPTIONS US_SOFTWARE_GOFAST \ 948 USING_SVR4_H SVR4_ASM_SPEC FUNCTION_ARG FUNCTION_ARG_ADVANCE \ 949 FUNCTION_INCOMING_ARG IRA_COVER_CLASSES TARGET_VERSION \ 950 MACHINE_TYPE TARGET_HAS_TARGETCM ASM_OUTPUT_BSS \ 951 SETJMP_VIA_SAVE_AREA FORBIDDEN_INC_DEC_CLASSES \ 952 PREFERRED_OUTPUT_RELOAD_CLASS SYSTEM_INCLUDE_DIR \ 953 STANDARD_INCLUDE_DIR STANDARD_INCLUDE_COMPONENT \ 954 LINK_ELIMINATE_DUPLICATE_LDIRECTORIES MIPS_DEBUGGING_INFO \ 955 IDENT_ASM_OP ALL_COP_ADDITIONAL_REGISTER_NAMES DBX_OUTPUT_LBRAC \ 956 DBX_OUTPUT_NFUN DBX_OUTPUT_RBRAC RANGE_TEST_NON_SHORT_CIRCUIT \ 957 REAL_VALUE_TRUNCATE REVERSE_CONDEXEC_PREDICATES_P \ 958 TARGET_ALIGN_ANON_BITFIELDS TARGET_NARROW_VOLATILE_BITFIELDS \ 959 IDENT_ASM_OP UNALIGNED_SHORT_ASM_OP UNALIGNED_INT_ASM_OP \ 960 UNALIGNED_LONG_ASM_OP UNALIGNED_DOUBLE_INT_ASM_OP \ 961 USE_COMMON_FOR_ONE_ONLY IFCVT_EXTRA_FIELDS IFCVT_INIT_EXTRA_FIELDS \ 962 CASE_USE_BIT_TESTS FIXUNS_TRUNC_LIKE_FIX_TRUNC \ 963 GO_IF_MODE_DEPENDENT_ADDRESS DELAY_SLOTS_FOR_EPILOGUE \ 964 ELIGIBLE_FOR_EPILOGUE_DELAY TARGET_C99_FUNCTIONS TARGET_HAS_SINCOS \ 965 REG_CLASS_FROM_LETTER CONST_OK_FOR_LETTER_P \ 966 CONST_DOUBLE_OK_FOR_LETTER_P EXTRA_CONSTRAINT \ 967 REG_CLASS_FROM_CONSTRAINT REG_CLASS_FOR_CONSTRAINT \ 968 EXTRA_CONSTRAINT_STR EXTRA_MEMORY_CONSTRAINT \ 969 EXTRA_ADDRESS_CONSTRAINT CONST_DOUBLE_OK_FOR_CONSTRAINT_P \ 970 CALLER_SAVE_PROFITABLE LARGEST_EXPONENT_IS_NORMAL \ 971 ROUND_TOWARDS_ZERO SF_SIZE DF_SIZE XF_SIZE TF_SIZE LIBGCC2_TF_CEXT \ 972 LIBGCC2_LONG_DOUBLE_TYPE_SIZE 973 974 /* Hooks that are no longer used. */ 975 #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ 976 LANG_HOOKS_MARK_TREE LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES \ 977 LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \ 978 LANG_HOOKS_PUSHLEVEL LANG_HOOKS_SET_BLOCK \ 979 LANG_HOOKS_MAYBE_BUILD_CLEANUP LANG_HOOKS_UPDATE_DECL_AFTER_SAVING \ 980 LANG_HOOKS_POPLEVEL LANG_HOOKS_TRUTHVALUE_CONVERSION \ 981 TARGET_PROMOTE_FUNCTION_ARGS TARGET_PROMOTE_FUNCTION_RETURN \ 982 LANG_HOOKS_MISSING_ARGUMENT LANG_HOOKS_HASH_TYPES \ 983 TARGET_HANDLE_OFAST TARGET_OPTION_OPTIMIZATION \ 984 TARGET_IRA_COVER_CLASSES TARGET_HELP \ 985 TARGET_HANDLE_PRAGMA_EXTERN_PREFIX \ 986 TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN \ 987 TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD \ 988 989 /* Arrays that were deleted in favor of a functional interface. */ 990 #pragma GCC poison built_in_decls implicit_built_in_decls 991 992 /* Hooks into libgcc2. */ 993 #pragma GCC poison LIBGCC2_DOUBLE_TYPE_SIZE LIBGCC2_WORDS_BIG_ENDIAN \ 994 LIBGCC2_FLOAT_WORDS_BIG_ENDIAN 995 996 /* Miscellaneous macros that are no longer used. */ 997 #pragma GCC poison USE_MAPPED_LOCATION GET_ENVIRONMENT 998 999 /* Libiberty macros that are no longer used in GCC. */ 1000 #undef ANSI_PROTOTYPES 1001 #undef PTR_CONST 1002 #undef LONG_DOUBLE 1003 #undef VPARAMS 1004 #undef VA_OPEN 1005 #undef VA_FIXEDARG 1006 #undef VA_CLOSE 1007 #undef VA_START 1008 #pragma GCC poison ANSI_PROTOTYPES PTR_CONST LONG_DOUBLE VPARAMS VA_OPEN \ 1009 VA_FIXEDARG VA_CLOSE VA_START 1010 #endif /* IN_GCC */ 1011 1012 /* Front ends should never have to include middle-end headers. Enforce 1013 this by poisoning the header double-include protection defines. */ 1014 #ifdef IN_GCC_FRONTEND 1015 #pragma GCC poison GCC_RTL_H GCC_EXCEPT_H GCC_EXPR_H 1016 #endif 1017 1018 /* Note: not all uses of the `index' token (e.g. variable names and 1019 structure members) have been eliminated. */ 1020 #undef bcopy 1021 #undef bzero 1022 #undef bcmp 1023 #undef rindex 1024 #pragma GCC poison bcopy bzero bcmp rindex 1025 1026 #endif /* GCC >= 3.0 */ 1027 1028 /* This macro allows casting away const-ness to pass -Wcast-qual 1029 warnings. DO NOT USE THIS UNLESS YOU REALLY HAVE TO! It should 1030 only be used in certain specific cases. One valid case is where 1031 the C standard definitions or prototypes force you to. E.g. if you 1032 need to free a const object, or if you pass a const string to 1033 execv, et al. Another valid use would be in an allocation function 1034 that creates const objects that need to be initialized. In some 1035 cases we have non-const functions that return the argument 1036 (e.g. next_nonnote_insn). Rather than create const shadow 1037 functions, we can cast away const-ness in calling these interfaces 1038 if we're careful to verify that the called function does indeed not 1039 modify its argument and the return value is only used in a const 1040 context. (This can be somewhat dangerous as these assumptions can 1041 change after the fact). Beyond these uses, most other cases of 1042 using this macro should be viewed with extreme caution. */ 1043 1044 #ifdef __cplusplus 1045 #define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X)) 1046 #else 1047 #if defined(__GNUC__) && GCC_VERSION > 4000 1048 /* GCC 4.0.x has a bug where it may ICE on this expression, 1049 so does GCC 3.4.x (PR17436). */ 1050 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) 1051 #elif defined(__GNUC__) 1052 static inline char * 1053 helper_const_non_const_cast (const char *p) 1054 { 1055 union { 1056 const char *const_c; 1057 char *c; 1058 } val; 1059 val.const_c = p; 1060 return val.c; 1061 } 1062 1063 #define CONST_CAST2(TOTYPE,FROMTYPE,X) \ 1064 ((TOTYPE) helper_const_non_const_cast ((const char *) (FROMTYPE) (X))) 1065 #else 1066 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X)) 1067 #endif 1068 #endif 1069 #define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X)) 1070 #define CONST_CAST_TREE(X) CONST_CAST (union tree_node *, (X)) 1071 #define CONST_CAST_RTX(X) CONST_CAST (struct rtx_def *, (X)) 1072 #define CONST_CAST_RTX_INSN(X) CONST_CAST (struct rtx_insn *, (X)) 1073 #define CONST_CAST_BB(X) CONST_CAST (struct basic_block_def *, (X)) 1074 #define CONST_CAST_GIMPLE(X) CONST_CAST (struct gimple_statement_base *, (X)) 1075 1076 /* Activate certain diagnostics as warnings (not errors via the 1077 -Werror flag). */ 1078 #if GCC_VERSION >= 4003 1079 /* If asserts are disabled, activate -Wuninitialized as a warning (not 1080 an error/-Werror). */ 1081 #ifndef ENABLE_ASSERT_CHECKING 1082 #pragma GCC diagnostic warning "-Wuninitialized" 1083 #endif 1084 #endif 1085 1086 #ifdef ENABLE_VALGRIND_ANNOTATIONS 1087 # ifdef HAVE_VALGRIND_MEMCHECK_H 1088 # include <valgrind/memcheck.h> 1089 # elif defined HAVE_MEMCHECK_H 1090 # include <memcheck.h> 1091 # else 1092 # include <valgrind.h> 1093 # endif 1094 /* Compatibility macros to let valgrind 3.1 work. */ 1095 # ifndef VALGRIND_MAKE_MEM_NOACCESS 1096 # define VALGRIND_MAKE_MEM_NOACCESS VALGRIND_MAKE_NOACCESS 1097 # endif 1098 # ifndef VALGRIND_MAKE_MEM_DEFINED 1099 # define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_READABLE 1100 # endif 1101 # ifndef VALGRIND_MAKE_MEM_UNDEFINED 1102 # define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_WRITABLE 1103 # endif 1104 #else 1105 /* Avoid #ifdef:s when we can help it. */ 1106 #define VALGRIND_DISCARD(x) 1107 #define VALGRIND_MALLOCLIKE_BLOCK(w,x,y,z) 1108 #define VALGRIND_FREELIKE_BLOCK(x,y) 1109 #endif 1110 1111 /* In LTO -fwhole-program build we still want to keep the debug functions available 1112 for debugger. Mark them as used to prevent removal. */ 1113 #if (GCC_VERSION > 4000) 1114 #define DEBUG_FUNCTION __attribute__ ((__used__)) 1115 #define DEBUG_VARIABLE __attribute__ ((__used__)) 1116 #else 1117 #define DEBUG_FUNCTION 1118 #define DEBUG_VARIABLE 1119 #endif 1120 1121 /* General macro to extract bit Y of X. */ 1122 #define TEST_BIT(X, Y) (((X) >> (Y)) & 1) 1123 1124 /* Get definitions of HOST_WIDE_INT. */ 1125 #include "hwint.h" 1126 1127 #endif /* ! GCC_SYSTEM_H */ 1128