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