Line data Source code
1 : /* Get common system includes and various definitions and declarations based
2 : on autoconf macros.
3 : Copyright (C) 1998-2026 Free Software Foundation, Inc.
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 :
22 : #ifndef GCC_SYSTEM_H
23 : #define GCC_SYSTEM_H
24 :
25 : /* True if __builtin_* () is supported.
26 : This is done for optimizing GCC itself. */
27 : #ifdef __has_builtin
28 : # define STAGE0_CXX_HAS_BUILTIN(NAME) __has_builtin (__builtin_ ## NAME)
29 : #else
30 : # define STAGE0_CXX_HAS_BUILTIN(NAME) 0
31 : #endif
32 :
33 : /* Define this so that inttypes.h defines the PRI?64 macros even
34 : when compiling with a C++ compiler. Define it here so in the
35 : event inttypes.h gets pulled in by another header it is already
36 : defined. */
37 : #define __STDC_FORMAT_MACROS
38 :
39 : /* We must include stdarg.h before stdio.h. */
40 : #include <stdarg.h>
41 :
42 : #ifndef va_copy
43 : # ifdef __va_copy
44 : # define va_copy(d,s) __va_copy (d, s)
45 : # else
46 : # define va_copy(d,s) ((d) = (s))
47 : # endif
48 : #endif
49 :
50 : #include <stddef.h>
51 : #include <stdio.h>
52 :
53 : /* Define a generic NULL if one hasn't already been defined. */
54 : #ifndef NULL
55 : #define NULL 0
56 : #endif
57 :
58 : /* Use the unlocked open routines from libiberty. */
59 :
60 : /* Some of these are #define on some systems, e.g. on AIX to redirect
61 : the names to 64bit capable functions for LARGE_FILES support. These
62 : redefs are pointless here so we can override them. */
63 :
64 : #undef fopen
65 : #undef freopen
66 :
67 : #define fopen(PATH, MODE) fopen_unlocked (PATH, MODE)
68 : #define fdopen(FILDES, MODE) fdopen_unlocked (FILDES, MODE)
69 : #define freopen(PATH, MODE, STREAM) freopen_unlocked (PATH, MODE, STREAM)
70 :
71 : /* The compiler is not a multi-threaded application and therefore we
72 : do not have to use the locking functions. In fact, using the locking
73 : functions can cause the compiler to be significantly slower under
74 : I/O bound conditions (such as -g -O0 on very large source files).
75 :
76 : HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio
77 : code is multi-thread safe by default. If it is set to 0, then do
78 : not worry about using the _unlocked functions.
79 :
80 : fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are
81 : extensions and need to be prototyped by hand (since we do not
82 : define _GNU_SOURCE). */
83 :
84 : #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED
85 :
86 : # ifdef HAVE_PUTC_UNLOCKED
87 : # undef putc
88 : # define putc(C, Stream) putc_unlocked (C, Stream)
89 : # endif
90 : # ifdef HAVE_PUTCHAR_UNLOCKED
91 : # undef putchar
92 : # define putchar(C) putchar_unlocked (C)
93 : # endif
94 : # ifdef HAVE_GETC_UNLOCKED
95 : # undef getc
96 : # define getc(Stream) getc_unlocked (Stream)
97 : # endif
98 : # ifdef HAVE_GETCHAR_UNLOCKED
99 : # undef getchar
100 : # define getchar() getchar_unlocked ()
101 : # endif
102 : # ifdef HAVE_FPUTC_UNLOCKED
103 : # undef fputc
104 : # define fputc(C, Stream) fputc_unlocked (C, Stream)
105 : # endif
106 :
107 : #ifdef __cplusplus
108 : extern "C" {
109 : #endif
110 :
111 : # ifdef HAVE_CLEARERR_UNLOCKED
112 : # undef clearerr
113 : # define clearerr(Stream) clearerr_unlocked (Stream)
114 : # if defined (HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
115 : extern void clearerr_unlocked (FILE *);
116 : # endif
117 : # endif
118 : # ifdef HAVE_FEOF_UNLOCKED
119 : # undef feof
120 : # define feof(Stream) feof_unlocked (Stream)
121 : # if defined (HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
122 : extern int feof_unlocked (FILE *);
123 : # endif
124 : # endif
125 : # ifdef HAVE_FILENO_UNLOCKED
126 : # undef fileno
127 : # define fileno(Stream) fileno_unlocked (Stream)
128 : # if defined (HAVE_DECL_FILENO_UNLOCKED) && !HAVE_DECL_FILENO_UNLOCKED
129 : extern int fileno_unlocked (FILE *);
130 : # endif
131 : # endif
132 : # ifdef HAVE_FFLUSH_UNLOCKED
133 : # undef fflush
134 : # define fflush(Stream) fflush_unlocked (Stream)
135 : # if defined (HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
136 : extern int fflush_unlocked (FILE *);
137 : # endif
138 : # endif
139 : # ifdef HAVE_FGETC_UNLOCKED
140 : # undef fgetc
141 : # define fgetc(Stream) fgetc_unlocked (Stream)
142 : # if defined (HAVE_DECL_FGETC_UNLOCKED) && !HAVE_DECL_FGETC_UNLOCKED
143 : extern int fgetc_unlocked (FILE *);
144 : # endif
145 : # endif
146 : # ifdef HAVE_FGETS_UNLOCKED
147 : # undef fgets
148 : # define fgets(S, n, Stream) fgets_unlocked (S, n, Stream)
149 : # if defined (HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
150 : extern char *fgets_unlocked (char *, int, FILE *);
151 : # endif
152 : # endif
153 : # ifdef HAVE_FPUTS_UNLOCKED
154 : # undef fputs
155 : # define fputs(String, Stream) fputs_unlocked (String, Stream)
156 : # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
157 : extern int fputs_unlocked (const char *, FILE *);
158 : # endif
159 : # endif
160 : # ifdef HAVE_FERROR_UNLOCKED
161 : # undef ferror
162 : # define ferror(Stream) ferror_unlocked (Stream)
163 : # if defined (HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
164 : extern int ferror_unlocked (FILE *);
165 : # endif
166 : # endif
167 : # ifdef HAVE_FREAD_UNLOCKED
168 : # undef fread
169 : # define fread(Ptr, Size, N, Stream) fread_unlocked (Ptr, Size, N, Stream)
170 : # if defined (HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
171 : extern size_t fread_unlocked (void *, size_t, size_t, FILE *);
172 : # endif
173 : # endif
174 : # ifdef HAVE_FWRITE_UNLOCKED
175 : # undef fwrite
176 : # define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream)
177 : # if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
178 : extern size_t fwrite_unlocked (const void *, size_t, size_t, FILE *);
179 : # endif
180 : # endif
181 : # ifdef HAVE_FPRINTF_UNLOCKED
182 : # undef fprintf
183 : /* We can't use a function-like macro here because we don't know if
184 : we have varargs macros. */
185 : # define fprintf fprintf_unlocked
186 : # if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED
187 : extern int fprintf_unlocked (FILE *, const char *, ...);
188 : # endif
189 : # endif
190 :
191 : #ifdef __cplusplus
192 : }
193 : #endif
194 :
195 : #endif
196 :
197 : /* ??? Glibc's fwrite/fread_unlocked macros cause
198 : "warning: signed and unsigned type in conditional expression". */
199 : #undef fread_unlocked
200 : #undef fwrite_unlocked
201 :
202 : /* Include C++ standard headers before "safe-ctype.h" to avoid GCC
203 : poisoning the ctype macros through safe-ctype.h */
204 :
205 : #ifdef __cplusplus
206 : #ifdef INCLUDE_ALGORITHM
207 : # include <algorithm>
208 : #endif
209 : #ifdef INCLUDE_DEQUE
210 : # include <deque>
211 : #endif
212 : #ifdef INCLUDE_LIST
213 : # include <list>
214 : #endif
215 : #ifdef INCLUDE_MAP
216 : # include <map>
217 : #endif
218 : #ifdef INCLUDE_SET
219 : # include <set>
220 : #endif
221 : #ifdef INCLUDE_STRING
222 : # include <string>
223 : #endif
224 : #ifdef INCLUDE_VECTOR
225 : # include <vector>
226 : #endif
227 : #ifdef INCLUDE_ARRAY
228 : # include <array>
229 : #endif
230 : #ifdef INCLUDE_FUNCTIONAL
231 : # include <functional>
232 : #endif
233 : #ifdef INCLUDE_SSTREAM
234 : # include <sstream>
235 : #endif
236 : #ifdef INCLUDE_ITERATOR
237 : # include <iterator>
238 : #endif
239 : # include <memory>
240 : # include <cstring>
241 : # include <initializer_list>
242 : # include <new>
243 : # include <utility>
244 : # include <type_traits>
245 : #endif
246 :
247 : /* There are an extraordinary number of issues with <ctype.h>.
248 : The last straw is that it varies with the locale. Use libiberty's
249 : replacement instead. */
250 : #include "safe-ctype.h"
251 :
252 : #include <sys/types.h>
253 :
254 : #include <errno.h>
255 :
256 : /* Some of glibc's string inlines cause warnings. Plus we'd rather
257 : rely on (and therefore test) GCC's string builtins. */
258 : #define __NO_STRING_INLINES
259 :
260 : #ifdef STRING_WITH_STRINGS
261 : # include <string.h>
262 : # include <strings.h>
263 : #else
264 : # ifdef HAVE_STRING_H
265 : # include <string.h>
266 : # else
267 : # ifdef HAVE_STRINGS_H
268 : # include <strings.h>
269 : # endif
270 : # endif
271 : #endif
272 :
273 : #include <stdlib.h>
274 :
275 : /* When compiling C++ we need to include <cstdlib> as well as <stdlib.h> so
276 : that it is processed before we poison "malloc"; otherwise, if a source
277 : file uses a standard library header that includes <cstdlib>, we will get
278 : an error about 'using std::malloc'. */
279 : #ifdef __cplusplus
280 : #include <cstdlib>
281 : #endif
282 :
283 : /* Undef vec_free from AIX stdlib.h header which conflicts with vec.h. */
284 : #undef vec_free
285 :
286 : /* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and
287 : FATAL_EXIT_CODE to EXIT_SUCCESS and EXIT_FAILURE respectively,
288 : or 0 and 1 if those macros are not defined. */
289 : #ifndef SUCCESS_EXIT_CODE
290 : # ifdef EXIT_SUCCESS
291 : # define SUCCESS_EXIT_CODE EXIT_SUCCESS
292 : # else
293 : # define SUCCESS_EXIT_CODE 0
294 : # endif
295 : #endif
296 :
297 : #ifndef FATAL_EXIT_CODE
298 : # ifdef EXIT_FAILURE
299 : # define FATAL_EXIT_CODE EXIT_FAILURE
300 : # else
301 : # define FATAL_EXIT_CODE 1
302 : # endif
303 : #endif
304 :
305 : #define ICE_EXIT_CODE 4
306 :
307 : #ifdef HAVE_UNISTD_H
308 : # include <unistd.h>
309 : #endif
310 :
311 : #ifdef HAVE_SYS_PARAM_H
312 : # include <sys/param.h>
313 : /* We use these identifiers later and they appear in some vendor param.h's. */
314 : # undef PREFETCH
315 : # undef m_slot
316 : #endif
317 :
318 : #include <limits.h>
319 :
320 : /* A macro to determine whether a VALUE lies inclusively within a
321 : certain range without evaluating the VALUE more than once. This
322 : macro won't warn if the VALUE is unsigned and the LOWER bound is
323 : zero, as it would e.g. with "VALUE >= 0 && ...". Note the LOWER
324 : bound *is* evaluated twice, and LOWER must not be greater than
325 : UPPER. However the bounds themselves can be either positive or
326 : negative. */
327 : #define IN_RANGE(VALUE, LOWER, UPPER) \
328 : ((unsigned HOST_WIDE_INT) (VALUE) - (unsigned HOST_WIDE_INT) (LOWER) \
329 : <= (unsigned HOST_WIDE_INT) (UPPER) - (unsigned HOST_WIDE_INT) (LOWER))
330 :
331 : /* Infrastructure for defining missing _MAX and _MIN macros. Note that
332 : macros defined with these cannot be used in #if. */
333 :
334 : /* The extra casts work around common compiler bugs. */
335 : #define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
336 : /* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
337 : It is necessary at least when t == time_t. */
338 : #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
339 : ? (t) 1 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
340 : #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
341 :
342 : /* Use that infrastructure to provide a few constants. */
343 : #ifndef UCHAR_MAX
344 : # define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char)
345 : #endif
346 :
347 : #ifdef TIME_WITH_SYS_TIME
348 : # include <sys/time.h>
349 : # include <time.h>
350 : #else
351 : # if HAVE_SYS_TIME_H
352 : # include <sys/time.h>
353 : # else
354 : # ifdef HAVE_TIME_H
355 : # include <time.h>
356 : # endif
357 : # endif
358 : #endif
359 :
360 : #ifdef HAVE_FCNTL_H
361 : # include <fcntl.h>
362 : #else
363 : # ifdef HAVE_SYS_FILE_H
364 : # include <sys/file.h>
365 : # endif
366 : #endif
367 :
368 : #ifdef HAVE_SYS_LOCKING_H
369 : # include <sys/locking.h>
370 : #endif
371 :
372 : #ifndef SEEK_SET
373 : # define SEEK_SET 0
374 : # define SEEK_CUR 1
375 : # define SEEK_END 2
376 : #endif
377 : #ifndef F_OK
378 : # define F_OK 0
379 : # define X_OK 1
380 : # define W_OK 2
381 : # define R_OK 4
382 : #endif
383 : #ifndef O_RDONLY
384 : # define O_RDONLY 0
385 : #endif
386 : #ifndef O_WRONLY
387 : # define O_WRONLY 1
388 : #endif
389 : #ifndef O_BINARY
390 : # define O_BINARY 0
391 : #endif
392 :
393 : /* Some systems define these in, e.g., param.h. We undefine these names
394 : here to avoid the warnings. We prefer to use our definitions since we
395 : know they are correct. */
396 :
397 : #undef MIN
398 : #undef MAX
399 : #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
400 : #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
401 :
402 : /* Returns the least number N such that N * Y >= X. */
403 : #define CEIL(x,y) (((x) + (y) - 1) / (y))
404 :
405 : /* This macro rounds x up to the y boundary. */
406 : #define ROUND_UP(x,y) (((x) + (y) - 1) & ~((y) - 1))
407 :
408 : /* This macro rounds x down to the y boundary. */
409 : #define ROUND_DOWN(x,y) ((x) & ~((y) - 1))
410 :
411 : #ifdef HAVE_SYS_WAIT_H
412 : #include <sys/wait.h>
413 : #endif
414 :
415 : #ifndef WIFSIGNALED
416 : #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
417 : #endif
418 : #ifndef WTERMSIG
419 : #define WTERMSIG(S) ((S) & 0x7f)
420 : #endif
421 : #ifndef WIFEXITED
422 : #define WIFEXITED(S) (((S) & 0xff) == 0)
423 : #endif
424 : #ifndef WEXITSTATUS
425 : #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
426 : #endif
427 : #ifndef WSTOPSIG
428 : #define WSTOPSIG WEXITSTATUS
429 : #endif
430 : #ifndef WCOREDUMP
431 : #define WCOREDUMP(S) ((S) & WCOREFLG)
432 : #endif
433 : #ifndef WCOREFLG
434 : #define WCOREFLG 0200
435 : #endif
436 :
437 : #include <signal.h>
438 : #if !defined (SIGCHLD) && defined (SIGCLD)
439 : # define SIGCHLD SIGCLD
440 : #endif
441 :
442 : #ifdef HAVE_SYS_MMAN_H
443 : # include <sys/mman.h>
444 : #endif
445 :
446 : #ifndef MAP_FAILED
447 : # define MAP_FAILED ((void *)-1)
448 : #endif
449 :
450 : #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
451 : # define MAP_ANONYMOUS MAP_ANON
452 : #endif
453 :
454 : #ifdef HAVE_SYS_RESOURCE_H
455 : # include <sys/resource.h>
456 : #endif
457 :
458 : #ifdef HAVE_SYS_TIMES_H
459 : # include <sys/times.h>
460 : #endif
461 :
462 : /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they
463 : are defined to 0 then we must provide the relevant declaration
464 : here. These checks will be in the undefined state while configure
465 : is running so be careful to test "defined (HAVE_DECL_*)". */
466 :
467 : #ifdef __cplusplus
468 : extern "C" {
469 : #endif
470 :
471 : #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD
472 : extern char *getcwd (char *, size_t);
473 : #endif
474 :
475 : #if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT
476 : extern int getopt (int, char * const *, const char *);
477 : #endif
478 :
479 : #if defined (HAVE_DECL_GETPAGESIZE) && !HAVE_DECL_GETPAGESIZE
480 : extern int getpagesize (void);
481 : #endif
482 :
483 : #if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD
484 : extern char *getwd (char *);
485 : #endif
486 :
487 : #if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK
488 : extern void *sbrk (int);
489 : #endif
490 :
491 : #if defined (HAVE_DECL_SETENV) && !HAVE_DECL_SETENV
492 : int setenv(const char *, const char *, int);
493 : #endif
494 :
495 : #if defined (HAVE_DECL_STPCPY) && !HAVE_DECL_STPCPY
496 : extern char *stpcpy (char *, const char *);
497 : #endif
498 :
499 : #if defined (HAVE_DECL_UNSETENV) && !HAVE_DECL_UNSETENV
500 : int unsetenv(const char *);
501 : #endif
502 :
503 : #ifdef __cplusplus
504 : }
505 : #endif
506 :
507 : #ifdef HAVE_STDINT_H
508 : #include <stdint.h>
509 : #endif
510 :
511 : #ifdef HAVE_INTTYPES_H
512 : #include <inttypes.h>
513 : #endif
514 :
515 : #ifndef SIZE_MAX
516 : # define SIZE_MAX INTTYPE_MAXIMUM (size_t)
517 : #endif
518 :
519 : #ifdef __cplusplus
520 : extern "C" {
521 : #endif
522 :
523 : /* If the system doesn't provide strsignal, we get it defined in
524 : libiberty but no declaration is supplied. */
525 : #if !defined (HAVE_STRSIGNAL) \
526 : || (defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL)
527 : # ifndef strsignal
528 : extern const char *strsignal (int);
529 : # endif
530 : #endif
531 :
532 : #ifdef HAVE_GETRLIMIT
533 : # if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT
534 : # ifndef getrlimit
535 : struct rlimit;
536 : extern int getrlimit (int, struct rlimit *);
537 : # endif
538 : # endif
539 : #endif
540 :
541 : #ifdef HAVE_SETRLIMIT
542 : # if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT
543 : # ifndef setrlimit
544 : struct rlimit;
545 : extern int setrlimit (int, const struct rlimit *);
546 : # endif
547 : # endif
548 : #endif
549 :
550 : #if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
551 : extern int snprintf (char *, size_t, const char *, ...);
552 : #endif
553 :
554 : #if defined (HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
555 : extern int vsnprintf (char *, size_t, const char *, va_list);
556 : #endif
557 :
558 : #ifdef __cplusplus
559 : }
560 : #endif
561 :
562 : /* 1 if we have C99 designated initializers. */
563 : #if !defined(HAVE_DESIGNATED_INITIALIZERS)
564 : #ifdef __cplusplus
565 : #define HAVE_DESIGNATED_INITIALIZERS 0
566 : #else
567 : #define HAVE_DESIGNATED_INITIALIZERS \
568 : ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
569 : #endif
570 : #endif
571 :
572 : #if HAVE_SYS_STAT_H
573 : # include <sys/stat.h>
574 : #endif
575 :
576 : /* Test if something is a normal file. */
577 : #ifndef S_ISREG
578 : #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
579 : #endif
580 :
581 : /* Test if something is a directory. */
582 : #ifndef S_ISDIR
583 : #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
584 : #endif
585 :
586 : /* Test if something is a character special file. */
587 : #ifndef S_ISCHR
588 : #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
589 : #endif
590 :
591 : /* Test if something is a block special file. */
592 : #ifndef S_ISBLK
593 : #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
594 : #endif
595 :
596 : /* Test if something is a socket. */
597 : #ifndef S_ISSOCK
598 : # ifdef S_IFSOCK
599 : # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
600 : # else
601 : # define S_ISSOCK(m) 0
602 : # endif
603 : #endif
604 :
605 : /* Test if something is a FIFO. */
606 : #ifndef S_ISFIFO
607 : # ifdef S_IFIFO
608 : # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
609 : # else
610 : # define S_ISFIFO(m) 0
611 : # endif
612 : #endif
613 :
614 : /* Define well known filenos if the system does not define them. */
615 : #ifndef STDIN_FILENO
616 : # define STDIN_FILENO 0
617 : #endif
618 : #ifndef STDOUT_FILENO
619 : # define STDOUT_FILENO 1
620 : #endif
621 : #ifndef STDERR_FILENO
622 : # define STDERR_FILENO 2
623 : #endif
624 :
625 : /* Some systems have mkdir that takes a single argument. */
626 : #ifdef MKDIR_TAKES_ONE_ARG
627 : # define mkdir(a,b) mkdir (a)
628 : #endif
629 :
630 : #ifndef HAVE_KILL
631 : # define kill(p,s) raise (s)
632 : #endif
633 :
634 : /* Provide a way to print an address via printf. */
635 : #ifndef HOST_PTR_PRINTF
636 : #define HOST_PTR_PRINTF "%p"
637 : #endif /* ! HOST_PTR_PRINTF */
638 :
639 : /* By default, colon separates directories in a path. */
640 : #ifndef PATH_SEPARATOR
641 : #define PATH_SEPARATOR ':'
642 : #endif
643 :
644 : /* Filename handling macros. */
645 : #include "filenames.h"
646 :
647 : /* These should be phased out in favor of IS_DIR_SEPARATOR, where possible. */
648 : #ifndef DIR_SEPARATOR
649 : # define DIR_SEPARATOR '/'
650 : # ifdef HAVE_DOS_BASED_FILE_SYSTEM
651 : # define DIR_SEPARATOR_2 '\\'
652 : # endif
653 : #endif
654 :
655 : #if defined (INCLUDE_DLFCN_H) && defined (HAVE_DLFCN_H)
656 : /* If plugin support is enabled, we could use libdl. */
657 : #include <dlfcn.h>
658 : #endif
659 :
660 : /* Do not introduce a gmp.h dependency on the build system. */
661 : #ifndef GENERATOR_FILE
662 : #include <gmp.h>
663 :
664 : class auto_mpz
665 : {
666 : public:
667 21016237 : auto_mpz () { mpz_init (m_mpz); }
668 21016237 : ~auto_mpz () { mpz_clear (m_mpz); }
669 :
670 29383782 : operator mpz_t& () { return m_mpz; }
671 : mpz_ptr operator-> () { return m_mpz; }
672 :
673 : auto_mpz (const auto_mpz &) = delete;
674 : auto_mpz &operator= (const auto_mpz &) = delete;
675 :
676 : #if GCC_VERSION < 4008 || GCC_VERSION >= 5000
677 : /* GCC 4.8 and 4.9 don't support this, only fixed in PR62101 for 5.0. */
678 : friend void mpz_clear (auto_mpz&) = delete;
679 : friend void mpz_init (auto_mpz&) = delete;
680 : #endif
681 :
682 : private:
683 : mpz_t m_mpz;
684 : };
685 : #endif
686 :
687 : /* Get libiberty declarations. */
688 : #include "libiberty.h"
689 :
690 : #undef FFS /* Some systems predefine this symbol; don't let it interfere. */
691 : #undef FLOAT /* Likewise. */
692 : #undef ABS /* Likewise. */
693 : #undef PC /* Likewise. */
694 :
695 : /* Provide a default for the HOST_BIT_BUCKET.
696 : This suffices for POSIX-like hosts. */
697 :
698 : #ifndef HOST_BIT_BUCKET
699 : #define HOST_BIT_BUCKET "/dev/null"
700 : #endif
701 :
702 : #ifndef offsetof
703 : #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
704 : #endif
705 :
706 : /* Various error reporting routines want to use __FUNCTION__. */
707 : #if (GCC_VERSION < 2007)
708 : #ifndef __FUNCTION__
709 : #define __FUNCTION__ "?"
710 : #endif /* ! __FUNCTION__ */
711 : #endif
712 :
713 : /* __builtin_expect(A, B) evaluates to A, but notifies the compiler that
714 : the most likely value of A is B. This feature was added at some point
715 : between 2.95 and 3.0. Let's use 3.0 as the lower bound for now. */
716 : #if (GCC_VERSION < 3000)
717 : #define __builtin_expect(a, b) (a)
718 : #endif
719 :
720 : #define LIKELY(x) (__builtin_expect ((x), 1))
721 : #define UNLIKELY(x) (__builtin_expect ((x), 0))
722 :
723 :
724 : #ifdef INCLUDE_MUTEX
725 : # include <mutex>
726 : #endif
727 :
728 : #ifdef INCLUDE_MALLOC_H
729 : #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
730 : #include <malloc.h>
731 : #endif
732 : #endif
733 :
734 : #ifdef INCLUDE_ISL
735 : #ifdef HAVE_isl
736 : #include <isl/options.h>
737 : #include <isl/ctx.h>
738 : #include <isl/val.h>
739 : #include <isl/set.h>
740 : #include <isl/union_set.h>
741 : #include <isl/map.h>
742 : #include <isl/union_map.h>
743 : #include <isl/aff.h>
744 : #include <isl/constraint.h>
745 : #include <isl/flow.h>
746 : #include <isl/ilp.h>
747 : #include <isl/schedule.h>
748 : #include <isl/ast_build.h>
749 : #include <isl/schedule_node.h>
750 : #include <isl/id.h>
751 : #include <isl/space.h>
752 : #endif
753 : #endif
754 :
755 : /* Redefine 'abort' to report an internal error w/o coredump, and
756 : reporting the location of the error in the source file.
757 : Instead of directly calling 'abort' or 'fancy_abort', GCC code
758 : should normally call 'internal_error' with a specific message. */
759 : extern void fancy_abort (const char *, int, const char *)
760 : ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
761 : #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
762 :
763 : /* Use gcc_assert(EXPR) to test invariants. */
764 : #if ENABLE_ASSERT_CHECKING
765 : #define gcc_assert(EXPR) \
766 : ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
767 : #elif (GCC_VERSION >= 4005)
768 : #define gcc_assert(EXPR) \
769 : ((void)(UNLIKELY (!(EXPR)) ? __builtin_unreachable (), 0 : 0))
770 : #else
771 : /* Include EXPR, so that unused variable warnings do not occur. */
772 : #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
773 : #endif
774 :
775 : #if CHECKING_P
776 : #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
777 : #else
778 : /* N.B.: in release build EXPR is not evaluated. */
779 : #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
780 : #endif
781 :
782 : #if GCC_VERSION >= 4000
783 : #define ALWAYS_INLINE inline __attribute__ ((always_inline))
784 : #else
785 : #define ALWAYS_INLINE inline
786 : #endif
787 :
788 : #if GCC_VERSION >= 3004
789 : #define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
790 : #else
791 : #define WARN_UNUSED_RESULT
792 : #endif
793 :
794 : /* Use gcc_unreachable() to mark unreachable locations (like an
795 : unreachable default case of a switch. Do not use gcc_assert(0). */
796 : #if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING
797 : #define gcc_unreachable() __builtin_unreachable ()
798 : #else
799 : #define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__))
800 : #endif
801 :
802 : #if GCC_VERSION >= 7000 && defined(__has_attribute)
803 : # if __has_attribute(fallthrough)
804 : # define gcc_fallthrough() __attribute__((fallthrough))
805 : # else
806 : # define gcc_fallthrough()
807 : # endif
808 : #else
809 : # define gcc_fallthrough()
810 : #endif
811 :
812 : #if GCC_VERSION >= 3001
813 : #define STATIC_CONSTANT_P(X) (__builtin_constant_p (X) && (X))
814 : #else
815 : #define STATIC_CONSTANT_P(X) (false && (X))
816 : #endif
817 :
818 : #ifdef __cplusplus
819 : #define STATIC_ASSERT(X) \
820 : static_assert ((X), #X)
821 : #else
822 : #define STATIC_ASSERT(X) \
823 : typedef int assertion1[(X) ? 1 : -1] ATTRIBUTE_UNUSED
824 : #endif
825 :
826 : /* Provide a fake boolean type. We make no attempt to use the
827 : C99 _Bool, as it may not be available in the bootstrap compiler,
828 : and even if it is, it is liable to be buggy.
829 : This must be after all inclusion of system headers, as some of
830 : them will mess us up. */
831 :
832 : #undef TRUE
833 : #undef FALSE
834 :
835 : #ifdef __cplusplus
836 : /* Obsolete. */
837 : # define TRUE true
838 : # define FALSE false
839 : #else /* !__cplusplus */
840 : # undef bool
841 : # undef true
842 : # undef false
843 :
844 : # define bool unsigned char
845 : # define true 1
846 : # define false 0
847 :
848 : /* Obsolete. */
849 : # define TRUE true
850 : # define FALSE false
851 : #endif /* !__cplusplus */
852 :
853 : /* As the last action in this file, we poison the identifiers that
854 : shouldn't be used. Note, luckily gcc-3.0's token-based integrated
855 : preprocessor won't trip on poisoned identifiers that arrive from
856 : the expansion of macros. E.g. #define strrchr rindex, won't error
857 : if rindex is poisoned after this directive is issued and later on
858 : strrchr is called.
859 :
860 : Note: We define bypass macros for the few cases where we really
861 : want to use the libc memory allocation routines. Otherwise we
862 : insist you use the "x" versions from libiberty. */
863 :
864 : #define really_call_malloc malloc
865 : #define really_call_calloc calloc
866 : #define really_call_realloc realloc
867 :
868 : #if defined(FLEX_SCANNER) || defined(YYBISON) || defined(YYBYACC)
869 : /* Flex and bison use malloc and realloc. Yuk. Note that this means
870 : really_call_* cannot be used in a .l or .y file. */
871 : #define malloc xmalloc
872 : #define realloc xrealloc
873 : #endif
874 :
875 : #if (GCC_VERSION >= 3000)
876 :
877 : /* Note autoconf checks for prototype declarations and includes
878 : system.h while doing so. Only poison these tokens if actually
879 : compiling gcc, so that the autoconf declaration tests for malloc
880 : etc don't spuriously fail. */
881 : #ifdef IN_GCC
882 :
883 : #undef calloc
884 : #undef strdup
885 : #undef strndup
886 : #pragma GCC poison calloc strdup strndup
887 :
888 : #if !defined(FLEX_SCANNER) && !defined(YYBISON)
889 : #undef malloc
890 : #undef realloc
891 : #pragma GCC poison malloc realloc
892 : #endif
893 :
894 : /* The %m format should be used when GCC's main diagnostic functions
895 : supporting %m are available, and xstrerror from libiberty
896 : otherwise. */
897 : #undef strerror
898 : #pragma GCC poison strerror
899 :
900 : /* loc_t is defined on some systems and too inviting for some
901 : programmers to avoid. */
902 : #undef loc_t
903 : #pragma GCC poison loc_t
904 :
905 : /* Old target macros that have moved to the target hooks structure. */
906 : #pragma GCC poison ASM_OPEN_PAREN ASM_CLOSE_PAREN \
907 : FUNCTION_PROLOGUE FUNCTION_EPILOGUE \
908 : FUNCTION_END_PROLOGUE FUNCTION_BEGIN_EPILOGUE \
909 : DECL_MACHINE_ATTRIBUTES COMP_TYPE_ATTRIBUTES INSERT_ATTRIBUTES \
910 : VALID_MACHINE_DECL_ATTRIBUTE VALID_MACHINE_TYPE_ATTRIBUTE \
911 : SET_DEFAULT_TYPE_ATTRIBUTES SET_DEFAULT_DECL_ATTRIBUTES \
912 : MERGE_MACHINE_TYPE_ATTRIBUTES MERGE_MACHINE_DECL_ATTRIBUTES \
913 : MD_INIT_BUILTINS MD_EXPAND_BUILTIN ASM_OUTPUT_CONSTRUCTOR \
914 : ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \
915 : WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \
916 : ENCODE_SECTION_INFO STRIP_NAME_ENCODING ASM_GLOBALIZE_LABEL \
917 : ASM_OUTPUT_MI_THUNK CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS \
918 : ADDRESS_COST MACHINE_DEPENDENT_REORG ASM_FILE_START ASM_FILE_END \
919 : ASM_SIMPLIFY_DWARF_ADDR INIT_TARGET_OPTABS INIT_SUBTARGET_OPTABS \
920 : INIT_GOFAST_OPTABS MULSI3_LIBCALL MULDI3_LIBCALL DIVSI3_LIBCALL \
921 : DIVDI3_LIBCALL UDIVSI3_LIBCALL UDIVDI3_LIBCALL MODSI3_LIBCALL \
922 : MODDI3_LIBCALL UMODSI3_LIBCALL UMODDI3_LIBCALL BUILD_VA_LIST_TYPE \
923 : PRETEND_OUTGOING_VARARGS_NAMED STRUCT_VALUE_INCOMING_REGNUM \
924 : ASM_OUTPUT_SECTION_NAME PROMOTE_FUNCTION_ARGS PROMOTE_FUNCTION_MODE \
925 : STRUCT_VALUE_INCOMING STRICT_ARGUMENT_NAMING \
926 : PROMOTE_FUNCTION_RETURN PROMOTE_PROTOTYPES STRUCT_VALUE_REGNUM \
927 : SETUP_INCOMING_VARARGS EXPAND_BUILTIN_SAVEREGS \
928 : DEFAULT_SHORT_ENUMS SPLIT_COMPLEX_ARGS MD_ASM_CLOBBERS \
929 : HANDLE_PRAGMA_REDEFINE_EXTNAME HANDLE_PRAGMA_EXTERN_PREFIX \
930 : MUST_PASS_IN_STACK FUNCTION_ARG_PASS_BY_REFERENCE \
931 : VECTOR_MODE_SUPPORTED_P TARGET_SUPPORTS_HIDDEN \
932 : FUNCTION_ARG_PARTIAL_NREGS ASM_OUTPUT_DWARF_DTPREL \
933 : ALLOCATE_INITIAL_VALUE LEGITIMIZE_ADDRESS FRAME_POINTER_REQUIRED \
934 : CAN_ELIMINATE TRAMPOLINE_TEMPLATE INITIALIZE_TRAMPOLINE \
935 : TRAMPOLINE_ADJUST_ADDRESS STATIC_CHAIN STATIC_CHAIN_INCOMING \
936 : RETURN_POPS_ARGS UNITS_PER_SIMD_WORD OVERRIDE_OPTIONS \
937 : OPTIMIZATION_OPTIONS CLASS_LIKELY_SPILLED_P \
938 : USING_SJLJ_EXCEPTIONS TARGET_UNWIND_INFO \
939 : CAN_DEBUG_WITHOUT_FP UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
940 : HOT_TEXT_SECTION_NAME LEGITIMATE_CONSTANT_P ALWAYS_STRIP_DOTDOT \
941 : OUTPUT_ADDR_CONST_EXTRA SMALL_REGISTER_CLASSES ASM_OUTPUT_IDENT \
942 : ASM_BYTE_OP MEMBER_TYPE_FORCES_BLK LIBGCC2_HAS_SF_MODE \
943 : LIBGCC2_HAS_DF_MODE LIBGCC2_HAS_XF_MODE LIBGCC2_HAS_TF_MODE \
944 : CLEAR_BY_PIECES_P MOVE_BY_PIECES_P SET_BY_PIECES_P \
945 : STORE_BY_PIECES_P TARGET_FLT_EVAL_METHOD \
946 : HARD_REGNO_CALL_PART_CLOBBERED HARD_REGNO_MODE_OK \
947 : MODES_TIEABLE_P FUNCTION_ARG_PADDING SLOW_UNALIGNED_ACCESS \
948 : HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE \
949 : SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS \
950 : TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT \
951 : STARTING_FRAME_OFFSET FLOAT_TYPE_SIZE DOUBLE_TYPE_SIZE \
952 : LONG_DOUBLE_TYPE_SIZE
953 :
954 : /* Target macros only used for code built for the target, that have
955 : moved to libgcc-tm.h or have never been present elsewhere. */
956 : #pragma GCC poison DECLARE_LIBRARY_RENAMES LIBGCC2_GNU_PREFIX \
957 : MD_UNWIND_SUPPORT MD_FROB_UPDATE_CONTEXT ENABLE_EXECUTE_STACK \
958 : REG_VALUE_IN_UNWIND_CONTEXT ASSUME_EXTENDED_UNWIND_CONTEXT
959 :
960 : /* Other obsolete target macros, or macros that used to be in target
961 : headers and were not used, and may be obsolete or may never have
962 : been used. */
963 : #pragma GCC poison INT_ASM_OP ASM_OUTPUT_EH_REGION_BEG CPP_PREDEFINES \
964 : ASM_OUTPUT_EH_REGION_END ASM_OUTPUT_LABELREF_AS_INT SMALL_STACK \
965 : DOESNT_NEED_UNWINDER EH_TABLE_LOOKUP OBJC_SELECTORS_WITHOUT_LABELS \
966 : OMIT_EH_TABLE EASY_DIV_EXPR IMPLICIT_FIX_EXPR \
967 : LONGJMP_RESTORE_FROM_STACK MAX_INT_TYPE_SIZE ASM_IDENTIFY_GCC \
968 : STDC_VALUE TRAMPOLINE_ALIGN ASM_IDENTIFY_GCC_AFTER_SOURCE \
969 : SLOW_ZERO_EXTEND SUBREG_REGNO_OFFSET DWARF_LINE_MIN_INSTR_LENGTH \
970 : TRADITIONAL_RETURN_FLOAT NO_BUILTIN_SIZE_TYPE \
971 : NO_BUILTIN_PTRDIFF_TYPE NO_BUILTIN_WCHAR_TYPE NO_BUILTIN_WINT_TYPE \
972 : BLOCK_PROFILER BLOCK_PROFILER_CODE FUNCTION_BLOCK_PROFILER \
973 : FUNCTION_BLOCK_PROFILER_EXIT MACHINE_STATE_SAVE \
974 : MACHINE_STATE_RESTORE SCCS_DIRECTIVE SECTION_ASM_OP BYTEORDER \
975 : ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL HOST_WORDS_BIG_ENDIAN \
976 : OBJC_PROLOGUE ALLOCATE_TRAMPOLINE HANDLE_PRAGMA ROUND_TYPE_SIZE \
977 : ROUND_TYPE_SIZE_UNIT CONST_SECTION_ASM_OP CRT_GET_RFIB_TEXT \
978 : INSN_CACHE_DEPTH INSN_CACHE_SIZE \
979 : INSN_CACHE_LINE_WIDTH INIT_SECTION_PREAMBLE NEED_ATEXIT ON_EXIT \
980 : EXIT_BODY OBJECT_FORMAT_ROSE MULTIBYTE_CHARS MAP_CHARACTER \
981 : LIBGCC_NEEDS_DOUBLE FINAL_PRESCAN_LABEL DEFAULT_CALLER_SAVES \
982 : LOAD_ARGS_REVERSED MAX_INTEGER_COMPUTATION_MODE \
983 : CONVERT_HARD_REGISTER_TO_SSA_P ASM_OUTPUT_MAIN_SOURCE_FILENAME \
984 : FIRST_INSN_ADDRESS TEXT_SECTION SHARED_BSS_SECTION_ASM_OP \
985 : PROMOTED_MODE EXPAND_BUILTIN_VA_END \
986 : LINKER_DOES_NOT_WORK_WITH_DWARF2 FUNCTION_ARG_KEEP_AS_REFERENCE \
987 : GIV_SORT_CRITERION MAX_LONG_TYPE_SIZE MAX_LONG_DOUBLE_TYPE_SIZE \
988 : MAX_WCHAR_TYPE_SIZE SHARED_SECTION_ASM_OP INTEGRATE_THRESHOLD \
989 : FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE \
990 : TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE \
991 : BUILTIN_SETJMP_FRAME_VALUE \
992 : SUNOS4_SHARED_LIBRARIES PROMOTE_FOR_CALL_ONLY \
993 : SPACE_AFTER_L_OPTION NO_RECURSIVE_FUNCTION_CSE \
994 : DEFAULT_MAIN_RETURN TARGET_MEM_FUNCTIONS EXPAND_BUILTIN_VA_ARG \
995 : COLLECT_PARSE_FLAG DWARF2_GENERATE_TEXT_SECTION_LABEL WINNING_GDB \
996 : ASM_OUTPUT_FILENAME ASM_OUTPUT_SOURCE_LINE FILE_NAME_JOINER \
997 : GDB_INV_REF_REGPARM_STABS_LETTER \
998 : PUT_SDB_SRC_FILE STABS_GCC_MARKER SDB_GENERATE_FAKE \
999 : NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE \
1000 : CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0 \
1001 : TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT \
1002 : LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE \
1003 : TARGET_OPTIONS TARGET_SWITCHES EXTRA_CC_MODES FINALIZE_PIC \
1004 : PREDICATE_CODES SPECIAL_MODE_PREDICATES UNALIGNED_WORD_ASM_OP \
1005 : EXTRA_SECTIONS EXTRA_SECTION_FUNCTIONS READONLY_DATA_SECTION \
1006 : TARGET_ASM_EXCEPTION_SECTION TARGET_ASM_EH_FRAME_SECTION \
1007 : SMALL_ARG_MAX ASM_OUTPUT_SHARED_BSS ASM_OUTPUT_SHARED_COMMON \
1008 : ASM_OUTPUT_SHARED_LOCAL ASM_MAKE_LABEL_LINKONCE \
1009 : STACK_CHECK_PROBE_INTERVAL STACK_CHECK_PROBE_LOAD \
1010 : ORDER_REGS_FOR_LOCAL_ALLOC FUNCTION_OUTGOING_VALUE \
1011 : ASM_DECLARE_CONSTANT_NAME MODIFY_TARGET_NAME SWITCHES_NEED_SPACES \
1012 : SWITCH_CURTAILS_COMPILATION SWITCH_TAKES_ARG WORD_SWITCH_TAKES_ARG \
1013 : TARGET_OPTION_TRANSLATE_TABLE HANDLE_PRAGMA_PACK_PUSH_POP \
1014 : HANDLE_SYSV_PRAGMA HANDLE_PRAGMA_WEAK CONDITIONAL_REGISTER_USAGE \
1015 : FUNCTION_ARG_BOUNDARY MUST_USE_SJLJ_EXCEPTIONS US_SOFTWARE_GOFAST \
1016 : USING_SVR4_H SVR4_ASM_SPEC FUNCTION_ARG FUNCTION_ARG_ADVANCE \
1017 : FUNCTION_INCOMING_ARG IRA_COVER_CLASSES TARGET_VERSION \
1018 : MACHINE_TYPE TARGET_HAS_TARGETCM ASM_OUTPUT_BSS \
1019 : SETJMP_VIA_SAVE_AREA FORBIDDEN_INC_DEC_CLASSES \
1020 : PREFERRED_OUTPUT_RELOAD_CLASS SYSTEM_INCLUDE_DIR \
1021 : STANDARD_INCLUDE_DIR STANDARD_INCLUDE_COMPONENT \
1022 : LINK_ELIMINATE_DUPLICATE_LDIRECTORIES MIPS_DEBUGGING_INFO \
1023 : IDENT_ASM_OP ALL_COP_ADDITIONAL_REGISTER_NAMES \
1024 : RANGE_TEST_NON_SHORT_CIRCUIT EXTENDED_SDB_BASIC_TYPES \
1025 : REAL_VALUE_TRUNCATE REVERSE_CONDEXEC_PREDICATES_P \
1026 : TARGET_ALIGN_ANON_BITFIELDS TARGET_NARROW_VOLATILE_BITFIELDS \
1027 : IDENT_ASM_OP UNALIGNED_SHORT_ASM_OP UNALIGNED_INT_ASM_OP \
1028 : UNALIGNED_LONG_ASM_OP UNALIGNED_DOUBLE_INT_ASM_OP \
1029 : USE_COMMON_FOR_ONE_ONLY IFCVT_EXTRA_FIELDS IFCVT_INIT_EXTRA_FIELDS \
1030 : CASE_USE_BIT_TESTS FIXUNS_TRUNC_LIKE_FIX_TRUNC \
1031 : GO_IF_MODE_DEPENDENT_ADDRESS DELAY_SLOTS_FOR_EPILOGUE \
1032 : ELIGIBLE_FOR_EPILOGUE_DELAY TARGET_C99_FUNCTIONS TARGET_HAS_SINCOS \
1033 : REG_CLASS_FROM_LETTER CONST_OK_FOR_LETTER_P \
1034 : CONST_DOUBLE_OK_FOR_LETTER_P EXTRA_CONSTRAINT \
1035 : REG_CLASS_FROM_CONSTRAINT REG_CLASS_FOR_CONSTRAINT \
1036 : EXTRA_CONSTRAINT_STR EXTRA_MEMORY_CONSTRAINT \
1037 : EXTRA_ADDRESS_CONSTRAINT CONST_DOUBLE_OK_FOR_CONSTRAINT_P \
1038 : CALLER_SAVE_PROFITABLE LARGEST_EXPONENT_IS_NORMAL \
1039 : ROUND_TOWARDS_ZERO SF_SIZE DF_SIZE XF_SIZE TF_SIZE LIBGCC2_TF_CEXT \
1040 : LIBGCC2_LONG_DOUBLE_TYPE_SIZE STRUCT_VALUE \
1041 : EH_FRAME_IN_DATA_SECTION TARGET_FLT_EVAL_METHOD_NON_DEFAULT \
1042 : JCR_SECTION_NAME TARGET_USE_JCR_SECTION SDB_DEBUGGING_INFO \
1043 : SDB_DEBUG NO_IMPLICIT_EXTERN_C NOTICE_UPDATE_CC \
1044 : CC_STATUS_MDEP_INIT CC_STATUS_MDEP CC_STATUS SLOW_SHORT_ACCESS \
1045 : WIDEST_HARDWARE_FP_SIZE ADA_LONG_TYPE_SIZE
1046 :
1047 : /* Hooks that are no longer used. */
1048 : #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \
1049 : LANG_HOOKS_MARK_TREE LANG_HOOKS_INSERT_DEFAULT_ATTRIBUTES \
1050 : LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \
1051 : LANG_HOOKS_PUSHLEVEL LANG_HOOKS_SET_BLOCK \
1052 : LANG_HOOKS_MAYBE_BUILD_CLEANUP LANG_HOOKS_UPDATE_DECL_AFTER_SAVING \
1053 : LANG_HOOKS_POPLEVEL LANG_HOOKS_TRUTHVALUE_CONVERSION \
1054 : TARGET_PROMOTE_FUNCTION_ARGS TARGET_PROMOTE_FUNCTION_RETURN \
1055 : LANG_HOOKS_MISSING_ARGUMENT LANG_HOOKS_HASH_TYPES \
1056 : TARGET_HANDLE_OFAST TARGET_OPTION_OPTIMIZATION \
1057 : TARGET_IRA_COVER_CLASSES TARGET_HELP \
1058 : TARGET_HANDLE_PRAGMA_EXTERN_PREFIX \
1059 : TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_EVEN \
1060 : TARGET_VECTORIZE_BUILTIN_MUL_WIDEN_ODD \
1061 : TARGET_MD_ASM_CLOBBERS TARGET_RELAXED_ORDERING \
1062 : TARGET_INVALID_PARAMETER_TYPE \
1063 : TARGET_INVALID_RETURN_TYPE
1064 :
1065 : /* Arrays that were deleted in favor of a functional interface. */
1066 : #pragma GCC poison built_in_decls implicit_built_in_decls
1067 :
1068 : /* Hooks into libgcc2. */
1069 : #pragma GCC poison LIBGCC2_DOUBLE_TYPE_SIZE LIBGCC2_WORDS_BIG_ENDIAN \
1070 : LIBGCC2_FLOAT_WORDS_BIG_ENDIAN
1071 :
1072 : /* Miscellaneous macros that are no longer used. */
1073 : #pragma GCC poison USE_MAPPED_LOCATION GET_ENVIRONMENT \
1074 : HAVE_DESIGNATED_UNION_INITIALIZERS
1075 :
1076 : /* Libiberty macros that are no longer used in GCC. */
1077 : #undef ANSI_PROTOTYPES
1078 : #undef PTR_CONST
1079 : #undef LONG_DOUBLE
1080 : #undef VPARAMS
1081 : #undef VA_OPEN
1082 : #undef VA_FIXEDARG
1083 : #undef VA_CLOSE
1084 : #undef VA_START
1085 : #pragma GCC poison ANSI_PROTOTYPES PTR_CONST LONG_DOUBLE VPARAMS VA_OPEN \
1086 : VA_FIXEDARG VA_CLOSE VA_START
1087 : #endif /* IN_GCC */
1088 :
1089 : /* Front ends should never have to include middle-end headers. Enforce
1090 : this by poisoning the header double-include protection defines. */
1091 : #ifdef IN_GCC_FRONTEND
1092 : #pragma GCC poison GCC_RTL_H GCC_EXCEPT_H GCC_EXPR_H
1093 : #endif
1094 :
1095 : /* Note: not all uses of the `index' token (e.g. variable names and
1096 : structure members) have been eliminated. */
1097 : #undef bcopy
1098 : #undef bzero
1099 : #undef bcmp
1100 : #undef rindex
1101 : #pragma GCC poison bcopy bzero bcmp rindex
1102 :
1103 : /* Poison ENABLE_CHECKING macro that should be replaced with
1104 : 'if (flag_checking)', or with CHECKING_P macro. */
1105 : #pragma GCC poison ENABLE_CHECKING
1106 :
1107 : #endif /* GCC >= 3.0 */
1108 :
1109 : /* Activate certain diagnostics as warnings (not errors via the
1110 : -Werror flag). */
1111 : #if GCC_VERSION >= 4003
1112 : /* If asserts are disabled, activate -Wuninitialized as a warning (not
1113 : an error/-Werror). */
1114 : #ifndef ENABLE_ASSERT_CHECKING
1115 : #pragma GCC diagnostic warning "-Wuninitialized"
1116 : #endif
1117 : #endif
1118 :
1119 : #ifdef ENABLE_VALGRIND_ANNOTATIONS
1120 : #include <valgrind/memcheck.h>
1121 : #else
1122 : /* VALGRIND_DISCARD unregisters the given block handle,
1123 : but our code misuses it for discarding annotations. */
1124 : #define VALGRIND_DISCARD(x)
1125 : #endif
1126 :
1127 : /* Macros to temporarily ignore some warnings. */
1128 : #if GCC_VERSION >= 6000
1129 : #define GCC_DIAGNOSTIC_STRINGIFY(x) #x
1130 : #define GCC_DIAGNOSTIC_PUSH_IGNORED(x) \
1131 : _Pragma ("GCC diagnostic push") \
1132 : _Pragma (GCC_DIAGNOSTIC_STRINGIFY (GCC diagnostic ignored #x))
1133 : #define GCC_DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop")
1134 : #else
1135 : #define GCC_DIAGNOSTIC_PUSH_IGNORED(x)
1136 : #define GCC_DIAGNOSTIC_POP
1137 : #endif
1138 :
1139 : /* In LTO -fwhole-program build we still want to keep the debug functions available
1140 : for debugger. Mark them as used to prevent removal. */
1141 : #if (GCC_VERSION > 4000)
1142 : #define DEBUG_FUNCTION __attribute__ ((__used__))
1143 : #define DEBUG_VARIABLE __attribute__ ((__used__))
1144 : #else
1145 : #define DEBUG_FUNCTION
1146 : #define DEBUG_VARIABLE
1147 : #endif
1148 :
1149 : /* General macro to extract bit Y of X. */
1150 : #define TEST_BIT(X, Y) (((X) >> (Y)) & 1)
1151 :
1152 : /* Get definitions of HOST_WIDE_INT. */
1153 : #include "hwint.h"
1154 :
1155 : typedef int sort_r_cmp_fn (const void *, const void *, void *);
1156 : void qsort_chk (void *, size_t, size_t, sort_r_cmp_fn *, void *);
1157 : void gcc_sort_r (void *, size_t, size_t, sort_r_cmp_fn *, void *);
1158 : void gcc_qsort (void *, size_t, size_t, int (*)(const void *, const void *));
1159 : void gcc_stablesort (void *, size_t, size_t,
1160 : int (*)(const void *, const void *));
1161 : void gcc_stablesort_r (void *, size_t, size_t, sort_r_cmp_fn *, void *data);
1162 : /* Redirect four-argument qsort calls to gcc_qsort; one-argument invocations
1163 : correspond to vec::qsort, and use C qsort internally. */
1164 : #define PP_5th(a1, a2, a3, a4, a5, ...) a5
1165 : #undef qsort
1166 : #define qsort(...) PP_5th (__VA_ARGS__, gcc_qsort, 3, 2, qsort, 0) (__VA_ARGS__)
1167 :
1168 : #define ONE_K 1024
1169 : #define ONE_M (ONE_K * ONE_K)
1170 : #define ONE_G (ONE_K * ONE_M)
1171 :
1172 : /* Display a number as an integer multiple of either:
1173 : - 1024, if said integer is >= to 10 K (in base 2)
1174 : - 1024 * 1024, if said integer is >= 10 M in (base 2)
1175 : */
1176 : #define SIZE_SCALE(x) (((x) < 10 * ONE_K \
1177 : ? (x) \
1178 : : ((x) < 10 * ONE_M \
1179 : ? (x) / ONE_K \
1180 : : (x) / ONE_M)))
1181 :
1182 : /* For a given integer, display either:
1183 : - the character 'k', if the number is higher than 10 K (in base 2)
1184 : but strictly lower than 10 M (in base 2)
1185 : - the character 'M' if the number is higher than 10 M (in base2)
1186 : - the character ' ' if the number is strictly lower than 10 K */
1187 : #define SIZE_LABEL(x) ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M'))
1188 :
1189 : /* Display an integer amount as multiple of 1K or 1M (in base 2).
1190 : Display the correct unit (either k, M, or ' ') after the amount, as
1191 : well. */
1192 : #define SIZE_AMOUNT(size) (uint64_t)SIZE_SCALE (size), SIZE_LABEL (size)
1193 :
1194 : /* Format string particle for printing a SIZE_AMOUNT with N being the width
1195 : of the number. */
1196 : #define PRsa(n) "%" #n PRIu64 "%c"
1197 :
1198 : /* System headers may define NULL to be an integer (e.g. 0L), which cannot be
1199 : used safely in certain contexts (e.g. as sentinels). Redefine NULL to
1200 : nullptr in order to make it safer. Note that this might confuse system
1201 : headers, however, by convention they must not be included after this point.
1202 : */
1203 : #ifdef __cplusplus
1204 : #undef NULL
1205 : #define NULL nullptr
1206 : #endif
1207 :
1208 : /* Workaround clang on PowerPC which has vec_step as reserved keyword
1209 : rather than function-like macro defined in <altivec.h>. See PR114369. */
1210 : #if defined(__clang__) && defined(__powerpc__)
1211 : #define vec_step vec_step_
1212 : #endif
1213 :
1214 : /* Return true if STR string starts with PREFIX. */
1215 :
1216 : inline bool
1217 1911644859 : startswith (const char *str, const char *prefix)
1218 : {
1219 1911644859 : return strncmp (str, prefix, strlen (prefix)) == 0;
1220 : }
1221 :
1222 : /* Return true if STR string ends with SUFFIX. */
1223 :
1224 : inline bool
1225 297 : endswith (const char *str, const char *suffix)
1226 : {
1227 297 : size_t str_len = strlen (str);
1228 297 : size_t suffix_len = strlen (suffix);
1229 297 : if (str_len < suffix_len)
1230 : return false;
1231 :
1232 297 : return memcmp (str + str_len - suffix_len, suffix, suffix_len) == 0;
1233 : }
1234 :
1235 : #endif /* ! GCC_SYSTEM_H */
|