GCC Middle and Back End API Reference
tsystem.h
Go to the documentation of this file.
1/* Get common system includes and various definitions and declarations
2 based on target macros.
3 Copyright (C) 2000-2024 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
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
25
26#ifndef GCC_TSYSTEM_H
27#define GCC_TSYSTEM_H
28
29/* System headers (e.g. stdio.h, stdlib.h, unistd.h) sometimes
30 indirectly include getopt.h. Our -I flags will cause gcc's gnu
31 getopt.h to be included, not the platform's copy. In the default
32 case, gnu getopt.h will provide us with a no-argument prototype
33 which will generate -Wstrict-prototypes warnings. None of the
34 target files actually use getopt, so it is safe to tell gnu
35 getopt.h we never need this prototype. */
36#ifndef HAVE_DECL_GETOPT
37#define HAVE_DECL_GETOPT 1
38#endif
39
40/* We want everything from the glibc headers. */
41#define _GNU_SOURCE 1
42
43/* GCC supplies these headers. */
44#include <stddef.h>
45#include <float.h>
46
47#ifdef inhibit_libc
48
49#ifndef malloc
50extern void *malloc (size_t);
51#endif
52
53#ifndef calloc
54extern void *calloc(size_t, size_t);
55#endif
56
57#ifndef realloc
58extern void *realloc(void *, size_t);
59#endif
60
61#ifndef free
62extern void free (void *);
63#endif
64
65#ifndef atexit
66extern int atexit (void (*)(void));
67#endif
68
69#ifndef abort
70#define abort() __builtin_trap ()
71#endif
72
73#ifndef strlen
74extern size_t strlen (const char *);
75#endif
76
77#ifndef memcpy
78extern void *memcpy (void *, const void *, size_t);
79#endif
80
81#ifndef memset
82extern void *memset (void *, int, size_t);
83#endif
84
85#else /* ! inhibit_libc */
86/* We disable this when inhibit_libc, so that gcc can still be built without
87 needing header files first. */
88/* ??? This is not a good solution, since prototypes may be required in
89 some cases for correct code. */
90
91/* GCC supplies this header. */
92#include <stdarg.h>
93
94/* All systems have this header. */
95#include <stdio.h>
96
97/* All systems have this header. */
98#include <sys/types.h>
99
100/* All systems have this header. */
101#include <errno.h>
102
103#ifndef errno
104extern int errno;
105#endif
106
107/* If these system headers do not exist, fixincludes must create them. */
108#include <string.h>
109#include <stdlib.h>
110#include <unistd.h>
111
112/* GCC supplies this header. */
113#include <limits.h>
114
115/* If these system headers do not exist, fixincludes must create them. */
116#include <time.h>
117
118#endif /* inhibit_libc */
119
120/* Define a generic NULL if one hasn't already been defined. */
121#ifndef NULL
122#define NULL 0
123#endif
124
125/* GCC always provides __builtin_alloca(x). */
126#undef alloca
127#define alloca(x) __builtin_alloca(x)
128
129#ifdef ENABLE_RUNTIME_CHECKING
130#define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0))
131#else
132/* Include EXPR, so that unused variable warnings do not occur. */
133#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
134#endif
135/* Use gcc_unreachable() to mark unreachable locations (like an
136 unreachable default case of a switch. Do not use gcc_assert(0). */
137#define gcc_unreachable() (abort ())
138
139#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
140#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
141
142/* Filename handling macros. */
143#include "filenames.h"
144
145#endif /* ! GCC_TSYSTEM_H */
#define realloc
Definition gengtype-lex.l:33
#define malloc
Definition gengtype-lex.l:32
free(str)
int errno