1 /* system.h - Get common system includes and various definitions and
2 declarations based on autoconf macros.
3 Copyright (C) 1998 Free Software Foundation, Inc.
7 #ifndef __GCC_SYSTEM_H__
8 #define __GCC_SYSTEM_H__
13 /* Jim Meyering writes:
15 "... Some ctype macros are valid only for character codes that
16 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
17 using /bin/cc or gcc but without giving an ansi option). So, all
18 ctype uses should be through macros like ISPRINT... If
19 STDC_HEADERS is defined, then autoconf has verified that the ctype
20 macros don't need to be guarded with references to isascii. ...
21 Defining isascii to 1 should let any compiler worth its salt
22 eliminate the && through constant folding."
26 "... Furthermore, isupper(c) etc. have an undefined result if c is
27 outside the range -1 <= c <= 255. One is tempted to write isupper(c)
28 with c being of type `char', but this is wrong if c is an 8-bit
29 character >= 128 which gets sign-extended to a negative value.
30 The macro ISUPPER protects against this as well." */
32 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
33 # define IN_CTYPE_DOMAIN(c) 1
35 # define IN_CTYPE_DOMAIN(c) isascii(c)
39 # define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
41 # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
44 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
46 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
49 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
50 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
51 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
52 #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
53 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
54 #define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
55 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
56 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
57 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
58 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
60 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
61 - Its arg may be any int or unsigned int; it need not be an unsigned char.
62 - It's guaranteed to evaluate its argument exactly once.
63 - It's typically faster.
64 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
65 only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
66 it's important to use the locale's definition of `digit' even when the
67 host does not conform to Posix. */
68 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
71 #include <sys/types.h>
81 # ifdef HAVE_STRINGS_H
94 #ifdef HAVE_SYS_PARAM_H
95 # include <sys/param.h>
102 #ifdef TIME_WITH_SYS_TIME
103 # include <sys/time.h>
107 # include <sys/time.h>
116 # include <sys/file.h>
135 # ifdef NEED_DECLARATION_BCOPY
136 extern void bcopy ();
138 # else /* ! HAVE_BCOPY */
139 # define bcopy(src,dst,len) memcpy ((dst),(src),(len))
145 # ifdef NEED_DECLARATION_BCMP
148 # else /* ! HAVE_BCMP */
149 # define bcmp(left,right,len) memcmp ((left),(right),(len))
155 # ifdef NEED_DECLARATION_BZERO
156 extern void bzero ();
158 # else /* ! HAVE_BZERO */
159 # define bzero(dst,len) memset ((dst),0,(len))
165 # ifdef NEED_DECLARATION_INDEX
166 extern char *index ();
168 # else /* ! HAVE_INDEX */
169 # define index strchr
175 # ifdef NEED_DECLARATION_RINDEX
176 extern char *rindex ();
178 # else /* ! HAVE_RINDEX */
179 # define rindex strrchr
183 #ifdef NEED_DECLARATION_FREE
187 #ifdef NEED_DECLARATION_GETENV
188 extern char *getenv ();
191 /* Redefine abort to report an internal error w/o coredump, and reporting the
192 location of the error in the source file. */
196 #ifndef USE_SYSTEM_ABORT
197 #define USE_SYSTEM_ABORT
198 #endif /* !USE_SYSTEM_ABORT */
199 #endif /* !__GNUC__ */
200 #endif /* !__STDC__ */
202 #ifndef USE_SYSTEM_ABORT
203 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
206 "%s:%d: Internal compiler error\n", __FILE__, __LINE__), \
207 exit (FATAL_EXIT_CODE))
212 "%s:%d: Internal compiler error in function %s\n", \
213 __FILE__, __LINE__, __PRETTY_FUNCTION__), \
214 exit (FATAL_EXIT_CODE))
216 #endif /* recent gcc */
217 #endif /* !USE_SYSTEM_ABORT */
220 #endif /* __GCC_SYSTEM_H__ */