1 /* Get common system includes and various definitions and declarations based
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2009
4 Free Software Foundation, Inc.
6 This file is part of GCC.
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
10 Software Foundation; either version 3, or (at your option) any later
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
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 #ifndef FIXINC_SYSTEM_H
24 #define FIXINC_SYSTEM_H
26 /* We must include stdarg.h before stdio.h. */
35 /* Define a generic NULL if one hasn't already been defined. */
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)
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).
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.
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). */
58 #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED
60 # ifdef HAVE_PUTC_UNLOCKED
62 # define putc(C, Stream) putc_unlocked (C, Stream)
64 # ifdef HAVE_PUTCHAR_UNLOCKED
66 # define putchar(C) putchar_unlocked (C)
68 # ifdef HAVE_GETC_UNLOCKED
70 # define getc(Stream) getc_unlocked (Stream)
72 # ifdef HAVE_GETCHAR_UNLOCKED
74 # define getchar() getchar_unlocked ()
76 # ifdef HAVE_FPUTC_UNLOCKED
78 # define fputc(C, Stream) fputc_unlocked (C, Stream)
81 # ifdef HAVE_CLEARERR_UNLOCKED
83 # define clearerr(Stream) clearerr_unlocked (Stream)
84 # if defined (HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
85 extern void clearerr_unlocked (FILE *);
88 # ifdef HAVE_FEOF_UNLOCKED
90 # define feof(Stream) feof_unlocked (Stream)
91 # if defined (HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
92 extern int feof_unlocked (FILE *);
95 # ifdef HAVE_FILENO_UNLOCKED
97 # define fileno(Stream) fileno_unlocked (Stream)
98 # if defined (HAVE_DECL_FILENO_UNLOCKED) && !HAVE_DECL_FILENO_UNLOCKED
99 extern int fileno_unlocked (FILE *);
102 # ifdef HAVE_FFLUSH_UNLOCKED
104 # define fflush(Stream) fflush_unlocked (Stream)
105 # if defined (HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
106 extern int fflush_unlocked (FILE *);
109 # ifdef HAVE_FGETC_UNLOCKED
111 # define fgetc(Stream) fgetc_unlocked (Stream)
112 # if defined (HAVE_DECL_FGETC_UNLOCKED) && !HAVE_DECL_FGETC_UNLOCKED
113 extern int fgetc_unlocked (FILE *);
116 # ifdef HAVE_FGETS_UNLOCKED
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 *);
123 # ifdef HAVE_FPUTS_UNLOCKED
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 *);
130 # ifdef HAVE_FERROR_UNLOCKED
132 # define ferror(Stream) ferror_unlocked (Stream)
133 # if defined (HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
134 extern int ferror_unlocked (FILE *);
137 # ifdef HAVE_FREAD_UNLOCKED
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 *);
144 # ifdef HAVE_FWRITE_UNLOCKED
146 # define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream)
147 # if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
148 extern size_t fwrite_unlocked (const void *, size_t, size_t, FILE *);
151 # ifdef HAVE_FPRINTF_UNLOCKED
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 *, ...);
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
168 #include <sys/types.h>
171 #if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
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
182 # ifdef HAVE_STRINGS_H
183 # include <strings.h>
198 # ifdef HAVE_SYS_FILE_H
199 # include <sys/file.h>
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_*)". */
208 #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
209 extern void abort (void);
212 #if defined (HAVE_DECL_MEMMEM) && !HAVE_DECL_MEMMEM
213 extern void *memmem (const void *, size_t, const void *, size_t);
217 # include <sys/stat.h>
220 /* Test if something is a normal file. */
222 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
225 /* Filename handling macros. */
226 #include "filenames.h"
228 /* Get libiberty declarations. */
229 #include "libiberty.h"
230 #include "safe-ctype.h"
232 #endif /* ! FIXINC_SYSTEM_H */