* arm.c (arm_split_constant): Don't try to force a constant to
[official-gcc.git] / gcc / system.h
blobe668a9e950ba3a3eab2bda4821bbb522e706315b
1 /* system.h - Get common system includes and various definitions and
2 declarations based on autoconf macros.
3 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #ifndef __GCC_SYSTEM_H__
23 #define __GCC_SYSTEM_H__
25 /* We must include stdarg.h/varargs.h before stdio.h. */
26 #ifdef ANSI_PROTOTYPES
27 #include <stdarg.h>
28 #else
29 #include <varargs.h>
30 #endif
32 #include <stdio.h>
34 /* Define a generic NULL if one hasn't already been defined. */
35 #ifndef NULL
36 #define NULL 0
37 #endif
39 /* The compiler is not a multi-threaded application and therefore we
40 do not have to use the locking functions. */
41 #ifdef HAVE_PUTC_UNLOCKED
42 # undef putc
43 # define putc(C, Stream) putc_unlocked (C, Stream)
44 #endif
45 #ifdef HAVE_FPUTC_UNLOCKED
46 # undef fputc
47 # define fputc(C, Stream) fputc_unlocked (C, Stream)
48 #endif
49 #ifdef HAVE_FPUTS_UNLOCKED
50 # undef fputs
51 # define fputs(String, Stream) fputs_unlocked (String, Stream)
52 #endif
54 #include <ctype.h>
56 /* Jim Meyering writes:
58 "... Some ctype macros are valid only for character codes that
59 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
60 using /bin/cc or gcc but without giving an ansi option). So, all
61 ctype uses should be through macros like ISPRINT... If
62 STDC_HEADERS is defined, then autoconf has verified that the ctype
63 macros don't need to be guarded with references to isascii. ...
64 Defining isascii to 1 should let any compiler worth its salt
65 eliminate the && through constant folding."
67 Bruno Haible adds:
69 "... Furthermore, isupper(c) etc. have an undefined result if c is
70 outside the range -1 <= c <= 255. One is tempted to write isupper(c)
71 with c being of type `char', but this is wrong if c is an 8-bit
72 character >= 128 which gets sign-extended to a negative value.
73 The macro ISUPPER protects against this as well." */
75 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
76 # define IN_CTYPE_DOMAIN(c) 1
77 #else
78 # define IN_CTYPE_DOMAIN(c) isascii(c)
79 #endif
81 #ifdef isblank
82 # define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
83 #else
84 # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
85 #endif
86 #ifdef isgraph
87 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
88 #else
89 # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
90 #endif
92 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
93 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
94 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
95 #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
96 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
97 #define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
98 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
99 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
100 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
101 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
103 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
104 - Its arg may be any int or unsigned int; it need not be an unsigned char.
105 - It's guaranteed to evaluate its argument exactly once.
106 - It's typically faster.
107 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
108 only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
109 it's important to use the locale's definition of `digit' even when the
110 host does not conform to Posix. */
111 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
114 #include <sys/types.h>
115 #include <errno.h>
117 #ifndef errno
118 extern int errno;
119 #endif
121 #ifdef STRING_WITH_STRINGS
122 # include <string.h>
123 # include <strings.h>
124 #else
125 # ifdef HAVE_STRING_H
126 # include <string.h>
127 # else
128 # ifdef HAVE_STRINGS_H
129 # include <strings.h>
130 # endif
131 # endif
132 #endif
134 #ifdef HAVE_STDLIB_H
135 # include <stdlib.h>
136 #endif
138 #ifdef HAVE_UNISTD_H
139 # include <unistd.h>
140 #endif
142 #ifdef HAVE_SYS_PARAM_H
143 # include <sys/param.h>
144 #endif
146 #if HAVE_LIMITS_H
147 # include <limits.h>
148 #endif
150 /* Find HOST_WIDEST_INT and set its bit size, type and print macros.
151 It will be the largest integer mode supported by the host which may
152 (or may not) be larger than HOST_WIDE_INT. This must appear after
153 <limits.h> since we only use `long long' if its bigger than a
154 `long' and also if it is supported by macros in limits.h. For old
155 hosts which don't have a limits.h (and thus won't include it in
156 stage2 cause we don't rerun configure) we assume gcc supports long
157 long.) Note, you won't get these defined if you don't include
158 {ht}config.h before this file to set the HOST_BITS_PER_* macros. */
160 #ifndef HOST_WIDEST_INT
161 # if defined (HOST_BITS_PER_LONG) && defined (HOST_BITS_PER_LONGLONG)
162 # if (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) || defined (LLONG_MAX) || defined (__GNUC__))
163 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
164 # define HOST_WIDEST_INT long long
165 # define HOST_WIDEST_INT_PRINT_DEC "%lld"
166 # define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
167 # define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
168 # else
169 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
170 # define HOST_WIDEST_INT long
171 # define HOST_WIDEST_INT_PRINT_DEC "%ld"
172 # define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
173 # define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
174 # endif /*(long long>long) && (LONG_LONG_MAX||LONGLONG_MAX||LLONG_MAX||GNUC)*/
175 # endif /* defined(HOST_BITS_PER_LONG) && defined(HOST_BITS_PER_LONGLONG) */
176 #endif /* ! HOST_WIDEST_INT */
178 #ifdef TIME_WITH_SYS_TIME
179 # include <sys/time.h>
180 # include <time.h>
181 #else
182 # if HAVE_SYS_TIME_H
183 # include <sys/time.h>
184 # else
185 # ifdef HAVE_TIME_H
186 # include <time.h>
187 # endif
188 # endif
189 #endif
191 #ifdef HAVE_FCNTL_H
192 # include <fcntl.h>
193 #else
194 # ifdef HAVE_SYS_FILE_H
195 # include <sys/file.h>
196 # endif
197 #endif
199 #ifndef SEEK_SET
200 # define SEEK_SET 0
201 # define SEEK_CUR 1
202 # define SEEK_END 2
203 #endif
204 #ifndef F_OK
205 # define F_OK 0
206 # define X_OK 1
207 # define W_OK 2
208 # define R_OK 4
209 #endif
210 #ifndef O_RDONLY
211 # define O_RDONLY 0
212 #endif
213 #ifndef O_WRONLY
214 # define O_WRONLY 1
215 #endif
217 /* Some systems define these in, e.g., param.h. We undefine these names
218 here to avoid the warnings. We prefer to use our definitions since we
219 know they are correct. */
221 #undef MIN
222 #undef MAX
223 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
224 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
226 #ifdef HAVE_SYS_WAIT_H
227 #include <sys/wait.h>
228 #endif
230 #ifndef WIFSIGNALED
231 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
232 #endif
233 #ifndef WTERMSIG
234 #define WTERMSIG(S) ((S) & 0x7f)
235 #endif
236 #ifndef WIFEXITED
237 #define WIFEXITED(S) (((S) & 0xff) == 0)
238 #endif
239 #ifndef WEXITSTATUS
240 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
241 #endif
245 #ifndef bcopy
246 # ifdef HAVE_BCOPY
247 # ifdef NEED_DECLARATION_BCOPY
248 extern void bcopy ();
249 # endif
250 # else /* ! HAVE_BCOPY */
251 # define bcopy(src,dst,len) memmove((dst),(src),(len))
252 # endif
253 #endif
255 #ifndef bcmp
256 # ifdef HAVE_BCMP
257 # ifdef NEED_DECLARATION_BCMP
258 extern int bcmp ();
259 # endif
260 # else /* ! HAVE_BCMP */
261 # define bcmp(left,right,len) memcmp ((left),(right),(len))
262 # endif
263 #endif
265 #ifndef bzero
266 # ifdef HAVE_BZERO
267 # ifdef NEED_DECLARATION_BZERO
268 extern void bzero ();
269 # endif
270 # else /* ! HAVE_BZERO */
271 # define bzero(dst,len) memset ((dst),0,(len))
272 # endif
273 #endif
275 #ifndef index
276 # ifdef HAVE_INDEX
277 # ifdef NEED_DECLARATION_INDEX
278 extern char *index ();
279 # endif
280 # else /* ! HAVE_INDEX */
281 # define index strchr
282 # endif
283 #endif
285 #ifndef rindex
286 # ifdef HAVE_RINDEX
287 # ifdef NEED_DECLARATION_RINDEX
288 extern char *rindex ();
289 # endif
290 # else /* ! HAVE_RINDEX */
291 # define rindex strrchr
292 # endif
293 #endif
295 #ifdef NEED_DECLARATION_ATOF
296 extern double atof ();
297 #endif
299 #ifdef NEED_DECLARATION_ATOL
300 extern long atol();
301 #endif
303 #ifdef NEED_DECLARATION_FREE
304 extern void free ();
305 #endif
307 #ifdef NEED_DECLARATION_GETCWD
308 extern char *getcwd ();
309 #endif
311 #ifdef NEED_DECLARATION_GETENV
312 extern char *getenv ();
313 #endif
315 #ifdef NEED_DECLARATION_GETWD
316 extern char *getwd ();
317 #endif
319 #ifdef NEED_DECLARATION_SBRK
320 extern char *sbrk ();
321 #endif
323 #ifdef HAVE_STRERROR
324 # ifdef NEED_DECLARATION_STRERROR
325 # ifndef strerror
326 extern char *strerror ();
327 # endif
328 # endif
329 #else /* ! HAVE_STRERROR */
330 extern int sys_nerr;
331 extern char *sys_errlist[];
332 #endif /* HAVE_STRERROR */
334 #ifdef HAVE_STRSIGNAL
335 # ifdef NEED_DECLARATION_STRSIGNAL
336 # ifndef strsignal
337 extern char * strsignal ();
338 # endif
339 # endif
340 #else /* ! HAVE_STRSIGNAL */
341 # ifndef SYS_SIGLIST_DECLARED
342 # ifndef NO_SYS_SIGLIST
343 extern char * sys_siglist[];
344 # endif
345 # endif
346 #endif /* HAVE_STRSIGNAL */
348 #ifdef HAVE_GETRLIMIT
349 # ifdef NEED_DECLARATION_GETRLIMIT
350 # ifndef getrlimit
351 extern int getrlimit ();
352 # endif
353 # endif
354 #endif
356 #ifdef HAVE_SETRLIMIT
357 # ifdef NEED_DECLARATION_SETRLIMIT
358 # ifndef setrlimit
359 extern int setrlimit ();
360 # endif
361 # endif
362 #endif
364 /* HAVE_VOLATILE only refers to the stage1 compiler. We also check
365 __STDC__ and assume gcc sets it and has volatile in stage >=2. */
366 #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
367 #define volatile
368 #endif
370 /* Redefine abort to report an internal error w/o coredump, and reporting the
371 location of the error in the source file. */
372 #ifndef abort
373 #ifndef __STDC__
374 #ifndef __GNUC__
375 #ifndef USE_SYSTEM_ABORT
376 #define USE_SYSTEM_ABORT
377 #endif /* !USE_SYSTEM_ABORT */
378 #endif /* !__GNUC__ */
379 #endif /* !__STDC__ */
381 #ifdef USE_SYSTEM_ABORT
382 # ifdef NEED_DECLARATION_ABORT
383 extern void abort ();
384 # endif
385 #else
386 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
387 #define abort() \
388 (fprintf (stderr, \
389 "%s:%d: Internal compiler error\n", __FILE__, __LINE__), \
390 exit (FATAL_EXIT_CODE))
392 #else
393 #define abort() \
394 (fprintf (stderr, \
395 "%s:%d: Internal compiler error in function %s\n" \
396 "Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.\n" \
397 "See <URL:http://egcs.cygnus.com/faq.html#bugreport> for details.\n", \
398 __FILE__, __LINE__, __PRETTY_FUNCTION__), \
399 exit (FATAL_EXIT_CODE))
401 #endif /* recent gcc */
402 #endif /* USE_SYSTEM_ABORT */
403 #endif /* !abort */
406 /* Define a STRINGIFY macro that's right for ANSI or traditional C.
407 HAVE_CPP_STRINGIFY only refers to the stage1 compiler. Assume that
408 (non-traditional) gcc used in stage2 or later has this feature.
410 Note: if the argument passed to STRINGIFY is itself a macro, eg
411 #define foo bar, STRINGIFY(foo) will produce "foo", not "bar".
412 Although the __STDC__ case could be made to expand this via a layer
413 of indirection, the traditional C case can not do so. Therefore
414 this behavior is not supported. */
415 #ifndef STRINGIFY
416 # if defined(HAVE_CPP_STRINGIFY) || (defined(__GNUC__) && defined(__STDC__))
417 # define STRINGIFY(STRING) #STRING
418 # else
419 # define STRINGIFY(STRING) "STRING"
420 # endif
421 #endif /* ! STRINGIFY */
423 #if HAVE_SYS_STAT_H
424 # include <sys/stat.h>
425 #endif
427 /* Test if something is a normal file. */
428 #ifndef S_ISREG
429 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
430 #endif
432 /* Test if something is a directory. */
433 #ifndef S_ISDIR
434 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
435 #endif
437 /* Test if something is a character special file. */
438 #ifndef S_ISCHR
439 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
440 #endif
442 /* Test if something is a socket. */
443 #ifndef S_ISSOCK
444 # ifdef S_IFSOCK
445 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
446 # else
447 # define S_ISSOCK(m) 0
448 # endif
449 #endif
451 /* Test if something is a FIFO. */
452 #ifndef S_ISFIFO
453 # ifdef S_IFIFO
454 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
455 # else
456 # define S_ISFIFO(m) 0
457 # endif
458 #endif
460 /* Approximate O_NONBLOCK. */
461 #ifndef O_NONBLOCK
462 #define O_NONBLOCK O_NDELAY
463 #endif
465 /* Approximate O_NOCTTY. */
466 #ifndef O_NOCTTY
467 #define O_NOCTTY 0
468 #endif
470 /* Get libiberty declarations. */
471 #include "libiberty.h"
473 #endif /* __GCC_SYSTEM_H__ */