diff options
author | brolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-11-25 11:56:54 +0000 |
---|---|---|
committer | brolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-11-25 11:56:54 +0000 |
commit | 7dd5e644220c89607c893634fe070609cb845f4b (patch) | |
tree | 253cbf23655502b69467d0b7954eb66616f10a2c /gcc/cpplib.h | |
parent | 8593ebbf70bda4333cea0cf72e3ea223f1c28fbc (diff) | |
download | gcc-7dd5e644220c89607c893634fe070609cb845f4b.tar.gz |
Wed Nov 25 14:54:46 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h: Delete struct import_file. Add ihash element to
struct cpp_buffer. Delete dont_repeat_files and
import_hash_table elements from cpp_reader; change
all_include_files to a hash table. Delete all foobar_include
/ last_foobar_include elements from struct cpp_options; put
back four such: quote_include, bracket_include,
system_include, after_include. Redo struct file_name_list
completely. Add new structure type include_hash. Add
prototypes for merge_include_chains and include_hash. Change
prototypes for finclude, find_include_file, and
append_include_chain to match changes below.
* cppfiles.c (simplify_pathname, include_hash,
remap_filename, merge_include_chains): New functions.
(add_import, lookup_import, open_include_file): Removed.
(INO_T_EQ): Define this (copied from cccp.c).
(hack_vms_include_specification): Remove all calls and #if 0
out the definition. It was being called incorrectly and at
the wrong times. Until a VMSie can look at this, it's better
to not pretend to support it.
(append_include_chain): Change calling convention; now takes
only one directory at a time, and sets up the data structure
itself.
(redundant_include_p): Rewritten - this is now used for all
include redundancy, whether by #ifndef, #import, or #pragma
once. Looks up things in the include hash table.
(file_cleanup): Decrement pfile->system_include_depth here if
it's >0.
(find_include_file): Calling convention changed; now passes
around a struct include_hash instead of 3 separate parameters.
Guts ripped out and replaced with new include_hash mechanism.
(finclude): Calling convention changed as for
find_include_file. Error exits pulled out-of-line. Reformat.
(safe_read): Return a long, not an int.
(deps_output): Don't recurse.
* cpplib.c (is_system_include): Deleted.
(path_include): Fix up call to append_include_chain.
(do_include): Fix up calls to find_include_file and finclude.
Clean up dependency output a bit. Shorten obnoxiously lengthy
#import warning message. Don't decrement
pfile->system_include_depth here.
(do_pragma): Understand the include_hash structure. Reformat.
(do_endif): Correct handling of control macros. Understand
the include_hash.
(cpp_start_read): Fix up calls to finclude. Call
merge_include_chains.
(cpp_handle_option): Fix up calls to append_include_chain.
Understand the four partial include chains.
(cpp_finish): Add debugging code (#if 0-ed out) for the
include_hash.
(cpp_cleanup): Free the include_hash, not the import hash and
the all_include and dont_repeat lists which no longer exist.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23857 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r-- | gcc/cpplib.h | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 99745c98f22..fe2810237dc 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -96,17 +96,6 @@ extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *)); /* This frees resources used by PFILE. */ extern void cpp_cleanup PARAMS ((cpp_reader *PFILE)); -/* Maintain and search list of included files, for #import. */ - -#define IMPORT_HASH_SIZE 31 - -struct import_file { - char *name; - ino_t inode; - dev_t dev; - struct import_file *next; -}; - /* If we have a huge buffer, may need to cache more recent counts */ #define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base) @@ -120,10 +109,14 @@ struct cpp_buffer { char *fname; /* Filename specified with #line command. */ char *nominal_fname; + /* Actual directory of this file, used only for "" includes */ + char *dir; + size_t dlen; - /* Record where in the search path this file was found. - For #include_next. */ - struct file_name_list *dir; + /* Pointer into the include hash table. Used for include_next and + to record control macros. + ->fname is an alias to ->ihash->fname. */ + struct include_hash *ihash; long line_base; long lineno; /* Line number at CPP_LINE_BASE. */ @@ -185,20 +178,13 @@ struct cpp_reader { /* Current depth in #include directives that use <...>. */ int system_include_depth; - /* List of included files that contained #pragma once. */ - struct file_name_list *dont_repeat_files; - - /* List of other included files. - If ->control_macro if nonzero, the file had a #ifndef - around the entire contents, and ->control_macro gives the macro name. */ - struct file_name_list *all_include_files; + /* Hash table of other included files. See cppfiles.c */ +#define ALL_INCLUDE_HASHSIZE 71 + struct include_hash *all_include_files[ALL_INCLUDE_HASHSIZE]; /* Current maximum length of directory names in the search path for include files. (Altered as we get more of them.) */ - int max_include_len; - - /* Hash table of files already included with #include or #import. */ - struct import_file *import_hash_table[IMPORT_HASH_SIZE]; + unsigned int max_include_len; struct if_stack *if_stack; @@ -441,23 +427,12 @@ struct cpp_options { char done_initializing; - struct file_name_list *include; /* First dir to search */ - /* First dir to search for <file> */ - /* This is the first element to use for #include <...>. - If it is 0, use the entire chain for such includes. */ - struct file_name_list *first_bracket_include; - /* This is the first element in the chain that corresponds to - a directory of system header files. */ - struct file_name_list *first_system_include; - struct file_name_list *last_include; /* Last in chain */ - - /* Chain of include directories to put at the end of the other chain. */ - struct file_name_list *after_include; - struct file_name_list *last_after_include; /* Last in chain */ - - /* Chain to put at the start of the system include files. */ - struct file_name_list *before_system; - struct file_name_list *last_before_system; /* Last in chain */ + /* Search paths for include files. system_include, after_include are + only used during option parsing. */ + struct file_name_list *quote_include; /* First dir to search for "file" */ + struct file_name_list *bracket_include;/* First dir to search for <file> */ + struct file_name_list *system_include; /* First dir with system headers */ + struct file_name_list *after_include; /* Headers to search after system */ /* Directory prefix that should replace `/usr' in the standard include file directories. */ @@ -506,22 +481,45 @@ struct cpp_options { #define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic) #define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps) +/* List of directories to look for include files in. */ struct file_name_list - { - struct file_name_list *next; - char *fname; - /* If the following is nonzero, it is a macro name. - Don't include the file again if that macro is defined. */ - U_CHAR *control_macro; - /* If the following is nonzero, it is a C-language system include - directory. */ - int c_system_include_path; - /* Mapping of file names for this directory. */ - struct file_name_map *name_map; - /* Non-zero if name_map is valid. */ - int got_name_map; - }; +{ + struct file_name_list *next; + char *name; + unsigned int nlen; + /* We use these to tell if the directory mentioned here is a duplicate + of an earlier directory on the search path. */ + ino_t ino; + dev_t dev; + /* If the following is nonzero, it is a C-language system include + directory. */ + int sysp; + /* Mapping of file names for this directory. + Only used on MS-DOS and related platforms. */ + struct file_name_map *name_map; +}; +#define ABSOLUTE_PATH ((struct file_name_list *)-1) +/* This structure is used for the table of all includes. It is + indexed by the `short name' (the name as it appeared in the + #include statement) which is stored in *nshort. */ +struct include_hash +{ + struct include_hash *next; + /* Next file with the same short name but a + different (partial) pathname). */ + struct include_hash *next_this_file; + + /* Location of the file in the include search path. + Used for include_next */ + struct file_name_list *foundhere; + char *name; /* (partial) pathname of file */ + char *nshort; /* name of file as referenced in #include */ + char *control_macro; /* macro, if any, preventing reinclusion - see + redundant_include_p */ + char *buf, *limit; /* for file content cache, not yet implemented */ +}; + /* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found via the same directory as the file that #included it. */ #define SELF_DIR_DUMMY ((struct file_name_list *) (~0)) @@ -706,15 +704,17 @@ extern void cpp_print_containing_files PROTO ((cpp_reader *)); /* In cppfiles.c */ extern void append_include_chain PROTO ((cpp_reader *, - struct file_name_list *, - struct file_name_list *)); -extern int finclude PROTO ((cpp_reader *, int, char *, - int, struct file_name_list *)); + struct file_name_list **, + char *, int)); +extern void merge_include_chains PROTO ((struct cpp_options *)); extern int find_include_file PROTO ((cpp_reader *, char *, - unsigned long, char *, int, struct file_name_list *, - struct file_name_list **)); + struct include_hash **, + int *)); +extern int finclude PROTO ((cpp_reader *, int, + struct include_hash *)); extern void deps_output PROTO ((cpp_reader *, char *, int)); +extern struct include_hash *include_hash PROTO ((cpp_reader *, char *, int)); /* Bleargh. */ extern char *savestring PROTO ((char *)); |