From 29fff22a0aac95ec7acfe76c862b93839acf9a0a Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 18 Jan 2011 23:49:12 +0000 Subject: [PATCH] Switched set, pset, eset to size_t, hash remains unsigned. [r28253] --- include/libfirm/adt/eset.h | 4 ++-- include/libfirm/adt/pmap.h | 6 ++--- include/libfirm/adt/pset.h | 6 ++--- include/libfirm/adt/set.h | 8 +++---- ir/adt/eset.c | 4 ++-- ir/adt/pmap.c | 6 ++--- ir/adt/set.c | 45 +++++++++++++++++++------------------- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/include/libfirm/adt/eset.h b/include/libfirm/adt/eset.h index a68328bba..bb35aac79 100644 --- a/include/libfirm/adt/eset.h +++ b/include/libfirm/adt/eset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -49,7 +49,7 @@ FIRM_API eset *eset_copy(eset *source); FIRM_API void eset_destroy(eset *s); /** Returns the number of elements in the set. */ -FIRM_API int eset_count(eset *s); +FIRM_API size_t eset_count(eset *s); /** Inserts an address into the set. */ FIRM_API void eset_insert(eset *s, void *p); diff --git a/include/libfirm/adt/pmap.h b/include/libfirm/adt/pmap.h index cca1d66e9..30b667444 100644 --- a/include/libfirm/adt/pmap.h +++ b/include/libfirm/adt/pmap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -45,7 +45,7 @@ typedef struct pmap_entry { FIRM_API pmap *pmap_create(void); /** Creates a new empty map with an initial number of slots. */ -FIRM_API pmap *pmap_create_ex(int slots); +FIRM_API pmap *pmap_create_ex(size_t slots); /** Deletes a map. */ FIRM_API void pmap_destroy(pmap *); @@ -65,7 +65,7 @@ FIRM_API pmap_entry * pmap_find(pmap *map, const void * key); /** Returns the value of "key". */ FIRM_API void * pmap_get(pmap *map, const void * key); -FIRM_API int pmap_count(pmap *map); +FIRM_API size_t pmap_count(pmap *map); /** * Returns the first entry of a map if the map is not empty. diff --git a/include/libfirm/adt/pset.h b/include/libfirm/adt/pset.h index 4476c2aab..773d276ed 100644 --- a/include/libfirm/adt/pset.h +++ b/include/libfirm/adt/pset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -91,7 +91,7 @@ typedef int (*pset_cmp_fun) (const void *elt, const void *key); * @returns * created pset */ -FIRM_API pset *new_pset(pset_cmp_fun func, int slots); +FIRM_API pset *new_pset(pset_cmp_fun func, size_t slots); /** * Deletes a pset. @@ -108,7 +108,7 @@ FIRM_API void del_pset(pset *pset); * * @param pset the pset */ -FIRM_API int pset_count(pset *pset); +FIRM_API size_t pset_count(pset *pset); /** * Searches an element pointer in a pset. diff --git a/include/libfirm/adt/set.h b/include/libfirm/adt/set.h index b10dbfb4d..828dadd5c 100644 --- a/include/libfirm/adt/set.h +++ b/include/libfirm/adt/set.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -75,7 +75,7 @@ typedef int (*set_cmp_fun) (const void *elt, const void *key, size_t size); * @returns * created set */ -FIRM_API set *new_set(set_cmp_fun func, int slots); +FIRM_API set *new_set(set_cmp_fun func, size_t slots); /** * Deletes a set and all elements of it. @@ -89,7 +89,7 @@ FIRM_API void del_set(set *set); * * @param set the set */ -FIRM_API int set_count(set *set); +FIRM_API size_t set_count(set *set); /** * Searches an element in a set. @@ -225,7 +225,7 @@ void set_stats (set *set); * * @param set the set */ -FIRM_API void set_describe (set *set); +FIRM_API void set_describe(set *set); #endif diff --git a/ir/adt/eset.c b/ir/adt/eset.c index ecf347c16..453ad2b60 100644 --- a/ir/adt/eset.c +++ b/ir/adt/eset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -70,7 +70,7 @@ void eset_destroy(eset *s) } /* Returns the number of elements in the set. */ -int eset_count(eset *s) +size_t eset_count(eset *s) { return set_count((set *)s); } diff --git a/ir/adt/pmap.c b/ir/adt/pmap.c index a18d5bbcc..3ce03a94b 100644 --- a/ir/adt/pmap.c +++ b/ir/adt/pmap.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -56,7 +56,7 @@ static int pmap_entry_cmp(const void *p1, const void *p2, size_t size) } /* Creates a new empty map with an initial number of slots. */ -pmap *pmap_create_ex(int slots) +pmap *pmap_create_ex(size_t slots) { return (pmap *)new_set(pmap_entry_cmp, slots); } @@ -97,7 +97,7 @@ void * pmap_get(pmap *map, const void *key) return entry == NULL ? NULL : entry->value; } -int pmap_count(pmap *map) +size_t pmap_count(pmap *map) { return set_count(M2S(map)); } diff --git a/ir/adt/set.c b/ir/adt/set.c index 29245f59e..1806437fe 100644 --- a/ir/adt/set.c +++ b/ir/adt/set.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -65,6 +65,7 @@ #include #include #include "xmalloc.h" +#include "lc_printf.h" #ifdef PSET # include "pset.h" #else @@ -90,10 +91,10 @@ typedef struct element { struct SET { - unsigned p; /**< Next bucket to be split */ - unsigned maxp; /**< upper bound on p during expansion */ - unsigned nkey; /**< current # keys */ - unsigned nseg; /**< current # segments */ + size_t p; /**< Next bucket to be split */ + size_t maxp; /**< upper bound on p during expansion */ + size_t nkey; /**< current # keys */ + size_t nseg; /**< current # segments */ Segment *dir[DIRECTORY_SIZE]; MANGLEP(cmp_fun) cmp; /**< function comparing entries */ unsigned iter_i, iter_j; @@ -103,8 +104,8 @@ struct SET { #endif struct obstack obst; /**< obstack for allocation all data */ #ifdef STATS - int naccess, ncollision, ndups; - int max_chain_len; + size_t naccess, ncollision, ndups; + size_t max_chain_len; #endif #ifdef DEBUG const char *tag; /**< an optionally tag for distinguishing sets */ @@ -116,16 +117,16 @@ struct SET { void MANGLEP(stats) (SET *table) { - int nfree = 0; + size_t nfree = 0; #ifdef PSET Element *q = table->free_list; while (q) { q = q->chain; ++nfree; } #endif - printf (" accesses collisions keys duplicates longest wasted\n%12d%12d%12d%12d%12d%12d\n", + lc_printf(" accesses collisions keys duplicates longest wasted\n%12zu%12zu%12zu%12zu%12zu%12zu\n", table->naccess, table->ncollision, table->nkey, table->ndups, table->max_chain_len, nfree); } -static inline void stat_chain_len(SET *table, int chain_len) +static inline void stat_chain_len(SET *table, size_t chain_len) { table->ncollision += chain_len; if (table->max_chain_len < chain_len) table->max_chain_len = chain_len; @@ -149,11 +150,11 @@ const char *MANGLEP(tag); void MANGLEP(describe) (SET *table) { - unsigned i, j, collide; + size_t i, j, collide; Element *ptr; Segment *seg; - printf ("p=%u maxp=%u nkey=%u nseg=%u\n", + lc_printf("p=%zu maxp=%zu nkey=%zu nseg=%zu\n", table->p, table->maxp, table->nkey, table->nseg); for (i = 0; i < table->nseg; i++) { seg = table->dir[i]; @@ -161,11 +162,11 @@ void MANGLEP(describe) (SET *table) collide = 0; ptr = seg[j]; while (ptr) { - if (collide) printf ("<%3d>", collide); + if (collide) lc_printf("<%3zu>", collide); else printf ("table"); - printf ("[%d][%3d]: %u %p\n", i, j, ptr->entry.hash, (void *)ptr->entry.dptr); + lc_printf("[%zd][%3zd]: %u %p\n", i, j, ptr->entry.hash, (void *)ptr->entry.dptr); ptr = ptr->chain; - collide++; + ++collide; } } } @@ -177,7 +178,7 @@ void MANGLEP(describe) (SET *table) #endif /* !DEBUG */ -SET *(PMANGLE(new)) (MANGLEP(cmp_fun) cmp, int nslots) +SET *(PMANGLE(new)) (MANGLEP(cmp_fun) cmp, size_t nslots) { int i; SET *table = XMALLOC(SET); @@ -227,7 +228,7 @@ void PMANGLE(del) (SET *table) xfree (table); } -int MANGLEP(count) (SET *table) +size_t MANGLEP(count) (SET *table) { return table->nkey; } @@ -322,9 +323,9 @@ static inline int loaded(SET *table) */ static void expand_table(SET *table) { - unsigned NewAddress; - int OldSegmentIndex, NewSegmentIndex; - int OldSegmentDir, NewSegmentDir; + size_t NewAddress; + size_t OldSegmentIndex, NewSegmentIndex; + size_t OldSegmentDir, NewSegmentDir; Segment *OldSegment; Segment *NewSegment; Element *Current; @@ -390,7 +391,7 @@ void * MANGLE(_,_search) (SET *table, int SegmentIndex; MANGLEP(cmp_fun) cmp = table->cmp; Segment q; - int chain_len = 0; + size_t chain_len = 0; assert (table); assert (key); @@ -412,7 +413,7 @@ void * MANGLE(_,_search) (SET *table, ++chain_len; } - stat_chain_len (table, chain_len); + stat_chain_len(table, chain_len); if (!q && (action != MANGLE(_,_find))) { /* not found, insert */ assert (!table->iter_tail && "insert an element into a set that is iterated"); -- 2.20.1