diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-03-12 23:46:05 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-03-12 23:46:05 +0000 |
commit | 5ecec5dabe4dbe0744ff950108e23d2675e77eac (patch) | |
tree | a98d122ee7a482f328ecd041626122a0cd1beaa8 /gcc/cpphash.h | |
parent | a25d35f6be24a9f7ee6b012ee5fef7b81a7ec9df (diff) | |
download | gcc-5ecec5dabe4dbe0744ff950108e23d2675e77eac.tar.gz |
Convert cpplib to use libiberty/hashtab.c.
* cpplib.h (struct cpp_reader): Make hashtab and
all_include_files of type 'struct htab *'. Delete HASHSIZE
and ALL_INCLUDE_HASHSIZE macros.
* cpphash.h: Update prototypes.
(struct hashnode): Remove next, prev, and bucket_hdr members.
Make length a size_t. Add hash member.
(struct ihash): Remove next member. Add hash member. Make
name a flexible array member.
* cppfiles.c: Include hashtab.h.
(include_hash): Delete.
(IHASHSIZE): New macro.
(hash_IHASH, eq_IHASH, _cpp_init_include_hash): New functions.
(cpp_included): Do the hash lookup here.
(_cpp_find_include_file): Rewrite.
(cpp_read_file): Put the "fake" hash entry into the hash
table. Honor the control_macro, if it turns out we've seen
the file before. Don't push the buffer here.
(_cpp_read_include_file): Push the buffer here.
(OMODES): New macro. Use it whenever we call open(2).
* cpphash.c: Include hashtab.h.
(hash_HASHNODE, eq_HASHNODE, del_HASHNODE, dump_hash_helper,
_cpp_init_macro_hash, _cpp_dump_macro_hash, _cpp_make_hashnode,
_cpp_lookup_slot): New functions.
(HASHSIZE): new macro.
(hashf, _cpp_install, _cpp_delete_macro): Delete.
(_cpp_lookup): Use hashtab.h routines.
* cppinit.c: Include hashtab.h.
(cpp_reader_init): Call _cpp_init_macro_hash and
_cpp_init_include_hash. Don't allocate hashtab directly.
(cpp_cleanup): Just call htab_delete on pfile->hashtab and
pfile->all_include_files.
(initialize_builtins): Use _cpp_make_hashnode and
htab_find_slot to add hash entries.
(cpp_finish): Just call _cpp_dump_macro_hash.
* cpplib.c: Include hashtab.h.
(do_define): Use _cpp_lookup_slot and _cpp_make_hashnode to
create hash entries.
(do_pragma_poison, do_assert): Likewise.
(do_include): Don't push the buffer here. Don't increment
system_include_depth unless _cpp_read_include_file succeeds.
(do_undef, do_unassert): Use _cpp_lookup_slot and htab_clear_slot
or htab_remove_elt.
(do_pragma_implementation): Use alloca to create copy.
* Makefile.in: Update dependencies.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32497 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpphash.h')
-rw-r--r-- | gcc/cpphash.h | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/gcc/cpphash.h b/gcc/cpphash.h index d44299a2721..c842ea6e121 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -132,15 +132,11 @@ union hashval typedef struct hashnode HASHNODE; struct hashnode { - struct hashnode *next; /* double links for easy deletion */ - struct hashnode *prev; - struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash - chain is kept, in case the node is the head - of the chain and gets deleted. */ - enum node_type type; /* type of special token */ - int length; /* length of token, for quick comparison */ - U_CHAR *name; /* the actual name */ + const U_CHAR *name; /* the actual name */ + size_t length; /* length of token, for quick comparison */ + unsigned long hash; /* cached hash value */ union hashval value; /* pointer to expansion, or whatever */ + enum node_type type; /* type of special token */ }; /* List of directories to look for include files in. */ @@ -169,7 +165,6 @@ struct file_name_list #include statement) which is stored in *nshort. */ struct ihash { - struct ihash *next; /* Next file with the same short name but a different (partial) pathname). */ struct ihash *next_this_file; @@ -177,12 +172,13 @@ struct ihash /* Location of the file in the include search path. Used for include_next */ struct file_name_list *foundhere; - const char *name; /* (partial) pathname of file */ - const char *nshort; /* name of file as referenced in #include */ + + unsigned long hash; /* save hash value for future reference */ + const char *nshort; /* name of file as referenced in #include; + points into name[] */ const U_CHAR *control_macro; /* macro, if any, preventing reinclusion - see redundant_include_p */ - char *buf, *limit; /* for file content cache, - not yet implemented */ + const char name[1]; /* (partial) pathname of file */ }; typedef struct ihash IHASH; @@ -247,19 +243,23 @@ extern unsigned char _cpp_IStable[256]; (CPP_OPTIONS (PFILE)->pedantic && !CPP_BUFFER (pfile)->system_header_p) /* In cpphash.c */ -extern HASHNODE *_cpp_install PARAMS ((cpp_reader *, const U_CHAR *, int, - enum node_type, const char *)); -extern HASHNODE *_cpp_lookup PARAMS ((cpp_reader *, const U_CHAR *, int)); -extern void _cpp_free_definition PARAMS ((DEFINITION *)); -extern void _cpp_delete_macro PARAMS ((HASHNODE *)); - -extern DEFINITION *_cpp_create_definition - PARAMS ((cpp_reader *, int)); -extern int _cpp_compare_defs PARAMS ((cpp_reader *, DEFINITION *, - DEFINITION *)); -extern void _cpp_macroexpand PARAMS ((cpp_reader *, HASHNODE *)); -extern void _cpp_dump_definition PARAMS ((cpp_reader *, const U_CHAR *, long, - DEFINITION *)); +extern HASHNODE *_cpp_make_hashnode PARAMS ((const U_CHAR *, size_t, + enum node_type, + unsigned long)); +extern HASHNODE *_cpp_lookup PARAMS ((cpp_reader *, + const U_CHAR *, int)); +extern HASHNODE **_cpp_lookup_slot PARAMS ((cpp_reader *, + const U_CHAR *, int, int, + unsigned long *)); +extern void _cpp_free_definition PARAMS ((DEFINITION *)); +extern DEFINITION *_cpp_create_definition PARAMS ((cpp_reader *, int)); +extern void _cpp_dump_definition PARAMS ((cpp_reader *, const U_CHAR *, + long, DEFINITION *)); +extern int _cpp_compare_defs PARAMS ((cpp_reader *, DEFINITION *, + DEFINITION *)); +extern void _cpp_macroexpand PARAMS ((cpp_reader *, HASHNODE *)); +extern void _cpp_init_macro_hash PARAMS ((cpp_reader *)); +extern void _cpp_dump_macro_hash PARAMS ((cpp_reader *)); /* In cppfiles.c */ extern void _cpp_simplify_pathname PARAMS ((char *)); @@ -267,6 +267,7 @@ extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *, struct file_name_list *, IHASH **, int *)); extern int _cpp_read_include_file PARAMS ((cpp_reader *, int, IHASH *)); +extern void _cpp_init_include_hash PARAMS ((cpp_reader *)); /* In cppexp.c */ extern int _cpp_parse_expr PARAMS ((cpp_reader *)); |