]>
Commit | Line | Data |
---|---|---|
88ae23e7 | 1 | /* Part of CPP library. |
5d8ebbd8 NB |
2 | Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 |
3 | Free Software Foundation, Inc. | |
4283012f JL |
4 | |
5 | This program is free software; you can redistribute it and/or modify it | |
6 | under the terms of the GNU General Public License as published by the | |
7 | Free Software Foundation; either version 2, or (at your option) any | |
8 | later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
42b17236 | 17 | Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
4283012f | 18 | |
88ae23e7 ZW |
19 | /* This header defines all the internal data structures and functions |
20 | that need to be visible across files. It's called cpphash.h for | |
21 | historical reasons. */ | |
22 | ||
2a967f3d NB |
23 | #ifndef GCC_CPPHASH_H |
24 | #define GCC_CPPHASH_H | |
bb52fa7f | 25 | |
2a967f3d NB |
26 | #include "hashtable.h" |
27 | ||
28 | struct directive; /* Deliberately incomplete. */ | |
af0d16cd | 29 | struct pending_option; |
87ed109f | 30 | struct op; |
8121d2c3 | 31 | |
601328bb NB |
32 | typedef unsigned char uchar; |
33 | #define U (const uchar *) /* Intended use: U"string" */ | |
34 | ||
4268e8bb NB |
35 | #define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t)) |
36 | ||
93c80368 NB |
37 | /* Test if a sign is valid within a preprocessing number. */ |
38 | #define VALID_SIGN(c, prevc) \ | |
39 | (((c) == '+' || (c) == '-') && \ | |
40 | ((prevc) == 'e' || (prevc) == 'E' \ | |
bdb05a7b NB |
41 | || (((prevc) == 'p' || (prevc) == 'P') \ |
42 | && CPP_OPTION (pfile, extended_numbers)))) | |
93c80368 | 43 | |
8121d2c3 NB |
44 | #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION) |
45 | #define CPP_BUFFER(PFILE) ((PFILE)->buffer) | |
8121d2c3 NB |
46 | #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + (BUF)->col_adjust) |
47 | #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur) | |
48 | ||
49 | /* Maximum nesting of cpp_buffers. We use a static limit, partly for | |
50 | efficiency, and partly to limit runaway recursion. */ | |
51 | #define CPP_STACK_MAX 200 | |
52 | ||
c70f6ed3 NB |
53 | /* Host alignment handling. */ |
54 | struct dummy | |
55 | { | |
56 | char c; | |
57 | union | |
58 | { | |
59 | double d; | |
60 | int *p; | |
61 | } u; | |
62 | }; | |
63 | ||
64 | #define DEFAULT_ALIGNMENT offsetof (struct dummy, u) | |
65 | #define CPP_ALIGN2(size, align) (((size) + ((align) - 1)) & ~((align) - 1)) | |
66 | #define CPP_ALIGN(size) CPP_ALIGN2 (size, DEFAULT_ALIGNMENT) | |
67 | ||
601328bb NB |
68 | /* Each macro definition is recorded in a cpp_macro structure. |
69 | Variadic macros cannot occur with traditional cpp. */ | |
70 | struct cpp_macro | |
71 | { | |
6618c5d4 NB |
72 | /* Parameters, if any. */ |
73 | cpp_hashnode **params; | |
74 | ||
75 | /* Replacement tokens (ISO) or replacement text (traditional). See | |
76 | comment at top of cpptrad.c for how traditional function-like | |
77 | macros are encoded. */ | |
601328bb NB |
78 | union |
79 | { | |
6618c5d4 NB |
80 | cpp_token *tokens; |
81 | const uchar *text; | |
601328bb | 82 | } exp; |
6618c5d4 NB |
83 | |
84 | /* Definition line number. */ | |
85 | unsigned int line; | |
86 | ||
87 | /* Number of tokens in expansion, or bytes for traditional macros. */ | |
88 | unsigned int count; | |
89 | ||
90 | /* Number of parameters. */ | |
91 | unsigned short paramc; | |
92 | ||
93 | /* If a function-like macro. */ | |
94 | unsigned int fun_like : 1; | |
95 | ||
96 | /* If a variadic macro. */ | |
97 | unsigned int variadic : 1; | |
98 | ||
99 | /* If macro defined in system header. */ | |
100 | unsigned int syshdr : 1; | |
601328bb NB |
101 | }; |
102 | ||
644eddaa | 103 | /* A generic memory buffer, and operations on it. */ |
b8af0ca5 NB |
104 | typedef struct _cpp_buff _cpp_buff; |
105 | struct _cpp_buff | |
106 | { | |
107 | struct _cpp_buff *next; | |
ece54d54 | 108 | unsigned char *base, *cur, *limit; |
b8af0ca5 NB |
109 | }; |
110 | ||
ece54d54 | 111 | extern _cpp_buff *_cpp_get_buff PARAMS ((cpp_reader *, size_t)); |
b8af0ca5 | 112 | extern void _cpp_release_buff PARAMS ((cpp_reader *, _cpp_buff *)); |
8c3b2693 NB |
113 | extern void _cpp_extend_buff PARAMS ((cpp_reader *, _cpp_buff **, size_t)); |
114 | extern _cpp_buff *_cpp_append_extend_buff PARAMS ((cpp_reader *, _cpp_buff *, | |
115 | size_t)); | |
b8af0ca5 | 116 | extern void _cpp_free_buff PARAMS ((_cpp_buff *)); |
8c3b2693 | 117 | extern unsigned char *_cpp_aligned_alloc PARAMS ((cpp_reader *, size_t)); |
ece54d54 | 118 | extern unsigned char *_cpp_unaligned_alloc PARAMS ((cpp_reader *, size_t)); |
644eddaa | 119 | |
8c3b2693 | 120 | #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur) |
ece54d54 NB |
121 | #define BUFF_FRONT(BUFF) ((BUFF)->cur) |
122 | #define BUFF_LIMIT(BUFF) ((BUFF)->limit) | |
b8af0ca5 | 123 | |
591e15a1 NB |
124 | /* List of directories to look for include files in. */ |
125 | struct search_path | |
88ae23e7 | 126 | { |
591e15a1 NB |
127 | struct search_path *next; |
128 | ||
129 | /* NOTE: NAME may not be null terminated for the case of the current | |
130 | file's directory! */ | |
131 | const char *name; | |
132 | unsigned int len; | |
88ae23e7 | 133 | /* We use these to tell if the directory mentioned here is a duplicate |
591e15a1 | 134 | of an earlier directory on the search path. */ |
88ae23e7 ZW |
135 | ino_t ino; |
136 | dev_t dev; | |
591e15a1 | 137 | /* Non-zero if it is a system include directory. */ |
88ae23e7 | 138 | int sysp; |
591e15a1 NB |
139 | /* Mapping of file names for this directory. Only used on MS-DOS |
140 | and related platforms. */ | |
88ae23e7 ZW |
141 | struct file_name_map *name_map; |
142 | }; | |
bfb9dc7f | 143 | |
ba133c96 NB |
144 | /* #include types. */ |
145 | enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE}; | |
146 | ||
4ed5bcfb | 147 | union utoken |
8121d2c3 | 148 | { |
4ed5bcfb NB |
149 | const cpp_token *token; |
150 | const cpp_token **ptoken; | |
8121d2c3 NB |
151 | }; |
152 | ||
5d8ebbd8 | 153 | /* A "run" of tokens; part of a chain of runs. */ |
5fddcffc NB |
154 | typedef struct tokenrun tokenrun; |
155 | struct tokenrun | |
156 | { | |
bdcbe496 | 157 | tokenrun *next, *prev; |
5fddcffc NB |
158 | cpp_token *base, *limit; |
159 | }; | |
160 | ||
82eda77e NB |
161 | /* Accessor macros for struct cpp_context. */ |
162 | #define FIRST(c) (c->u.iso.first) | |
163 | #define LAST(c) (c->u.iso.last) | |
164 | #define CUR(c) (c->u.trad.cur) | |
165 | #define RLIMIT(c) (c->u.trad.rlimit) | |
166 | ||
8121d2c3 NB |
167 | typedef struct cpp_context cpp_context; |
168 | struct cpp_context | |
169 | { | |
170 | /* Doubly-linked list. */ | |
171 | cpp_context *next, *prev; | |
172 | ||
82eda77e NB |
173 | union |
174 | { | |
175 | /* For ISO macro expansion. Contexts other than the base context | |
176 | are contiguous tokens. e.g. macro expansions, expanded | |
177 | argument tokens. */ | |
178 | struct | |
179 | { | |
180 | union utoken first; | |
181 | union utoken last; | |
182 | } iso; | |
183 | ||
184 | /* For traditional macro expansion. */ | |
185 | struct | |
186 | { | |
187 | const uchar *cur; | |
188 | const uchar *rlimit; | |
189 | } trad; | |
190 | } u; | |
8121d2c3 | 191 | |
1e013d2e | 192 | /* If non-NULL, a buffer used for storage related to this context. |
c9e7a609 | 193 | When the context is popped, the buffer is released. */ |
1e013d2e NB |
194 | _cpp_buff *buff; |
195 | ||
644eddaa NB |
196 | /* For a macro context, the macro node, otherwise NULL. */ |
197 | cpp_hashnode *macro; | |
4ed5bcfb NB |
198 | |
199 | /* True if utoken element is token, else ptoken. */ | |
200 | bool direct_p; | |
8121d2c3 NB |
201 | }; |
202 | ||
203 | struct lexer_state | |
204 | { | |
205 | /* Nonzero if first token on line is CPP_HASH. */ | |
206 | unsigned char in_directive; | |
207 | ||
cef0d199 NB |
208 | /* True if we are skipping a failed conditional group. */ |
209 | unsigned char skipping; | |
210 | ||
8121d2c3 NB |
211 | /* Nonzero if in a directive that takes angle-bracketed headers. */ |
212 | unsigned char angled_headers; | |
213 | ||
214 | /* Nonzero to save comments. Turned off if discard_comments, and in | |
215 | all directives apart from #define. */ | |
216 | unsigned char save_comments; | |
217 | ||
8121d2c3 NB |
218 | /* Nonzero if we're mid-comment. */ |
219 | unsigned char lexing_comment; | |
220 | ||
221 | /* Nonzero if lexing __VA_ARGS__ is valid. */ | |
222 | unsigned char va_args_ok; | |
223 | ||
224 | /* Nonzero if lexing poisoned identifiers is valid. */ | |
225 | unsigned char poisoned_ok; | |
226 | ||
227 | /* Nonzero to prevent macro expansion. */ | |
df383483 | 228 | unsigned char prevent_expansion; |
8121d2c3 NB |
229 | |
230 | /* Nonzero when parsing arguments to a function-like macro. */ | |
231 | unsigned char parsing_args; | |
87ed109f NB |
232 | |
233 | /* Nonzero to skip evaluating part of an expression. */ | |
234 | unsigned int skip_eval; | |
8121d2c3 NB |
235 | }; |
236 | ||
237 | /* Special nodes - identifiers with predefined significance. */ | |
238 | struct spec_nodes | |
239 | { | |
8121d2c3 | 240 | cpp_hashnode *n_defined; /* defined operator */ |
037313ae ZW |
241 | cpp_hashnode *n_true; /* C++ keyword true */ |
242 | cpp_hashnode *n_false; /* C++ keyword false */ | |
8121d2c3 NB |
243 | cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */ |
244 | }; | |
245 | ||
5d8ebbd8 | 246 | /* Represents the contents of a file cpplib has read in. */ |
27e2564a NB |
247 | struct cpp_buffer |
248 | { | |
249 | const unsigned char *cur; /* current position */ | |
480709cc | 250 | const unsigned char *backup_to; /* if peeked character is not wanted */ |
27e2564a NB |
251 | const unsigned char *rlimit; /* end of valid data */ |
252 | const unsigned char *line_base; /* start of current line */ | |
27e2564a | 253 | |
27e2564a NB |
254 | struct cpp_buffer *prev; |
255 | ||
644eddaa | 256 | const unsigned char *buf; /* Entire character buffer. */ |
27e2564a | 257 | |
29401c30 NB |
258 | /* Pointer into the include table; non-NULL if this is a file |
259 | buffer. Used for include_next and to record control macros. */ | |
27e2564a NB |
260 | struct include_file *inc; |
261 | ||
262 | /* Value of if_stack at start of this file. | |
263 | Used to prohibit unmatched #endif (etc) in an include file. */ | |
264 | struct if_stack *if_stack; | |
265 | ||
266 | /* Token column position adjustment owing to tabs in whitespace. */ | |
267 | unsigned int col_adjust; | |
268 | ||
bd969772 NB |
269 | /* Contains PREV_WHITE and/or AVOID_LPASTE. */ |
270 | unsigned char saved_flags; | |
271 | ||
27e2564a NB |
272 | /* Because of the way the lexer works, -Wtrigraphs can sometimes |
273 | warn twice for the same trigraph. This helps prevent that. */ | |
274 | const unsigned char *last_Wtrigraphs; | |
275 | ||
276 | /* True if we have already warned about C++ comments in this file. | |
277 | The warning happens only for C89 extended mode with -pedantic on, | |
278 | or for -Wtraditional, and only once per file (otherwise it would | |
279 | be far too noisy). */ | |
280 | unsigned char warned_cplusplus_comments; | |
281 | ||
282 | /* True if we don't process trigraphs and escaped newlines. True | |
283 | for preprocessed input, command line directives, and _Pragma | |
284 | buffers. */ | |
285 | unsigned char from_stage3; | |
286 | ||
ba133c96 NB |
287 | /* Nonzero means that the directory to start searching for "" |
288 | include files has been calculated and stored in "dir" below. */ | |
289 | unsigned char search_cached; | |
290 | ||
ef6e958a NB |
291 | /* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is |
292 | true, a CPP_EOF token is then returned. Otherwise, the next | |
293 | token from the enclosing buffer is returned. */ | |
294 | bool return_at_eof; | |
295 | ||
591e15a1 NB |
296 | /* The directory of the this buffer's file. Its NAME member is not |
297 | allocated, so we don't need to worry about freeing it. */ | |
298 | struct search_path dir; | |
004cb263 NB |
299 | |
300 | /* Used for buffer overlays by cpptrad.c. */ | |
301 | const uchar *saved_cur, *saved_rlimit, *saved_line_base; | |
27e2564a NB |
302 | }; |
303 | ||
8121d2c3 NB |
304 | /* A cpp_reader encapsulates the "state" of a pre-processor run. |
305 | Applying cpp_get_token repeatedly yields a stream of pre-processor | |
306 | tokens. Usually, there is only one cpp_reader object active. */ | |
8121d2c3 NB |
307 | struct cpp_reader |
308 | { | |
309 | /* Top of buffer stack. */ | |
310 | cpp_buffer *buffer; | |
311 | ||
312 | /* Lexer state. */ | |
313 | struct lexer_state state; | |
314 | ||
67821e3a | 315 | /* Source line tracking. */ |
d82fc108 | 316 | struct line_maps line_maps; |
47d89cf3 | 317 | const struct line_map *map; |
1444f2ed | 318 | unsigned int line; |
1444f2ed | 319 | |
50410426 | 320 | /* The line of the '#' of the current directive. */ |
8bbbef34 | 321 | unsigned int directive_line; |
8121d2c3 | 322 | |
b8af0ca5 | 323 | /* Memory buffers. */ |
8c3b2693 | 324 | _cpp_buff *a_buff; /* Aligned permanent storage. */ |
ece54d54 NB |
325 | _cpp_buff *u_buff; /* Unaligned permanent storage. */ |
326 | _cpp_buff *free_buffs; /* Free buffer chain. */ | |
b8af0ca5 | 327 | |
8121d2c3 NB |
328 | /* Context stack. */ |
329 | struct cpp_context base_context; | |
330 | struct cpp_context *context; | |
331 | ||
332 | /* If in_directive, the directive if known. */ | |
333 | const struct directive *directive; | |
334 | ||
af0d16cd NB |
335 | /* The next -include-d file; NULL if they all are done. If it |
336 | points to NULL, the last one is in progress, and | |
337 | _cpp_maybe_push_include_file has yet to restore the line map. */ | |
338 | struct pending_option **next_include_file; | |
339 | ||
8121d2c3 | 340 | /* Multiple inlcude optimisation. */ |
8121d2c3 NB |
341 | const cpp_hashnode *mi_cmacro; |
342 | const cpp_hashnode *mi_ind_cmacro; | |
6d18adbc | 343 | bool mi_valid; |
8121d2c3 | 344 | |
5fddcffc NB |
345 | /* Lexing. */ |
346 | cpp_token *cur_token; | |
347 | tokenrun base_run, *cur_run; | |
bdcbe496 | 348 | unsigned int lookaheads; |
5fddcffc NB |
349 | |
350 | /* Non-zero prevents the lexer from re-using the token runs. */ | |
351 | unsigned int keep_tokens; | |
352 | ||
8121d2c3 NB |
353 | /* Error counter for exit code. */ |
354 | unsigned int errors; | |
355 | ||
8121d2c3 NB |
356 | /* Buffer to hold macro definition string. */ |
357 | unsigned char *macro_buffer; | |
358 | unsigned int macro_buffer_len; | |
359 | ||
8121d2c3 NB |
360 | /* Tree of other included files. See cppfiles.c. */ |
361 | struct splay_tree_s *all_include_files; | |
362 | ||
8121d2c3 NB |
363 | /* Current maximum length of directory names in the search path |
364 | for include files. (Altered as we get more of them.) */ | |
365 | unsigned int max_include_len; | |
366 | ||
367 | /* Date and time tokens. Calculated together if either is requested. */ | |
368 | cpp_token date; | |
369 | cpp_token time; | |
370 | ||
4ed5bcfb NB |
371 | /* EOF token, and a token forcing paste avoidance. */ |
372 | cpp_token avoid_paste; | |
373 | cpp_token eof; | |
374 | ||
8121d2c3 NB |
375 | /* Opaque handle to the dependencies of mkdeps.c. Used by -M etc. */ |
376 | struct deps *deps; | |
377 | ||
378 | /* Obstack holding all macro hash nodes. This never shrinks. | |
379 | See cpphash.c */ | |
2a967f3d | 380 | struct obstack hash_ob; |
8121d2c3 NB |
381 | |
382 | /* Obstack holding buffer and conditional structures. This is a | |
2a967f3d NB |
383 | real stack. See cpplib.c. */ |
384 | struct obstack buffer_ob; | |
8121d2c3 NB |
385 | |
386 | /* Pragma table - dynamic, because a library user can add to the | |
387 | list of recognized pragmas. */ | |
388 | struct pragma_entry *pragmas; | |
389 | ||
390 | /* Call backs. */ | |
391 | struct cpp_callbacks cb; | |
392 | ||
df383483 | 393 | /* Identifier hash table. */ |
2a967f3d NB |
394 | struct ht *hash_table; |
395 | ||
87ed109f NB |
396 | /* Expression parser stack. */ |
397 | struct op *op_stack, *op_limit; | |
398 | ||
8121d2c3 NB |
399 | /* User visible options. */ |
400 | struct cpp_options opts; | |
401 | ||
402 | /* Special nodes - identifiers with predefined significance to the | |
403 | preprocessor. */ | |
404 | struct spec_nodes spec_nodes; | |
405 | ||
2a967f3d NB |
406 | /* Whether cpplib owns the hashtable. */ |
407 | unsigned char our_hashtable; | |
004cb263 NB |
408 | |
409 | /* Traditional preprocessing output buffer. */ | |
410 | uchar *trad_out_base, *trad_out_limit; | |
411 | uchar *trad_out_cur; | |
412 | unsigned int trad_line; | |
8121d2c3 NB |
413 | }; |
414 | ||
f6bbde28 | 415 | /* Character classes. Based on the more primitive macros in safe-ctype.h. |
88ae23e7 | 416 | If the definition of `numchar' looks odd to you, please look up the |
91fcd158 NB |
417 | definition of a pp-number in the C standard [section 6.4.8 of C99]. |
418 | ||
419 | In the unlikely event that characters other than \r and \n enter | |
420 | the set is_vspace, the macro handle_newline() in cpplex.c must be | |
421 | updated. */ | |
ae79697b | 422 | #define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident)) |
88ae23e7 | 423 | |
f6bbde28 ZW |
424 | #define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x)) |
425 | #define is_numchar(x) ISIDNUM(x) | |
426 | #define is_idstart(x) (ISIDST(x) || _dollar_ok(x)) | |
427 | #define is_numstart(x) ISDIGIT(x) | |
428 | #define is_hspace(x) ISBLANK(x) | |
429 | #define is_vspace(x) IS_VSPACE(x) | |
430 | #define is_nvspace(x) IS_NVSPACE(x) | |
431 | #define is_space(x) IS_SPACE_OR_NUL(x) | |
88ae23e7 | 432 | |
f6bbde28 | 433 | /* This table is constant if it can be initialized at compile time, |
88ae23e7 ZW |
434 | which is the case if cpp was compiled with GCC >=2.7, or another |
435 | compiler that supports C99. */ | |
61d0346d | 436 | #if HAVE_DESIGNATED_INITIALIZERS |
61d0346d | 437 | extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1]; |
88ae23e7 | 438 | #else |
61d0346d | 439 | extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1]; |
88ae23e7 ZW |
440 | #endif |
441 | ||
442 | /* Macros. */ | |
443 | ||
ae79697b | 444 | #define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps) |
bef985f3 | 445 | #define CPP_IN_SYSTEM_HEADER(PFILE) ((PFILE)->map && (PFILE)->map->sysp) |
28e0f040 NB |
446 | #define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic) |
447 | #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional) | |
88ae23e7 | 448 | |
58fea6af | 449 | /* In cpperror.c */ |
ebef4e8c | 450 | extern int _cpp_begin_message PARAMS ((cpp_reader *, int, |
97293897 | 451 | unsigned int, unsigned int)); |
58fea6af | 452 | |
711b8824 | 453 | /* In cppmacro.c */ |
f8f769ea | 454 | extern void _cpp_free_definition PARAMS ((cpp_hashnode *)); |
cbc69f84 | 455 | extern bool _cpp_create_definition PARAMS ((cpp_reader *, cpp_hashnode *)); |
93c80368 | 456 | extern void _cpp_pop_context PARAMS ((cpp_reader *)); |
cbc69f84 | 457 | extern void _cpp_push_text_context PARAMS ((cpp_reader *, cpp_hashnode *, |
1ce676a0 | 458 | const uchar *, size_t)); |
c70f6ed3 NB |
459 | extern bool _cpp_save_parameter PARAMS ((cpp_reader *, cpp_macro *, |
460 | cpp_hashnode *)); | |
1ce676a0 NB |
461 | extern bool _cpp_arguments_ok PARAMS ((cpp_reader *, cpp_macro *, |
462 | const cpp_hashnode *, | |
463 | unsigned int)); | |
711b8824 ZW |
464 | |
465 | /* In cpphash.c */ | |
2a967f3d NB |
466 | extern void _cpp_init_hashtable PARAMS ((cpp_reader *, hash_table *)); |
467 | extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *)); | |
bb52fa7f | 468 | |
88ae23e7 | 469 | /* In cppfiles.c */ |
d6d52dd6 | 470 | extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *)); |
642ce434 | 471 | extern void _cpp_never_reread PARAMS ((struct include_file *)); |
e7182666 | 472 | extern char *_cpp_simplify_pathname PARAMS ((char *)); |
e5eba70a NB |
473 | extern bool _cpp_read_file PARAMS ((cpp_reader *, const char *)); |
474 | extern bool _cpp_execute_include PARAMS ((cpp_reader *, | |
ba133c96 NB |
475 | const cpp_token *, |
476 | enum include_type)); | |
93c80368 NB |
477 | extern int _cpp_compare_file_date PARAMS ((cpp_reader *, |
478 | const cpp_token *)); | |
c71f835b ZW |
479 | extern void _cpp_report_missing_guards PARAMS ((cpp_reader *)); |
480 | extern void _cpp_init_includes PARAMS ((cpp_reader *)); | |
481 | extern void _cpp_cleanup_includes PARAMS ((cpp_reader *)); | |
af0d16cd | 482 | extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *, |
29401c30 | 483 | struct include_file *)); |
88ae23e7 ZW |
484 | |
485 | /* In cppexp.c */ | |
87ed109f NB |
486 | extern bool _cpp_parse_expr PARAMS ((cpp_reader *)); |
487 | extern struct op *_cpp_expand_op_stack PARAMS ((cpp_reader *)); | |
88ae23e7 | 488 | |
45b966db | 489 | /* In cpplex.c */ |
4ed5bcfb | 490 | extern cpp_token *_cpp_temp_token PARAMS ((cpp_reader *)); |
345894b4 | 491 | extern const cpp_token *_cpp_lex_token PARAMS ((cpp_reader *)); |
14baae01 | 492 | extern cpp_token *_cpp_lex_direct PARAMS ((cpp_reader *)); |
15dad1d9 ZW |
493 | extern int _cpp_equiv_tokens PARAMS ((const cpp_token *, |
494 | const cpp_token *)); | |
5fddcffc | 495 | extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int)); |
45b966db | 496 | |
d7bc7a98 | 497 | /* In cppinit.c. */ |
af0d16cd | 498 | extern void _cpp_maybe_push_include_file PARAMS ((cpp_reader *)); |
d7bc7a98 | 499 | |
45b966db | 500 | /* In cpplib.c */ |
60284a59 | 501 | extern int _cpp_test_assertion PARAMS ((cpp_reader *, unsigned int *)); |
93c80368 NB |
502 | extern int _cpp_handle_directive PARAMS ((cpp_reader *, int)); |
503 | extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *)); | |
a5c3cccd | 504 | extern void _cpp_do__Pragma PARAMS ((cpp_reader *)); |
2a967f3d | 505 | extern void _cpp_init_directives PARAMS ((cpp_reader *)); |
58fea6af | 506 | extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *)); |
67821e3a | 507 | extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason, |
47d89cf3 NB |
508 | const char *, |
509 | unsigned int, unsigned int)); | |
ef6e958a | 510 | extern void _cpp_pop_buffer PARAMS ((cpp_reader *)); |
12cf91fe | 511 | |
004cb263 | 512 | /* In cpptrad.c. */ |
afb03408 | 513 | extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *, int)); |
004cb263 NB |
514 | extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *, |
515 | size_t)); | |
cbc69f84 NB |
516 | extern cpp_hashnode *_cpp_lex_identifier_trad PARAMS ((cpp_reader *)); |
517 | extern void _cpp_set_trad_context PARAMS ((cpp_reader *)); | |
c70f6ed3 | 518 | extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *)); |
afb03408 NB |
519 | extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *, |
520 | const cpp_macro *)); | |
004cb263 | 521 | |
c31a6508 | 522 | /* Utility routines and macros. */ |
562a5c27 | 523 | #define DSC(str) (const uchar *)str, sizeof str - 1 |
c31a6508 | 524 | #define xnew(T) (T *) xmalloc (sizeof(T)) |
a58d32c2 | 525 | #define xcnew(T) (T *) xcalloc (1, sizeof(T)) |
c31a6508 | 526 | #define xnewvec(T, N) (T *) xmalloc (sizeof(T) * (N)) |
711b8824 | 527 | #define xcnewvec(T, N) (T *) xcalloc (N, sizeof(T)) |
c71f835b | 528 | #define xobnew(O, T) (T *) obstack_alloc (O, sizeof(T)) |
c31a6508 | 529 | |
8121d2c3 NB |
530 | /* These are inline functions instead of macros so we can get type |
531 | checking. */ | |
562a5c27 NB |
532 | static inline int ustrcmp PARAMS ((const uchar *, const uchar *)); |
533 | static inline int ustrncmp PARAMS ((const uchar *, const uchar *, | |
8121d2c3 | 534 | size_t)); |
562a5c27 NB |
535 | static inline size_t ustrlen PARAMS ((const uchar *)); |
536 | static inline uchar *uxstrdup PARAMS ((const uchar *)); | |
537 | static inline uchar *ustrchr PARAMS ((const uchar *, int)); | |
538 | static inline int ufputs PARAMS ((const uchar *, FILE *)); | |
8121d2c3 NB |
539 | |
540 | static inline int | |
541 | ustrcmp (s1, s2) | |
562a5c27 | 542 | const uchar *s1, *s2; |
8121d2c3 NB |
543 | { |
544 | return strcmp ((const char *)s1, (const char *)s2); | |
545 | } | |
546 | ||
547 | static inline int | |
548 | ustrncmp (s1, s2, n) | |
562a5c27 | 549 | const uchar *s1, *s2; |
8121d2c3 NB |
550 | size_t n; |
551 | { | |
552 | return strncmp ((const char *)s1, (const char *)s2, n); | |
553 | } | |
554 | ||
555 | static inline size_t | |
556 | ustrlen (s1) | |
562a5c27 | 557 | const uchar *s1; |
8121d2c3 NB |
558 | { |
559 | return strlen ((const char *)s1); | |
560 | } | |
561 | ||
562a5c27 | 562 | static inline uchar * |
8121d2c3 | 563 | uxstrdup (s1) |
562a5c27 | 564 | const uchar *s1; |
8121d2c3 | 565 | { |
562a5c27 | 566 | return (uchar *) xstrdup ((const char *)s1); |
8121d2c3 NB |
567 | } |
568 | ||
562a5c27 | 569 | static inline uchar * |
8121d2c3 | 570 | ustrchr (s1, c) |
562a5c27 | 571 | const uchar *s1; |
8121d2c3 NB |
572 | int c; |
573 | { | |
562a5c27 | 574 | return (uchar *) strchr ((const char *)s1, c); |
8121d2c3 NB |
575 | } |
576 | ||
577 | static inline int | |
578 | ufputs (s, f) | |
562a5c27 | 579 | const uchar *s; |
8121d2c3 NB |
580 | FILE *f; |
581 | { | |
582 | return fputs ((const char *)s, f); | |
583 | } | |
584 | ||
88657302 | 585 | #endif /* ! GCC_CPPHASH_H */ |