aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-02-10 02:23:08 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-02-10 02:23:08 +0000
commitbb52fa7f8606991a77af8ff6f0edabb8d7ffd280 (patch)
treea1c32725cdbb29b80f1f744fec3575eb7ad9997d /gcc/cpplib.c
parentae6f3fe9f6035dd43b0eaa153e95843325f67f08 (diff)
downloadgcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.zip
gcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.tar.gz
gcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.tar.bz2
cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only.
* cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only. Kill cpp_hashnode typedef. MACRODEF, DEFINITION, struct hashnode, struct macrodef, struct definition, scan_decls prototype, default defn of INCLUDE_LEN_FUDGE moved elsewhere. * cpphash.h: MACRODEF, DEFINITION, struct macrodef, struct definition, and struct hashnode moved here. Remove the unused 'predefined' field from struct definition. Replace the 'args' union with its sole member. All users updated (cpphash.c). Delete HASHSTEP and MAKE_POS macros, and hashf prototype. Add multiple include guard. * cpphash.c (hashf): Make static; use better algorithm; drop HASHSIZE parameter; return an unsigned int. (cpp_lookup): Drop HASH parameter. PFILE parameter is used. Calculate HASHSIZE modulus here. (cpp_install): Drop HASH parameter. Calculate HASHSIZE modulus here. (create_definition): Drop PREDEFINITION parameter. * cpplib.c (do_define): Don't calculate a hash value here. Don't pass (keyword == NULL) to create_definition. * scan.h: Prototype scan_decls here. * cppfiles.c: Move INCLUDE_LEN_FUDGE default defn here. * cppexp.c, cppfiles.c, cppinit.c, cpplib.c, fix-header.c: All callers of cpp_lookup and cpp_install updated. From-SVN: r31881
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 7abb331..896d602 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -654,7 +654,6 @@ do_define (pfile, keyword)
cpp_reader *pfile;
const struct directive *keyword;
{
- int hashcode;
MACRODEF mdef;
HASHNODE *hp;
long here;
@@ -678,13 +677,11 @@ do_define (pfile, keyword)
CPP_SET_WRITTEN (pfile, here);
- mdef = create_definition (macro, end, pfile, keyword == NULL);
+ mdef = create_definition (macro, end, pfile);
if (mdef.defn == 0)
return 0;
- hashcode = hashf (mdef.symnam, mdef.symlen, HASHSIZE);
-
- if ((hp = cpp_lookup (pfile, mdef.symnam, mdef.symlen, hashcode)) != NULL)
+ if ((hp = cpp_lookup (pfile, mdef.symnam, mdef.symlen)) != NULL)
{
int ok = 0;
/* Redefining a precompiled key is ok. */
@@ -720,8 +717,7 @@ do_define (pfile, keyword)
}
}
else
- cpp_install (pfile, mdef.symnam, mdef.symlen, new_type,
- (char *) mdef.defn, hashcode);
+ cpp_install (pfile, mdef.symnam, mdef.symlen, new_type, (char *)mdef.defn);
if (keyword != NULL && keyword->type == T_DEFINE)
{
@@ -1475,7 +1471,7 @@ do_undef (pfile, keyword)
sym_length = check_macro_name (pfile, buf);
- while ((hp = cpp_lookup (pfile, name, sym_length, -1)) != NULL)
+ while ((hp = cpp_lookup (pfile, name, sym_length)) != NULL)
{
/* If we are generating additional info for debugging (with -g) we
need to pass through all effective #undef commands. */
@@ -1923,7 +1919,7 @@ do_xifdef (pfile, keyword)
}
else if (token == CPP_NAME)
{
- HASHNODE *hp = cpp_lookup (pfile, ident, ident_length, -1);
+ HASHNODE *hp = cpp_lookup (pfile, ident, ident_length);
skip = (hp == NULL) ^ (keyword->type == T_IFNDEF);
if (start_of_file && !skip)
{
@@ -2617,7 +2613,7 @@ cpp_get_token (pfile)
return CPP_NAME;
ident = pfile->token_buffer + before_name_written;
ident_len = CPP_PWRITTEN (pfile) - ident;
- hp = cpp_lookup (pfile, ident, ident_len, -1);
+ hp = cpp_lookup (pfile, ident, ident_len);
if (!hp)
return CPP_NAME;
if (hp->type == T_DISABLED)
@@ -3018,16 +3014,16 @@ do_assert (pfile, keyword)
thislen = strlen (sym);
baselen = index (sym, '(') - sym;
- this = cpp_lookup (pfile, sym, thislen, -1);
+ this = cpp_lookup (pfile, sym, thislen);
if (this)
{
cpp_warning (pfile, "`%s' re-asserted", sym);
goto error;
}
- base = cpp_lookup (pfile, sym, baselen, -1);
+ base = cpp_lookup (pfile, sym, baselen);
if (! base)
- base = cpp_install (pfile, sym, baselen, T_ASSERT, 0, -1);
+ base = cpp_install (pfile, sym, baselen, T_ASSERT, 0);
else if (base->type != T_ASSERT)
{
/* Token clash - but with what?! */
@@ -3036,7 +3032,7 @@ do_assert (pfile, keyword)
}
this = cpp_install (pfile, sym, thislen, T_ASSERT,
- (char *)base->value.aschain, -1);
+ (char *)base->value.aschain);
base->value.aschain = this;
pfile->limit = (unsigned char *) sym; /* Pop */
@@ -3077,7 +3073,7 @@ do_unassert (pfile, keyword)
thislen = strlen (sym);
if (ret == 1)
{
- base = cpp_lookup (pfile, sym, thislen, -1);
+ base = cpp_lookup (pfile, sym, thislen);
if (! base)
goto error; /* It isn't an error to #undef what isn't #defined,
so it isn't an error to #unassert what isn't
@@ -3093,9 +3089,9 @@ do_unassert (pfile, keyword)
else
{
baselen = index (sym, '(') - sym;
- base = cpp_lookup (pfile, sym, baselen, -1);
+ base = cpp_lookup (pfile, sym, baselen);
if (! base) goto error;
- this = cpp_lookup (pfile, sym, thislen, -1);
+ this = cpp_lookup (pfile, sym, thislen);
if (! this) goto error;
next = base;
@@ -3144,7 +3140,7 @@ cpp_read_check_assertion (pfile)
result = 0;
else
{
- hp = cpp_lookup (pfile, name, CPP_PWRITTEN (pfile) - name, -1);
+ hp = cpp_lookup (pfile, name, CPP_PWRITTEN (pfile) - name);
result = (hp != 0);
}