]>
gcc.gnu.org Git - gcc.git/blob - gcc/system.h
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__
10 /* We must include stdarg.h/varargs.h before stdio.h. */
19 /* Define a generic NULL if one hasn't already been defined. */
26 /* Jim Meyering writes:
28 "... Some ctype macros are valid only for character codes that
29 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
30 using /bin/cc or gcc but without giving an ansi option). So, all
31 ctype uses should be through macros like ISPRINT... If
32 STDC_HEADERS is defined, then autoconf has verified that the ctype
33 macros don't need to be guarded with references to isascii. ...
34 Defining isascii to 1 should let any compiler worth its salt
35 eliminate the && through constant folding."
39 "... Furthermore, isupper(c) etc. have an undefined result if c is
40 outside the range -1 <= c <= 255. One is tempted to write isupper(c)
41 with c being of type `char', but this is wrong if c is an 8-bit
42 character >= 128 which gets sign-extended to a negative value.
43 The macro ISUPPER protects against this as well." */
45 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
46 # define IN_CTYPE_DOMAIN(c) 1
48 # define IN_CTYPE_DOMAIN(c) isascii(c)
52 # define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
54 # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
57 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
59 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
62 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
63 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
64 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
65 #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
66 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
67 #define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
68 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
69 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
70 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
71 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
73 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
74 - Its arg may be any int or unsigned int; it need not be an unsigned char.
75 - It's guaranteed to evaluate its argument exactly once.
76 - It's typically faster.
77 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
78 only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
79 it's important to use the locale's definition of `digit' even when the
80 host does not conform to Posix. */
81 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
84 #include <sys/types.h>
91 #ifdef STRING_WITH_STRINGS
98 # ifdef HAVE_STRINGS_H
112 #ifdef HAVE_SYS_PARAM_H
113 # include <sys/param.h>
120 #ifdef TIME_WITH_SYS_TIME
121 # include <sys/time.h>
125 # include <sys/time.h>
136 # ifdef HAVE_SYS_FILE_H
137 # include <sys/file.h>
163 # ifdef NEED_DECLARATION_BCOPY
164 extern void bcopy ();
166 # else /* ! HAVE_BCOPY */
167 # define bcopy(src,dst,len) memcpy ((dst),(src),(len))
173 # ifdef NEED_DECLARATION_BCMP
176 # else /* ! HAVE_BCMP */
177 # define bcmp(left,right,len) memcmp ((left),(right),(len))
183 # ifdef NEED_DECLARATION_BZERO
184 extern void bzero ();
186 # else /* ! HAVE_BZERO */
187 # define bzero(dst,len) memset ((dst),0,(len))
193 # ifdef NEED_DECLARATION_INDEX
194 extern char *index ();
196 # else /* ! HAVE_INDEX */
197 # define index strchr
203 # ifdef NEED_DECLARATION_RINDEX
204 extern char *rindex ();
206 # else /* ! HAVE_RINDEX */
207 # define rindex strrchr
211 #ifdef NEED_DECLARATION_ATOF
212 extern double atof ();
215 #ifdef NEED_DECLARATION_ATOL
219 #ifdef NEED_DECLARATION_FREE
223 #ifdef NEED_DECLARATION_GETCWD
224 extern char *getcwd ();
227 #ifdef NEED_DECLARATION_GETENV
228 extern char *getenv ();
231 #ifdef NEED_DECLARATION_GETWD
232 extern char *getwd ();
235 #ifdef NEED_DECLARATION_SBRK
236 extern char *sbrk ();
240 # ifdef NEED_DECLARATION_STRERROR
242 extern char *strerror ();
245 #else /* ! HAVE_STRERROR */
247 extern char *sys_errlist
[];
248 #endif /* HAVE_STRERROR */
250 #ifdef HAVE_STRSIGNAL
251 # ifdef NEED_DECLARATION_STRSIGNAL
253 extern char * strsignal ();
256 #else /* ! HAVE_STRSIGNAL */
257 # ifndef SYS_SIGLIST_DECLARED
258 # ifndef NO_SYS_SIGLIST
259 extern char * sys_siglist
[];
262 #endif /* HAVE_STRSIGNAL */
264 #ifdef HAVE_GETRLIMIT
265 # ifdef NEED_DECLARATION_GETRLIMIT
267 extern int getrlimit ();
272 #ifdef HAVE_SETRLIMIT
273 # ifdef NEED_DECLARATION_SETRLIMIT
275 extern int setrlimit ();
280 /* HAVE_VOLATILE only refers to the stage1 compiler. We also check
281 __STDC__ and assume gcc sets it and has volatile in stage >=2. */
282 #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
286 /* Redefine abort to report an internal error w/o coredump, and reporting the
287 location of the error in the source file. */
291 #ifndef USE_SYSTEM_ABORT
292 #define USE_SYSTEM_ABORT
293 #endif /* !USE_SYSTEM_ABORT */
294 #endif /* !__GNUC__ */
295 #endif /* !__STDC__ */
297 #ifdef USE_SYSTEM_ABORT
298 # ifdef NEED_DECLARATION_ABORT
299 extern void abort ();
302 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
305 "%s:%d: Internal compiler error\n", __FILE__, __LINE__), \
306 exit (FATAL_EXIT_CODE))
311 "%s:%d: Internal compiler error in function %s\n", \
312 __FILE__, __LINE__, __PRETTY_FUNCTION__), \
313 exit (FATAL_EXIT_CODE))
315 #endif /* recent gcc */
316 #endif /* USE_SYSTEM_ABORT */
320 /* Define a STRINGIFY macro that's right for ANSI or traditional C.
321 HAVE_CPP_STRINGIFY only refers to the stage1 compiler. Assume that
322 (non-traditional) gcc used in stage2 or later has this feature.
324 Note: if the argument passed to STRINGIFY is itself a macro, eg
325 #define foo bar, STRINGIFY(foo) will produce "foo", not "bar".
326 Although the __STDC__ case could be made to expand this via a layer
327 of indirection, the traditional C case can not do so. Therefore
328 this behavior is not supported. */
330 # if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
331 # define STRINGIFY(STRING) #STRING
333 # define STRINGIFY(STRING) "STRING"
335 #endif /* ! STRINGIFY */
338 /* These macros are here in preparation for the use of gettext in egcs. */
339 #define _(String) String
340 #define N_(String) String
342 #endif /* __GCC_SYSTEM_H__ */
This page took 0.049173 seconds and 5 git commands to generate.