]>
Commit | Line | Data |
---|---|---|
5abc1f74 BK |
1 | |
2 | /* Install modified versions of certain ANSI-incompatible system header | |
3 | files which are fixed to work correctly with ANSI C and placed in a | |
6e6a1681 | 4 | directory that GCC will search. |
5abc1f74 | 5 | |
748086b7 | 6 | Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2009 |
6e6a1681 | 7 | Free Software Foundation, Inc. |
5abc1f74 | 8 | |
6e6a1681 | 9 | This file is part of GCC. |
5abc1f74 | 10 | |
6e6a1681 | 11 | GCC is free software; you can redistribute it and/or modify |
5abc1f74 | 12 | it under the terms of the GNU General Public License as published by |
748086b7 | 13 | the Free Software Foundation; either version 3, or (at your option) |
5abc1f74 BK |
14 | any later version. |
15 | ||
6e6a1681 | 16 | GCC is distributed in the hope that it will be useful, |
5abc1f74 BK |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU General Public License | |
748086b7 JJ |
22 | along with GCC; see the file COPYING3. If not see |
23 | <http://www.gnu.org/licenses/>. */ | |
5abc1f74 | 24 | |
88657302 RH |
25 | #ifndef GCC_FIXLIB_H |
26 | #define GCC_FIXLIB_H | |
5abc1f74 | 27 | |
a26c3bb5 | 28 | #include "config.h" |
5abc1f74 | 29 | #include "system.h" |
27eaa708 | 30 | #include <signal.h> |
5abc1f74 | 31 | |
ab747408 | 32 | #include "xregex.h" |
878a5794 | 33 | #include "libiberty.h" |
5abc1f74 BK |
34 | |
35 | #ifndef STDIN_FILENO | |
36 | # define STDIN_FILENO 0 | |
37 | #endif | |
38 | #ifndef STDOUT_FILENO | |
39 | # define STDOUT_FILENO 1 | |
40 | #endif | |
41 | ||
f4a8f279 AL |
42 | #if ! defined( SIGCHLD ) && defined( SIGCLD ) |
43 | # define SIGCHLD SIGCLD | |
44 | #endif | |
45 | ||
46 | #ifndef SIGQUIT | |
47 | #define SIGQUIT SIGTERM | |
48 | #endif | |
49 | #ifndef SIGIOT | |
50 | #define SIGIOT SIGTERM | |
51 | #endif | |
52 | #ifndef SIGPIPE | |
53 | #define SIGPIPE SIGTERM | |
54 | #endif | |
55 | #ifndef SIGALRM | |
56 | #define SIGALRM SIGTERM | |
57 | #endif | |
58 | #ifndef SIGKILL | |
59 | #define SIGKILL SIGTERM | |
60 | #endif | |
61 | ||
5abc1f74 BK |
62 | typedef int t_success; |
63 | ||
64 | #define FAILURE (-1) | |
65 | #define SUCCESS 0 | |
66 | #define PROBLEM 1 | |
67 | ||
68 | #define SUCCEEDED(p) ((p) == SUCCESS) | |
69 | #define SUCCESSFUL(p) SUCCEEDED (p) | |
70 | #define FAILED(p) ((p) < SUCCESS) | |
71 | #define HADGLITCH(p) ((p) > SUCCESS) | |
72 | ||
2629a114 BK |
73 | #ifndef DEBUG |
74 | # define STATIC static | |
75 | #else | |
76 | # define STATIC | |
77 | #endif | |
5abc1f74 BK |
78 | |
79 | #define tSCC static const char | |
80 | #define tCC const char | |
81 | #define tSC static char | |
82 | ||
83 | /* If this particular system's header files define the macro `MAXPATHLEN', | |
84 | we happily take advantage of it; otherwise we use a value which ought | |
85 | to be large enough. */ | |
86 | #ifndef MAXPATHLEN | |
87 | # define MAXPATHLEN 4096 | |
88 | #endif | |
89 | ||
90 | #ifndef EXIT_SUCCESS | |
91 | # define EXIT_SUCCESS 0 | |
92 | #endif | |
93 | #ifndef EXIT_FAILURE | |
94 | # define EXIT_FAILURE 1 | |
95 | #endif | |
96 | ||
687262b1 BK |
97 | #define EXIT_BROKEN 3 |
98 | ||
5abc1f74 BK |
99 | #define NUL '\0' |
100 | ||
101 | #ifndef NOPROCESS | |
102 | #define NOPROCESS ((pid_t) -1) | |
103 | #define NULLPROCESS ((pid_t)0) | |
104 | ||
105 | #define EXIT_PANIC 99 | |
3af556f7 | 106 | #endif /* NOPROCESS */ |
5abc1f74 | 107 | |
2629a114 BK |
108 | #define IGNORE_ARG(a) ((void)(a)) |
109 | ||
f6242907 | 110 | typedef enum t_bool |
5abc1f74 BK |
111 | { |
112 | BOOL_FALSE, BOOL_TRUE | |
113 | } t_bool; | |
114 | ||
87ad679b BK |
115 | typedef int apply_fix_p_t; /* Apply Fix Predicate Type */ |
116 | ||
117 | #define APPLY_FIX 0 | |
118 | #define SKIP_FIX 1 | |
119 | ||
e02ecf39 BK |
120 | #define ENV_TABLE \ |
121 | _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \ | |
122 | "output from config.guess" ) \ | |
123 | \ | |
62a99405 BK |
124 | _ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \ |
125 | "directory of fixincl and applyfix" ) \ | |
126 | \ | |
e02ecf39 BK |
127 | _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \ |
128 | "directory of original files" ) \ | |
129 | \ | |
130 | _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \ | |
131 | "current directory for fixincl" ) \ | |
132 | \ | |
133 | _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \ | |
134 | "output directory" ) \ | |
135 | \ | |
89b8abbf PB |
136 | _ENV_( pz_mn_name_pat, BOOL_FALSE, "MN_NAME_PAT", \ |
137 | "regex matching forbidden identifiers" ) \ | |
138 | \ | |
e02ecf39 BK |
139 | _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \ |
140 | "amount of user entertainment" ) \ | |
141 | \ | |
142 | _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \ | |
143 | "leader to trim from file names" ) | |
144 | ||
89b8abbf PB |
145 | #define _ENV_(v,m,n,t) extern tCC* v; |
146 | ENV_TABLE | |
147 | #undef _ENV_ | |
148 | ||
35dfe415 BK |
149 | /* Test Descriptor |
150 | ||
151 | Each fix may have associated tests that determine | |
152 | whether the fix needs to be applied or not. | |
153 | Each test has a type (from the te_test_type enumeration); | |
154 | associated test text; and, if the test is TT_EGREP or | |
155 | the negated form TT_NEGREP, a pointer to the compiled | |
156 | version of the text string. | |
157 | ||
158 | */ | |
159 | typedef enum | |
160 | { | |
161 | TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION | |
162 | } te_test_type; | |
163 | ||
164 | typedef struct test_desc tTestDesc; | |
165 | ||
166 | struct test_desc | |
167 | { | |
168 | te_test_type type; | |
169 | const char *pz_test_text; | |
170 | regex_t *p_test_regex; | |
171 | }; | |
172 | ||
173 | typedef struct patch_desc tPatchDesc; | |
174 | ||
175 | /* Fix Descriptor | |
176 | ||
177 | Everything you ever wanted to know about how to apply | |
178 | a particular fix (which files, how to qualify them, | |
179 | how to actually make the fix, etc...) | |
180 | ||
71e06bde BK |
181 | NB: the FD_ defines are BIT FLAGS, even though |
182 | some are mutually exclusive | |
35dfe415 BK |
183 | |
184 | */ | |
185 | #define FD_MACH_ONLY 0x0000 | |
186 | #define FD_MACH_IFNOT 0x0001 | |
187 | #define FD_SHELL_SCRIPT 0x0002 | |
188 | #define FD_SUBROUTINE 0x0004 | |
189 | #define FD_REPLACEMENT 0x0008 | |
190 | #define FD_SKIP_TEST 0x8000 | |
191 | ||
192 | typedef struct fix_desc tFixDesc; | |
193 | struct fix_desc | |
194 | { | |
ba8fcfc3 BK |
195 | tCC* fix_name; /* Name of the fix */ |
196 | tCC* file_list; /* List of files it applies to */ | |
197 | tCC** papz_machs; /* List of machine/os-es it applies to */ | |
198 | int test_ct; | |
199 | int fd_flags; | |
200 | tTestDesc* p_test_desc; | |
201 | tCC** patch_args; | |
202 | long unused; | |
35dfe415 BK |
203 | }; |
204 | ||
687262b1 BK |
205 | typedef struct { |
206 | int type_name_len; | |
207 | tCC* pz_type; | |
208 | tCC* pz_TYPE; | |
209 | tCC* pz_gtype; | |
687262b1 BK |
210 | } t_gnu_type_map; |
211 | ||
212 | extern int gnu_type_map_ct; | |
213 | ||
e02ecf39 BK |
214 | #ifdef HAVE_MMAP_FILE |
215 | #define UNLOAD_DATA() do { if (curr_data_mapped) { \ | |
216 | munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \ | |
217 | else free ((void*)pz_curr_data); } while(0) | |
218 | #else | |
219 | #define UNLOAD_DATA() free ((void*)pz_curr_data) | |
220 | #endif | |
221 | ||
5abc1f74 BK |
222 | /* |
223 | * Exported procedures | |
224 | */ | |
f4dbf936 | 225 | char * load_file_data ( FILE* fp ); |
3af556f7 | 226 | |
878a5794 | 227 | #ifdef IS_CXX_HEADER_NEEDED |
f4dbf936 | 228 | t_bool is_cxx_header ( tCC* filename, tCC* filetext ); |
878a5794 | 229 | #endif /* IS_CXX_HEADER_NEEDED */ |
3af556f7 | 230 | |
878a5794 | 231 | #ifdef SKIP_QUOTE_NEEDED |
f4dbf936 | 232 | tCC* skip_quote ( char q, char* text ); |
878a5794 | 233 | #endif |
35dfe415 | 234 | |
f4dbf936 | 235 | void compile_re ( tCC* pat, regex_t* re, int match, tCC *e1, tCC *e2 ); |
3af556f7 | 236 | |
f4dbf936 | 237 | void apply_fix ( tFixDesc* p_fixd, tCC* filname ); |
3af556f7 | 238 | apply_fix_p_t |
f4dbf936 | 239 | run_test ( tCC* t_name, tCC* f_name, tCC* text ); |
35dfe415 | 240 | |
283da1d3 | 241 | #ifdef SEPARATE_FIX_PROC |
f4dbf936 | 242 | char* make_raw_shell_str ( char* pz_d, tCC* pz_s, size_t smax ); |
62a99405 BK |
243 | #endif |
244 | ||
89b8abbf | 245 | t_bool mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who ); |
ad643a75 PB |
246 | |
247 | void initialize_opts ( void ); | |
88657302 | 248 | #endif /* ! GCC_FIXLIB_H */ |