]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cpphash.h
cvsignore: Add info files.
[thirdparty/gcc.git] / gcc / cpphash.h
CommitLineData
88ae23e7
ZW
1/* Part of CPP library.
2 Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4283012f
JL
3
4This program is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the
6Free Software Foundation; either version 2, or (at your option) any
7later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
42b17236 16Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
4283012f 17
88ae23e7
ZW
18/* This header defines all the internal data structures and functions
19 that need to be visible across files. It's called cpphash.h for
20 historical reasons. */
21
bb52fa7f
ZW
22#ifndef __GCC_CPPHASH__
23#define __GCC_CPPHASH__
24
93c80368
NB
25/* Test if a sign is valid within a preprocessing number. */
26#define VALID_SIGN(c, prevc) \
27 (((c) == '+' || (c) == '-') && \
28 ((prevc) == 'e' || (prevc) == 'E' \
bdb05a7b
NB
29 || (((prevc) == 'p' || (prevc) == 'P') \
30 && CPP_OPTION (pfile, extended_numbers))))
93c80368
NB
31
32/* Memory pools. */
33#define ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
34#define POOL_FRONT(p) ((p)->cur->front)
35#define POOL_LIMIT(p) ((p)->cur->limit)
36#define POOL_BASE(p) ((p)->cur->base)
37#define POOL_SIZE(p) ((p)->cur->limit - (p)->cur->base)
38#define POOL_ROOM(p) ((p)->cur->limit - (p)->cur->front)
39#define POOL_USED(p) ((p)->cur->front - (p)->cur->base)
40#define POOL_COMMIT(p, len) do {((p)->cur->front += ALIGN (len, (p)->align));\
41 if ((p)->cur->front > (p)->cur->limit) abort ();} while (0)
42
43typedef struct cpp_chunk cpp_chunk;
44struct cpp_chunk
15dad1d9 45{
93c80368
NB
46 cpp_chunk *next;
47 unsigned char *front;
48 unsigned char *limit;
49 unsigned char *base;
15dad1d9
ZW
50};
51
88ae23e7
ZW
52/* List of directories to look for include files in. */
53struct file_name_list
54{
55 struct file_name_list *next;
56 struct file_name_list *alloc; /* for the cache of
57 current directory entries */
58 char *name;
59 unsigned int nlen;
60 /* We use these to tell if the directory mentioned here is a duplicate
61 of an earlier directory on the search path. */
62 ino_t ino;
63 dev_t dev;
64 /* If the following is nonzero, it is a C-language system include
65 directory. */
66 int sysp;
67 /* Mapping of file names for this directory.
68 Only used on MS-DOS and related platforms. */
69 struct file_name_map *name_map;
70};
71#define ABSOLUTE_PATH ((struct file_name_list *)-1)
72
a58d32c2
ZW
73/* The cmacro works like this: If it's NULL, the file is to be
74 included again. If it's NEVER_REREAD, the file is never to be
75 included again. Otherwise it is a macro hashnode, and the file is
93c80368
NB
76 to be included again if the macro is defined or not as specified by
77 DEFINED. */
a58d32c2
ZW
78#define NEVER_REREAD ((const cpp_hashnode *)-1)
79#define DO_NOT_REREAD(inc) \
93c80368
NB
80((inc)->cmacro && ((inc)->cmacro == NEVER_REREAD \
81 || ((inc)->cmacro->type == NT_MACRO) == (inc)->defined))
bfb9dc7f 82
27e2564a
NB
83struct cpp_buffer
84{
85 const unsigned char *cur; /* current position */
86 const unsigned char *rlimit; /* end of valid data */
87 const unsigned char *line_base; /* start of current line */
88 cppchar_t read_ahead; /* read ahead character */
89 cppchar_t extra_char; /* extra read-ahead for long tokens. */
90
91 struct cpp_reader *pfile; /* Owns this buffer. */
92 struct cpp_buffer *prev;
93
94 const unsigned char *buf; /* entire buffer */
95
96 /* Filename specified with #line command. */
97 const char *nominal_fname;
98
99 /* Actual directory of this file, used only for "" includes */
100 struct file_name_list *actual_dir;
101
102 /* Pointer into the include table. Used for include_next and
103 to record control macros. */
104 struct include_file *inc;
105
106 /* Value of if_stack at start of this file.
107 Used to prohibit unmatched #endif (etc) in an include file. */
108 struct if_stack *if_stack;
109
110 /* Token column position adjustment owing to tabs in whitespace. */
111 unsigned int col_adjust;
112
113 /* Line number at line_base (above). */
114 unsigned int lineno;
115
116 /* Because of the way the lexer works, -Wtrigraphs can sometimes
117 warn twice for the same trigraph. This helps prevent that. */
118 const unsigned char *last_Wtrigraphs;
119
120 /* True if we have already warned about C++ comments in this file.
121 The warning happens only for C89 extended mode with -pedantic on,
122 or for -Wtraditional, and only once per file (otherwise it would
123 be far too noisy). */
124 unsigned char warned_cplusplus_comments;
125
126 /* True if we don't process trigraphs and escaped newlines. True
127 for preprocessed input, command line directives, and _Pragma
128 buffers. */
129 unsigned char from_stage3;
130
131 /* Temporary storage for pfile->skipping whilst in a directive. */
132 unsigned char was_skipping;
642ce434
NB
133
134 /* 1 = system header file, 2 = C system header file used for C++. */
135 unsigned char sysp;
27e2564a
NB
136};
137
f6bbde28 138/* Character classes. Based on the more primitive macros in safe-ctype.h.
88ae23e7 139 If the definition of `numchar' looks odd to you, please look up the
91fcd158
NB
140 definition of a pp-number in the C standard [section 6.4.8 of C99].
141
142 In the unlikely event that characters other than \r and \n enter
143 the set is_vspace, the macro handle_newline() in cpplex.c must be
144 updated. */
ae79697b 145#define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
88ae23e7 146
f6bbde28
ZW
147#define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x))
148#define is_numchar(x) ISIDNUM(x)
149#define is_idstart(x) (ISIDST(x) || _dollar_ok(x))
150#define is_numstart(x) ISDIGIT(x)
151#define is_hspace(x) ISBLANK(x)
152#define is_vspace(x) IS_VSPACE(x)
153#define is_nvspace(x) IS_NVSPACE(x)
154#define is_space(x) IS_SPACE_OR_NUL(x)
88ae23e7 155
f6bbde28 156/* This table is constant if it can be initialized at compile time,
88ae23e7
ZW
157 which is the case if cpp was compiled with GCC >=2.7, or another
158 compiler that supports C99. */
61d0346d 159#if HAVE_DESIGNATED_INITIALIZERS
61d0346d 160extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
88ae23e7 161#else
61d0346d 162extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
88ae23e7
ZW
163#endif
164
165/* Macros. */
166
88ae23e7 167#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
ae79697b 168#define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps)
bfb9dc7f 169#define CPP_IN_SYSTEM_HEADER(PFILE) \
642ce434 170 (CPP_BUFFER (PFILE) && CPP_BUFFER (PFILE)->sysp)
c31a6508 171#define CPP_PEDANTIC(PF) \
317639a8 172 CPP_OPTION (PF, pedantic)
07aa0b04 173#define CPP_WTRADITIONAL(PF) \
317639a8 174 CPP_OPTION (PF, warn_traditional)
88ae23e7 175
711b8824
ZW
176/* Hash step. The hash calculation is duplicated in cpp_lookup and
177 parse_name. */
0d9f234d 178#define HASHSTEP(r, c) ((r) * 67 + (c - 113));
711b8824 179
58fea6af
ZW
180/* In cpperror.c */
181enum error_type { WARNING = 0, PEDWARN, ERROR, FATAL, ICE };
182extern int _cpp_begin_message PARAMS ((cpp_reader *, enum error_type,
93c80368 183 const char *, const cpp_lexer_pos *));
58fea6af 184
711b8824 185/* In cppmacro.c */
f8f769ea 186extern void _cpp_free_definition PARAMS ((cpp_hashnode *));
041c3194 187extern int _cpp_create_definition PARAMS ((cpp_reader *, cpp_hashnode *));
93c80368 188extern void _cpp_pop_context PARAMS ((cpp_reader *));
93c80368 189extern void _cpp_free_lookaheads PARAMS ((cpp_reader *));
b528a07e 190extern void _cpp_release_lookahead PARAMS ((cpp_reader *));
93c80368
NB
191extern void _cpp_push_token PARAMS ((cpp_reader *, const cpp_token *,
192 const cpp_lexer_pos *));
711b8824
ZW
193
194/* In cpphash.c */
93c80368
NB
195extern void _cpp_init_hashtable PARAMS ((cpp_reader *));
196extern void _cpp_cleanup_hashtable PARAMS ((cpp_reader *));
197extern cpp_hashnode *_cpp_lookup_with_hash PARAMS ((cpp_reader*, size_t,
198 unsigned int));
bb52fa7f 199
88ae23e7 200/* In cppfiles.c */
642ce434 201extern void _cpp_never_reread PARAMS ((struct include_file *));
88ae23e7 202extern void _cpp_simplify_pathname PARAMS ((char *));
614c7d37 203extern int _cpp_read_file PARAMS ((cpp_reader *, const char *));
93c80368 204extern void _cpp_execute_include PARAMS ((cpp_reader *,
642ce434 205 const cpp_token *, int, int));
93c80368
NB
206extern int _cpp_compare_file_date PARAMS ((cpp_reader *,
207 const cpp_token *));
c71f835b
ZW
208extern void _cpp_report_missing_guards PARAMS ((cpp_reader *));
209extern void _cpp_init_includes PARAMS ((cpp_reader *));
210extern void _cpp_cleanup_includes PARAMS ((cpp_reader *));
f9a0e96c 211extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *, cpp_buffer *));
88ae23e7
ZW
212
213/* In cppexp.c */
214extern int _cpp_parse_expr PARAMS ((cpp_reader *));
215
45b966db 216/* In cpplex.c */
93c80368 217extern void _cpp_lex_token PARAMS ((cpp_reader *, cpp_token *));
15dad1d9
ZW
218extern int _cpp_equiv_tokens PARAMS ((const cpp_token *,
219 const cpp_token *));
93c80368
NB
220extern void _cpp_init_pool PARAMS ((cpp_pool *, unsigned int,
221 unsigned int, unsigned int));
222extern void _cpp_free_pool PARAMS ((cpp_pool *));
223extern unsigned char *_cpp_pool_reserve PARAMS ((cpp_pool *, unsigned int));
224extern unsigned char *_cpp_pool_alloc PARAMS ((cpp_pool *, unsigned int));
225extern unsigned char *_cpp_next_chunk PARAMS ((cpp_pool *, unsigned int,
226 unsigned char **));
227extern void _cpp_lock_pool PARAMS ((cpp_pool *));
228extern void _cpp_unlock_pool PARAMS ((cpp_pool *));
45b966db
ZW
229
230/* In cpplib.c */
93c80368
NB
231extern int _cpp_test_assertion PARAMS ((cpp_reader *, int *));
232extern int _cpp_handle_directive PARAMS ((cpp_reader *, int));
233extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *));
a5c3cccd 234extern void _cpp_do__Pragma PARAMS ((cpp_reader *));
c71f835b
ZW
235extern void _cpp_init_stacks PARAMS ((cpp_reader *));
236extern void _cpp_cleanup_stacks PARAMS ((cpp_reader *));
58fea6af 237extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *));
27e2564a
NB
238extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum cpp_fc_reason,
239 const char *, unsigned int));
12cf91fe 240
c31a6508 241/* Utility routines and macros. */
93c80368 242#define DSC(str) (const U_CHAR *)str, sizeof str - 1
c31a6508 243#define xnew(T) (T *) xmalloc (sizeof(T))
a58d32c2 244#define xcnew(T) (T *) xcalloc (1, sizeof(T))
c31a6508 245#define xnewvec(T, N) (T *) xmalloc (sizeof(T) * (N))
711b8824 246#define xcnewvec(T, N) (T *) xcalloc (N, sizeof(T))
c71f835b 247#define xobnew(O, T) (T *) obstack_alloc (O, sizeof(T))
c31a6508 248
bb52fa7f 249#endif