system.h revision 117395
190075Sobrien/* Get common system includes and various definitions and declarations based 290075Sobrien on autoconf macros. 390075Sobrien Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 450397Sobrien 590075SobrienThis file is part of GCC. 650397Sobrien 790075SobrienGCC is free software; you can redistribute it and/or modify it under 890075Sobrienthe terms of the GNU General Public License as published by the Free 990075SobrienSoftware Foundation; either version 2, or (at your option) any later 1090075Sobrienversion. 1152284Sobrien 1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY 1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or 1490075SobrienFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1590075Sobrienfor more details. 1652284Sobrien 1752284SobrienYou should have received a copy of the GNU General Public License 1890075Sobrienalong with GCC; see the file COPYING. If not, write to the Free 1990075SobrienSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 2090075Sobrien02111-1307, USA. */ 2152284Sobrien 2250397Sobrien 2390075Sobrien#ifndef GCC_SYSTEM_H 2490075Sobrien#define GCC_SYSTEM_H 2590075Sobrien 2690075Sobrien/* We must include stdarg.h/varargs.h before stdio.h. */ 2752284Sobrien#ifdef ANSI_PROTOTYPES 2852284Sobrien#include <stdarg.h> 2952284Sobrien#else 3052284Sobrien#include <varargs.h> 3152284Sobrien#endif 3252284Sobrien 3390075Sobrien#ifndef va_copy 3490075Sobrien# ifdef __va_copy 3590075Sobrien# define va_copy(d,s) __va_copy((d),(s)) 3690075Sobrien# else 3790075Sobrien# define va_copy(d,s) ((d) = (s)) 3890075Sobrien# endif 3990075Sobrien#endif 4090075Sobrien 4190075Sobrien#ifdef HAVE_STDDEF_H 4290075Sobrien# include <stddef.h> 4390075Sobrien#endif 4490075Sobrien 4550397Sobrien#include <stdio.h> 4650397Sobrien 4750397Sobrien/* Define a generic NULL if one hasn't already been defined. */ 4850397Sobrien#ifndef NULL 4950397Sobrien#define NULL 0 5050397Sobrien#endif 5150397Sobrien 5252284Sobrien/* The compiler is not a multi-threaded application and therefore we 5390075Sobrien do not have to use the locking functions. In fact, using the locking 5490075Sobrien functions can cause the compiler to be significantly slower under 5590075Sobrien I/O bound conditions (such as -g -O0 on very large source files). 5652284Sobrien 5790075Sobrien HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio 5890075Sobrien code is multi-thread safe by default. If it is set to 0, then do 5990075Sobrien not worry about using the _unlocked functions. 6052284Sobrien 6190075Sobrien fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are 6290075Sobrien extensions and need to be prototyped by hand (since we do not 6390075Sobrien define _GNU_SOURCE). */ 6452284Sobrien 6590075Sobrien#if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED 6690075Sobrien 6790075Sobrien# ifdef HAVE_PUTC_UNLOCKED 6890075Sobrien# undef putc 6990075Sobrien# define putc(C, Stream) putc_unlocked (C, Stream) 7052284Sobrien# endif 7190075Sobrien# ifdef HAVE_FPUTC_UNLOCKED 7290075Sobrien# undef fputc 7390075Sobrien# define fputc(C, Stream) fputc_unlocked (C, Stream) 7490075Sobrien# endif 7552284Sobrien 7690075Sobrien# ifdef HAVE_FPUTS_UNLOCKED 7790075Sobrien# undef fputs 7890075Sobrien# define fputs(String, Stream) fputs_unlocked (String, Stream) 7990075Sobrien# if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED 8090075Sobrienextern int fputs_unlocked PARAMS ((const char *, FILE *)); 8190075Sobrien# endif 8290075Sobrien# endif 8390075Sobrien# ifdef HAVE_FWRITE_UNLOCKED 8490075Sobrien# undef fwrite 8590075Sobrien# define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream) 8690075Sobrien# if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED 8790075Sobrienextern int fwrite_unlocked PARAMS ((const PTR, size_t, size_t, FILE *)); 8890075Sobrien# endif 8990075Sobrien# endif 9090075Sobrien# ifdef HAVE_FPRINTF_UNLOCKED 9190075Sobrien# undef fprintf 9290075Sobrien/* We can't use a function-like macro here because we don't know if 9390075Sobrien we have varargs macros. */ 9490075Sobrien# define fprintf fprintf_unlocked 9590075Sobrien# if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED 9690075Sobrienextern int fprintf_unlocked PARAMS ((FILE *, const char *, ...)); 9790075Sobrien# endif 9890075Sobrien# endif 9950397Sobrien 10050397Sobrien#endif 10150397Sobrien 10290075Sobrien/* There are an extraordinary number of issues with <ctype.h>. 10390075Sobrien The last straw is that it varies with the locale. Use libiberty's 10490075Sobrien replacement instead. */ 10590075Sobrien#include <safe-ctype.h> 10650397Sobrien 10790075Sobrien#include <sys/types.h> 10850397Sobrien 10950397Sobrien#include <errno.h> 11050397Sobrien 11190075Sobrien#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO 11250397Sobrienextern int errno; 11350397Sobrien#endif 11450397Sobrien 11552284Sobrien#ifdef STRING_WITH_STRINGS 11650397Sobrien# include <string.h> 11752284Sobrien# include <strings.h> 11850397Sobrien#else 11952284Sobrien# ifdef HAVE_STRING_H 12052284Sobrien# include <string.h> 12152284Sobrien# else 12252284Sobrien# ifdef HAVE_STRINGS_H 12352284Sobrien# include <strings.h> 12452284Sobrien# endif 12550397Sobrien# endif 12650397Sobrien#endif 12750397Sobrien 12850397Sobrien#ifdef HAVE_STDLIB_H 12950397Sobrien# include <stdlib.h> 13050397Sobrien#endif 13150397Sobrien 13290075Sobrien/* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and 13390075Sobrien FATAL_EXIT_CODE to EXIT_SUCCESS and EXIT_FAILURE respectively, 13490075Sobrien or 0 and 1 if those macros are not defined. */ 13590075Sobrien#ifndef SUCCESS_EXIT_CODE 13690075Sobrien# ifdef EXIT_SUCCESS 13790075Sobrien# define SUCCESS_EXIT_CODE EXIT_SUCCESS 13890075Sobrien# else 13990075Sobrien# define SUCCESS_EXIT_CODE 0 14090075Sobrien# endif 14190075Sobrien#endif 14290075Sobrien 14390075Sobrien#ifndef FATAL_EXIT_CODE 14490075Sobrien# ifdef EXIT_FAILURE 14590075Sobrien# define FATAL_EXIT_CODE EXIT_FAILURE 14690075Sobrien# else 14790075Sobrien# define FATAL_EXIT_CODE 1 14890075Sobrien# endif 14990075Sobrien#endif 15090075Sobrien 15150397Sobrien#ifdef HAVE_UNISTD_H 15250397Sobrien# include <unistd.h> 15350397Sobrien#endif 15450397Sobrien 15550397Sobrien#ifdef HAVE_SYS_PARAM_H 15650397Sobrien# include <sys/param.h> 15790075Sobrien/* We use this identifier later and it appears in some vendor param.h's. */ 15890075Sobrien# undef PREFETCH 15950397Sobrien#endif 16050397Sobrien 16150397Sobrien#if HAVE_LIMITS_H 16250397Sobrien# include <limits.h> 16350397Sobrien#endif 16450397Sobrien 16590075Sobrien/* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ 16690075Sobrien#include "hwint.h" 16752284Sobrien 16890075Sobrien/* A macro to determine whether a VALUE lies inclusively within a 16990075Sobrien certain range without evaluating the VALUE more than once. This 17090075Sobrien macro won't warn if the VALUE is unsigned and the LOWER bound is 17190075Sobrien zero, as it would e.g. with "VALUE >= 0 && ...". Note the LOWER 17290075Sobrien bound *is* evaluated twice, and LOWER must not be greater than 17390075Sobrien UPPER. However the bounds themselves can be either positive or 17490075Sobrien negative. */ 17590075Sobrien#define IN_RANGE(VALUE, LOWER, UPPER) \ 17690075Sobrien ((unsigned HOST_WIDE_INT) ((VALUE) - (LOWER)) <= ((UPPER) - (LOWER))) 17752284Sobrien 17890075Sobrien/* Infrastructure for defining missing _MAX and _MIN macros. Note that 17990075Sobrien macros defined with these cannot be used in #if. */ 18090075Sobrien 18190075Sobrien/* The extra casts work around common compiler bugs. */ 18290075Sobrien#define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 18390075Sobrien/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. 18490075Sobrien It is necessary at least when t == time_t. */ 18590075Sobrien#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ 18690075Sobrien ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0)) 18790075Sobrien#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) 18890075Sobrien 18990075Sobrien/* Use that infrastructure to provide a few constants. */ 19090075Sobrien#ifndef UCHAR_MAX 19190075Sobrien# define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char) 19290075Sobrien#endif 19390075Sobrien 19450397Sobrien#ifdef TIME_WITH_SYS_TIME 19550397Sobrien# include <sys/time.h> 19650397Sobrien# include <time.h> 19750397Sobrien#else 19850397Sobrien# if HAVE_SYS_TIME_H 19950397Sobrien# include <sys/time.h> 20050397Sobrien# else 20150397Sobrien# ifdef HAVE_TIME_H 20250397Sobrien# include <time.h> 20350397Sobrien# endif 20450397Sobrien# endif 20550397Sobrien#endif 20650397Sobrien 20750397Sobrien#ifdef HAVE_FCNTL_H 20850397Sobrien# include <fcntl.h> 20950397Sobrien#else 21050397Sobrien# ifdef HAVE_SYS_FILE_H 21150397Sobrien# include <sys/file.h> 21250397Sobrien# endif 21350397Sobrien#endif 21450397Sobrien 21550397Sobrien#ifndef SEEK_SET 21650397Sobrien# define SEEK_SET 0 21750397Sobrien# define SEEK_CUR 1 21850397Sobrien# define SEEK_END 2 21950397Sobrien#endif 22050397Sobrien#ifndef F_OK 22150397Sobrien# define F_OK 0 22250397Sobrien# define X_OK 1 22350397Sobrien# define W_OK 2 22450397Sobrien# define R_OK 4 22550397Sobrien#endif 22650397Sobrien#ifndef O_RDONLY 22750397Sobrien# define O_RDONLY 0 22850397Sobrien#endif 22950397Sobrien#ifndef O_WRONLY 23050397Sobrien# define O_WRONLY 1 23150397Sobrien#endif 23250397Sobrien 23352284Sobrien/* Some systems define these in, e.g., param.h. We undefine these names 23452284Sobrien here to avoid the warnings. We prefer to use our definitions since we 23552284Sobrien know they are correct. */ 23650397Sobrien 23752284Sobrien#undef MIN 23852284Sobrien#undef MAX 23952284Sobrien#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) 24052284Sobrien#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) 24150397Sobrien 24290075Sobrien/* Returns the least number N such that N * Y >= X. */ 24390075Sobrien#define CEIL(x,y) (((x) + (y) - 1) / (y)) 24490075Sobrien 24552284Sobrien#ifdef HAVE_SYS_WAIT_H 24652284Sobrien#include <sys/wait.h> 24752284Sobrien#endif 24852284Sobrien 24952284Sobrien#ifndef WIFSIGNALED 25052284Sobrien#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) 25152284Sobrien#endif 25252284Sobrien#ifndef WTERMSIG 25352284Sobrien#define WTERMSIG(S) ((S) & 0x7f) 25452284Sobrien#endif 25552284Sobrien#ifndef WIFEXITED 25652284Sobrien#define WIFEXITED(S) (((S) & 0xff) == 0) 25752284Sobrien#endif 25852284Sobrien#ifndef WEXITSTATUS 25952284Sobrien#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) 26052284Sobrien#endif 26152284Sobrien#ifndef WSTOPSIG 26252284Sobrien#define WSTOPSIG WEXITSTATUS 26352284Sobrien#endif 264117395Skan#ifndef WCOREDUMP 265117395Skan#define WCOREDUMP(S) ((S) & WCOREFLG) 266117395Skan#endif 267117395Skan#ifndef WCOREFLG 268117395Skan#define WCOREFLG 0200 269117395Skan#endif 27052284Sobrien 27190075Sobrien/* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they 27290075Sobrien are defined to 0 then we must provide the relevant declaration 27390075Sobrien here. These checks will be in the undefined state while configure 27490075Sobrien is running so be careful to test "defined (HAVE_DECL_*)". */ 27552284Sobrien 27690075Sobrien#if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF 27790075Sobrienextern double atof PARAMS ((const char *)); 27850397Sobrien#endif 27950397Sobrien 28090075Sobrien#if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL 28190075Sobrienextern long atol PARAMS ((const char *)); 28250397Sobrien#endif 28350397Sobrien 28490075Sobrien#if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE 28590075Sobrienextern void free PARAMS ((PTR)); 28650397Sobrien#endif 28750397Sobrien 28890075Sobrien#if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD 28990075Sobrienextern char *getcwd PARAMS ((char *, size_t)); 29050397Sobrien#endif 29150397Sobrien 29290075Sobrien#if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV 29390075Sobrienextern char *getenv PARAMS ((const char *)); 29450397Sobrien#endif 29550397Sobrien 29690075Sobrien#if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT 29790075Sobrienextern int getopt PARAMS ((int, char * const *, const char *)); 29850397Sobrien#endif 29950397Sobrien 30090075Sobrien#if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD 30190075Sobrienextern char *getwd PARAMS ((char *)); 30250397Sobrien#endif 30350397Sobrien 30490075Sobrien#if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK 30590075Sobrienextern PTR sbrk PARAMS ((int)); 30650397Sobrien#endif 30750397Sobrien 30890075Sobrien#if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR 30990075Sobrienextern char *strstr PARAMS ((const char *, const char *)); 31050397Sobrien#endif 31150397Sobrien 31290075Sobrien#ifdef HAVE_MALLOC_H 31390075Sobrien#include <malloc.h> 31450397Sobrien#endif 31550397Sobrien 31690075Sobrien#if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC 31790075Sobrienextern PTR malloc PARAMS ((size_t)); 31850397Sobrien#endif 31950397Sobrien 32090075Sobrien#if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC 32190075Sobrienextern PTR calloc PARAMS ((size_t, size_t)); 32250397Sobrien#endif 32350397Sobrien 32490075Sobrien#if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC 32590075Sobrienextern PTR realloc PARAMS ((PTR, size_t)); 32652284Sobrien#endif 32752284Sobrien 32890075Sobrien/* If the system doesn't provide strsignal, we get it defined in 32990075Sobrien libiberty but no declaration is supplied. */ 33090075Sobrien#ifndef HAVE_STRSIGNAL 33190075Sobrien# ifndef strsignal 33290075Sobrienextern const char *strsignal PARAMS ((int)); 33350397Sobrien# endif 33490075Sobrien#endif 33550397Sobrien 33650397Sobrien#ifdef HAVE_GETRLIMIT 33790075Sobrien# if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT 33850397Sobrien# ifndef getrlimit 33990075Sobrien# ifdef ANSI_PROTOTYPES 34090075Sobrienstruct rlimit; 34190075Sobrien# endif 34290075Sobrienextern int getrlimit PARAMS ((int, struct rlimit *)); 34350397Sobrien# endif 34450397Sobrien# endif 34550397Sobrien#endif 34650397Sobrien 34750397Sobrien#ifdef HAVE_SETRLIMIT 34890075Sobrien# if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT 34950397Sobrien# ifndef setrlimit 35090075Sobrien# ifdef ANSI_PROTOTYPES 35190075Sobrienstruct rlimit; 35290075Sobrien# endif 35390075Sobrienextern int setrlimit PARAMS ((int, const struct rlimit *)); 35450397Sobrien# endif 35550397Sobrien# endif 35650397Sobrien#endif 35750397Sobrien 35850397Sobrien/* HAVE_VOLATILE only refers to the stage1 compiler. We also check 35990075Sobrien __STDC__ and assume gcc sets it and has volatile in stage >=2. */ 36050397Sobrien#if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile) 36150397Sobrien#define volatile 36250397Sobrien#endif 36350397Sobrien 36490075Sobrien#if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT 36590075Sobrienextern void abort PARAMS ((void)); 36652284Sobrien#endif 36750397Sobrien 36890075Sobrien/* 1 if we have C99 designated initializers. */ 36990075Sobrien#if !defined(HAVE_DESIGNATED_INITIALIZERS) 37090075Sobrien#define HAVE_DESIGNATED_INITIALIZERS \ 37190075Sobrien ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)) 37290075Sobrien#endif 37350397Sobrien 37490075Sobrien/* 1 if we have _Bool. */ 37590075Sobrien#ifndef HAVE__BOOL 37690075Sobrien# define HAVE__BOOL \ 37790075Sobrien ((GCC_VERSION >= 3000) || (__STDC_VERSION__ >= 199901L)) 37890075Sobrien#endif 37950397Sobrien 38050397Sobrien 38152284Sobrien#if HAVE_SYS_STAT_H 38252284Sobrien# include <sys/stat.h> 38352284Sobrien#endif 38450397Sobrien 38552284Sobrien/* Test if something is a normal file. */ 38652284Sobrien#ifndef S_ISREG 38752284Sobrien#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 38852284Sobrien#endif 38950397Sobrien 39052284Sobrien/* Test if something is a directory. */ 39152284Sobrien#ifndef S_ISDIR 39252284Sobrien#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 39352284Sobrien#endif 39452284Sobrien 39552284Sobrien/* Test if something is a character special file. */ 39652284Sobrien#ifndef S_ISCHR 39752284Sobrien#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 39852284Sobrien#endif 39952284Sobrien 40090075Sobrien/* Test if something is a block special file. */ 40190075Sobrien#ifndef S_ISBLK 40290075Sobrien#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 40390075Sobrien#endif 40490075Sobrien 40552284Sobrien/* Test if something is a socket. */ 40652284Sobrien#ifndef S_ISSOCK 40752284Sobrien# ifdef S_IFSOCK 40852284Sobrien# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 40952284Sobrien# else 41052284Sobrien# define S_ISSOCK(m) 0 41152284Sobrien# endif 41252284Sobrien#endif 41352284Sobrien 41452284Sobrien/* Test if something is a FIFO. */ 41552284Sobrien#ifndef S_ISFIFO 41652284Sobrien# ifdef S_IFIFO 41752284Sobrien# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 41852284Sobrien# else 41952284Sobrien# define S_ISFIFO(m) 0 42052284Sobrien# endif 42152284Sobrien#endif 42252284Sobrien 42352284Sobrien/* Approximate O_NONBLOCK. */ 42452284Sobrien#ifndef O_NONBLOCK 42552284Sobrien#define O_NONBLOCK O_NDELAY 42652284Sobrien#endif 42752284Sobrien 42852284Sobrien/* Approximate O_NOCTTY. */ 42952284Sobrien#ifndef O_NOCTTY 43052284Sobrien#define O_NOCTTY 0 43152284Sobrien#endif 43252284Sobrien 43352284Sobrien/* Define well known filenos if the system does not define them. */ 43452284Sobrien#ifndef STDIN_FILENO 43552284Sobrien# define STDIN_FILENO 0 43652284Sobrien#endif 43752284Sobrien#ifndef STDOUT_FILENO 43852284Sobrien# define STDOUT_FILENO 1 43952284Sobrien#endif 44052284Sobrien#ifndef STDERR_FILENO 44152284Sobrien# define STDERR_FILENO 2 44252284Sobrien#endif 44352284Sobrien 44490075Sobrien/* Some systems have mkdir that takes a single argument. */ 44552284Sobrien#ifdef MKDIR_TAKES_ONE_ARG 44652284Sobrien# define mkdir(a,b) mkdir(a) 44752284Sobrien#endif 44852284Sobrien 44990075Sobrien/* Provide a way to print an address via printf. */ 45090075Sobrien#ifndef HOST_PTR_PRINTF 45190075Sobrien# ifdef HAVE_PRINTF_PTR 45290075Sobrien# define HOST_PTR_PRINTF "%p" 45390075Sobrien# else 45490075Sobrien# define HOST_PTR_PRINTF \ 45590075Sobrien (sizeof (int) == sizeof (char *) ? "%x" \ 45690075Sobrien : sizeof (long) == sizeof (char *) ? "%lx" : "%llx") 45790075Sobrien# endif 45890075Sobrien#endif /* ! HOST_PTR_PRINTF */ 45990075Sobrien 46090075Sobrien/* By default, colon separates directories in a path. */ 46190075Sobrien#ifndef PATH_SEPARATOR 46290075Sobrien#define PATH_SEPARATOR ':' 46390075Sobrien#endif 46490075Sobrien 46590075Sobrien#ifndef DIR_SEPARATOR 46690075Sobrien#define DIR_SEPARATOR '/' 46790075Sobrien#endif 46890075Sobrien 46990075Sobrien/* Define IS_DIR_SEPARATOR. */ 47090075Sobrien#ifndef DIR_SEPARATOR_2 47190075Sobrien# define IS_DIR_SEPARATOR(CH) ((CH) == DIR_SEPARATOR) 47290075Sobrien#else /* DIR_SEPARATOR_2 */ 47390075Sobrien# define IS_DIR_SEPARATOR(CH) \ 47490075Sobrien (((CH) == DIR_SEPARATOR) || ((CH) == DIR_SEPARATOR_2)) 47590075Sobrien#endif /* DIR_SEPARATOR_2 */ 47690075Sobrien 47790075Sobrien/* Say how to test for an absolute pathname. On Unix systems, this is if 47890075Sobrien it starts with a leading slash or a '$', the latter meaning the value of 47990075Sobrien an environment variable is to be used. On machien with DOS-based 48090075Sobrien file systems, it is also absolute if it starts with a drive identifier. */ 48190075Sobrien#ifdef HAVE_DOS_BASED_FILE_SYSTEM 48290075Sobrien#define IS_ABSOLUTE_PATHNAME(STR) \ 48390075Sobrien (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$' \ 48490075Sobrien || ((STR)[0] != '\0' && (STR)[1] == ':' && IS_DIR_SEPARATOR ((STR)[2]))) 48590075Sobrien#else 48690075Sobrien#define IS_ABSOLUTE_PATHNAME(STR) \ 48790075Sobrien (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$') 48890075Sobrien#endif 48990075Sobrien 49090075Sobrien/* Get libiberty declarations. */ 49152284Sobrien#include "libiberty.h" 49290075Sobrien#include "symcat.h" 49352284Sobrien 49490075Sobrien/* Provide a default for the HOST_BIT_BUCKET. 49590075Sobrien This suffices for POSIX-like hosts. */ 49690075Sobrien 49790075Sobrien#ifndef HOST_BIT_BUCKET 49890075Sobrien#define HOST_BIT_BUCKET "/dev/null" 49990075Sobrien#endif 50090075Sobrien 50190075Sobrien/* Be conservative and only use enum bitfields with GCC. 50290075Sobrien FIXME: provide a complete autoconf test for buggy enum bitfields. */ 50390075Sobrien 50490075Sobrien#if (GCC_VERSION > 2000) 50590075Sobrien#define ENUM_BITFIELD(TYPE) enum TYPE 50690075Sobrien#else 50790075Sobrien#define ENUM_BITFIELD(TYPE) unsigned int 50890075Sobrien#endif 50990075Sobrien 51090075Sobrien#ifndef offsetof 51190075Sobrien#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) 51290075Sobrien#endif 51390075Sobrien 51490075Sobrien/* Traditional C cannot initialize union members of structs. Provide 51590075Sobrien a macro which expands appropriately to handle it. This only works 51690075Sobrien if you intend to initialize the union member to zero since it relies 51790075Sobrien on default initialization to zero in the traditional C case. */ 51890075Sobrien#ifdef __STDC__ 51990075Sobrien#define UNION_INIT_ZERO , {0} 52090075Sobrien#else 52190075Sobrien#define UNION_INIT_ZERO 52290075Sobrien#endif 52390075Sobrien 52490075Sobrien/* Various error reporting routines want to use __FUNCTION__. */ 52590075Sobrien#if (GCC_VERSION < 2007) 52690075Sobrien#ifndef __FUNCTION__ 52790075Sobrien#define __FUNCTION__ "?" 52890075Sobrien#endif /* ! __FUNCTION__ */ 52990075Sobrien#endif 53090075Sobrien 53190075Sobrien/* __builtin_expect(A, B) evaluates to A, but notifies the compiler that 53290075Sobrien the most likely value of A is B. This feature was added at some point 53390075Sobrien between 2.95 and 3.0. Let's use 3.0 as the lower bound for now. */ 53490075Sobrien#if (GCC_VERSION < 3000) 53590075Sobrien#define __builtin_expect(a, b) (a) 53690075Sobrien#endif 53790075Sobrien 53890075Sobrien/* Provide some sort of boolean type. We use stdbool.h if it's 53990075Sobrien available. This must be after all inclusion of system headers, 54090075Sobrien as some of them will mess us up. */ 54190075Sobrien#undef bool 54290075Sobrien#undef true 54390075Sobrien#undef false 54490075Sobrien#undef TRUE 54590075Sobrien#undef FALSE 54690075Sobrien 54790075Sobrien#ifdef HAVE_STDBOOL_H 54890075Sobrien# include <stdbool.h> 54990075Sobrien#else 55090075Sobrien# if !HAVE__BOOL 55190075Sobrientypedef char _Bool; 55290075Sobrien# endif 55390075Sobrien# define bool _Bool 55490075Sobrien# define true 1 55590075Sobrien# define false 0 55690075Sobrien#endif 55790075Sobrien 55890075Sobrien#define TRUE true 55990075Sobrien#define FALSE false 56090075Sobrien 56190075Sobrien/* As the last action in this file, we poison the identifiers that 56290075Sobrien shouldn't be used. Note, luckily gcc-3.0's token-based integrated 56390075Sobrien preprocessor won't trip on poisoned identifiers that arrive from 56490075Sobrien the expansion of macros. E.g. #define strrchr rindex, won't error 56590075Sobrien if rindex is poisoned after this directive is issued and later on 56690075Sobrien strrchr is called. 56790075Sobrien 56890075Sobrien Note: We define bypass macros for the few cases where we really 56990075Sobrien want to use the libc memory allocation routines. Otherwise we 57090075Sobrien insist you use the "x" versions from libiberty. */ 57190075Sobrien 57290075Sobrien#define really_call_malloc malloc 57390075Sobrien#define really_call_calloc calloc 57490075Sobrien#define really_call_realloc realloc 57590075Sobrien 57690075Sobrien#if (GCC_VERSION >= 3000) 57790075Sobrien 57890075Sobrien/* Note autoconf checks for prototype declarations and includes 57990075Sobrien system.h while doing so. Only poison these tokens if actually 58090075Sobrien compiling gcc, so that the autoconf declaration tests for malloc 58190075Sobrien etc don't spuriously fail. */ 58290075Sobrien#ifdef IN_GCC 58390075Sobrien#undef calloc 58490075Sobrien#undef strdup 585117395Skan #pragma GCC poison calloc strdup 58690075Sobrien 587117395Skan#if defined(FLEX_SCANNER) || defined (YYBISON) 588117395Skan/* Flex and bison use malloc and realloc. Yuk. */ 589117395Skan#define malloc xmalloc 590117395Skan#define realloc xrealloc 591117395Skan#else 592117395Skan#undef malloc 593117395Skan#undef realloc 594117395Skan #pragma GCC poison malloc realloc 595117395Skan#endif 596117395Skan 59790075Sobrien/* Old target macros that have moved to the target hooks structure. */ 59890075Sobrien #pragma GCC poison ASM_OPEN_PAREN ASM_CLOSE_PAREN \ 59990075Sobrien FUNCTION_PROLOGUE FUNCTION_EPILOGUE \ 60090075Sobrien FUNCTION_END_PROLOGUE FUNCTION_BEGIN_EPILOGUE \ 60190075Sobrien DECL_MACHINE_ATTRIBUTES COMP_TYPE_ATTRIBUTES INSERT_ATTRIBUTES \ 60290075Sobrien VALID_MACHINE_DECL_ATTRIBUTE VALID_MACHINE_TYPE_ATTRIBUTE \ 60390075Sobrien SET_DEFAULT_TYPE_ATTRIBUTES SET_DEFAULT_DECL_ATTRIBUTES \ 60490075Sobrien MERGE_MACHINE_TYPE_ATTRIBUTES MERGE_MACHINE_DECL_ATTRIBUTES \ 60590075Sobrien MD_INIT_BUILTINS MD_EXPAND_BUILTIN ASM_OUTPUT_CONSTRUCTOR \ 606117395Skan ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \ 607117395Skan WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \ 608117395Skan ENCODE_SECTION_INFO STRIP_NAME_ENCODING ASM_GLOBALIZE_LABEL \ 609117395Skan ASM_OUTPUT_MI_THUNK 61090075Sobrien 611117395Skan/* Other obsolete target macros, or macros that used to be in target 61290075Sobrien headers and were not used, and may be obsolete or may never have 61390075Sobrien been used. */ 61490075Sobrien #pragma GCC poison INT_ASM_OP ASM_OUTPUT_EH_REGION_BEG \ 61590075Sobrien ASM_OUTPUT_EH_REGION_END ASM_OUTPUT_LABELREF_AS_INT \ 61690075Sobrien DOESNT_NEED_UNWINDER EH_TABLE_LOOKUP OBJC_SELECTORS_WITHOUT_LABELS \ 61790075Sobrien OMIT_EH_TABLE EASY_DIV_EXPR IMPLICIT_FIX_EXPR \ 61890075Sobrien LONGJMP_RESTORE_FROM_STACK MAX_INT_TYPE_SIZE ASM_IDENTIFY_GCC \ 61990075Sobrien STDC_VALUE TRAMPOLINE_ALIGN ASM_IDENTIFY_GCC_AFTER_SOURCE \ 620102780Skan SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET DWARF_LINE_MIN_INSTR_LENGTH \ 621117395Skan TRADITIONAL_RETURN_FLOAT NO_BUILTIN_SIZE_TYPE \ 622117395Skan NO_BUILTIN_PTRDIFF_TYPE NO_BUILTIN_WCHAR_TYPE NO_BUILTIN_WINT_TYPE \ 623117395Skan BLOCK_PROFILER BLOCK_PROFILER_CODE FUNCTION_BLOCK_PROFILER \ 624117395Skan FUNCTION_BLOCK_PROFILER_EXIT MACHINE_STATE_SAVE \ 625117395Skan MACHINE_STATE_RESTORE SCCS_DIRECTIVE SECTION_ASM_OP \ 626117395Skan ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL 62790075Sobrien 628117395Skan/* Hooks that are no longer used. */ 629117395Skan #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ 630117395Skan LANG_HOOKS_MARK_TREE 631117395Skan 63290075Sobrien#endif /* IN_GCC */ 63390075Sobrien 63490075Sobrien/* Note: not all uses of the `index' token (e.g. variable names and 63590075Sobrien structure members) have been eliminated. */ 63690075Sobrien#undef bcopy 63790075Sobrien#undef bzero 63890075Sobrien#undef bcmp 63990075Sobrien#undef rindex 64090075Sobrien #pragma GCC poison bcopy bzero bcmp rindex 64190075Sobrien 64290075Sobrien#endif /* GCC >= 3.0 */ 64390075Sobrien 64490075Sobrien#endif /* ! GCC_SYSTEM_H */ 645