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