aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-03-08 23:35:19 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-03-08 23:35:19 +0000
commit88ae23e71dffcd197fc5410a582a470fcbcc2ba9 (patch)
treed22a67043ad8f0cb553637f8f1774978410ad8d9 /gcc/cpphash.h
parent737faf1404678b40cb1f5dcf2ca816d2872fb347 (diff)
downloadgcc-88ae23e71dffcd197fc5410a582a470fcbcc2ba9.zip
gcc-88ae23e71dffcd197fc5410a582a470fcbcc2ba9.tar.gz
gcc-88ae23e71dffcd197fc5410a582a470fcbcc2ba9.tar.bz2
Makefile.in (LIBCPP_DEPS): New macro.
* Makefile.in (LIBCPP_DEPS): New macro. (cpplib.o, cpphash.o, cpperror.o, cppexp.o, cppfiles.o): Use it to declare deps. * cpperror.c: Include cpphash.h. * cppexp.c: Include cpphash.h. Remove MULTIBYTE_CHARS dingleberry. (lex): Don't use CPP_WARN_UNDEF. (_cpp_parse_expr): Return an int, the truth value. * cppfiles.c: Include cpphash.h. (_cpp_merge_include_chains): Move to cppinit.c and make static. * cppinit.c (include_defaults_array): Disentangle. (cpp_cleanup): Don't free the if stack here. (cpp_finish): Pop off all buffers, not just one. * cpplib.c (eval_if_expr): Return int. (do_xifdef): Rename do_ifdef. (handle_directive): Don't use CPP_PREPROCESSED. (cpp_get_token): Don't use CPP_C89. * fix-header.c: Don't use CPP_OPTIONS. * cpplib.h: Move U_CHAR, enum node_type, struct file_name_list, struct ihash, is_idchar, is_idstart, is_numchar, is_numstart, is_hspace, is_space, CPP_BUF_PEEK, CPP_BUF_GET, CPP_FORWARD, CPP_PUTS, CPP_PUTS_Q, CPP_PUTC, CPP_PUTC_Q, CPP_NUL_TERMINATE, CPP_NUL_TERMINATE_Q, CPP_BUMP_BUFFER_LINE, CPP_BUMP_LINE, CPP_PREV_BUFFER, CPP_PRINT_DEPS, CPP_TRADITIONAL, CPP_PEDANTIC, and prototypes of _cpp_simplify_pathname, _cpp_find_include_file, _cpp_read_include_file, and _cpp_parse_expr to cpphash.h. Move struct if_stack to cpplib.c. Move struct cpp_pending to cppinit.c. Change all uses of U_CHAR to be unsigned char instead. Delete CPP_WARN_UNDEF, CPP_C89, and CPP_PREPROCESSED. From-SVN: r32435
Diffstat (limited to 'gcc/cpphash.h')
-rw-r--r--gcc/cpphash.h171
1 files changed, 168 insertions, 3 deletions
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index 814dccd..d44299a 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -1,5 +1,5 @@
-/* Part of CPP library. (Macro hash table support.)
- Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Part of CPP library.
+ Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -15,9 +15,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* This header defines all the internal data structures and functions
+ that need to be visible across files. It's called cpphash.h for
+ historical reasons. */
+
#ifndef __GCC_CPPHASH__
#define __GCC_CPPHASH__
+typedef unsigned char U_CHAR;
+
/* Structure allocated for every #define. For a simple replacement
such as
#define foo bar ,
@@ -70,6 +76,50 @@ struct definition
U_CHAR *argnames;
};
+/* 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 --- also used in keyword table */
+enum node_type
+{
+ T_DEFINE = 1, /* `#define' */
+ T_INCLUDE, /* `#include' */
+ T_INCLUDE_NEXT, /* `#include_next' */
+ T_IMPORT, /* `#import' */
+ T_IFDEF, /* `#ifdef' */
+ T_IFNDEF, /* `#ifndef' */
+ T_IF, /* `#if' */
+ T_ELSE, /* `#else' */
+ T_PRAGMA, /* `#pragma' */
+ T_ELIF, /* `#elif' */
+ T_UNDEF, /* `#undef' */
+ T_LINE, /* `#line' */
+ T_ERROR, /* `#error' */
+ T_WARNING, /* `#warning' */
+ T_ENDIF, /* `#endif' */
+ T_SCCS, /* `#sccs' */
+ T_IDENT, /* `#ident' */
+ T_ASSERT, /* `#assert' */
+ T_UNASSERT, /* `#unassert', */
+ T_SPECLINE, /* `__LINE__' */
+ T_DATE, /* `__DATE__' */
+ T_FILE, /* `__FILE__' */
+ T_BASE_FILE, /* `__BASE_FILE__' */
+ T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
+ T_VERSION, /* `__VERSION__' */
+ T_TIME, /* `__TIME__' */
+ T_STDC, /* `__STDC__' */
+ T_CONST, /* Constant string, used by `__SIZE_TYPE__' etc */
+ T_MACRO, /* macro defined by `#define' */
+ T_DISABLED, /* macro temporarily turned off for rescan */
+ T_POISON, /* macro defined with `#pragma poison' */
+ T_UNUSED /* Used for something not defined. */
+};
+
/* different kinds of things that can appear in the value field
of a hash node. */
union hashval
@@ -80,7 +130,8 @@ union hashval
};
typedef struct hashnode HASHNODE;
-struct 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
@@ -92,6 +143,110 @@ struct hashnode {
union hashval value; /* pointer to expansion, or whatever */
};
+/* List of directories to look for include files in. */
+struct file_name_list
+{
+ struct file_name_list *next;
+ struct file_name_list *alloc; /* for the cache of
+ current directory entries */
+ 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 ihash
+{
+ struct ihash *next;
+ /* Next file with the same short name but a
+ different (partial) pathname). */
+ struct ihash *next_this_file;
+
+ /* 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 */
+ const U_CHAR *control_macro; /* macro, if any, preventing reinclusion -
+ see redundant_include_p */
+ char *buf, *limit; /* for file content cache,
+ not yet implemented */
+};
+typedef struct ihash IHASH;
+
+/* Character classes.
+ If the definition of `numchar' looks odd to you, please look up the
+ definition of a pp-number in the C standard [section 6.4.8 of C99] */
+#define ISidnum 0x01 /* a-zA-Z0-9_ */
+#define ISidstart 0x02 /* _a-zA-Z */
+#define ISnumstart 0x04 /* 0-9 */
+#define IShspace 0x08 /* ' ' \t \f \v */
+#define ISspace 0x10 /* ' ' \t \f \v \n */
+
+#define _dollar_ok(x) ((x) == '$' && CPP_OPTIONS (pfile)->dollars_in_ident)
+
+#define is_idchar(x) ((_cpp_IStable[x] & ISidnum) || _dollar_ok(x))
+#define is_idstart(x) ((_cpp_IStable[x] & ISidstart) || _dollar_ok(x))
+#define is_numchar(x) (_cpp_IStable[x] & ISidnum)
+#define is_numstart(x) (_cpp_IStable[x] & ISnumstart)
+#define is_hspace(x) (_cpp_IStable[x] & IShspace)
+#define is_space(x) (_cpp_IStable[x] & ISspace)
+
+/* This table is constant if it can be initialized at compile time,
+ which is the case if cpp was compiled with GCC >=2.7, or another
+ compiler that supports C99. */
+#if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)
+extern const unsigned char _cpp_IStable[256];
+#else
+extern unsigned char _cpp_IStable[256];
+#endif
+
+/* Macros. */
+
+#define CPP_BUF_PEEK(BUFFER) \
+ ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF)
+#define CPP_BUF_GET(BUFFER) \
+ ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF)
+#define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N))
+
+/* Append string STR (of length N) to PFILE's output buffer.
+ Assume there is enough space. */
+#define CPP_PUTS_Q(PFILE, STR, N) \
+ (memcpy ((PFILE)->limit, STR, (N)), (PFILE)->limit += (N))
+/* Append string STR (of length N) to PFILE's output buffer. Make space. */
+#define CPP_PUTS(PFILE, STR, N) CPP_RESERVE(PFILE, N), CPP_PUTS_Q(PFILE, STR,N)
+/* Append character CH to PFILE's output buffer. Assume sufficient space. */
+#define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH))
+/* Append character CH to PFILE's output buffer. Make space if need be. */
+#define CPP_PUTC(PFILE, CH) (CPP_RESERVE (PFILE, 1), CPP_PUTC_Q (PFILE, CH))
+/* Make sure PFILE->limit is followed by '\0'. */
+#define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0)
+#define CPP_NUL_TERMINATE(PFILE) (CPP_RESERVE(PFILE, 1), *(PFILE)->limit = 0)
+
+/* Advance the current line by one. */
+#define CPP_BUMP_BUFFER_LINE(PBUF) ((PBUF)->lineno++,\
+ (PBUF)->line_base = (PBUF)->cur)
+#define CPP_BUMP_LINE(PFILE) CPP_BUMP_BUFFER_LINE(CPP_BUFFER(PFILE))
+#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
+
+#define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps)
+#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)->traditional)
+#define CPP_PEDANTIC(PFILE) \
+ (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));
@@ -106,4 +261,14 @@ extern void _cpp_macroexpand PARAMS ((cpp_reader *, HASHNODE *));
extern void _cpp_dump_definition PARAMS ((cpp_reader *, const U_CHAR *, long,
DEFINITION *));
+/* In cppfiles.c */
+extern void _cpp_simplify_pathname PARAMS ((char *));
+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 *));
+
+/* In cppexp.c */
+extern int _cpp_parse_expr PARAMS ((cpp_reader *));
+
#endif