OSDN Git Service

Mark the generated insn not the set as being DWARF2_FRAME_RELATED_P.
[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 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 #include <stdio.h>
47
48 /* Define a generic NULL if one hasn't already been defined.  */
49 #ifndef NULL
50 #define NULL 0
51 #endif
52
53 /* The compiler is not a multi-threaded application and therefore we
54    do not have to use the locking functions.
55
56    HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the IO
57    code is multi-thread safe by default.  If it is set to 0, then do
58    not worry about using the _unlocked functions.
59    
60    fputs_unlocked is an extension and needs to be prototyped specially.  */
61
62 #if defined HAVE_PUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
63 # undef putc
64 # define putc(C, Stream) putc_unlocked (C, Stream)
65 #endif
66 #if defined HAVE_FPUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
67 # undef fputc
68 # define fputc(C, Stream) fputc_unlocked (C, Stream)
69 #endif
70 #if defined HAVE_FPUTS_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
71 # undef fputs
72 # define fputs(String, Stream) fputs_unlocked (String, Stream)
73 # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
74 extern int fputs_unlocked PARAMS ((const char *, FILE *));
75 # endif
76 #endif
77
78 /* There are an extraordinary number of issues with <ctype.h>.
79    The last straw is that it varies with the locale.  Use libiberty's
80    replacement instead.  */
81 #include <safe-ctype.h>
82
83 /* Define a default escape character; it's different for EBCDIC.  */
84 #ifndef TARGET_ESC
85 #define TARGET_ESC 033
86 #endif
87
88 #include <sys/types.h>
89
90 #include <errno.h>
91
92 #ifndef errno
93 extern int errno;
94 #endif
95
96 #ifdef STRING_WITH_STRINGS
97 # include <string.h>
98 # include <strings.h>
99 #else
100 # ifdef HAVE_STRING_H
101 #  include <string.h>
102 # else
103 #  ifdef HAVE_STRINGS_H
104 #   include <strings.h>
105 #  endif
106 # endif
107 #endif
108
109 #ifdef HAVE_STDLIB_H
110 # include <stdlib.h>
111 # ifdef USE_C_ALLOCA
112 /* Note that systems that use glibc have a <stdlib.h> that includes
113    <alloca.h> that defines alloca, so let USE_C_ALLOCA override this. */
114 # undef alloca
115 #endif
116 #endif
117
118 #ifdef HAVE_UNISTD_H
119 # include <unistd.h>
120 #endif
121
122 #ifdef HAVE_SYS_PARAM_H
123 # include <sys/param.h>
124 #endif
125
126 #if HAVE_LIMITS_H
127 # include <limits.h>
128 #endif
129
130 /* Find HOST_WIDEST_INT and set its bit size, type and print macros.
131    It will be the largest integer mode supported by the host which may
132    (or may not) be larger than HOST_WIDE_INT.  This must appear after
133    <limits.h> since we only use `long long' if its bigger than a
134    `long' and also if it is supported by macros in limits.h.  For old
135    hosts which don't have a limits.h (and thus won't include it in
136    stage2 cause we don't rerun configure) we assume gcc supports long
137    long.)  Note, you won't get these defined if you don't include
138    {ht}config.h before this file to set the HOST_BITS_PER_* macros. */
139
140 #ifndef HOST_WIDEST_INT
141 # if defined (HOST_BITS_PER_LONG) && defined (HOST_BITS_PER_LONGLONG)
142 #  if (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) || defined (LLONG_MAX) || defined (__GNUC__))
143 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
144 #   define HOST_WIDEST_INT long long
145 #   define HOST_WIDEST_INT_PRINT_DEC "%lld"
146 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
147 #   define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
148 #  else
149 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
150 #   define HOST_WIDEST_INT long
151 #   define HOST_WIDEST_INT_PRINT_DEC "%ld"
152 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
153 #   define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
154 #  endif /*(long long>long) && (LONG_LONG_MAX||LONGLONG_MAX||LLONG_MAX||GNUC)*/
155 # endif /* defined(HOST_BITS_PER_LONG) && defined(HOST_BITS_PER_LONGLONG) */
156 #endif /* ! HOST_WIDEST_INT */
157
158 /* Infrastructure for defining missing _MAX and _MIN macros.  Note that
159    macros defined with these cannot be used in #if.  */
160
161 /* The extra casts work around common compiler bugs.  */
162 #define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
163 /* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
164    It is necessary at least when t == time_t.  */
165 #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
166                              ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
167 #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
168
169 /* Use that infrastructure to provide a few constants.  */
170 #ifndef UCHAR_MAX
171 # define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char)
172 #endif
173
174 #ifdef TIME_WITH_SYS_TIME
175 # include <sys/time.h>
176 # include <time.h>
177 #else
178 # if HAVE_SYS_TIME_H
179 #  include <sys/time.h>
180 # else
181 #  ifdef HAVE_TIME_H
182 #   include <time.h>
183 #  endif
184 # endif
185 #endif
186
187 #ifdef HAVE_FCNTL_H
188 # include <fcntl.h>
189 #else
190 # ifdef HAVE_SYS_FILE_H
191 #  include <sys/file.h>
192 # endif
193 #endif
194
195 #ifndef SEEK_SET
196 # define SEEK_SET 0
197 # define SEEK_CUR 1
198 # define SEEK_END 2
199 #endif
200 #ifndef F_OK
201 # define F_OK 0
202 # define X_OK 1
203 # define W_OK 2
204 # define R_OK 4
205 #endif
206 #ifndef O_RDONLY
207 # define O_RDONLY 0
208 #endif
209 #ifndef O_WRONLY
210 # define O_WRONLY 1
211 #endif
212
213 /* Some systems define these in, e.g., param.h.  We undefine these names
214    here to avoid the warnings.  We prefer to use our definitions since we
215    know they are correct.  */
216
217 #undef MIN
218 #undef MAX
219 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
220 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
221
222 /* Returns the least number N such that N * Y >= X.  */
223 #define CEIL(x,y) (((x) + (y) - 1) / (y))
224
225 #ifdef HAVE_SYS_WAIT_H
226 #include <sys/wait.h>
227 #endif
228
229 #ifndef WIFSIGNALED
230 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
231 #endif
232 #ifndef WTERMSIG
233 #define WTERMSIG(S) ((S) & 0x7f)
234 #endif
235 #ifndef WIFEXITED
236 #define WIFEXITED(S) (((S) & 0xff) == 0)
237 #endif
238 #ifndef WEXITSTATUS
239 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
240 #endif
241 #ifndef WSTOPSIG
242 #define WSTOPSIG WEXITSTATUS
243 #endif
244
245 /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1.  If they
246    are defined to 0 then we must provide the relevant declaration
247    here.  These checks will be in the undefined state while configure
248    is running so be careful to test "defined (HAVE_DECL_*)".  */
249
250 #ifndef bcopy
251 # ifdef HAVE_BCOPY
252 #  if defined (HAVE_DECL_BCOPY) && !HAVE_DECL_BCOPY
253 extern void bcopy PARAMS ((const PTR, PTR, size_t));
254 #  endif
255 # else /* ! HAVE_BCOPY */
256 #  define bcopy(src,dst,len) memmove((dst),(src),(len))
257 # endif
258 #endif
259
260 #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
261 extern double atof PARAMS ((const char *));
262 #endif
263
264 #if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL
265 extern long atol PARAMS ((const char *));
266 #endif
267
268 #if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE
269 extern void free PARAMS ((PTR));
270 #endif
271
272 #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD
273 extern char *getcwd PARAMS ((char *, size_t));
274 #endif
275
276 #if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV
277 extern char *getenv PARAMS ((const char *));
278 #endif
279
280 #if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT
281 extern int getopt PARAMS ((int, char **, char *));
282 #endif
283
284 #if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD
285 extern char *getwd PARAMS ((char *));
286 #endif
287
288 #if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK
289 extern PTR sbrk PARAMS ((int));
290 #endif
291
292 #if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR
293 extern char *strstr PARAMS ((const char *, const char *));
294 #endif
295
296 #ifdef HAVE_MALLOC_H
297 #include <malloc.h>
298 #endif
299
300 #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
301 extern PTR malloc PARAMS ((size_t));
302 #endif
303
304 #if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC
305 extern PTR calloc PARAMS ((size_t, size_t));
306 #endif
307
308 #if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC
309 extern PTR realloc PARAMS ((PTR, size_t));
310 #endif
311
312 /* If the system doesn't provide strsignal, we get it defined in
313    libiberty but no declaration is supplied. */
314 #ifndef HAVE_STRSIGNAL
315 # ifndef strsignal
316 extern const char *strsignal PARAMS ((int));
317 # endif
318 #endif
319
320 #ifdef HAVE_GETRLIMIT
321 # if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT
322 #  ifndef getrlimit
323 #   ifdef ANSI_PROTOTYPES
324 struct rlimit;
325 #   endif
326 extern int getrlimit PARAMS ((int, struct rlimit *));
327 #  endif
328 # endif
329 #endif
330
331 #ifdef HAVE_SETRLIMIT
332 # if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT
333 #  ifndef setrlimit
334 #   ifdef ANSI_PROTOTYPES
335 struct rlimit;
336 #   endif
337 extern int setrlimit PARAMS ((int, const struct rlimit *));
338 #  endif
339 # endif
340 #endif
341
342 /* HAVE_VOLATILE only refers to the stage1 compiler.  We also check
343    __STDC__ and assume gcc sets it and has volatile in stage >=2. */
344 #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
345 #define volatile
346 #endif
347
348 #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
349 extern void abort PARAMS ((void));
350 #endif
351
352 /* 1 if we have C99 designated initializers.  */
353 #if !defined(HAVE_DESIGNATED_INITIALIZERS)
354 #define HAVE_DESIGNATED_INITIALIZERS \
355   ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
356 #endif
357
358 /* Define a STRINGIFY macro that's right for ANSI or traditional C.
359    Note: if the argument passed to STRINGIFY is itself a macro, eg
360    #define foo bar, STRINGIFY(foo) will produce "foo", not "bar".
361    Although the __STDC__ case could be made to expand this via a layer
362    of indirection, the traditional C case can not do so.  Therefore
363    this behavior is not supported. */
364 #ifndef STRINGIFY
365 # ifdef HAVE_STRINGIZE
366 #  define STRINGIFY(STRING) #STRING
367 # else
368 #  define STRINGIFY(STRING) "STRING"
369 # endif
370 #endif /* ! STRINGIFY */
371
372 #if HAVE_SYS_STAT_H
373 # include <sys/stat.h>
374 #endif
375
376 /* Test if something is a normal file.  */
377 #ifndef S_ISREG
378 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
379 #endif
380
381 /* Test if something is a directory.  */
382 #ifndef S_ISDIR
383 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
384 #endif
385
386 /* Test if something is a character special file.  */
387 #ifndef S_ISCHR
388 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
389 #endif
390
391 /* Test if something is a block special file.  */
392 #ifndef S_ISBLK
393 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
394 #endif
395
396 /* Test if something is a socket.  */
397 #ifndef S_ISSOCK
398 # ifdef S_IFSOCK
399 #   define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
400 # else
401 #   define S_ISSOCK(m) 0
402 # endif
403 #endif
404
405 /* Test if something is a FIFO.  */
406 #ifndef S_ISFIFO
407 # ifdef S_IFIFO
408 #  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
409 # else
410 #  define S_ISFIFO(m) 0
411 # endif
412 #endif
413
414 /* Approximate O_NONBLOCK.  */
415 #ifndef O_NONBLOCK
416 #define O_NONBLOCK O_NDELAY
417 #endif
418
419 /* Approximate O_NOCTTY.  */
420 #ifndef O_NOCTTY
421 #define O_NOCTTY 0
422 #endif
423
424 /* Define well known filenos if the system does not define them.  */
425 #ifndef STDIN_FILENO
426 # define STDIN_FILENO   0
427 #endif
428 #ifndef STDOUT_FILENO
429 # define STDOUT_FILENO  1
430 #endif
431 #ifndef STDERR_FILENO
432 # define STDERR_FILENO  2
433 #endif
434
435 /* Some systems have mkdir that takes a single argument. */
436 #ifdef MKDIR_TAKES_ONE_ARG
437 # define mkdir(a,b) mkdir(a)
438 #endif
439
440 /* Provide a way to print an address via printf.  */
441 #ifndef HOST_PTR_PRINTF
442 # ifdef HAVE_PRINTF_PTR
443 #  define HOST_PTR_PRINTF "%p"
444 # else
445 #  define HOST_PTR_PRINTF \
446     (sizeof (int) == sizeof (char *) ? "%x" \
447      : sizeof (long) == sizeof (char *) ? "%lx" : "%llx")
448 # endif
449 #endif /* ! HOST_PTR_PRINTF */
450
451 /* By default, colon separates directories in a path.  */
452 #ifndef PATH_SEPARATOR
453 #define PATH_SEPARATOR ':'
454 #endif
455
456 #ifndef DIR_SEPARATOR
457 #define DIR_SEPARATOR '/'
458 #endif
459
460 /* Define IS_DIR_SEPARATOR.  */
461 #ifndef DIR_SEPARATOR_2
462 # define IS_DIR_SEPARATOR(CH) ((CH) == DIR_SEPARATOR)
463 #else /* DIR_SEPARATOR_2 */
464 # define IS_DIR_SEPARATOR(CH) \
465         (((CH) == DIR_SEPARATOR) || ((CH) == DIR_SEPARATOR_2))
466 #endif /* DIR_SEPARATOR_2 */
467
468 /* Say how to test for an absolute pathname.  On Unix systems, this is if
469    it starts with a leading slash or a '$', the latter meaning the value of
470    an environment variable is to be used.  On machien with DOS-based
471    file systems, it is also absolute if it starts with a drive identifier.  */
472 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
473 #define IS_ABSOLUTE_PATHNAME(STR) \
474   (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$' \
475    || ((STR)[0] != '\0' && (STR)[1] == ':' && IS_DIR_SEPARATOR ((STR)[2])))
476 #else
477 #define IS_ABSOLUTE_PATHNAME(STR) \
478   (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$')
479 #endif
480
481 /* Get libiberty declarations. */
482 #include "libiberty.h"
483
484 /* Make sure that ONLY_INT_FIELDS has an integral value.  */
485 #ifdef ONLY_INT_FIELDS
486 #undef ONLY_INT_FIELDS
487 #define ONLY_INT_FIELDS 1
488 #else
489 #define ONLY_INT_FIELDS 0
490 #endif 
491
492 /* Provide a default for the HOST_BIT_BUCKET.
493    This suffices for POSIX-like hosts.  */
494
495 #ifndef HOST_BIT_BUCKET
496 #define HOST_BIT_BUCKET "/dev/null"
497 #endif
498
499 /* Enumerated bitfields are safe to use unless we've been explictly told
500    otherwise or if they are signed. */
501  
502 #define USE_ENUM_BITFIELDS (__GNUC__ || (!ONLY_INT_FIELDS && ENUM_BITFIELDS_ARE_UNSIGNED))
503
504 #if USE_ENUM_BITFIELDS
505 #define ENUM_BITFIELD(TYPE) enum TYPE
506 #else
507 #define ENUM_BITFIELD(TYPE) unsigned int
508 #endif
509
510 #ifndef offsetof
511 #define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *)0)->MEMBER)
512 #endif
513
514 /* Traditional C cannot initialize union members of structs.  Provide
515    a macro which expands appropriately to handle it.  This only works
516    if you intend to initalize the union member to zero since it relies
517    on default initialization to zero in the traditional C case.  */
518 #ifdef __STDC__
519 #define UNION_INIT_ZERO , {0}
520 #else
521 #define UNION_INIT_ZERO
522 #endif
523
524 /* GCC now gives implicit declaration warnings for undeclared builtins.  */
525 #if defined(__GNUC__) && defined (__SIZE_TYPE__)
526 extern void *alloca (__SIZE_TYPE__);
527 #endif
528
529 /* Various error reporting routines want to use __FUNCTION__.  */
530 #if (GCC_VERSION < 2007)
531 #ifndef __FUNCTION__
532 #define __FUNCTION__ "?"
533 #endif /* ! __FUNCTION__ */
534 #endif
535
536 #endif /* __GCC_SYSTEM_H__ */