diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-12-12 17:48:13 +0100 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-12-20 09:25:37 -0500 |
commit | 4ccd9baa59b24ae700ccf39e01dbf36214e48a5f (patch) | |
tree | 66cbbcea492a7721712f1ddcd02bd81365c676e3 /src/shared/hashmap.c | |
parent | 3f006fb44de6f2308da94ea26b133773e18cb188 (diff) |
configure.ac: add a generic --enable-debug, replace --enable-hashmap-debug
There will be more debugging options later.
--enable-debug will enable them all.
--enable-debug=hashmap will enable only hashmap debugging.
Also rename the C #define to ENABLE_DEBUG_* pattern.
NOTE: We add the debugging code to hashmap.{c,h} but do not
add the option in configure.ac. We may do so at a later time.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared/hashmap.c')
-rw-r--r-- | src/shared/hashmap.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c index 5b329e0851..b777b4d026 100644 --- a/src/shared/hashmap.c +++ b/src/shared/hashmap.c @@ -137,7 +137,7 @@ typedef uint8_t dib_raw_t; #define DIB_FREE UINT_MAX -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP struct hashmap_debug_info { LIST_FIELDS(struct hashmap_debug_info, debug_list); unsigned max_entries; /* high watermark of n_entries */ @@ -158,9 +158,9 @@ static LIST_HEAD(struct hashmap_debug_info, hashmap_debug_list); #define HASHMAP_DEBUG_FIELDS struct hashmap_debug_info debug; -#else /* !ENABLE_HASHMAP_DEBUG */ +#else /* !ENABLE_DEBUG_HASHMAP */ #define HASHMAP_DEBUG_FIELDS -#endif /* ENABLE_HASHMAP_DEBUG */ +#endif /* ENABLE_DEBUG_HASHMAP */ enum HashmapType { HASHMAP_TYPE_PLAIN, @@ -552,7 +552,7 @@ static void base_remove_entry(HashmapBase *h, unsigned idx) { dibs = dib_raw_ptr(h); assert(dibs[idx] != DIB_RAW_FREE); -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP h->debug.rem_count++; h->debug.last_rem_idx = idx; #endif @@ -631,7 +631,7 @@ static unsigned hashmap_iterate_in_insertion_order(OrderedHashmap *h, Iterator * assert(e->p.b.key == i->next_key); } -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP i->prev_idx = idx; #endif @@ -688,7 +688,7 @@ static unsigned hashmap_iterate_in_internal_order(HashmapBase *h, Iterator *i) { } idx = i->idx; -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP i->prev_idx = idx; #endif @@ -711,7 +711,7 @@ static unsigned hashmap_iterate_entry(HashmapBase *h, Iterator *i) { return IDX_NIL; } -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP if (i->idx == IDX_FIRST) { i->put_count = h->debug.put_count; i->rem_count = h->debug.rem_count; @@ -799,7 +799,7 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu shared_hash_key_initialized= true; } -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug); h->debug.func = func; h->debug.file = file; @@ -854,7 +854,7 @@ static void hashmap_free_no_clear(HashmapBase *h) { assert(!h->has_indirect); assert(!h->n_direct_entries); -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug); #endif @@ -961,7 +961,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx, dib_raw_t raw_dib, *dibs; unsigned dib, distance; -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP h->debug.put_count++; #endif @@ -1055,7 +1055,7 @@ static int hashmap_base_put_boldly(HashmapBase *h, unsigned idx, assert_se(hashmap_put_robin_hood(h, idx, swap) == false); n_entries_inc(h); -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP h->debug.max_entries = MAX(h->debug.max_entries, n_entries(h)); #endif @@ -1283,7 +1283,7 @@ int hashmap_replace(Hashmap *h, const void *key, void *value) { idx = bucket_scan(h, hash, key); if (idx != IDX_NIL) { e = plain_bucket_at(h, idx); -#ifdef ENABLE_HASHMAP_DEBUG +#ifdef ENABLE_DEBUG_HASHMAP /* Although the key is equal, the key pointer may have changed, * and this would break our assumption for iterating. So count * this operation as incompatible with iteration. */ |