aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/Makefile.in6
-rw-r--r--gcc/fix-header.c3
-rw-r--r--gcc/gen-protos.c27
-rw-r--r--gcc/scan.c15
-rw-r--r--gcc/scan.h1
6 files changed, 57 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c842bc6..b0c2ec9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2000-02-08 Zack Weinberg <zack@wolery.cumb.org>
+
+ * Makefile.in (GEN_PROTOS_OBJS): Remove libcpp.a.
+ (gen_protos.o): Don't depend on cpplib.h or cpphash.h.
+ (fix-header.o): Don't depend on cpphash.h.
+
+ * scan.c (hashstr): New function.
+ * scan.h: Prototype it.
+ * fix-header.c: Don't include cpphash.h. Use hashstr.
+ * gen-protos.c: Don't include cpphash.h or cpplib.h. Use
+ hashstr. Report hash table statistics. Add private
+ definition of xrealloc.
+
2000-02-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* i386.h (TARGET_SWITCHES): Fix typo in option name.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index cb8ff00..ee34ad6 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2246,12 +2246,12 @@ deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
touch deduced.h; \
fi
-GEN_PROTOS_OBJS = gen-protos.o scan.o libcpp.a
+GEN_PROTOS_OBJS = gen-protos.o scan.o
gen-protos: $(GEN_PROTOS_OBJS) $(HOST_LIBDEPS)
${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o gen-protos \
$(GEN_PROTOS_OBJS) $(HOST_LIBS)
-gen-protos.o: gen-protos.c scan.h $(build_xm_file) system.h cpplib.h cpphash.h
+gen-protos.o: gen-protos.c scan.h $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gen-protos.c
scan.o: scan.c scan.h $(build_xm_file) system.h
@@ -2272,7 +2272,7 @@ fix-header: fix-header.o scan-decls.o scan.o xsys-protos.h $(HOST_LIBDEPS) \
scan-decls.o scan.o libcpp.a $(HOST_LIBS)
fix-header.o: fix-header.c $(srcdir)/../include/obstack.h scan.h \
- xsys-protos.h $(build_xm_file) system.h cpplib.h cpphash.h
+ xsys-protos.h $(build_xm_file) system.h cpplib.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/fix-header.c
scan-decls.o: scan-decls.c scan.h cpplib.h $(build_xm_file) system.h
diff --git a/gcc/fix-header.c b/gcc/fix-header.c
index b01f656..f01eadc 100644
--- a/gcc/fix-header.c
+++ b/gcc/fix-header.c
@@ -75,7 +75,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "obstack.h"
#include "scan.h"
#include "cpplib.h"
-#include "cpphash.h"
static void v_fatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
static void fatal PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
@@ -381,7 +380,7 @@ lookup_std_proto (name, name_length)
const char *name;
int name_length;
{
- int i = hashf (name, name_length, HASH_SIZE);
+ int i = hashstr (name, name_length) % HASH_SIZE;
int i0 = i;
for (;;)
{
diff --git a/gcc/gen-protos.c b/gcc/gen-protos.c
index 4971962..32eb80e 100644
--- a/gcc/gen-protos.c
+++ b/gcc/gen-protos.c
@@ -18,8 +18,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "hconfig.h"
#include "system.h"
#include "scan.h"
-#include "cpplib.h"
-#include "cpphash.h"
#undef abort
int verbose = 0;
@@ -31,6 +29,7 @@ static int parse_fn_proto PARAMS ((char *, char *, struct fn_decl *));
#define HASH_SIZE 2503 /* a prime */
int hash_tab[HASH_SIZE];
int next_index;
+int collisions;
static void
add_hash (fname)
@@ -39,10 +38,11 @@ add_hash (fname)
int i, i0;
/* NOTE: If you edit this, also edit lookup_std_proto in fix-header.c !! */
- i = hashf (fname, strlen (fname), HASH_SIZE);
+ i = hashstr (fname, strlen (fname)) % HASH_SIZE;
i0 = i;
if (hash_tab[i] != 0)
{
+ collisions++;
for (;;)
{
i = (i+1) % HASH_SIZE;
@@ -186,5 +186,26 @@ main (argc, argv)
fprintf (outf, " %d,\n", hash_tab[i]);
fprintf (outf, "};\n");
+ fprintf (stderr, "gen-protos: %d entries %d collisions\n",
+ next_index, collisions);
+
return 0;
}
+
+/* Needed by scan.o. We can't use libiberty here. */
+PTR
+xrealloc (p, s)
+ PTR p;
+ size_t s;
+{
+ PTR r;
+ if (s == 0)
+ s = 1;
+ if (p)
+ r = realloc (p, s);
+ else
+ r = malloc (s);
+ if (!r)
+ abort ();
+ return r;
+}
diff --git a/gcc/scan.c b/gcc/scan.c
index 24dd6632..4af6a43 100644
--- a/gcc/scan.c
+++ b/gcc/scan.c
@@ -236,3 +236,18 @@ get_token (fp, s)
*s->ptr = 0;
return c;
}
+
+unsigned int
+hashstr (str, len)
+ const char *str;
+ unsigned int len;
+{
+ unsigned int n = len;
+ unsigned int r = 0;
+ const unsigned char *s = (const unsigned char *)str;
+
+ do
+ r = r * 67 + (*s++ - 113);
+ while (--n);
+ return r + len;
+}
diff --git a/gcc/scan.h b/gcc/scan.h
index b2c2893..a2d9644 100644
--- a/gcc/scan.h
+++ b/gcc/scan.h
@@ -60,6 +60,7 @@ extern int read_upto _PARAMS((FILE *, sstring *, int));
extern unsigned long hash _PARAMS((const char *));
extern void recognized_function _PARAMS((const char *, int, int, const char *, int, int, const char *, int));
extern void recognized_extern _PARAMS((const char *, int, const char *, int));
+extern unsigned int hashstr _PARAMS((const char *, unsigned int));
/* get_token is a simple C lexer. */
#define IDENTIFIER_TOKEN 300