]>
Commit | Line | Data |
---|---|---|
71b5d516 PB |
1 | /* Get common system includes and various definitions and declarations based |
2 | on autoconf macros. | |
748086b7 | 3 | Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2009 |
71b5d516 PB |
4 | Free Software Foundation, Inc. |
5 | ||
748086b7 | 6 | This file is part of GCC. |
71b5d516 PB |
7 | |
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
748086b7 | 10 | Software Foundation; either version 3, or (at your option) any later |
71b5d516 PB |
11 | version. |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
748086b7 JJ |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
71b5d516 PB |
21 | |
22 | ||
23 | #ifndef FIXINC_SYSTEM_H | |
24 | #define FIXINC_SYSTEM_H | |
25 | ||
26 | /* We must include stdarg.h before stdio.h. */ | |
27 | #include <stdarg.h> | |
28 | ||
29 | #ifdef HAVE_STDDEF_H | |
30 | # include <stddef.h> | |
31 | #endif | |
32 | ||
33 | #include <stdio.h> | |
34 | ||
35 | /* Define a generic NULL if one hasn't already been defined. */ | |
36 | #ifndef NULL | |
37 | #define NULL 0 | |
38 | #endif | |
39 | ||
042630ad KG |
40 | /* Use the unlocked open routines from libiberty. */ |
41 | #define fopen(PATH,MODE) fopen_unlocked(PATH,MODE) | |
42 | #define fdopen(FILDES,MODE) fdopen_unlocked(FILDES,MODE) | |
43 | #define freopen(PATH,MODE,STREAM) freopen_unlocked(PATH,MODE,STREAM) | |
44 | ||
71b5d516 PB |
45 | /* fixincludes is not a multi-threaded application and therefore we |
46 | do not have to use the locking functions. In fact, using the locking | |
47 | functions can cause the compiler to be significantly slower under | |
48 | I/O bound conditions (such as -g -O0 on very large source files). | |
49 | ||
50 | HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio | |
51 | code is multi-thread safe by default. If it is set to 0, then do | |
52 | not worry about using the _unlocked functions. | |
53 | ||
54 | fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are | |
55 | extensions and need to be prototyped by hand (since we do not | |
56 | define _GNU_SOURCE). */ | |
57 | ||
58 | #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED | |
59 | ||
60 | # ifdef HAVE_PUTC_UNLOCKED | |
61 | # undef putc | |
62 | # define putc(C, Stream) putc_unlocked (C, Stream) | |
63 | # endif | |
0d667716 KG |
64 | # ifdef HAVE_PUTCHAR_UNLOCKED |
65 | # undef putchar | |
66 | # define putchar(C) putchar_unlocked (C) | |
67 | # endif | |
68 | # ifdef HAVE_GETC_UNLOCKED | |
69 | # undef getc | |
70 | # define getc(Stream) getc_unlocked (Stream) | |
71 | # endif | |
72 | # ifdef HAVE_GETCHAR_UNLOCKED | |
73 | # undef getchar | |
74 | # define getchar() getchar_unlocked () | |
75 | # endif | |
71b5d516 PB |
76 | # ifdef HAVE_FPUTC_UNLOCKED |
77 | # undef fputc | |
78 | # define fputc(C, Stream) fputc_unlocked (C, Stream) | |
79 | # endif | |
80 | ||
0d667716 KG |
81 | # ifdef HAVE_CLEARERR_UNLOCKED |
82 | # undef clearerr | |
83 | # define clearerr(Stream) clearerr_unlocked (Stream) | |
84 | # if defined (HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED | |
85 | extern void clearerr_unlocked (FILE *); | |
86 | # endif | |
87 | # endif | |
88 | # ifdef HAVE_FEOF_UNLOCKED | |
89 | # undef feof | |
90 | # define feof(Stream) feof_unlocked (Stream) | |
91 | # if defined (HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED | |
92 | extern int feof_unlocked (FILE *); | |
93 | # endif | |
94 | # endif | |
95 | # ifdef HAVE_FILENO_UNLOCKED | |
96 | # undef fileno | |
97 | # define fileno(Stream) fileno_unlocked (Stream) | |
98 | # if defined (HAVE_DECL_FILENO_UNLOCKED) && !HAVE_DECL_FILENO_UNLOCKED | |
99 | extern int fileno_unlocked (FILE *); | |
100 | # endif | |
101 | # endif | |
102 | # ifdef HAVE_FFLUSH_UNLOCKED | |
103 | # undef fflush | |
104 | # define fflush(Stream) fflush_unlocked (Stream) | |
105 | # if defined (HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED | |
106 | extern int fflush_unlocked (FILE *); | |
107 | # endif | |
108 | # endif | |
109 | # ifdef HAVE_FGETC_UNLOCKED | |
110 | # undef fgetc | |
111 | # define fgetc(Stream) fgetc_unlocked (Stream) | |
112 | # if defined (HAVE_DECL_FGETC_UNLOCKED) && !HAVE_DECL_FGETC_UNLOCKED | |
113 | extern int fgetc_unlocked (FILE *); | |
114 | # endif | |
115 | # endif | |
116 | # ifdef HAVE_FGETS_UNLOCKED | |
117 | # undef fgets | |
118 | # define fgets(S, n, Stream) fgets_unlocked (S, n, Stream) | |
119 | # if defined (HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED | |
120 | extern char *fgets_unlocked (char *, int, FILE *); | |
121 | # endif | |
122 | # endif | |
71b5d516 PB |
123 | # ifdef HAVE_FPUTS_UNLOCKED |
124 | # undef fputs | |
125 | # define fputs(String, Stream) fputs_unlocked (String, Stream) | |
126 | # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED | |
127 | extern int fputs_unlocked (const char *, FILE *); | |
128 | # endif | |
129 | # endif | |
0d667716 KG |
130 | # ifdef HAVE_FERROR_UNLOCKED |
131 | # undef ferror | |
132 | # define ferror(Stream) ferror_unlocked (Stream) | |
133 | # if defined (HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED | |
134 | extern int ferror_unlocked (FILE *); | |
135 | # endif | |
136 | # endif | |
137 | # ifdef HAVE_FREAD_UNLOCKED | |
138 | # undef fread | |
139 | # define fread(Ptr, Size, N, Stream) fread_unlocked (Ptr, Size, N, Stream) | |
140 | # if defined (HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED | |
141 | extern size_t fread_unlocked (void *, size_t, size_t, FILE *); | |
142 | # endif | |
143 | # endif | |
71b5d516 PB |
144 | # ifdef HAVE_FWRITE_UNLOCKED |
145 | # undef fwrite | |
146 | # define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream) | |
147 | # if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED | |
0d667716 | 148 | extern size_t fwrite_unlocked (const void *, size_t, size_t, FILE *); |
71b5d516 PB |
149 | # endif |
150 | # endif | |
151 | # ifdef HAVE_FPRINTF_UNLOCKED | |
152 | # undef fprintf | |
153 | /* We can't use a function-like macro here because we don't know if | |
154 | we have varargs macros. */ | |
155 | # define fprintf fprintf_unlocked | |
156 | # if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED | |
157 | extern int fprintf_unlocked (FILE *, const char *, ...); | |
158 | # endif | |
159 | # endif | |
160 | ||
161 | #endif | |
162 | ||
163 | /* ??? Glibc's fwrite/fread_unlocked macros cause | |
164 | "warning: signed and unsigned type in conditional expression". */ | |
165 | #undef fread_unlocked | |
166 | #undef fwrite_unlocked | |
167 | ||
168 | #include <sys/types.h> | |
169 | #include <errno.h> | |
170 | ||
171 | #if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO | |
172 | extern int errno; | |
173 | #endif | |
174 | ||
175 | /* Some of glibc's string inlines cause warnings. Plus we'd rather | |
176 | rely on (and therefore test) GCC's string builtins. */ | |
177 | #define __NO_STRING_INLINES | |
178 | ||
179 | #ifdef HAVE_STRING_H | |
180 | # include <string.h> | |
181 | #else | |
182 | # ifdef HAVE_STRINGS_H | |
183 | # include <strings.h> | |
184 | # endif | |
185 | #endif | |
186 | ||
187 | #ifdef HAVE_STDLIB_H | |
188 | # include <stdlib.h> | |
189 | #endif | |
190 | ||
191 | #ifdef HAVE_UNISTD_H | |
192 | # include <unistd.h> | |
193 | #endif | |
194 | ||
195 | #ifdef HAVE_FCNTL_H | |
196 | # include <fcntl.h> | |
197 | #else | |
198 | # ifdef HAVE_SYS_FILE_H | |
199 | # include <sys/file.h> | |
200 | # endif | |
201 | #endif | |
202 | ||
203 | /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they | |
204 | are defined to 0 then we must provide the relevant declaration | |
205 | here. These checks will be in the undefined state while configure | |
206 | is running so be careful to test "defined (HAVE_DECL_*)". */ | |
207 | ||
208 | #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT | |
209 | extern void abort (void); | |
210 | #endif | |
211 | ||
212 | #if HAVE_SYS_STAT_H | |
213 | # include <sys/stat.h> | |
214 | #endif | |
215 | ||
216 | /* Test if something is a normal file. */ | |
217 | #ifndef S_ISREG | |
218 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
219 | #endif | |
220 | ||
221 | /* Filename handling macros. */ | |
222 | #include "filenames.h" | |
223 | ||
224 | /* Get libiberty declarations. */ | |
225 | #include "libiberty.h" | |
226 | #include "safe-ctype.h" | |
227 | ||
228 | #endif /* ! FIXINC_SYSTEM_H */ |