]>
Commit | Line | Data |
---|---|---|
5daf7ede | 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 | |
fef0883b | 4 | directory that GCC will search. |
5daf7ede | 5 | |
fef0883b | 6 | Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 |
7 | Free Software Foundation, Inc. | |
5daf7ede | 8 | |
fef0883b | 9 | This file is part of GCC. |
5daf7ede | 10 | |
fef0883b | 11 | GCC is free software; you can redistribute it and/or modify |
5daf7ede | 12 | it under the terms of the GNU General Public License as published by |
13 | the Free Software Foundation; either version 2, or (at your option) | |
14 | any later version. | |
15 | ||
fef0883b | 16 | GCC is distributed in the hope that it will be useful, |
5daf7ede | 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 | |
fef0883b | 22 | along with GCC; see the file COPYING. If not, write to |
5daf7ede | 23 | the Free Software Foundation, 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. */ | |
25 | ||
2a281353 | 26 | #ifndef GCC_FIXLIB_H |
27 | #define GCC_FIXLIB_H | |
5daf7ede | 28 | |
9aac3497 | 29 | #include "config.h" |
5daf7ede | 30 | #include "system.h" |
805e22b2 | 31 | #include "coretypes.h" |
32 | #include "tm.h" | |
ca58af19 | 33 | #include <signal.h> |
5daf7ede | 34 | |
30f9dc1c | 35 | #include "xregex.h" |
7cd86c4d | 36 | #include "libiberty.h" |
5daf7ede | 37 | |
38 | #ifndef STDIN_FILENO | |
39 | # define STDIN_FILENO 0 | |
40 | #endif | |
41 | #ifndef STDOUT_FILENO | |
42 | # define STDOUT_FILENO 1 | |
43 | #endif | |
44 | ||
45 | typedef int t_success; | |
46 | ||
47 | #define FAILURE (-1) | |
48 | #define SUCCESS 0 | |
49 | #define PROBLEM 1 | |
50 | ||
51 | #define SUCCEEDED(p) ((p) == SUCCESS) | |
52 | #define SUCCESSFUL(p) SUCCEEDED (p) | |
53 | #define FAILED(p) ((p) < SUCCESS) | |
54 | #define HADGLITCH(p) ((p) > SUCCESS) | |
55 | ||
5beb4ba0 | 56 | #ifndef DEBUG |
57 | # define STATIC static | |
58 | #else | |
59 | # define STATIC | |
60 | #endif | |
5daf7ede | 61 | |
62 | #define tSCC static const char | |
63 | #define tCC const char | |
64 | #define tSC static char | |
65 | ||
66 | /* If this particular system's header files define the macro `MAXPATHLEN', | |
67 | we happily take advantage of it; otherwise we use a value which ought | |
68 | to be large enough. */ | |
69 | #ifndef MAXPATHLEN | |
70 | # define MAXPATHLEN 4096 | |
71 | #endif | |
72 | ||
73 | #ifndef EXIT_SUCCESS | |
74 | # define EXIT_SUCCESS 0 | |
75 | #endif | |
76 | #ifndef EXIT_FAILURE | |
77 | # define EXIT_FAILURE 1 | |
78 | #endif | |
79 | ||
6c013a2f | 80 | #define EXIT_BROKEN 3 |
81 | ||
5daf7ede | 82 | #define NUL '\0' |
83 | ||
84 | #ifndef NOPROCESS | |
85 | #define NOPROCESS ((pid_t) -1) | |
86 | #define NULLPROCESS ((pid_t)0) | |
87 | ||
88 | #define EXIT_PANIC 99 | |
2548396b | 89 | #endif /* NOPROCESS */ |
5daf7ede | 90 | |
5beb4ba0 | 91 | #define IGNORE_ARG(a) ((void)(a)) |
92 | ||
e6c3d97b | 93 | typedef enum t_bool |
5daf7ede | 94 | { |
95 | BOOL_FALSE, BOOL_TRUE | |
96 | } t_bool; | |
97 | ||
a98784e9 | 98 | typedef int apply_fix_p_t; /* Apply Fix Predicate Type */ |
99 | ||
100 | #define APPLY_FIX 0 | |
101 | #define SKIP_FIX 1 | |
102 | ||
cc42f3d4 | 103 | #define ENV_TABLE \ |
104 | _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \ | |
105 | "output from config.guess" ) \ | |
106 | \ | |
70ba55fd | 107 | _ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \ |
108 | "directory of fixincl and applyfix" ) \ | |
109 | \ | |
cc42f3d4 | 110 | _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \ |
111 | "directory of original files" ) \ | |
112 | \ | |
113 | _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \ | |
114 | "current directory for fixincl" ) \ | |
115 | \ | |
116 | _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \ | |
117 | "output directory" ) \ | |
118 | \ | |
31b04dee | 119 | _ENV_( pz_mn_name_pat, BOOL_FALSE, "MN_NAME_PAT", \ |
120 | "regex matching forbidden identifiers" ) \ | |
121 | \ | |
cc42f3d4 | 122 | _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \ |
123 | "amount of user entertainment" ) \ | |
124 | \ | |
125 | _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \ | |
126 | "leader to trim from file names" ) | |
127 | ||
31b04dee | 128 | #define _ENV_(v,m,n,t) extern tCC* v; |
129 | ENV_TABLE | |
130 | #undef _ENV_ | |
131 | ||
09fe1d5c | 132 | /* Test Descriptor |
133 | ||
134 | Each fix may have associated tests that determine | |
135 | whether the fix needs to be applied or not. | |
136 | Each test has a type (from the te_test_type enumeration); | |
137 | associated test text; and, if the test is TT_EGREP or | |
138 | the negated form TT_NEGREP, a pointer to the compiled | |
139 | version of the text string. | |
140 | ||
141 | */ | |
142 | typedef enum | |
143 | { | |
144 | TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION | |
145 | } te_test_type; | |
146 | ||
147 | typedef struct test_desc tTestDesc; | |
148 | ||
149 | struct test_desc | |
150 | { | |
151 | te_test_type type; | |
152 | const char *pz_test_text; | |
153 | regex_t *p_test_regex; | |
154 | }; | |
155 | ||
156 | typedef struct patch_desc tPatchDesc; | |
157 | ||
158 | /* Fix Descriptor | |
159 | ||
160 | Everything you ever wanted to know about how to apply | |
161 | a particular fix (which files, how to qualify them, | |
162 | how to actually make the fix, etc...) | |
163 | ||
94f426d1 | 164 | NB: the FD_ defines are BIT FLAGS, even though |
165 | some are mutually exclusive | |
09fe1d5c | 166 | |
167 | */ | |
168 | #define FD_MACH_ONLY 0x0000 | |
169 | #define FD_MACH_IFNOT 0x0001 | |
170 | #define FD_SHELL_SCRIPT 0x0002 | |
171 | #define FD_SUBROUTINE 0x0004 | |
172 | #define FD_REPLACEMENT 0x0008 | |
173 | #define FD_SKIP_TEST 0x8000 | |
174 | ||
175 | typedef struct fix_desc tFixDesc; | |
176 | struct fix_desc | |
177 | { | |
e6650807 | 178 | tCC* fix_name; /* Name of the fix */ |
179 | tCC* file_list; /* List of files it applies to */ | |
180 | tCC** papz_machs; /* List of machine/os-es it applies to */ | |
181 | int test_ct; | |
182 | int fd_flags; | |
183 | tTestDesc* p_test_desc; | |
184 | tCC** patch_args; | |
185 | long unused; | |
09fe1d5c | 186 | }; |
187 | ||
6c013a2f | 188 | typedef struct { |
189 | int type_name_len; | |
190 | tCC* pz_type; | |
191 | tCC* pz_TYPE; | |
192 | tCC* pz_gtype; | |
6c013a2f | 193 | } t_gnu_type_map; |
194 | ||
195 | extern int gnu_type_map_ct; | |
196 | ||
cc42f3d4 | 197 | #ifdef HAVE_MMAP_FILE |
198 | #define UNLOAD_DATA() do { if (curr_data_mapped) { \ | |
199 | munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \ | |
200 | else free ((void*)pz_curr_data); } while(0) | |
201 | #else | |
202 | #define UNLOAD_DATA() free ((void*)pz_curr_data) | |
203 | #endif | |
204 | ||
5daf7ede | 205 | /* |
206 | * Exported procedures | |
207 | */ | |
a95bcb36 | 208 | char * load_file_data ( FILE* fp ); |
2548396b | 209 | |
7cd86c4d | 210 | #ifdef IS_CXX_HEADER_NEEDED |
a95bcb36 | 211 | t_bool is_cxx_header ( tCC* filename, tCC* filetext ); |
7cd86c4d | 212 | #endif /* IS_CXX_HEADER_NEEDED */ |
2548396b | 213 | |
7cd86c4d | 214 | #ifdef SKIP_QUOTE_NEEDED |
a95bcb36 | 215 | tCC* skip_quote ( char q, char* text ); |
7cd86c4d | 216 | #endif |
09fe1d5c | 217 | |
a95bcb36 | 218 | void compile_re ( tCC* pat, regex_t* re, int match, tCC *e1, tCC *e2 ); |
2548396b | 219 | |
a95bcb36 | 220 | void apply_fix ( tFixDesc* p_fixd, tCC* filname ); |
2548396b | 221 | apply_fix_p_t |
a95bcb36 | 222 | run_test ( tCC* t_name, tCC* f_name, tCC* text ); |
09fe1d5c | 223 | |
d3aacc3b | 224 | #ifdef SEPARATE_FIX_PROC |
a95bcb36 | 225 | char* make_raw_shell_str ( char* pz_d, tCC* pz_s, size_t smax ); |
70ba55fd | 226 | #endif |
227 | ||
31b04dee | 228 | t_bool mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who ); |
2a281353 | 229 | #endif /* ! GCC_FIXLIB_H */ |