system.h revision 132718
190075Sobrien/* Get common system includes and various definitions and declarations based 290075Sobrien on autoconf macros. 3132718Skan Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 4132718Skan Free Software Foundation, Inc. 550397Sobrien 690075SobrienThis file is part of GCC. 750397Sobrien 890075SobrienGCC is free software; you can redistribute it and/or modify it under 990075Sobrienthe terms of the GNU General Public License as published by the Free 1090075SobrienSoftware Foundation; either version 2, or (at your option) any later 1190075Sobrienversion. 1252284Sobrien 1390075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY 1490075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or 1590075SobrienFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1690075Sobrienfor more details. 1752284Sobrien 1852284SobrienYou should have received a copy of the GNU General Public License 1990075Sobrienalong with GCC; see the file COPYING. If not, write to the Free 2090075SobrienSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 2190075Sobrien02111-1307, USA. */ 2252284Sobrien 2350397Sobrien 2490075Sobrien#ifndef GCC_SYSTEM_H 2590075Sobrien#define GCC_SYSTEM_H 2690075Sobrien 27132718Skan/* We must include stdarg.h before stdio.h. */ 2852284Sobrien#include <stdarg.h> 2952284Sobrien 3090075Sobrien#ifndef va_copy 3190075Sobrien# ifdef __va_copy 3290075Sobrien# define va_copy(d,s) __va_copy((d),(s)) 3390075Sobrien# else 3490075Sobrien# define va_copy(d,s) ((d) = (s)) 3590075Sobrien# endif 3690075Sobrien#endif 3790075Sobrien 3890075Sobrien#ifdef HAVE_STDDEF_H 3990075Sobrien# include <stddef.h> 4090075Sobrien#endif 4190075Sobrien 4250397Sobrien#include <stdio.h> 4350397Sobrien 4450397Sobrien/* Define a generic NULL if one hasn't already been defined. */ 4550397Sobrien#ifndef NULL 4650397Sobrien#define NULL 0 4750397Sobrien#endif 4850397Sobrien 4952284Sobrien/* The compiler is not a multi-threaded application and therefore we 5090075Sobrien do not have to use the locking functions. In fact, using the locking 5190075Sobrien functions can cause the compiler to be significantly slower under 5290075Sobrien I/O bound conditions (such as -g -O0 on very large source files). 5352284Sobrien 5490075Sobrien HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio 5590075Sobrien code is multi-thread safe by default. If it is set to 0, then do 5690075Sobrien not worry about using the _unlocked functions. 57132718Skan 5890075Sobrien fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are 5990075Sobrien extensions and need to be prototyped by hand (since we do not 6090075Sobrien define _GNU_SOURCE). */ 6152284Sobrien 6290075Sobrien#if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED 6390075Sobrien 6490075Sobrien# ifdef HAVE_PUTC_UNLOCKED 6590075Sobrien# undef putc 6690075Sobrien# define putc(C, Stream) putc_unlocked (C, Stream) 6752284Sobrien# endif 6890075Sobrien# ifdef HAVE_FPUTC_UNLOCKED 6990075Sobrien# undef fputc 7090075Sobrien# define fputc(C, Stream) fputc_unlocked (C, Stream) 7190075Sobrien# endif 7252284Sobrien 7390075Sobrien# ifdef HAVE_FPUTS_UNLOCKED 7490075Sobrien# undef fputs 7590075Sobrien# define fputs(String, Stream) fputs_unlocked (String, Stream) 7690075Sobrien# if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED 77132718Skanextern int fputs_unlocked (const char *, FILE *); 7890075Sobrien# endif 7990075Sobrien# endif 8090075Sobrien# ifdef HAVE_FWRITE_UNLOCKED 8190075Sobrien# undef fwrite 8290075Sobrien# define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream) 8390075Sobrien# if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED 84132718Skanextern int fwrite_unlocked (const void *, size_t, size_t, FILE *); 8590075Sobrien# endif 8690075Sobrien# endif 8790075Sobrien# ifdef HAVE_FPRINTF_UNLOCKED 8890075Sobrien# undef fprintf 8990075Sobrien/* We can't use a function-like macro here because we don't know if 9090075Sobrien we have varargs macros. */ 9190075Sobrien# define fprintf fprintf_unlocked 9290075Sobrien# if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED 93132718Skanextern int fprintf_unlocked (FILE *, const char *, ...); 9490075Sobrien# endif 9590075Sobrien# endif 9650397Sobrien 9750397Sobrien#endif 9850397Sobrien 99132718Skan/* ??? Glibc's fwrite/fread_unlocked macros cause 100132718Skan "warning: signed and unsigned type in conditional expression". */ 101132718Skan#undef fread_unlocked 102132718Skan#undef fwrite_unlocked 103132718Skan 10490075Sobrien/* There are an extraordinary number of issues with <ctype.h>. 10590075Sobrien The last straw is that it varies with the locale. Use libiberty's 10690075Sobrien replacement instead. */ 10790075Sobrien#include <safe-ctype.h> 10850397Sobrien 10990075Sobrien#include <sys/types.h> 11050397Sobrien 11150397Sobrien#include <errno.h> 11250397Sobrien 11390075Sobrien#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO 11450397Sobrienextern int errno; 11550397Sobrien#endif 11650397Sobrien 117132718Skan/* Some of glibc's string inlines cause warnings. Plus we'd rather 118132718Skan rely on (and therefore test) GCC's string builtins. */ 119132718Skan#define __NO_STRING_INLINES 120132718Skan 12152284Sobrien#ifdef STRING_WITH_STRINGS 12250397Sobrien# include <string.h> 12352284Sobrien# include <strings.h> 12450397Sobrien#else 12552284Sobrien# ifdef HAVE_STRING_H 12652284Sobrien# include <string.h> 12752284Sobrien# else 12852284Sobrien# ifdef HAVE_STRINGS_H 12952284Sobrien# include <strings.h> 13052284Sobrien# endif 13150397Sobrien# endif 13250397Sobrien#endif 13350397Sobrien 13450397Sobrien#ifdef HAVE_STDLIB_H 13550397Sobrien# include <stdlib.h> 13650397Sobrien#endif 13750397Sobrien 13890075Sobrien/* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and 13990075Sobrien FATAL_EXIT_CODE to EXIT_SUCCESS and EXIT_FAILURE respectively, 14090075Sobrien or 0 and 1 if those macros are not defined. */ 14190075Sobrien#ifndef SUCCESS_EXIT_CODE 14290075Sobrien# ifdef EXIT_SUCCESS 14390075Sobrien# define SUCCESS_EXIT_CODE EXIT_SUCCESS 14490075Sobrien# else 14590075Sobrien# define SUCCESS_EXIT_CODE 0 14690075Sobrien# endif 14790075Sobrien#endif 14890075Sobrien 14990075Sobrien#ifndef FATAL_EXIT_CODE 15090075Sobrien# ifdef EXIT_FAILURE 15190075Sobrien# define FATAL_EXIT_CODE EXIT_FAILURE 15290075Sobrien# else 15390075Sobrien# define FATAL_EXIT_CODE 1 15490075Sobrien# endif 15590075Sobrien#endif 15690075Sobrien 15750397Sobrien#ifdef HAVE_UNISTD_H 15850397Sobrien# include <unistd.h> 15950397Sobrien#endif 16050397Sobrien 16150397Sobrien#ifdef HAVE_SYS_PARAM_H 16250397Sobrien# include <sys/param.h> 16390075Sobrien/* We use this identifier later and it appears in some vendor param.h's. */ 16490075Sobrien# undef PREFETCH 16550397Sobrien#endif 16650397Sobrien 16750397Sobrien#if HAVE_LIMITS_H 16850397Sobrien# include <limits.h> 16950397Sobrien#endif 17050397Sobrien 17190075Sobrien/* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ 17290075Sobrien#include "hwint.h" 17352284Sobrien 17490075Sobrien/* A macro to determine whether a VALUE lies inclusively within a 17590075Sobrien certain range without evaluating the VALUE more than once. This 17690075Sobrien macro won't warn if the VALUE is unsigned and the LOWER bound is 17790075Sobrien zero, as it would e.g. with "VALUE >= 0 && ...". Note the LOWER 17890075Sobrien bound *is* evaluated twice, and LOWER must not be greater than 17990075Sobrien UPPER. However the bounds themselves can be either positive or 18090075Sobrien negative. */ 18190075Sobrien#define IN_RANGE(VALUE, LOWER, UPPER) \ 18290075Sobrien ((unsigned HOST_WIDE_INT) ((VALUE) - (LOWER)) <= ((UPPER) - (LOWER))) 18352284Sobrien 18490075Sobrien/* Infrastructure for defining missing _MAX and _MIN macros. Note that 18590075Sobrien macros defined with these cannot be used in #if. */ 18690075Sobrien 18790075Sobrien/* The extra casts work around common compiler bugs. */ 18890075Sobrien#define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 18990075Sobrien/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. 19090075Sobrien It is necessary at least when t == time_t. */ 19190075Sobrien#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ 19290075Sobrien ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0)) 19390075Sobrien#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) 19490075Sobrien 19590075Sobrien/* Use that infrastructure to provide a few constants. */ 19690075Sobrien#ifndef UCHAR_MAX 19790075Sobrien# define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char) 19890075Sobrien#endif 19990075Sobrien 20050397Sobrien#ifdef TIME_WITH_SYS_TIME 20150397Sobrien# include <sys/time.h> 20250397Sobrien# include <time.h> 20350397Sobrien#else 20450397Sobrien# if HAVE_SYS_TIME_H 20550397Sobrien# include <sys/time.h> 20650397Sobrien# else 20750397Sobrien# ifdef HAVE_TIME_H 20850397Sobrien# include <time.h> 20950397Sobrien# endif 21050397Sobrien# endif 21150397Sobrien#endif 21250397Sobrien 21350397Sobrien#ifdef HAVE_FCNTL_H 21450397Sobrien# include <fcntl.h> 21550397Sobrien#else 21650397Sobrien# ifdef HAVE_SYS_FILE_H 21750397Sobrien# include <sys/file.h> 21850397Sobrien# endif 21950397Sobrien#endif 22050397Sobrien 22150397Sobrien#ifndef SEEK_SET 22250397Sobrien# define SEEK_SET 0 22350397Sobrien# define SEEK_CUR 1 22450397Sobrien# define SEEK_END 2 22550397Sobrien#endif 22650397Sobrien#ifndef F_OK 22750397Sobrien# define F_OK 0 22850397Sobrien# define X_OK 1 22950397Sobrien# define W_OK 2 23050397Sobrien# define R_OK 4 23150397Sobrien#endif 23250397Sobrien#ifndef O_RDONLY 23350397Sobrien# define O_RDONLY 0 23450397Sobrien#endif 23550397Sobrien#ifndef O_WRONLY 23650397Sobrien# define O_WRONLY 1 23750397Sobrien#endif 23850397Sobrien 23952284Sobrien/* Some systems define these in, e.g., param.h. We undefine these names 24052284Sobrien here to avoid the warnings. We prefer to use our definitions since we 24152284Sobrien know they are correct. */ 24250397Sobrien 24352284Sobrien#undef MIN 24452284Sobrien#undef MAX 24552284Sobrien#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) 24652284Sobrien#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) 24750397Sobrien 24890075Sobrien/* Returns the least number N such that N * Y >= X. */ 24990075Sobrien#define CEIL(x,y) (((x) + (y) - 1) / (y)) 25090075Sobrien 25152284Sobrien#ifdef HAVE_SYS_WAIT_H 25252284Sobrien#include <sys/wait.h> 25352284Sobrien#endif 25452284Sobrien 25552284Sobrien#ifndef WIFSIGNALED 25652284Sobrien#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) 25752284Sobrien#endif 25852284Sobrien#ifndef WTERMSIG 25952284Sobrien#define WTERMSIG(S) ((S) & 0x7f) 26052284Sobrien#endif 26152284Sobrien#ifndef WIFEXITED 26252284Sobrien#define WIFEXITED(S) (((S) & 0xff) == 0) 26352284Sobrien#endif 26452284Sobrien#ifndef WEXITSTATUS 26552284Sobrien#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) 26652284Sobrien#endif 26752284Sobrien#ifndef WSTOPSIG 26852284Sobrien#define WSTOPSIG WEXITSTATUS 26952284Sobrien#endif 270117395Skan#ifndef WCOREDUMP 271117395Skan#define WCOREDUMP(S) ((S) & WCOREFLG) 272117395Skan#endif 273117395Skan#ifndef WCOREFLG 274117395Skan#define WCOREFLG 0200 275117395Skan#endif 27652284Sobrien 27790075Sobrien/* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they 27890075Sobrien are defined to 0 then we must provide the relevant declaration 27990075Sobrien here. These checks will be in the undefined state while configure 28090075Sobrien is running so be careful to test "defined (HAVE_DECL_*)". */ 28152284Sobrien 28290075Sobrien#if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF 283132718Skanextern double atof (const char *); 28450397Sobrien#endif 28550397Sobrien 28690075Sobrien#if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL 287132718Skanextern long atol (const char *); 28850397Sobrien#endif 28950397Sobrien 29090075Sobrien#if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE 291132718Skanextern void free (void *); 29250397Sobrien#endif 29350397Sobrien 29490075Sobrien#if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD 295132718Skanextern char *getcwd (char *, size_t); 29650397Sobrien#endif 29750397Sobrien 29890075Sobrien#if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV 299132718Skanextern char *getenv (const char *); 30050397Sobrien#endif 30150397Sobrien 30290075Sobrien#if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT 303132718Skanextern int getopt (int, char * const *, const char *); 30450397Sobrien#endif 30550397Sobrien 30690075Sobrien#if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD 307132718Skanextern char *getwd (char *); 30850397Sobrien#endif 30950397Sobrien 31090075Sobrien#if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK 311132718Skanextern void *sbrk (int); 31250397Sobrien#endif 31350397Sobrien 31490075Sobrien#if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR 315132718Skanextern char *strstr (const char *, const char *); 31650397Sobrien#endif 31750397Sobrien 31890075Sobrien#ifdef HAVE_MALLOC_H 31990075Sobrien#include <malloc.h> 32050397Sobrien#endif 32150397Sobrien 32290075Sobrien#if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC 323132718Skanextern void *malloc (size_t); 32450397Sobrien#endif 32550397Sobrien 32690075Sobrien#if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC 327132718Skanextern void *calloc (size_t, size_t); 32850397Sobrien#endif 32950397Sobrien 33090075Sobrien#if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC 331132718Skanextern void *realloc (void *, size_t); 33252284Sobrien#endif 33352284Sobrien 33490075Sobrien/* If the system doesn't provide strsignal, we get it defined in 33590075Sobrien libiberty but no declaration is supplied. */ 336132718Skan#if !defined (HAVE_STRSIGNAL) \ 337132718Skan || (defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL) 33890075Sobrien# ifndef strsignal 339132718Skanextern const char *strsignal (int); 34050397Sobrien# endif 34190075Sobrien#endif 34250397Sobrien 34350397Sobrien#ifdef HAVE_GETRLIMIT 34490075Sobrien# if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT 34550397Sobrien# ifndef getrlimit 34690075Sobrienstruct rlimit; 347132718Skanextern int getrlimit (int, struct rlimit *); 34850397Sobrien# endif 34950397Sobrien# endif 35050397Sobrien#endif 35150397Sobrien 35250397Sobrien#ifdef HAVE_SETRLIMIT 35390075Sobrien# if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT 35450397Sobrien# ifndef setrlimit 35590075Sobrienstruct rlimit; 356132718Skanextern int setrlimit (int, const struct rlimit *); 35750397Sobrien# endif 35850397Sobrien# endif 35950397Sobrien#endif 36050397Sobrien 361132718Skan#if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT 362132718Skanextern void abort (void); 36350397Sobrien#endif 36450397Sobrien 365132718Skan#if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF 366132718Skanextern int snprintf (char *, size_t, const char *, ...); 36752284Sobrien#endif 36850397Sobrien 36990075Sobrien/* 1 if we have C99 designated initializers. */ 37090075Sobrien#if !defined(HAVE_DESIGNATED_INITIALIZERS) 37190075Sobrien#define HAVE_DESIGNATED_INITIALIZERS \ 37290075Sobrien ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)) 37390075Sobrien#endif 37450397Sobrien 37590075Sobrien/* 1 if we have _Bool. */ 37690075Sobrien#ifndef HAVE__BOOL 37790075Sobrien# define HAVE__BOOL \ 37890075Sobrien ((GCC_VERSION >= 3000) || (__STDC_VERSION__ >= 199901L)) 37990075Sobrien#endif 38050397Sobrien 38150397Sobrien 38252284Sobrien#if HAVE_SYS_STAT_H 38352284Sobrien# include <sys/stat.h> 38452284Sobrien#endif 38550397Sobrien 38652284Sobrien/* Test if something is a normal file. */ 38752284Sobrien#ifndef S_ISREG 38852284Sobrien#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 38952284Sobrien#endif 39050397Sobrien 39152284Sobrien/* Test if something is a directory. */ 39252284Sobrien#ifndef S_ISDIR 39352284Sobrien#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 39452284Sobrien#endif 39552284Sobrien 39652284Sobrien/* Test if something is a character special file. */ 39752284Sobrien#ifndef S_ISCHR 39852284Sobrien#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 39952284Sobrien#endif 40052284Sobrien 40190075Sobrien/* Test if something is a block special file. */ 40290075Sobrien#ifndef S_ISBLK 40390075Sobrien#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 40490075Sobrien#endif 40590075Sobrien 40652284Sobrien/* Test if something is a socket. */ 40752284Sobrien#ifndef S_ISSOCK 40852284Sobrien# ifdef S_IFSOCK 40952284Sobrien# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 41052284Sobrien# else 41152284Sobrien# define S_ISSOCK(m) 0 41252284Sobrien# endif 41352284Sobrien#endif 41452284Sobrien 41552284Sobrien/* Test if something is a FIFO. */ 41652284Sobrien#ifndef S_ISFIFO 41752284Sobrien# ifdef S_IFIFO 41852284Sobrien# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 41952284Sobrien# else 42052284Sobrien# define S_ISFIFO(m) 0 42152284Sobrien# endif 42252284Sobrien#endif 42352284Sobrien 42452284Sobrien/* Approximate O_NONBLOCK. */ 42552284Sobrien#ifndef O_NONBLOCK 42652284Sobrien#define O_NONBLOCK O_NDELAY 42752284Sobrien#endif 42852284Sobrien 42952284Sobrien/* Approximate O_NOCTTY. */ 43052284Sobrien#ifndef O_NOCTTY 43152284Sobrien#define O_NOCTTY 0 43252284Sobrien#endif 43352284Sobrien 43452284Sobrien/* Define well known filenos if the system does not define them. */ 43552284Sobrien#ifndef STDIN_FILENO 43652284Sobrien# define STDIN_FILENO 0 43752284Sobrien#endif 43852284Sobrien#ifndef STDOUT_FILENO 43952284Sobrien# define STDOUT_FILENO 1 44052284Sobrien#endif 44152284Sobrien#ifndef STDERR_FILENO 44252284Sobrien# define STDERR_FILENO 2 44352284Sobrien#endif 44452284Sobrien 44590075Sobrien/* Some systems have mkdir that takes a single argument. */ 44652284Sobrien#ifdef MKDIR_TAKES_ONE_ARG 44752284Sobrien# define mkdir(a,b) mkdir(a) 44852284Sobrien#endif 44952284Sobrien 45090075Sobrien/* Provide a way to print an address via printf. */ 45190075Sobrien#ifndef HOST_PTR_PRINTF 45290075Sobrien# ifdef HAVE_PRINTF_PTR 45390075Sobrien# define HOST_PTR_PRINTF "%p" 454132718Skan# elif SIZEOF_INT == SIZEOF_VOID_P 455132718Skan# define HOST_PTR_PRINTF "%x" 456132718Skan# elif SIZEOF_LONG == SIZEOF_VOID_P 457132718Skan# define HOST_PTR_PRINTF "%lx" 45890075Sobrien# else 459132718Skan# define HOST_PTR_PRINTF "%llx" 46090075Sobrien# endif 46190075Sobrien#endif /* ! HOST_PTR_PRINTF */ 46290075Sobrien 46390075Sobrien/* By default, colon separates directories in a path. */ 46490075Sobrien#ifndef PATH_SEPARATOR 46590075Sobrien#define PATH_SEPARATOR ':' 46690075Sobrien#endif 46790075Sobrien 468132718Skan/* Filename handling macros. */ 469132718Skan#include "filenames.h" 470132718Skan 471132718Skan/* These should be phased out in favor of IS_DIR_SEPARATOR, where possible. */ 47290075Sobrien#ifndef DIR_SEPARATOR 473132718Skan# define DIR_SEPARATOR '/' 474132718Skan# ifdef HAVE_DOS_BASED_FILE_SYSTEM 475132718Skan# define DIR_SEPARATOR_2 '\\' 476132718Skan# endif 47790075Sobrien#endif 47890075Sobrien 47990075Sobrien/* Get libiberty declarations. */ 48052284Sobrien#include "libiberty.h" 48152284Sobrien 48290075Sobrien/* Provide a default for the HOST_BIT_BUCKET. 48390075Sobrien This suffices for POSIX-like hosts. */ 48490075Sobrien 48590075Sobrien#ifndef HOST_BIT_BUCKET 48690075Sobrien#define HOST_BIT_BUCKET "/dev/null" 48790075Sobrien#endif 48890075Sobrien 48990075Sobrien/* Be conservative and only use enum bitfields with GCC. 49090075Sobrien FIXME: provide a complete autoconf test for buggy enum bitfields. */ 49190075Sobrien 49290075Sobrien#if (GCC_VERSION > 2000) 493132718Skan#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE 49490075Sobrien#else 49590075Sobrien#define ENUM_BITFIELD(TYPE) unsigned int 49690075Sobrien#endif 49790075Sobrien 498132718Skan/* We only use bool bitfields with gcc3. Some supposedly C99 499132718Skan compilers don't handle them correctly. */ 500132718Skan#if (GCC_VERSION >= 3000) 501132718Skan#define BOOL_BITFIELD _Bool 502132718Skan#else 503132718Skan#define BOOL_BITFIELD unsigned int 504132718Skan#endif 505132718Skan 50690075Sobrien#ifndef offsetof 50790075Sobrien#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) 50890075Sobrien#endif 50990075Sobrien 51090075Sobrien/* Various error reporting routines want to use __FUNCTION__. */ 51190075Sobrien#if (GCC_VERSION < 2007) 51290075Sobrien#ifndef __FUNCTION__ 51390075Sobrien#define __FUNCTION__ "?" 51490075Sobrien#endif /* ! __FUNCTION__ */ 51590075Sobrien#endif 51690075Sobrien 51790075Sobrien/* __builtin_expect(A, B) evaluates to A, but notifies the compiler that 51890075Sobrien the most likely value of A is B. This feature was added at some point 51990075Sobrien between 2.95 and 3.0. Let's use 3.0 as the lower bound for now. */ 52090075Sobrien#if (GCC_VERSION < 3000) 52190075Sobrien#define __builtin_expect(a, b) (a) 52290075Sobrien#endif 52390075Sobrien 52490075Sobrien/* Provide some sort of boolean type. We use stdbool.h if it's 52590075Sobrien available. This must be after all inclusion of system headers, 52690075Sobrien as some of them will mess us up. */ 52790075Sobrien#undef bool 52890075Sobrien#undef true 52990075Sobrien#undef false 53090075Sobrien#undef TRUE 53190075Sobrien#undef FALSE 53290075Sobrien 53390075Sobrien#ifdef HAVE_STDBOOL_H 53490075Sobrien# include <stdbool.h> 53590075Sobrien#else 53690075Sobrien# if !HAVE__BOOL 53790075Sobrientypedef char _Bool; 53890075Sobrien# endif 53990075Sobrien# define bool _Bool 54090075Sobrien# define true 1 54190075Sobrien# define false 0 54290075Sobrien#endif 54390075Sobrien 54490075Sobrien#define TRUE true 54590075Sobrien#define FALSE false 54690075Sobrien 54790075Sobrien/* As the last action in this file, we poison the identifiers that 54890075Sobrien shouldn't be used. Note, luckily gcc-3.0's token-based integrated 54990075Sobrien preprocessor won't trip on poisoned identifiers that arrive from 55090075Sobrien the expansion of macros. E.g. #define strrchr rindex, won't error 55190075Sobrien if rindex is poisoned after this directive is issued and later on 55290075Sobrien strrchr is called. 55390075Sobrien 55490075Sobrien Note: We define bypass macros for the few cases where we really 55590075Sobrien want to use the libc memory allocation routines. Otherwise we 55690075Sobrien insist you use the "x" versions from libiberty. */ 55790075Sobrien 55890075Sobrien#define really_call_malloc malloc 55990075Sobrien#define really_call_calloc calloc 56090075Sobrien#define really_call_realloc realloc 56190075Sobrien 562132718Skan#if defined(FLEX_SCANNER) || defined(YYBISON) || defined(YYBYACC) 563132718Skan/* Flex and bison use malloc and realloc. Yuk. Note that this means 564132718Skan really_call_* cannot be used in a .l or .y file. */ 565132718Skan#define malloc xmalloc 566132718Skan#define realloc xrealloc 567132718Skan#endif 568132718Skan 56990075Sobrien#if (GCC_VERSION >= 3000) 57090075Sobrien 57190075Sobrien/* Note autoconf checks for prototype declarations and includes 57290075Sobrien system.h while doing so. Only poison these tokens if actually 57390075Sobrien compiling gcc, so that the autoconf declaration tests for malloc 57490075Sobrien etc don't spuriously fail. */ 57590075Sobrien#ifdef IN_GCC 57690075Sobrien#undef calloc 57790075Sobrien#undef strdup 578117395Skan #pragma GCC poison calloc strdup 57990075Sobrien 580132718Skan#if !defined(FLEX_SCANNER) && !defined(YYBISON) 581117395Skan#undef malloc 582117395Skan#undef realloc 583117395Skan #pragma GCC poison malloc realloc 584117395Skan#endif 585117395Skan 58690075Sobrien/* Old target macros that have moved to the target hooks structure. */ 58790075Sobrien #pragma GCC poison ASM_OPEN_PAREN ASM_CLOSE_PAREN \ 58890075Sobrien FUNCTION_PROLOGUE FUNCTION_EPILOGUE \ 58990075Sobrien FUNCTION_END_PROLOGUE FUNCTION_BEGIN_EPILOGUE \ 59090075Sobrien DECL_MACHINE_ATTRIBUTES COMP_TYPE_ATTRIBUTES INSERT_ATTRIBUTES \ 59190075Sobrien VALID_MACHINE_DECL_ATTRIBUTE VALID_MACHINE_TYPE_ATTRIBUTE \ 59290075Sobrien SET_DEFAULT_TYPE_ATTRIBUTES SET_DEFAULT_DECL_ATTRIBUTES \ 59390075Sobrien MERGE_MACHINE_TYPE_ATTRIBUTES MERGE_MACHINE_DECL_ATTRIBUTES \ 59490075Sobrien MD_INIT_BUILTINS MD_EXPAND_BUILTIN ASM_OUTPUT_CONSTRUCTOR \ 595117395Skan ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \ 596117395Skan WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \ 597117395Skan ENCODE_SECTION_INFO STRIP_NAME_ENCODING ASM_GLOBALIZE_LABEL \ 598132718Skan ASM_OUTPUT_MI_THUNK CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS \ 599132718Skan ADDRESS_COST MACHINE_DEPENDENT_REORG ASM_FILE_START ASM_FILE_END \ 600132718Skan ASM_SIMPLIFY_DWARF_ADDR INIT_TARGET_OPTABS INIT_SUBTARGET_OPTABS \ 601132718Skan INIT_GOFAST_OPTABS MULSI3_LIBCALL MULDI3_LIBCALL DIVSI3_LIBCALL \ 602132718Skan DIVDI3_LIBCALL UDIVSI3_LIBCALL UDIVDI3_LIBCALL MODSI3_LIBCALL \ 603132718Skan MODDI3_LIBCALL UMODSI3_LIBCALL UMODDI3_LIBCALL BUILD_VA_LIST_TYPE \ 604132718Skan PRETEND_OUTGOING_VARARGS_NAMED STRUCT_VALUE_INCOMING_REGNUM \ 605132718Skan SPLIT_COMPLEX_ARGS 60690075Sobrien 607117395Skan/* Other obsolete target macros, or macros that used to be in target 60890075Sobrien headers and were not used, and may be obsolete or may never have 60990075Sobrien been used. */ 610132718Skan #pragma GCC poison INT_ASM_OP ASM_OUTPUT_EH_REGION_BEG CPP_PREDEFINES \ 611132718Skan ASM_OUTPUT_EH_REGION_END ASM_OUTPUT_LABELREF_AS_INT SMALL_STACK \ 61290075Sobrien DOESNT_NEED_UNWINDER EH_TABLE_LOOKUP OBJC_SELECTORS_WITHOUT_LABELS \ 61390075Sobrien OMIT_EH_TABLE EASY_DIV_EXPR IMPLICIT_FIX_EXPR \ 61490075Sobrien LONGJMP_RESTORE_FROM_STACK MAX_INT_TYPE_SIZE ASM_IDENTIFY_GCC \ 61590075Sobrien STDC_VALUE TRAMPOLINE_ALIGN ASM_IDENTIFY_GCC_AFTER_SOURCE \ 616102780Skan SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET DWARF_LINE_MIN_INSTR_LENGTH \ 617117395Skan TRADITIONAL_RETURN_FLOAT NO_BUILTIN_SIZE_TYPE \ 618117395Skan NO_BUILTIN_PTRDIFF_TYPE NO_BUILTIN_WCHAR_TYPE NO_BUILTIN_WINT_TYPE \ 619117395Skan BLOCK_PROFILER BLOCK_PROFILER_CODE FUNCTION_BLOCK_PROFILER \ 620117395Skan FUNCTION_BLOCK_PROFILER_EXIT MACHINE_STATE_SAVE \ 621117395Skan MACHINE_STATE_RESTORE SCCS_DIRECTIVE SECTION_ASM_OP \ 622132718Skan ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL ASM_OUTPUT_INTERNAL_LABEL \ 623132718Skan OBJC_PROLOGUE ALLOCATE_TRAMPOLINE HANDLE_PRAGMA ROUND_TYPE_SIZE \ 624132718Skan ROUND_TYPE_SIZE_UNIT CONST_SECTION_ASM_OP CRT_GET_RFIB_TEXT \ 625132718Skan DBX_LBRAC_FIRST DBX_OUTPUT_ENUM DBX_OUTPUT_SOURCE_FILENAME \ 626132718Skan DBX_WORKING_DIRECTORY INSN_CACHE_DEPTH INSN_CACHE_SIZE \ 627132718Skan INSN_CACHE_LINE_WIDTH INIT_SECTION_PREAMBLE NEED_ATEXIT ON_EXIT \ 628132718Skan EXIT_BODY OBJECT_FORMAT_ROSE MULTIBYTE_CHARS MAP_CHARACTER \ 629132718Skan LIBGCC_NEEDS_DOUBLE FINAL_PRESCAN_LABEL DEFAULT_CALLER_SAVES \ 630132718Skan LOAD_ARGS_REVERSED MAX_INTEGER_COMPUTATION_MODE \ 631132718Skan CONVERT_HARD_REGISTER_TO_SSA_P ASM_OUTPUT_MAIN_SOURCE_FILENAME \ 632132718Skan FIRST_INSN_ADDRESS TEXT_SECTION SHARED_BSS_SECTION_ASM_OP \ 633132718Skan PROMOTED_MODE EXPAND_BUILTIN_VA_END \ 634132718Skan LINKER_DOES_NOT_WORK_WITH_DWARF2 63590075Sobrien 636117395Skan/* Hooks that are no longer used. */ 637117395Skan #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ 638132718Skan LANG_HOOKS_MARK_TREE LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES 639117395Skan 640132718Skan/* Libiberty macros that are no longer used in GCC. */ 641132718Skan#undef ANSI_PROTOTYPES 642132718Skan#undef PTR_CONST 643132718Skan#undef LONG_DOUBLE 644132718Skan#undef VPARAMS 645132718Skan#undef VA_OPEN 646132718Skan#undef VA_FIXEDARG 647132718Skan#undef VA_CLOSE 648132718Skan#undef VA_START 649132718Skan #pragma GCC poison ANSI_PROTOTYPES PTR_CONST LONG_DOUBLE VPARAMS VA_OPEN \ 650132718Skan VA_FIXEDARG VA_CLOSE VA_START 65190075Sobrien#endif /* IN_GCC */ 65290075Sobrien 65390075Sobrien/* Note: not all uses of the `index' token (e.g. variable names and 65490075Sobrien structure members) have been eliminated. */ 65590075Sobrien#undef bcopy 65690075Sobrien#undef bzero 65790075Sobrien#undef bcmp 65890075Sobrien#undef rindex 65990075Sobrien #pragma GCC poison bcopy bzero bcmp rindex 66090075Sobrien 66190075Sobrien#endif /* GCC >= 3.0 */ 66290075Sobrien 66390075Sobrien#endif /* ! GCC_SYSTEM_H */ 664