]>
Commit | Line | Data |
---|---|---|
c5c76735 JL |
1 | /* Get common system includes and various definitions and declarations based |
2 | on autoconf macros. | |
ccc50f7d | 3 | Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. |
aca69483 | 4 | |
1b0c6de6 JL |
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. */ | |
aca69483 | 21 | |
c5c76735 | 22 | |
aca69483 KG |
23 | #ifndef __GCC_SYSTEM_H__ |
24 | #define __GCC_SYSTEM_H__ | |
25 | ||
8b97e23b ML |
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 | ||
789f983a | 31 | /* We must include stdarg.h/varargs.h before stdio.h. */ |
5148a72b | 32 | #ifdef ANSI_PROTOTYPES |
789f983a KG |
33 | #include <stdarg.h> |
34 | #else | |
35 | #include <varargs.h> | |
36 | #endif | |
37 | ||
6f81b1ad RH |
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 | ||
aca69483 | 46 | #include <stdio.h> |
51db713f KG |
47 | |
48 | /* Define a generic NULL if one hasn't already been defined. */ | |
49 | #ifndef NULL | |
50 | #define NULL 0 | |
51 | #endif | |
52 | ||
54953b66 | 53 | /* The compiler is not a multi-threaded application and therefore we |
9c30c0e7 ZW |
54 | do not have to use the locking functions. |
55 | ||
f31e826b KG |
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. | |
9c30c0e7 ZW |
59 | |
60 | fputs_unlocked is an extension and needs to be prototyped specially. */ | |
61 | ||
f31e826b | 62 | #if defined HAVE_PUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED) |
54953b66 UD |
63 | # undef putc |
64 | # define putc(C, Stream) putc_unlocked (C, Stream) | |
65 | #endif | |
f31e826b | 66 | #if defined HAVE_FPUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED) |
54953b66 UD |
67 | # undef fputc |
68 | # define fputc(C, Stream) fputc_unlocked (C, Stream) | |
69 | #endif | |
f31e826b | 70 | #if defined HAVE_FPUTS_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED) |
54953b66 UD |
71 | # undef fputs |
72 | # define fputs(String, Stream) fputs_unlocked (String, Stream) | |
f31e826b | 73 | # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED |
cdadb1dd | 74 | extern int fputs_unlocked PARAMS ((const char *, FILE *)); |
9c30c0e7 | 75 | # endif |
54953b66 UD |
76 | #endif |
77 | ||
aca69483 KG |
78 | #include <ctype.h> |
79 | ||
80 | /* Jim Meyering writes: | |
9b91d8f4 | 81 | |
aca69483 KG |
82 | "... Some ctype macros are valid only for character codes that |
83 | isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when | |
84 | using /bin/cc or gcc but without giving an ansi option). So, all | |
85 | ctype uses should be through macros like ISPRINT... If | |
86 | STDC_HEADERS is defined, then autoconf has verified that the ctype | |
87 | macros don't need to be guarded with references to isascii. ... | |
88 | Defining isascii to 1 should let any compiler worth its salt | |
89 | eliminate the && through constant folding." | |
9b91d8f4 | 90 | |
aca69483 | 91 | Bruno Haible adds: |
9b91d8f4 | 92 | |
aca69483 KG |
93 | "... Furthermore, isupper(c) etc. have an undefined result if c is |
94 | outside the range -1 <= c <= 255. One is tempted to write isupper(c) | |
95 | with c being of type `char', but this is wrong if c is an 8-bit | |
96 | character >= 128 which gets sign-extended to a negative value. | |
97 | The macro ISUPPER protects against this as well." */ | |
9b91d8f4 | 98 | |
f3ad1f9c | 99 | #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) || defined(HOST_EBCDIC) |
aca69483 KG |
100 | # define IN_CTYPE_DOMAIN(c) 1 |
101 | #else | |
102 | # define IN_CTYPE_DOMAIN(c) isascii(c) | |
103 | #endif | |
9b91d8f4 | 104 | |
92a438d1 KG |
105 | /* The ctype functions are often implemented as macros which do |
106 | lookups in arrays using the parameter as the offset. If the ctype | |
107 | function parameter is a char, then gcc will (appropriately) warn | |
108 | that a "subscript has type char". Using a (signed) char as a subscript | |
109 | is bad because you may get negative offsets and thus it is not 8-bit | |
110 | safe. The CTYPE_CONV macro ensures that the parameter is cast to an | |
111 | unsigned char when a char is passed in. When an int is passed in, the | |
112 | parameter is left alone so we don't lose EOF. | |
113 | */ | |
114 | ||
115 | #define CTYPE_CONV(CH) \ | |
116 | (sizeof(CH) == sizeof(unsigned char) ? (int)(unsigned char)(CH) : (int)(CH)) | |
117 | ||
118 | ||
119 | /* WARNING! The argument to the ctype replacement macros below is | |
120 | evaluated more than once so it must not have side effects! */ | |
121 | ||
aca69483 | 122 | #ifdef isblank |
92a438d1 | 123 | # define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (CTYPE_CONV(c))) |
aca69483 KG |
124 | #else |
125 | # define ISBLANK(c) ((c) == ' ' || (c) == '\t') | |
126 | #endif | |
127 | #ifdef isgraph | |
92a438d1 | 128 | # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (CTYPE_CONV(c))) |
aca69483 | 129 | #else |
92a438d1 | 130 | # define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (CTYPE_CONV(c)) && !isspace (CTYPE_CONV(c))) |
aca69483 | 131 | #endif |
9b91d8f4 | 132 | |
92a438d1 KG |
133 | #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (CTYPE_CONV(c))) |
134 | #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (CTYPE_CONV(c))) | |
135 | #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (CTYPE_CONV(c))) | |
136 | #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (CTYPE_CONV(c))) | |
137 | #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (CTYPE_CONV(c))) | |
138 | #define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (CTYPE_CONV(c))) | |
139 | #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (CTYPE_CONV(c))) | |
140 | #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (CTYPE_CONV(c))) | |
141 | #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (CTYPE_CONV(c))) | |
142 | #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (CTYPE_CONV(c))) | |
143 | ||
144 | #if STDC_HEADERS | |
145 | # define TOLOWER(c) (tolower (CTYPE_CONV(c))) | |
146 | # define TOUPPER(c) (toupper (CTYPE_CONV(c))) | |
147 | #else | |
148 | # define TOLOWER(c) (ISUPPER (c) ? tolower (CTYPE_CONV(c)) : (c)) | |
149 | # define TOUPPER(c) (ISLOWER (c) ? toupper (CTYPE_CONV(c)) : (c)) | |
150 | #endif | |
9b91d8f4 | 151 | |
aca69483 KG |
152 | /* ISDIGIT differs from ISDIGIT_LOCALE, as follows: |
153 | - Its arg may be any int or unsigned int; it need not be an unsigned char. | |
154 | - It's guaranteed to evaluate its argument exactly once. | |
155 | - It's typically faster. | |
156 | Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that | |
157 | only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless | |
158 | it's important to use the locale's definition of `digit' even when the | |
159 | host does not conform to Posix. */ | |
160 | #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) | |
161 | ||
64f8a718 RH |
162 | /* Define a default escape character; its different for EBCDIC. */ |
163 | #ifndef TARGET_ESC | |
164 | #define TARGET_ESC 033 | |
165 | #endif | |
166 | ||
aca69483 | 167 | #include <sys/types.h> |
c5c76735 | 168 | |
aca69483 KG |
169 | #include <errno.h> |
170 | ||
171 | #ifndef errno | |
172 | extern int errno; | |
173 | #endif | |
174 | ||
ccc7d11a | 175 | #ifdef STRING_WITH_STRINGS |
aca69483 | 176 | # include <string.h> |
ccc7d11a | 177 | # include <strings.h> |
aca69483 | 178 | #else |
ccc7d11a KG |
179 | # ifdef HAVE_STRING_H |
180 | # include <string.h> | |
181 | # else | |
182 | # ifdef HAVE_STRINGS_H | |
183 | # include <strings.h> | |
184 | # endif | |
aca69483 KG |
185 | # endif |
186 | #endif | |
187 | ||
188 | #ifdef HAVE_STDLIB_H | |
189 | # include <stdlib.h> | |
512b62fb JM |
190 | # ifdef USE_C_ALLOCA |
191 | /* Note that systems that use glibc have a <stdlib.h> that includes | |
192 | <alloca.h> that defines alloca, so let USE_C_ALLOCA override this. */ | |
193 | # undef alloca | |
194 | #endif | |
aca69483 KG |
195 | #endif |
196 | ||
197 | #ifdef HAVE_UNISTD_H | |
198 | # include <unistd.h> | |
199 | #endif | |
200 | ||
201 | #ifdef HAVE_SYS_PARAM_H | |
202 | # include <sys/param.h> | |
203 | #endif | |
204 | ||
205 | #if HAVE_LIMITS_H | |
206 | # include <limits.h> | |
207 | #endif | |
208 | ||
f80d6fd7 KG |
209 | /* Find HOST_WIDEST_INT and set its bit size, type and print macros. |
210 | It will be the largest integer mode supported by the host which may | |
211 | (or may not) be larger than HOST_WIDE_INT. This must appear after | |
212 | <limits.h> since we only use `long long' if its bigger than a | |
213 | `long' and also if it is supported by macros in limits.h. For old | |
214 | hosts which don't have a limits.h (and thus won't include it in | |
215 | stage2 cause we don't rerun configure) we assume gcc supports long | |
216 | long.) Note, you won't get these defined if you don't include | |
217 | {ht}config.h before this file to set the HOST_BITS_PER_* macros. */ | |
218 | ||
219 | #ifndef HOST_WIDEST_INT | |
220 | # if defined (HOST_BITS_PER_LONG) && defined (HOST_BITS_PER_LONGLONG) | |
221 | # if (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) || defined (LLONG_MAX) || defined (__GNUC__)) | |
222 | # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG | |
223 | # define HOST_WIDEST_INT long long | |
224 | # define HOST_WIDEST_INT_PRINT_DEC "%lld" | |
225 | # define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu" | |
226 | # define HOST_WIDEST_INT_PRINT_HEX "0x%llx" | |
227 | # else | |
228 | # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG | |
229 | # define HOST_WIDEST_INT long | |
230 | # define HOST_WIDEST_INT_PRINT_DEC "%ld" | |
231 | # define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu" | |
232 | # define HOST_WIDEST_INT_PRINT_HEX "0x%lx" | |
233 | # endif /*(long long>long) && (LONG_LONG_MAX||LONGLONG_MAX||LLONG_MAX||GNUC)*/ | |
234 | # endif /* defined(HOST_BITS_PER_LONG) && defined(HOST_BITS_PER_LONGLONG) */ | |
235 | #endif /* ! HOST_WIDEST_INT */ | |
236 | ||
f12bc141 ZW |
237 | /* Infrastructure for defining missing _MAX and _MIN macros. Note that |
238 | macros defined with these cannot be used in #if. */ | |
239 | ||
240 | /* The extra casts work around common compiler bugs. */ | |
241 | #define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1)) | |
242 | /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. | |
243 | It is necessary at least when t == time_t. */ | |
244 | #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ | |
245 | ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0)) | |
246 | #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) | |
247 | ||
248 | /* Use that infrastructure to provide a few constants. */ | |
249 | #ifndef UCHAR_MAX | |
250 | # define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char) | |
251 | #endif | |
252 | ||
aca69483 KG |
253 | #ifdef TIME_WITH_SYS_TIME |
254 | # include <sys/time.h> | |
255 | # include <time.h> | |
256 | #else | |
257 | # if HAVE_SYS_TIME_H | |
e572c0c6 | 258 | # include <sys/time.h> |
aca69483 | 259 | # else |
e572c0c6 KG |
260 | # ifdef HAVE_TIME_H |
261 | # include <time.h> | |
262 | # endif | |
263 | # endif | |
aca69483 KG |
264 | #endif |
265 | ||
266 | #ifdef HAVE_FCNTL_H | |
267 | # include <fcntl.h> | |
268 | #else | |
e572c0c6 KG |
269 | # ifdef HAVE_SYS_FILE_H |
270 | # include <sys/file.h> | |
271 | # endif | |
aca69483 KG |
272 | #endif |
273 | ||
274 | #ifndef SEEK_SET | |
275 | # define SEEK_SET 0 | |
276 | # define SEEK_CUR 1 | |
277 | # define SEEK_END 2 | |
278 | #endif | |
279 | #ifndef F_OK | |
280 | # define F_OK 0 | |
281 | # define X_OK 1 | |
282 | # define W_OK 2 | |
283 | # define R_OK 4 | |
284 | #endif | |
e572c0c6 KG |
285 | #ifndef O_RDONLY |
286 | # define O_RDONLY 0 | |
287 | #endif | |
288 | #ifndef O_WRONLY | |
289 | # define O_WRONLY 1 | |
290 | #endif | |
aca69483 | 291 | |
36b8337d KG |
292 | /* Some systems define these in, e.g., param.h. We undefine these names |
293 | here to avoid the warnings. We prefer to use our definitions since we | |
294 | know they are correct. */ | |
295 | ||
296 | #undef MIN | |
297 | #undef MAX | |
298 | #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) | |
299 | #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) | |
300 | ||
13799af3 MM |
301 | /* Returns the least number N such that N * Y >= X. */ |
302 | #define CEIL(x,y) (((x) + (y) - 1) / (y)) | |
303 | ||
e9831ca0 KG |
304 | #ifdef HAVE_SYS_WAIT_H |
305 | #include <sys/wait.h> | |
306 | #endif | |
307 | ||
308 | #ifndef WIFSIGNALED | |
309 | #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) | |
310 | #endif | |
311 | #ifndef WTERMSIG | |
312 | #define WTERMSIG(S) ((S) & 0x7f) | |
313 | #endif | |
314 | #ifndef WIFEXITED | |
315 | #define WIFEXITED(S) (((S) & 0xff) == 0) | |
316 | #endif | |
317 | #ifndef WEXITSTATUS | |
318 | #define WEXITSTATUS(S) (((S) & 0xff00) >> 8) | |
319 | #endif | |
8fa213ac PDM |
320 | #ifndef WSTOPSIG |
321 | #define WSTOPSIG WEXITSTATUS | |
322 | #endif | |
e9831ca0 | 323 | |
f31e826b KG |
324 | /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they |
325 | are defined to 0 then we must provide the relevant declaration | |
326 | here. These checks will be in the undefined state while configure | |
327 | is running so be careful to test "defined (HAVE_DECL_*)". */ | |
aca69483 KG |
328 | |
329 | #ifndef bcopy | |
330 | # ifdef HAVE_BCOPY | |
f31e826b | 331 | # if defined (HAVE_DECL_BCOPY) && !HAVE_DECL_BCOPY |
d4d4ae5f | 332 | extern void bcopy PARAMS ((const PTR, PTR, size_t)); |
aca69483 KG |
333 | # endif |
334 | # else /* ! HAVE_BCOPY */ | |
b3c9dc1a | 335 | # define bcopy(src,dst,len) memmove((dst),(src),(len)) |
aca69483 KG |
336 | # endif |
337 | #endif | |
338 | ||
339 | #ifndef bcmp | |
340 | # ifdef HAVE_BCMP | |
f31e826b | 341 | # if defined (HAVE_DECL_BCMP) && !HAVE_DECL_BCMP |
d4d4ae5f | 342 | extern int bcmp PARAMS ((const PTR, const PTR, size_t)); |
aca69483 KG |
343 | # endif |
344 | # else /* ! HAVE_BCMP */ | |
345 | # define bcmp(left,right,len) memcmp ((left),(right),(len)) | |
346 | # endif | |
347 | #endif | |
348 | ||
349 | #ifndef bzero | |
350 | # ifdef HAVE_BZERO | |
f31e826b | 351 | # if defined (HAVE_DECL_BZERO) && !HAVE_DECL_BZERO |
d4d4ae5f | 352 | extern void bzero PARAMS ((PTR, size_t)); |
aca69483 KG |
353 | # endif |
354 | # else /* ! HAVE_BZERO */ | |
355 | # define bzero(dst,len) memset ((dst),0,(len)) | |
356 | # endif | |
357 | #endif | |
358 | ||
359 | #ifndef index | |
360 | # ifdef HAVE_INDEX | |
f31e826b | 361 | # if defined (HAVE_DECL_INDEX) && !HAVE_DECL_INDEX |
d4d4ae5f | 362 | extern char *index PARAMS ((const char *, int)); |
aca69483 KG |
363 | # endif |
364 | # else /* ! HAVE_INDEX */ | |
365 | # define index strchr | |
366 | # endif | |
367 | #endif | |
368 | ||
369 | #ifndef rindex | |
370 | # ifdef HAVE_RINDEX | |
f31e826b | 371 | # if defined (HAVE_DECL_RINDEX) && !HAVE_DECL_RINDEX |
d4d4ae5f | 372 | extern char *rindex PARAMS ((const char *, int)); |
aca69483 KG |
373 | # endif |
374 | # else /* ! HAVE_RINDEX */ | |
375 | # define rindex strrchr | |
376 | # endif | |
377 | #endif | |
378 | ||
f31e826b | 379 | #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF |
d4d4ae5f | 380 | extern double atof PARAMS ((const char *)); |
8f81384f KG |
381 | #endif |
382 | ||
f31e826b | 383 | #if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL |
d4d4ae5f | 384 | extern long atol PARAMS ((const char *)); |
8f81384f KG |
385 | #endif |
386 | ||
f31e826b | 387 | #if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE |
d4d4ae5f | 388 | extern void free PARAMS ((PTR)); |
aca69483 KG |
389 | #endif |
390 | ||
f31e826b | 391 | #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD |
d4d4ae5f | 392 | extern char *getcwd PARAMS ((char *, size_t)); |
6cd5dccd KG |
393 | #endif |
394 | ||
f31e826b | 395 | #if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV |
d4d4ae5f | 396 | extern char *getenv PARAMS ((const char *)); |
79e11844 KG |
397 | #endif |
398 | ||
f31e826b | 399 | #if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD |
d4d4ae5f | 400 | extern char *getwd PARAMS ((char *)); |
6cd5dccd KG |
401 | #endif |
402 | ||
f31e826b | 403 | #if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK |
d4d4ae5f | 404 | extern PTR sbrk PARAMS ((int)); |
8f81384f KG |
405 | #endif |
406 | ||
f31e826b | 407 | #if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR |
d4d4ae5f | 408 | extern char *strstr PARAMS ((const char *, const char *)); |
d3d5cc97 JL |
409 | #endif |
410 | ||
c5c76735 JL |
411 | #ifdef HAVE_MALLOC_H |
412 | #include <malloc.h> | |
413 | #endif | |
414 | ||
f31e826b | 415 | #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC |
d4d4ae5f | 416 | extern PTR malloc PARAMS ((size_t)); |
c5c76735 JL |
417 | #endif |
418 | ||
f31e826b | 419 | #if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC |
d4d4ae5f | 420 | extern PTR calloc PARAMS ((size_t, size_t)); |
c5c76735 JL |
421 | #endif |
422 | ||
f31e826b | 423 | #if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC |
d4d4ae5f | 424 | extern PTR realloc PARAMS ((PTR, size_t)); |
c5c76735 JL |
425 | #endif |
426 | ||
759af044 KG |
427 | /* If the system doesn't provide strsignal, we get it defined in |
428 | libiberty but no declaration is supplied. */ | |
f31e826b | 429 | #if defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL |
759af044 KG |
430 | # ifndef strsignal |
431 | extern const char *strsignal PARAMS ((int)); | |
007e8d2a | 432 | # endif |
759af044 | 433 | #endif |
007e8d2a | 434 | |
d2cabf16 | 435 | #ifdef HAVE_GETRLIMIT |
f31e826b | 436 | # if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT |
d2cabf16 | 437 | # ifndef getrlimit |
d4d4ae5f KG |
438 | # ifdef ANSI_PROTOTYPES |
439 | struct rlimit; | |
440 | # endif | |
441 | extern int getrlimit PARAMS ((int, struct rlimit *)); | |
d2cabf16 KG |
442 | # endif |
443 | # endif | |
444 | #endif | |
445 | ||
446 | #ifdef HAVE_SETRLIMIT | |
f31e826b | 447 | # if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT |
d2cabf16 | 448 | # ifndef setrlimit |
d4d4ae5f KG |
449 | # ifdef ANSI_PROTOTYPES |
450 | struct rlimit; | |
451 | # endif | |
452 | extern int setrlimit PARAMS ((int, const struct rlimit *)); | |
d2cabf16 KG |
453 | # endif |
454 | # endif | |
455 | #endif | |
456 | ||
e9b4fabf JL |
457 | /* HAVE_VOLATILE only refers to the stage1 compiler. We also check |
458 | __STDC__ and assume gcc sets it and has volatile in stage >=2. */ | |
459 | #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile) | |
460 | #define volatile | |
461 | #endif | |
462 | ||
f31e826b | 463 | #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT |
d4d4ae5f | 464 | extern void abort PARAMS ((void)); |
2a611d21 | 465 | #endif |
d4ba0ead KG |
466 | |
467 | /* Define a STRINGIFY macro that's right for ANSI or traditional C. | |
d4ba0ead KG |
468 | Note: if the argument passed to STRINGIFY is itself a macro, eg |
469 | #define foo bar, STRINGIFY(foo) will produce "foo", not "bar". | |
470 | Although the __STDC__ case could be made to expand this via a layer | |
471 | of indirection, the traditional C case can not do so. Therefore | |
472 | this behavior is not supported. */ | |
473 | #ifndef STRINGIFY | |
890ad3ea | 474 | # ifdef HAVE_STRINGIZE |
d4ba0ead KG |
475 | # define STRINGIFY(STRING) #STRING |
476 | # else | |
477 | # define STRINGIFY(STRING) "STRING" | |
478 | # endif | |
479 | #endif /* ! STRINGIFY */ | |
480 | ||
a05e22b8 RH |
481 | #if HAVE_SYS_STAT_H |
482 | # include <sys/stat.h> | |
483 | #endif | |
9855b854 MN |
484 | |
485 | /* Test if something is a normal file. */ | |
486 | #ifndef S_ISREG | |
487 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
488 | #endif | |
489 | ||
490 | /* Test if something is a directory. */ | |
491 | #ifndef S_ISDIR | |
492 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | |
493 | #endif | |
494 | ||
6458033d ZW |
495 | /* Test if something is a character special file. */ |
496 | #ifndef S_ISCHR | |
497 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) | |
498 | #endif | |
499 | ||
be3dad6f PDM |
500 | /* Test if something is a block special file. */ |
501 | #ifndef S_ISBLK | |
502 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) | |
503 | #endif | |
504 | ||
6458033d ZW |
505 | /* Test if something is a socket. */ |
506 | #ifndef S_ISSOCK | |
507 | # ifdef S_IFSOCK | |
508 | # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) | |
509 | # else | |
510 | # define S_ISSOCK(m) 0 | |
511 | # endif | |
512 | #endif | |
513 | ||
514 | /* Test if something is a FIFO. */ | |
515 | #ifndef S_ISFIFO | |
516 | # ifdef S_IFIFO | |
517 | # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) | |
518 | # else | |
519 | # define S_ISFIFO(m) 0 | |
520 | # endif | |
521 | #endif | |
522 | ||
523 | /* Approximate O_NONBLOCK. */ | |
524 | #ifndef O_NONBLOCK | |
525 | #define O_NONBLOCK O_NDELAY | |
526 | #endif | |
527 | ||
528 | /* Approximate O_NOCTTY. */ | |
529 | #ifndef O_NOCTTY | |
530 | #define O_NOCTTY 0 | |
531 | #endif | |
532 | ||
f3692274 ME |
533 | /* Define well known filenos if the system does not define them. */ |
534 | #ifndef STDIN_FILENO | |
535 | # define STDIN_FILENO 0 | |
536 | #endif | |
537 | #ifndef STDOUT_FILENO | |
538 | # define STDOUT_FILENO 1 | |
539 | #endif | |
924d8a7c | 540 | #ifndef STDERR_FILENO |
f3692274 ME |
541 | # define STDERR_FILENO 2 |
542 | #endif | |
543 | ||
75923b2f MK |
544 | /* Some systems have mkdir that takes a single argument. */ |
545 | #ifdef MKDIR_TAKES_ONE_ARG | |
546 | # define mkdir(a,b) mkdir(a) | |
547 | #endif | |
548 | ||
1eb14644 KG |
549 | /* Provide a way to print an address via printf. */ |
550 | #ifndef HOST_PTR_PRINTF | |
551 | # ifdef HAVE_PRINTF_PTR | |
552 | # define HOST_PTR_PRINTF "%p" | |
553 | # else | |
554 | # define HOST_PTR_PRINTF \ | |
555 | (sizeof (int) == sizeof (char *) ? "%x" \ | |
556 | : sizeof (long) == sizeof (char *) ? "%lx" : "%llx") | |
557 | # endif | |
558 | #endif /* ! HOST_PTR_PRINTF */ | |
559 | ||
d5b6516d MK |
560 | /* By default, colon separates directories in a path. */ |
561 | #ifndef PATH_SEPARATOR | |
562 | #define PATH_SEPARATOR ':' | |
563 | #endif | |
564 | ||
565 | #ifndef DIR_SEPARATOR | |
566 | #define DIR_SEPARATOR '/' | |
567 | #endif | |
568 | ||
569 | /* Define IS_DIR_SEPARATOR. */ | |
570 | #ifndef DIR_SEPARATOR_2 | |
571 | # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) | |
572 | #else /* DIR_SEPARATOR_2 */ | |
573 | # define IS_DIR_SEPARATOR(ch) \ | |
574 | (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) | |
575 | #endif /* DIR_SEPARATOR_2 */ | |
576 | ||
2778b98d KG |
577 | /* Get libiberty declarations. */ |
578 | #include "libiberty.h" | |
579 | ||
f0e5eeeb MM |
580 | /* Make sure that ONLY_INT_FIELDS has an integral value. */ |
581 | #ifdef ONLY_INT_FIELDS | |
582 | #undef ONLY_INT_FIELDS | |
583 | #define ONLY_INT_FIELDS 1 | |
584 | #else | |
585 | #define ONLY_INT_FIELDS 0 | |
586 | #endif | |
587 | ||
c149cc37 | 588 | /* Enumerated bitfields are safe to use unless we've been explictly told |
ac79db28 | 589 | otherwise or if they are signed. */ |
c149cc37 | 590 | |
f0e5eeeb | 591 | #define USE_ENUM_BITFIELDS (__GNUC__ || (!ONLY_INT_FIELDS && ENUM_BITFIELDS_ARE_UNSIGNED)) |
c149cc37 RL |
592 | |
593 | #if USE_ENUM_BITFIELDS | |
594 | #define ENUM_BITFIELD(TYPE) enum TYPE | |
595 | #else | |
596 | #define ENUM_BITFIELD(TYPE) unsigned int | |
597 | #endif | |
598 | ||
e0125cf3 KG |
599 | #ifndef offsetof |
600 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | |
601 | #endif | |
c149cc37 | 602 | |
7de9cc38 KG |
603 | /* Traditional C cannot initialize union members of structs. Provide |
604 | a macro which expands appropriately to handle it. This only works | |
605 | if you intend to initalize the union member to zero since it relies | |
606 | on default initialization to zero in the traditional C case. */ | |
607 | #ifdef __STDC__ | |
608 | #define UNION_INIT_ZERO , {0} | |
609 | #else | |
610 | #define UNION_INIT_ZERO | |
611 | #endif | |
612 | ||
2021c8d2 KG |
613 | /* GCC now gives implicit declaration warnings for undeclared builtins. */ |
614 | #if defined(__GNUC__) && defined (__SIZE_TYPE__) | |
615 | extern void *alloca (__SIZE_TYPE__); | |
616 | #endif | |
617 | ||
aca69483 | 618 | #endif /* __GCC_SYSTEM_H__ */ |