#ifndef GCC_CPPHASH_H
#define GCC_CPPHASH_H
#include "hashtable.h"
struct directive;
#define VALID_SIGN(c, prevc) \
(((c) == '+' || (c) == '-') && \
((prevc) == 'e' || (prevc) == 'E' \
|| (((prevc) == 'p' || (prevc) == 'P') \
&& CPP_OPTION (pfile, extended_numbers))))
#define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
#define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + (BUF)->col_adjust)
#define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur)
#define CPP_STACK_MAX 200
typedef struct _cpp_buff _cpp_buff;
struct _cpp_buff
{
struct _cpp_buff *next;
unsigned char *base, *cur, *limit;
};
extern _cpp_buff *_cpp_get_buff PARAMS ((cpp_reader *, size_t));
extern void _cpp_release_buff PARAMS ((cpp_reader *, _cpp_buff *));
extern void _cpp_extend_buff PARAMS ((cpp_reader *, _cpp_buff **, size_t));
extern _cpp_buff *_cpp_append_extend_buff PARAMS ((cpp_reader *, _cpp_buff *,
size_t));
extern void _cpp_free_buff PARAMS ((_cpp_buff *));
extern unsigned char *_cpp_aligned_alloc PARAMS ((cpp_reader *, size_t));
extern unsigned char *_cpp_unaligned_alloc PARAMS ((cpp_reader *, size_t));
#define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur)
#define BUFF_FRONT(BUFF) ((BUFF)->cur)
#define BUFF_LIMIT(BUFF) ((BUFF)->limit)
struct search_path
{
struct search_path *next;
const char *name;
unsigned int len;
ino_t ino;
dev_t dev;
int sysp;
struct file_name_map *name_map;
};
enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE};
union utoken
{
const cpp_token *token;
const cpp_token **ptoken;
};
typedef struct tokenrun tokenrun;
struct tokenrun
{
tokenrun *next, *prev;
cpp_token *base, *limit;
};
typedef struct cpp_context cpp_context;
struct cpp_context
{
cpp_context *next, *prev;
union utoken first;
union utoken last;
_cpp_buff *buff;
cpp_hashnode *macro;
bool direct_p;
};
struct lexer_state
{
unsigned char in_directive;
unsigned char skipping;
unsigned char angled_headers;
unsigned char save_comments;
unsigned char lexing_comment;
unsigned char va_args_ok;
unsigned char poisoned_ok;
unsigned char prevent_expansion;
unsigned char parsing_args;
};
struct spec_nodes
{
cpp_hashnode *n_defined;
cpp_hashnode *n_true;
cpp_hashnode *n_false;
cpp_hashnode *n__STRICT_ANSI__;
cpp_hashnode *n__VA_ARGS__;
};
struct cpp_buffer
{
const unsigned char *cur;
const unsigned char *backup_to;
const unsigned char *rlimit;
const unsigned char *line_base;
struct cpp_buffer *prev;
const unsigned char *buf;
struct include_file *inc;
struct if_stack *if_stack;
unsigned int col_adjust;
unsigned char saved_flags;
const unsigned char *last_Wtrigraphs;
unsigned char warned_cplusplus_comments;
unsigned char from_stage3;
unsigned char search_cached;
bool return_at_eof;
struct search_path dir;
};
struct cpp_reader
{
cpp_buffer *buffer;
struct lexer_state state;
struct line_maps line_maps;
const struct line_map *map;
unsigned int line;
unsigned int directive_line;
_cpp_buff *a_buff;
_cpp_buff *u_buff;
_cpp_buff *free_buffs;
struct cpp_context base_context;
struct cpp_context *context;
const struct directive *directive;
const cpp_hashnode *mi_cmacro;
const cpp_hashnode *mi_ind_cmacro;
bool mi_valid;
cpp_token *cur_token;
tokenrun base_run, *cur_run;
unsigned int lookaheads;
unsigned int keep_tokens;
unsigned int errors;
unsigned int mls_line;
unsigned int mls_col;
unsigned char *macro_buffer;
unsigned int macro_buffer_len;
struct splay_tree_s *all_include_files;
unsigned int max_include_len;
cpp_token date;
cpp_token time;
cpp_token avoid_paste;
cpp_token eof;
struct deps *deps;
struct obstack hash_ob;
struct obstack buffer_ob;
struct pragma_entry *pragmas;
struct cpp_callbacks cb;
struct ht *hash_table;
struct cpp_options opts;
struct spec_nodes spec_nodes;
unsigned char print_version;
unsigned char our_hashtable;
};
#define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
#define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x))
#define is_numchar(x) ISIDNUM(x)
#define is_idstart(x) (ISIDST(x) || _dollar_ok(x))
#define is_numstart(x) ISDIGIT(x)
#define is_hspace(x) ISBLANK(x)
#define is_vspace(x) IS_VSPACE(x)
#define is_nvspace(x) IS_NVSPACE(x)
#define is_space(x) IS_SPACE_OR_NUL(x)
#if HAVE_DESIGNATED_INITIALIZERS
extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
#else
extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
#endif
#define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps)
#define CPP_IN_SYSTEM_HEADER(PFILE) ((PFILE)->map && (PFILE)->map->sysp)
#define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic)
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
enum error_type { WARNING = 0, WARNING_SYSHDR, PEDWARN, ERROR, FATAL, ICE };
extern int _cpp_begin_message PARAMS ((cpp_reader *, enum error_type,
unsigned int, unsigned int));
extern void _cpp_free_definition PARAMS ((cpp_hashnode *));
extern int _cpp_create_definition PARAMS ((cpp_reader *, cpp_hashnode *));
extern void _cpp_pop_context PARAMS ((cpp_reader *));
extern void _cpp_init_hashtable PARAMS ((cpp_reader *, hash_table *));
extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *));
extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *));
extern void _cpp_never_reread PARAMS ((struct include_file *));
extern char *_cpp_simplify_pathname PARAMS ((char *));
extern bool _cpp_read_file PARAMS ((cpp_reader *, const char *));
extern bool _cpp_execute_include PARAMS ((cpp_reader *,
const cpp_token *,
enum include_type));
extern int _cpp_compare_file_date PARAMS ((cpp_reader *,
const cpp_token *));
extern void _cpp_report_missing_guards PARAMS ((cpp_reader *));
extern void _cpp_init_includes PARAMS ((cpp_reader *));
extern void _cpp_cleanup_includes PARAMS ((cpp_reader *));
extern bool _cpp_pop_file_buffer PARAMS ((cpp_reader *,
struct include_file *));
extern int _cpp_parse_expr PARAMS ((cpp_reader *));
extern cpp_token *_cpp_temp_token PARAMS ((cpp_reader *));
extern const cpp_token *_cpp_lex_token PARAMS ((cpp_reader *));
extern cpp_token *_cpp_lex_direct PARAMS ((cpp_reader *));
extern int _cpp_equiv_tokens PARAMS ((const cpp_token *,
const cpp_token *));
extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int));
extern bool _cpp_push_next_buffer PARAMS ((cpp_reader *));
extern int _cpp_test_assertion PARAMS ((cpp_reader *, int *));
extern int _cpp_handle_directive PARAMS ((cpp_reader *, int));
extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *));
extern void _cpp_do__Pragma PARAMS ((cpp_reader *));
extern void _cpp_init_directives PARAMS ((cpp_reader *));
extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *));
extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason,
const char *,
unsigned int, unsigned int));
extern void _cpp_pop_buffer PARAMS ((cpp_reader *));
#define DSC(str) (const U_CHAR *)str, sizeof str - 1
#define xnew(T) (T *) xmalloc (sizeof(T))
#define xcnew(T) (T *) xcalloc (1, sizeof(T))
#define xnewvec(T, N) (T *) xmalloc (sizeof(T) * (N))
#define xcnewvec(T, N) (T *) xcalloc (N, sizeof(T))
#define xobnew(O, T) (T *) obstack_alloc (O, sizeof(T))
typedef unsigned char U_CHAR;
#define U (const U_CHAR *)
static inline int ustrcmp PARAMS ((const U_CHAR *, const U_CHAR *));
static inline int ustrncmp PARAMS ((const U_CHAR *, const U_CHAR *,
size_t));
static inline size_t ustrlen PARAMS ((const U_CHAR *));
static inline U_CHAR *uxstrdup PARAMS ((const U_CHAR *));
static inline U_CHAR *ustrchr PARAMS ((const U_CHAR *, int));
static inline int ufputs PARAMS ((const U_CHAR *, FILE *));
static inline int
ustrcmp (s1, s2)
const U_CHAR *s1, *s2;
{
return strcmp ((const char *)s1, (const char *)s2);
}
static inline int
ustrncmp (s1, s2, n)
const U_CHAR *s1, *s2;
size_t n;
{
return strncmp ((const char *)s1, (const char *)s2, n);
}
static inline size_t
ustrlen (s1)
const U_CHAR *s1;
{
return strlen ((const char *)s1);
}
static inline U_CHAR *
uxstrdup (s1)
const U_CHAR *s1;
{
return (U_CHAR *) xstrdup ((const char *)s1);
}
static inline U_CHAR *
ustrchr (s1, c)
const U_CHAR *s1;
int c;
{
return (U_CHAR *) strchr ((const char *)s1, c);
}
static inline int
ufputs (s, f)
const U_CHAR *s;
FILE *f;
{
return fputs ((const char *)s, f);
}
#endif