mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
4be2e5d967
commit
5fa7f88c06
|
|
@ -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>
|
2000-02-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||||
|
|
||||||
* i386.h (TARGET_SWITCHES): Fix typo in option name.
|
* i386.h (TARGET_SWITCHES): Fix typo in option name.
|
||||||
|
|
|
||||||
|
|
@ -2246,12 +2246,12 @@ deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
|
||||||
touch deduced.h; \
|
touch deduced.h; \
|
||||||
fi
|
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)
|
gen-protos: $(GEN_PROTOS_OBJS) $(HOST_LIBDEPS)
|
||||||
${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o gen-protos \
|
${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o gen-protos \
|
||||||
$(GEN_PROTOS_OBJS) $(HOST_LIBS)
|
$(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
|
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gen-protos.c
|
||||||
|
|
||||||
scan.o: scan.c scan.h $(build_xm_file) system.h
|
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)
|
scan-decls.o scan.o libcpp.a $(HOST_LIBS)
|
||||||
|
|
||||||
fix-header.o: fix-header.c $(srcdir)/../include/obstack.h scan.h \
|
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
|
$(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
|
scan-decls.o: scan-decls.c scan.h cpplib.h $(build_xm_file) system.h
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
#include "obstack.h"
|
#include "obstack.h"
|
||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "cpplib.h"
|
#include "cpplib.h"
|
||||||
#include "cpphash.h"
|
|
||||||
|
|
||||||
static void v_fatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
|
static void v_fatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
|
||||||
static void fatal PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1 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;
|
const char *name;
|
||||||
int name_length;
|
int name_length;
|
||||||
{
|
{
|
||||||
int i = hashf (name, name_length, HASH_SIZE);
|
int i = hashstr (name, name_length) % HASH_SIZE;
|
||||||
int i0 = i;
|
int i0 = i;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
#include "hconfig.h"
|
#include "hconfig.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "cpplib.h"
|
|
||||||
#include "cpphash.h"
|
|
||||||
#undef abort
|
#undef abort
|
||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
@ -31,6 +29,7 @@ static int parse_fn_proto PARAMS ((char *, char *, struct fn_decl *));
|
||||||
#define HASH_SIZE 2503 /* a prime */
|
#define HASH_SIZE 2503 /* a prime */
|
||||||
int hash_tab[HASH_SIZE];
|
int hash_tab[HASH_SIZE];
|
||||||
int next_index;
|
int next_index;
|
||||||
|
int collisions;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_hash (fname)
|
add_hash (fname)
|
||||||
|
|
@ -39,10 +38,11 @@ add_hash (fname)
|
||||||
int i, i0;
|
int i, i0;
|
||||||
|
|
||||||
/* NOTE: If you edit this, also edit lookup_std_proto in fix-header.c !! */
|
/* 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;
|
i0 = i;
|
||||||
if (hash_tab[i] != 0)
|
if (hash_tab[i] != 0)
|
||||||
{
|
{
|
||||||
|
collisions++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
i = (i+1) % HASH_SIZE;
|
i = (i+1) % HASH_SIZE;
|
||||||
|
|
@ -186,5 +186,26 @@ main (argc, argv)
|
||||||
fprintf (outf, " %d,\n", hash_tab[i]);
|
fprintf (outf, " %d,\n", hash_tab[i]);
|
||||||
fprintf (outf, "};\n");
|
fprintf (outf, "};\n");
|
||||||
|
|
||||||
|
fprintf (stderr, "gen-protos: %d entries %d collisions\n",
|
||||||
|
next_index, collisions);
|
||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
15
gcc/scan.c
15
gcc/scan.c
|
|
@ -236,3 +236,18 @@ get_token (fp, s)
|
||||||
*s->ptr = 0;
|
*s->ptr = 0;
|
||||||
return c;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ extern int read_upto _PARAMS((FILE *, sstring *, int));
|
||||||
extern unsigned long hash _PARAMS((const char *));
|
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_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 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. */
|
/* get_token is a simple C lexer. */
|
||||||
#define IDENTIFIER_TOKEN 300
|
#define IDENTIFIER_TOKEN 300
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue