X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fset.c;h=f22c897804a27de59771c335f7f3cc676b7da58a;hb=6b7483c417524023d2675981f07e6c59e955428f;hp=bb8cab483bd8e9bf822eeefdd2f630a40186ce74;hpb=c174df932f2f720795dee5d4acb020ba67d6bfe1;p=libfirm diff --git a/ir/adt/set.c b/ir/adt/set.c index bb8cab483..f22c89780 100644 --- a/ir/adt/set.c +++ b/ir/adt/set.c @@ -59,7 +59,6 @@ #include #include #include -#include "misc.h" #include "xmalloc.h" #ifdef PSET # include "pset.h" @@ -86,13 +85,13 @@ typedef struct element { struct SET { - short p; /* Next bucket to be split */ - short maxp; /* upper bound on p during expansion */ - int nkey; /* current # keys */ - short nseg; /* current # segments */ + unsigned p; /* Next bucket to be split */ + unsigned maxp; /* upper bound on p during expansion */ + unsigned nkey; /* current # keys */ + unsigned nseg; /* current # segments */ Segment *dir[DIRECTORY_SIZE]; MANGLEP(cmp_fun) cmp; /* function comparing entries */ - int iter_i, iter_j; + unsigned iter_i, iter_j; Element *iter_tail; /* non-NULL while iterating over elts */ #ifdef PSET Element *free_list; /* list of free Elements */ @@ -145,14 +144,14 @@ stat_chain_len (SET *table, int chain_len) const char *MANGLEP(tag); -static void +void MANGLEP(describe) (SET *table) { - int i, j, collide; + unsigned i, j, collide; Element *ptr; Segment *seg; - printf ("p=%d maxp=%d nkey=%d nseg=%d\n", + printf ("p=%u maxp=%u nkey=%u nseg=%u\n", table->p, table->maxp, table->nkey, table->nseg); for (i = 0; i < table->nseg; i++) { seg = table->dir[i]; @@ -162,7 +161,7 @@ MANGLEP(describe) (SET *table) while (ptr) { if (collide) printf ("<%3d>", collide); else printf ("table"); - printf ("[%d][%3d]: %u %p\n", i, j, ptr->entry.hash, ptr->entry.dptr); + printf ("[%d][%3d]: %u %p\n", i, j, ptr->entry.hash, (void *)ptr->entry.dptr); ptr = ptr->chain; collide++; } @@ -179,10 +178,14 @@ SET * int i; SET *table = xmalloc (sizeof (SET)); - /* Adjust nslots up to next power of 2, minimum SEGMENT_SIZE */ - assert (nslots >= 0); - for (i = SEGMENT_SIZE; i < nslots; i <<= 1) assert (i < (i << 1)); - nslots = i >> SEGMENT_SIZE_SHIFT; + if (nslots > SEGMENT_SIZE * DIRECTORY_SIZE) + n_slots = DIRECTORY_SIZE; + else { + assert (nslots >= 0); + /* Adjust nslots up to next power of 2, minimum SEGMENT_SIZE */ + for (i = SEGMENT_SIZE; i < nslots; i <<= 1); + nslots = i >> SEGMENT_SIZE_SHIFT; + } table->nseg = table->p = table->nkey = 0; table->maxp = nslots << SEGMENT_SIZE_SHIFT;