aboutsummaryrefslogtreecommitdiff
path: root/gcc/gen-protos.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-02-08 21:27:02 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-02-08 21:27:02 +0000
commit5fa7f88c064df849718157fb4e90fa865e35fb5b (patch)
treedc89fdbfec79835dff420526e91afe6ae04f9ca8 /gcc/gen-protos.c
parent4be2e5d967e76bdec83d5b6d08d7b9c5ccacad75 (diff)
downloadgcc-5fa7f88c064df849718157fb4e90fa865e35fb5b.zip
gcc-5fa7f88c064df849718157fb4e90fa865e35fb5b.tar.gz
gcc-5fa7f88c064df849718157fb4e90fa865e35fb5b.tar.bz2
Makefile.in (GEN_PROTOS_OBJS): Remove libcpp.a.
* 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. From-SVN: r31854
Diffstat (limited to 'gcc/gen-protos.c')
-rw-r--r--gcc/gen-protos.c27
1 files changed, 24 insertions, 3 deletions
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;
+}