]>
Commit | Line | Data |
---|---|---|
71b5d516 PB |
1 | /* Get common system includes and various definitions and declarations based |
2 | on autoconf macros. | |
3 | Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 | |
4 | Free Software Foundation, Inc. | |
5 | ||
6 | This file is part of libcpp (aka cpplib). | |
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 | |
10 | Software Foundation; either version 2, or (at your option) any later | |
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 | |
19 | along with GCC; see the file COPYING. If not, write to the Free | |
20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
21 | 02111-1307, USA. */ | |
22 | ||
23 | ||
24 | #ifndef FIXINC_SYSTEM_H | |
25 | #define FIXINC_SYSTEM_H | |
26 | ||
27 | /* We must include stdarg.h before stdio.h. */ | |
28 | #include <stdarg.h> | |
29 | ||
30 | #ifdef HAVE_STDDEF_H | |
31 | # include <stddef.h> | |
32 | #endif | |
33 | ||
34 | #include <stdio.h> | |
35 | ||
36 | /* Define a generic NULL if one hasn't already been defined. */ | |
37 | #ifndef NULL | |
38 | #define NULL 0 | |
39 | #endif | |
40 | ||
41 | /* fixincludes is not a multi-threaded application and therefore we | |
42 | do not have to use the locking functions. In fact, using the locking | |
43 | functions can cause the compiler to be significantly slower under | |
44 | I/O bound conditions (such as -g -O0 on very large source files). | |
45 | ||
46 | HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio | |
47 | code is multi-thread safe by default. If it is set to 0, then do | |
48 | not worry about using the _unlocked functions. | |
49 | ||
50 | fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are | |
51 | extensions and need to be prototyped by hand (since we do not | |
52 | define _GNU_SOURCE). */ | |
53 | ||
54 | #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED | |
55 | ||
56 | # ifdef HAVE_PUTC_UNLOCKED | |
57 | # undef putc | |
58 | # define putc(C, Stream) putc_unlocked (C, Stream) | |
59 | # endif | |
60 | # ifdef HAVE_FPUTC_UNLOCKED | |
61 | # undef fputc | |
62 | # define fputc(C, Stream) fputc_unlocked (C, Stream) | |
63 | # endif | |
64 | ||
65 | # ifdef HAVE_FPUTS_UNLOCKED | |
66 | # undef fputs | |
67 | # define fputs(String, Stream) fputs_unlocked (String, Stream) | |
68 | # if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED | |
69 | extern int fputs_unlocked (const char *, FILE *); | |
70 | # endif | |
71 | # endif | |
72 | # ifdef HAVE_FWRITE_UNLOCKED | |
73 | # undef fwrite | |
74 | # define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream) | |
75 | # if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED | |
76 | extern int fwrite_unlocked (const void *, size_t, size_t, FILE *); | |
77 | # endif | |
78 | # endif | |
79 | # ifdef HAVE_FPRINTF_UNLOCKED | |
80 | # undef fprintf | |
81 | /* We can't use a function-like macro here because we don't know if | |
82 | we have varargs macros. */ | |
83 | # define fprintf fprintf_unlocked | |
84 | # if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED | |
85 | extern int fprintf_unlocked (FILE *, const char *, ...); | |
86 | # endif | |
87 | # endif | |
88 | ||
89 | #endif | |
90 | ||
91 | /* ??? Glibc's fwrite/fread_unlocked macros cause | |
92 | "warning: signed and unsigned type in conditional expression". */ | |
93 | #undef fread_unlocked | |
94 | #undef fwrite_unlocked | |
95 | ||
96 | #include <sys/types.h> | |
97 | #include <errno.h> | |
98 | ||
99 | #if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO | |
100 | extern int errno; | |
101 | #endif | |
102 | ||
103 | /* Some of glibc's string inlines cause warnings. Plus we'd rather | |
104 | rely on (and therefore test) GCC's string builtins. */ | |
105 | #define __NO_STRING_INLINES | |
106 | ||
107 | #ifdef HAVE_STRING_H | |
108 | # include <string.h> | |
109 | #else | |
110 | # ifdef HAVE_STRINGS_H | |
111 | # include <strings.h> | |
112 | # endif | |
113 | #endif | |
114 | ||
115 | #ifdef HAVE_STDLIB_H | |
116 | # include <stdlib.h> | |
117 | #endif | |
118 | ||
119 | #ifdef HAVE_UNISTD_H | |
120 | # include <unistd.h> | |
121 | #endif | |
122 | ||
123 | #ifdef HAVE_FCNTL_H | |
124 | # include <fcntl.h> | |
125 | #else | |
126 | # ifdef HAVE_SYS_FILE_H | |
127 | # include <sys/file.h> | |
128 | # endif | |
129 | #endif | |
130 | ||
131 | /* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they | |
132 | are defined to 0 then we must provide the relevant declaration | |
133 | here. These checks will be in the undefined state while configure | |
134 | is running so be careful to test "defined (HAVE_DECL_*)". */ | |
135 | ||
136 | #if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT | |
137 | extern void abort (void); | |
138 | #endif | |
139 | ||
140 | #if HAVE_SYS_STAT_H | |
141 | # include <sys/stat.h> | |
142 | #endif | |
143 | ||
144 | /* Test if something is a normal file. */ | |
145 | #ifndef S_ISREG | |
146 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
147 | #endif | |
148 | ||
149 | /* Filename handling macros. */ | |
150 | #include "filenames.h" | |
151 | ||
152 | /* Get libiberty declarations. */ | |
153 | #include "libiberty.h" | |
154 | #include "safe-ctype.h" | |
155 | ||
156 | #endif /* ! FIXINC_SYSTEM_H */ |