OSDN Git Service

* flow.c (find_unreachable_blocks): New function.
[pf3gnuchains/gcc-fork.git] / gcc / system.h
1 /* Get common system includes and various definitions and declarations based
2    on autoconf macros.
3    Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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.  */
21
22
23 #ifndef GCC_SYSTEM_H
24 #define GCC_SYSTEM_H
25
26 /* This is the location of the online document giving information how
27    to report bugs. If you change this string, also check for strings
28    not under control of the preprocessor.  */
29 #define GCCBUGURL "<URL:http://www.gnu.org/software/gcc/bugs.html>"
30
31 /* We must include stdarg.h/varargs.h before stdio.h. */
32 #ifdef ANSI_PROTOTYPES
33 #include <stdarg.h>
34 #else
35 #include <varargs.h>
36 #endif
37
38 #ifndef va_copy
39 # ifdef __va_copy
40 #   define va_copy(d,s)  __va_copy((d),(s))
41 # else
42 #   define va_copy(d,s)  ((d) = (s))
43 # endif
44 #endif
45
46 #ifdef HAVE_STDDEF_H
47 # include <stddef.h>
48 #endif
49
50 #include <stdio.h>
51
52 /* Define a generic NULL if one hasn't already been defined.  */
53 #ifndef NULL
54 #define NULL 0
55 #endif
56
57 /* The compiler is not a multi-threaded application and therefore we
58    do not have to use the locking functions.
59
60    HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the IO
61    code is multi-thread safe by default.  If it is set to 0, then do
62    not worry about using the _unlocked functions.
63    
64    fputs_unlocked is an extension and needs to be prototyped specially.  */
65
66 #if defined HAVE_PUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
67 # undef putc
68 # define putc(C, Stream) putc_unlocked (C, Stream)
69 #endif
70 #if defined HAVE_FPUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
71 # undef fputc
72 # define fputc(C, Stream) fputc_unlocked (C, Stream)
73 #endif
74 #if defined HAVE_FPUTS_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
75 # undef fputs
76 # define fputs(String, Stream) fputs_unlocked (String, Stream)
77 # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
78 extern int fputs_unlocked PARAMS ((const char *, FILE *));
79 # endif
80 #endif
81
82 /* There are an extraordinary number of issues with <ctype.h>.
83    The last straw is that it varies with the locale.  Use libiberty's
84    replacement instead.  */
85 #include <safe-ctype.h>
86
87 /* Define a default escape character; it's different for EBCDIC.  */
88 #ifndef TARGET_ESC
89 #define TARGET_ESC 033
90 #endif
91
92 #include <sys/types.h>
93
94 #include <errno.h>
95
96 #if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
97 extern int errno;
98 #endif
99
100 #ifdef STRING_WITH_STRINGS
101 # include <string.h>
102 # include <strings.h>
103 #else
104 # ifdef HAVE_STRING_H
105 #  include <string.h>
106 # else
107 #  ifdef HAVE_STRINGS_H
108 #   include <strings.h>
109 #  endif
110 # endif
111 #endif
112
113 #ifdef HAVE_STDLIB_H
114 # include <stdlib.h>
115 #endif
116
117 /* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and
118    FATAL_EXIT_CODE to EXIT_SUCCESS and EXIT_FAILURE respectively,
119    or 0 and 1 if those macros are not defined.  */
120 #ifndef SUCCESS_EXIT_CODE
121 # ifdef EXIT_SUCCESS
122 #  define SUCCESS_EXIT_CODE EXIT_SUCCESS
123 # else
124 #  define SUCCESS_EXIT_CODE 0
125 # endif
126 #endif
127
128 #ifndef FATAL_EXIT_CODE
129 # ifdef EXIT_FAILURE
130 #  define FATAL_EXIT_CODE EXIT_FAILURE
131 # else
132 #  define FATAL_EXIT_CODE 1
133 # endif
134 #endif
135
136 #ifdef HAVE_UNISTD_H
137 # include <unistd.h>
138 #endif
139
140 #ifdef HAVE_SYS_PARAM_H
141 # include <sys/param.h>
142 #endif
143
144 #if HAVE_LIMITS_H
145 # include <limits.h>
146 #endif
147
148 /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT.  */
149 #include "hwint.h"
150
151 /* Infrastructure for defining missing _MAX and _MIN macros.  Note that
152    macros defined with these cannot be used in #if.  */
153
154 /* The extra casts work around common compiler bugs.  */
155 #define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
156 /* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
157    It is necessary at least when t == time_t.  */
158 #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
159                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
160 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
161
162 /* Use that infrastructure to provide a few constants.  */
163 #ifndef UCHAR_MAX
164 # define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char)
165 #endif
166
167 #ifdef TIME_WITH_SYS_TIME
168 # include <sys/time.h>
169 # include <time.h>
170 #else
171 # if HAVE_SYS_TIME_H
172 #  include <sys/time.h>
173 # else
174 #  ifdef HAVE_TIME_H
175 #   include <time.h>
176 #  endif
177 # endif
178 #endif
179
180 #ifdef HAVE_FCNTL_H
181 # include <fcntl.h>
182 #else
183 # ifdef HAVE_SYS_FILE_H
184 #  include <sys/file.h>
185 # endif
186 #endif
187
188 #ifndef SEEK_SET
189 # define SEEK_SET 0
190 # define SEEK_CUR 1
191 # define SEEK_END 2
192 #endif
193 #ifndef F_OK
194 # define F_OK 0
195 # define X_OK 1
196 # define W_OK 2
197 # define R_OK 4
198 #endif
199 #ifndef O_RDONLY
200 # define O_RDONLY 0
201 #endif
202 #ifndef O_WRONLY
203 # define O_WRONLY 1
204 #endif
205
206 /* Some systems define these in, e.g., param.h.  We undefine these names
207    here to avoid the warnings.  We prefer to use our definitions since we
208    know they are correct.  */
209
210 #undef MIN
211 #undef MAX
212 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
213 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
214
215 /* Returns the least number N such that N * Y >= X.  */
216 #define CEIL(x,y) (((x) + (y) - 1) / (y))
217
218 #ifdef HAVE_SYS_WAIT_H
219 #include <sys/wait.h>
220 #endif
221
222 #ifndef WIFSIGNALED
223 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
224 #endif
225 #ifndef WTERMSIG
226 #define WTERMSIG(S) ((S) & 0x7f)
227 #endif
228 #ifndef WIFEXITED
229 #define WIFEXITED(S) (((S) & 0xff) == 0)
230 #endif
231 #ifndef WEXITSTATUS
232 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
233 #endif
234 #ifndef WSTOPSIG
235 #define WSTOPSIG WEXITSTATUS
236 #endif
237
238 /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1.  If they
239    are defined to 0 then we must provide the relevant declaration
240    here.  These checks will be in the undefined state while configure
241    is running so be careful to test "defined (HAVE_DECL_*)".  */
242
243 #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
244 extern double atof PARAMS ((const char *));
245 #endif
246
247 #if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL
248 extern long atol PARAMS ((const char *));
249 #endif
250
251 #if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE
252 extern void free PARAMS ((PTR));
253 #endif
254
255 #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD
256 extern char *getcwd PARAMS ((char *, size_t));
257 #endif
258
259 #if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV
260 extern char *getenv PARAMS ((const char *));
261 #endif
262
263 #if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT
264 extern int getopt PARAMS ((int, char * const *, const char *));
265 #endif
266
267 #if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD
268 extern char *getwd PARAMS ((char *));
269 #endif
270
271 #if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK
272 extern PTR sbrk PARAMS ((int));
273 #endif
274
275 #if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR
276 extern char *strstr PARAMS ((const char *, const char *));
277 #endif
278
279 #ifdef HAVE_MALLOC_H
280 #include <malloc.h>
281 #endif
282
283 #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
284 extern PTR malloc PARAMS ((size_t));
285 #endif
286
287 #if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC
288 extern PTR calloc PARAMS ((size_t, size_t));
289 #endif
290
291 #if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC
292 extern PTR realloc PARAMS ((PTR, size_t));
293 #endif
294
295 /* If the system doesn't provide strsignal, we get it defined in
296    libiberty but no declaration is supplied. */
297 #ifndef HAVE_STRSIGNAL
298 # ifndef strsignal
299 extern const char *strsignal PARAMS ((int));
300 # endif
301 #endif
302
303 #ifdef HAVE_GETRLIMIT
304 # if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT
305 #  ifndef getrlimit
306 #   ifdef ANSI_PROTOTYPES
307 struct rlimit;
308 #   endif
309 extern int getrlimit PARAMS ((int, struct rlimit *));
310 #  endif
311 # endif
312 #endif
313
314 #ifdef HAVE_SETRLIMIT
315 # if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT
316 #  ifndef setrlimit
317 #   ifdef ANSI_PROTOTYPES
318 struct rlimit;
319 #   endif
320 extern int setrlimit PARAMS ((int, const struct rlimit *));
321 #  endif
322 # endif
323 #endif
324
325 /* HAVE_VOLATILE only refers to the stage1 compiler.  We also check
326    __STDC__ and assume gcc sets it and has volatile in stage >=2. */
327 #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
328 #define volatile
329 #endif
330
331 #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
332 extern void abort PARAMS ((void));
333 #endif
334
335 /* 1 if we have C99 designated initializers.  */
336 #if !defined(HAVE_DESIGNATED_INITIALIZERS)
337 #define HAVE_DESIGNATED_INITIALIZERS \
338   ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
339 #endif
340
341 /* 1 if we have _Bool.  */
342 #ifndef HAVE__BOOL
343 # define HAVE__BOOL \
344    ((GCC_VERSION >= 3000) || (__STDC_VERSION__ >= 199901L))
345 #endif
346
347
348 #if HAVE_SYS_STAT_H
349 # include <sys/stat.h>
350 #endif
351
352 /* Test if something is a normal file.  */
353 #ifndef S_ISREG
354 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
355 #endif
356
357 /* Test if something is a directory.  */
358 #ifndef S_ISDIR
359 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
360 #endif
361
362 /* Test if something is a character special file.  */
363 #ifndef S_ISCHR
364 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
365 #endif
366
367 /* Test if something is a block special file.  */
368 #ifndef S_ISBLK
369 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
370 #endif
371
372 /* Test if something is a socket.  */
373 #ifndef S_ISSOCK
374 # ifdef S_IFSOCK
375 #   define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
376 # else
377 #   define S_ISSOCK(m) 0
378 # endif
379 #endif
380
381 /* Test if something is a FIFO.  */
382 #ifndef S_ISFIFO
383 # ifdef S_IFIFO
384 #  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
385 # else
386 #  define S_ISFIFO(m) 0
387 # endif
388 #endif
389
390 /* Approximate O_NONBLOCK.  */
391 #ifndef O_NONBLOCK
392 #define O_NONBLOCK O_NDELAY
393 #endif
394
395 /* Approximate O_NOCTTY.  */
396 #ifndef O_NOCTTY
397 #define O_NOCTTY 0
398 #endif
399
400 /* Define well known filenos if the system does not define them.  */
401 #ifndef STDIN_FILENO
402 # define STDIN_FILENO   0
403 #endif
404 #ifndef STDOUT_FILENO
405 # define STDOUT_FILENO  1
406 #endif
407 #ifndef STDERR_FILENO
408 # define STDERR_FILENO  2
409 #endif
410
411 /* Some systems have mkdir that takes a single argument. */
412 #ifdef MKDIR_TAKES_ONE_ARG
413 # define mkdir(a,b) mkdir(a)
414 #endif
415
416 /* Provide a way to print an address via printf.  */
417 #ifndef HOST_PTR_PRINTF
418 # ifdef HAVE_PRINTF_PTR
419 #  define HOST_PTR_PRINTF "%p"
420 # else
421 #  define HOST_PTR_PRINTF \
422     (sizeof (int) == sizeof (char *) ? "%x" \
423      : sizeof (long) == sizeof (char *) ? "%lx" : "%llx")
424 # endif
425 #endif /* ! HOST_PTR_PRINTF */
426
427 /* By default, colon separates directories in a path.  */
428 #ifndef PATH_SEPARATOR
429 #define PATH_SEPARATOR ':'
430 #endif
431
432 #ifndef DIR_SEPARATOR
433 #define DIR_SEPARATOR '/'
434 #endif
435
436 /* Define IS_DIR_SEPARATOR.  */
437 #ifndef DIR_SEPARATOR_2
438 # define IS_DIR_SEPARATOR(CH) ((CH) == DIR_SEPARATOR)
439 #else /* DIR_SEPARATOR_2 */
440 # define IS_DIR_SEPARATOR(CH) \
441         (((CH) == DIR_SEPARATOR) || ((CH) == DIR_SEPARATOR_2))
442 #endif /* DIR_SEPARATOR_2 */
443
444 /* Say how to test for an absolute pathname.  On Unix systems, this is if
445    it starts with a leading slash or a '$', the latter meaning the value of
446    an environment variable is to be used.  On machien with DOS-based
447    file systems, it is also absolute if it starts with a drive identifier.  */
448 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
449 #define IS_ABSOLUTE_PATHNAME(STR) \
450   (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$' \
451    || ((STR)[0] != '\0' && (STR)[1] == ':' && IS_DIR_SEPARATOR ((STR)[2])))
452 #else
453 #define IS_ABSOLUTE_PATHNAME(STR) \
454   (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$')
455 #endif
456
457 /* Get libiberty declarations. */
458 #include "libiberty.h"
459 #include "symcat.h"
460
461 /* Provide a default for the HOST_BIT_BUCKET.
462    This suffices for POSIX-like hosts.  */
463
464 #ifndef HOST_BIT_BUCKET
465 #define HOST_BIT_BUCKET "/dev/null"
466 #endif
467
468 /* Be conservative and only use enum bitfields with GCC.
469    FIXME: provide a complete autoconf test for buggy enum bitfields.  */
470
471 #if (GCC_VERSION > 2000)
472 #define ENUM_BITFIELD(TYPE) enum TYPE
473 #else
474 #define ENUM_BITFIELD(TYPE) unsigned int
475 #endif
476
477 #ifndef offsetof
478 #define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *)0)->MEMBER)
479 #endif
480
481 /* Traditional C cannot initialize union members of structs.  Provide
482    a macro which expands appropriately to handle it.  This only works
483    if you intend to initalize the union member to zero since it relies
484    on default initialization to zero in the traditional C case.  */
485 #ifdef __STDC__
486 #define UNION_INIT_ZERO , {0}
487 #else
488 #define UNION_INIT_ZERO
489 #endif
490
491 /* Various error reporting routines want to use __FUNCTION__.  */
492 #if (GCC_VERSION < 2007)
493 #ifndef __FUNCTION__
494 #define __FUNCTION__ "?"
495 #endif /* ! __FUNCTION__ */
496 #endif
497
498 /* Provide some sort of boolean type.  We use stdbool.h if it's
499   available.  This is dead last because various system headers might
500   mess us up.  */
501 #undef bool
502 #undef true
503 #undef false
504 #undef TRUE
505 #undef FALSE
506
507 #ifdef HAVE_STDBOOL_H
508 # include <stdbool.h>
509 #else
510 # if !HAVE__BOOL
511 typedef char _Bool;
512 # endif
513 # define bool _Bool
514 # define true 1
515 # define false 0
516 #endif
517
518 #define TRUE true
519 #define FALSE false
520
521 /* As the last action in this file, we poison the identifiers that
522    shouldn't be used.  Note, luckily gcc-3.0's token-based integrated
523    preprocessor won't trip on poisoned identifiers that arrive from
524    the expansion of macros.  E.g. #define strrchr rindex, won't error
525    if rindex is poisoned after this directive is issued and later on
526    strrchr is called.
527
528    Note: We define bypass macros for the few cases where we really
529    want to use the libc memory allocation routines.  Otherwise we
530    insist you use the "x" versions from libiberty.  */
531
532 #define really_call_malloc malloc
533 #define really_call_calloc calloc
534 #define really_call_realloc realloc
535
536 #if (GCC_VERSION >= 3000)
537
538 /* Note autoconf checks for prototype declarations and includes
539    system.h while doing so.  Only poison these tokens if actually
540    compiling gcc, so that the autoconf declaration tests for malloc
541    etc don't spuriously fail.  */
542 #ifdef IN_GCC
543 #undef malloc
544 #undef realloc
545 #undef calloc
546 #undef strdup
547  #pragma GCC poison malloc realloc calloc strdup
548 #endif /* IN_GCC */
549
550 /* Note: not all uses of the `index' token (e.g. variable names and
551    structure members) have been eliminated.  */
552 #undef bcopy
553 #undef bzero
554 #undef bcmp
555 #undef rindex
556  #pragma GCC poison bcopy bzero bcmp rindex
557
558 #endif /* GCC >= 3.0 */
559
560 #endif /* ! GCC_SYSTEM_H */