#ifndef GCC_CPPHASH_H
#define GCC_CPPHASH_H
#include "hashtable.h"
#include "cpp-id-data.h"
struct directive;
struct pending_option;
struct op;
#define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t))
#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
struct dummy
{
char c;
union
{
double d;
int *p;
} u;
};
#define DEFAULT_ALIGNMENT offsetof (struct dummy, u)
#define CPP_ALIGN2(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
#define CPP_ALIGN(size) CPP_ALIGN2 (size, DEFAULT_ALIGNMENT)
#define _cpp_mark_macro_used(NODE) do { \
if ((NODE)->type == NT_MACRO && !((NODE)->flags & NODE_BUILTIN)) \
(NODE)->value.macro->used = 1; } while (0)
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_PCH, 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;
};
#define FIRST(c) ((c)->u.iso.first)
#define LAST(c) ((c)->u.iso.last)
#define CUR(c) ((c)->u.trad.cur)
#define RLIMIT(c) ((c)->u.trad.rlimit)
typedef struct cpp_context cpp_context;
struct cpp_context
{
cpp_context *next, *prev;
union
{
struct
{
union utoken first;
union utoken last;
} iso;
struct
{
const uchar *cur;
const uchar *rlimit;
} trad;
} u;
_cpp_buff *buff;
cpp_hashnode *macro;
bool direct_p;
bool bol_p;
};
struct lexer_state
{
unsigned char in_directive;
unsigned char directive_wants_padding;
unsigned char skipping;
unsigned char angled_headers;
unsigned char in_expression;
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;
unsigned int skip_eval;
};
struct spec_nodes
{
cpp_hashnode *n_defined;
cpp_hashnode *n_true;
cpp_hashnode *n_false;
cpp_hashnode *n__VA_ARGS__;
};
struct printer
{
FILE *outf;
const struct line_map *map;
const cpp_token *prev;
const cpp_token *source;
unsigned int line;
unsigned char printed;
};
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;
const uchar *saved_cur, *saved_rlimit;
};
enum cpp_cinfo_state
{
CINFO_NONE,
CINFO_FOUND,
CINFO_VALID,
CINFO_READ,
CINFO_WRITE
};
struct cpp_reader
{
cpp_buffer *buffer;
cpp_buffer *overlaid_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;
struct pending_option **next_include_file;
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 char *macro_buffer;
unsigned int macro_buffer_len;
struct splay_tree_s *all_include_files;
unsigned int max_include_len;
unsigned int first_unused_line;
const uchar *date;
const uchar *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 op *op_stack, *op_limit;
struct cpp_options opts;
struct spec_nodes spec_nodes;
struct printer print;
unsigned char our_hashtable;
struct
{
uchar *base;
uchar *limit;
uchar *cur;
unsigned int first_line;
} out;
unsigned int saved_line;
struct cpp_savedstate *savedstate;
const char *cinfo_candidate_file;
const char *cinfo_src_file;
enum cpp_cinfo_state cinfo_state;
};
#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_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)
extern int _cpp_begin_message PARAMS ((cpp_reader *, int,
unsigned int, unsigned int));
extern void _cpp_free_definition PARAMS ((cpp_hashnode *));
extern bool _cpp_create_definition PARAMS ((cpp_reader *, cpp_hashnode *));
extern void _cpp_pop_context PARAMS ((cpp_reader *));
extern void _cpp_push_text_context PARAMS ((cpp_reader *, cpp_hashnode *,
const uchar *, size_t));
extern bool _cpp_save_parameter PARAMS ((cpp_reader *, cpp_macro *,
cpp_hashnode *));
extern bool _cpp_arguments_ok PARAMS ((cpp_reader *, cpp_macro *,
const cpp_hashnode *,
unsigned int));
extern const uchar *_cpp_builtin_macro_text PARAMS ((cpp_reader *,
cpp_hashnode *));
int _cpp_warn_if_unused_macro PARAMS ((cpp_reader *, cpp_hashnode *,
void *));
extern void _cpp_init_hashtable PARAMS ((cpp_reader *, hash_table *));
extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *));
extern int _cpp_save_file_entries PARAMS ((cpp_reader *, FILE *));
extern int _cpp_read_file_entries PARAMS ((cpp_reader *, FILE *));
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 void _cpp_pop_file_buffer PARAMS ((cpp_reader *,
struct include_file *));
extern int suppress_dbg_info PARAMS ((struct include_file *));
void find_include_cinfo PARAMS ((cpp_reader *, const char *));
extern bool _cpp_parse_expr PARAMS ((cpp_reader *));
extern struct op *_cpp_expand_op_stack 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 void _cpp_maybe_push_include_file PARAMS ((cpp_reader *));
extern int _cpp_test_assertion PARAMS ((cpp_reader *, unsigned int *));
extern int _cpp_handle_directive PARAMS ((cpp_reader *, int));
extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *));
extern char ** _cpp_save_pragma_names PARAMS ((cpp_reader *));
extern void _cpp_restore_pragma_names PARAMS ((cpp_reader *, 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 *));
extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *,
size_t));
extern void _cpp_remove_overlay PARAMS ((cpp_reader *));
extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *));
extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *,
const cpp_macro *));
extern uchar *_cpp_copy_replacement_text PARAMS ((const cpp_macro *, uchar *));
extern size_t _cpp_replacement_text_len PARAMS ((const cpp_macro *));
#define DSC(str) (const uchar *)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))
static inline int ustrcmp PARAMS ((const uchar *, const uchar *));
static inline int ustrncmp PARAMS ((const uchar *, const uchar *,
size_t));
static inline size_t ustrlen PARAMS ((const uchar *));
static inline uchar *uxstrdup PARAMS ((const uchar *));
static inline uchar *ustrchr PARAMS ((const uchar *, int));
static inline int ufputs PARAMS ((const uchar *, FILE *));
static inline int
ustrcmp (s1, s2)
const uchar *s1, *s2;
{
return strcmp ((const char *)s1, (const char *)s2);
}
static inline int
ustrncmp (s1, s2, n)
const uchar *s1, *s2;
size_t n;
{
return strncmp ((const char *)s1, (const char *)s2, n);
}
static inline size_t
ustrlen (s1)
const uchar *s1;
{
return strlen ((const char *)s1);
}
static inline uchar *
uxstrdup (s1)
const uchar *s1;
{
return (uchar *) xstrdup ((const char *)s1);
}
static inline uchar *
ustrchr (s1, c)
const uchar *s1;
int c;
{
return (uchar *) strchr ((const char *)s1, c);
}
static inline int
ufputs (s, f)
const uchar *s;
FILE *f;
{
return fputs ((const char *)s, f);
}
#endif