aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-05-28 05:56:38 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-05-28 05:56:38 +0000
commitf8f769ea4e694c516b9631ae8f2215cc6d5fb96f (patch)
tree2f5db92bd0f352a3b3a9f86ac6b719d86650e290 /gcc/cpplib.h
parente79f71f73dd44748c28d7f94b29d293722345e26 (diff)
downloadgcc-f8f769ea4e694c516b9631ae8f2215cc6d5fb96f.zip
gcc-f8f769ea4e694c516b9631ae8f2215cc6d5fb96f.tar.gz
gcc-f8f769ea4e694c516b9631ae8f2215cc6d5fb96f.tar.bz2
cppfiles.c: Read files in, using mmap if possible, then prescan them separately.
* cppfiles.c: Read files in, using mmap if possible, then prescan them separately. (read_file, read_with_read): New functions. * cpplex.c: Don't define UCHAR_MAX. (_cpp_read_and_prescan): Rename to _cpp_prescan. Don't read the file here. * cppinit.c (handle_option): Automatically define __cplusplus, __OBJC__, __ASEEMBLER__, _LANGUAGE_FORTRAN here when we see the respective -lang switch. * cpphash.h (enum node_type, struct hashnode, _cpp_lookup prototype): Move to... * cpplib.h: ... here. Rename struct hashnode to struct cpp_hashnode and give it a typedef. Rename _cpp_lookup to cpp_lookup. Add 'fe_value' slot, a union tree_node *. From-SVN: r34228
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r--gcc/cpplib.h60
1 files changed, 59 insertions, 1 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 68059cc..0ac5c27 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -35,6 +35,7 @@ typedef struct cpp_printer cpp_printer;
typedef struct cpp_token cpp_token;
typedef struct cpp_toklist cpp_toklist;
typedef struct cpp_name cpp_name;
+typedef struct cpp_hashnode cpp_hashnode;
/* The first two groups, apart from '=', can appear in preprocessor
expressions. This allows a lookup table to be implemented in
@@ -238,7 +239,7 @@ struct cpp_buffer
/* If the buffer is the expansion of a macro, this points to the
macro's hash table entry. */
- struct hashnode *macro;
+ struct cpp_hashnode *macro;
/* Value of if_stack at start of this file.
Used to prohibit unmatched #endif (etc) in an include file. */
@@ -590,6 +591,61 @@ struct cpp_printer
/* Name under which this program was invoked. */
extern const char *progname;
+/* The structure of a node in the hash table. The hash table
+ has entries for all tokens defined by #define commands (type T_MACRO),
+ plus some special tokens like __LINE__ (these each have their own
+ type, and the appropriate code is run when that type of node is seen.
+ It does not contain control words like "#define", which are recognized
+ by a separate piece of code. */
+
+/* different flavors of hash nodes */
+enum node_type
+{
+ T_VOID = 0, /* no definition yet */
+ T_SPECLINE, /* `__LINE__' */
+ T_DATE, /* `__DATE__' */
+ T_FILE, /* `__FILE__' */
+ T_BASE_FILE, /* `__BASE_FILE__' */
+ T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
+ T_TIME, /* `__TIME__' */
+ T_STDC, /* `__STDC__' */
+ T_CONST, /* Constant string, used by `__SIZE_TYPE__' etc */
+ T_XCONST, /* Ditto, but the string is malloced memory */
+ T_POISON, /* poisoned identifier */
+ T_MACRO, /* object-like macro */
+ T_FMACRO, /* function-like macro */
+ T_IDENTITY, /* macro defined to itself */
+ T_EMPTY, /* macro defined to nothing */
+ T_ASSERTION /* predicate for #assert */
+};
+
+/* There is a slot in the hashnode for use by front ends when integrated
+ with cpplib. It holds a tree (see tree.h) but we mustn't drag that
+ header into every user of cpplib.h. cpplib does not do anything with
+ this slot except clear it when a new node is created. */
+union tree_node;
+
+struct cpp_hashnode
+{
+ unsigned int hash; /* cached hash value */
+ unsigned short length; /* length of name */
+ ENUM_BITFIELD(node_type) type : 8; /* node type */
+ char disabled; /* macro turned off for rescan? */
+
+ union {
+ const unsigned char *cpval; /* some predefined macros */
+ const struct object_defn *odefn; /* #define foo bar */
+ const struct funct_defn *fdefn; /* #define foo(x) bar(x) */
+ struct predicate *pred; /* #assert */
+ } value;
+
+ union tree_node *fe_value; /* front end value */
+
+ const unsigned char name[1]; /* name[length] */
+};
+
+
+
extern void _cpp_lex_file PARAMS((cpp_reader *));
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern enum cpp_ttype cpp_get_token PARAMS ((cpp_reader *));
@@ -653,6 +709,8 @@ extern int cpp_idcmp PARAMS ((const unsigned char *,
/* In cpphash.c */
extern int cpp_defined PARAMS ((cpp_reader *,
const unsigned char *, int));
+extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *,
+ const unsigned char *, int));
/* In cppfiles.c */
extern int cpp_included PARAMS ((cpp_reader *, const char *));