diff options
Diffstat (limited to 'src/vppinfra/bihash_template.h')
-rw-r--r-- | src/vppinfra/bihash_template.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h index c4e120e4a1f..8f5879b4634 100644 --- a/src/vppinfra/bihash_template.h +++ b/src/vppinfra/bihash_template.h @@ -99,7 +99,6 @@ typedef struct STATIC_ASSERT_SIZEOF (BVT (clib_bihash_bucket), sizeof (u64)); -/* *INDENT-OFF* */ typedef CLIB_PACKED (struct { /* * Backing store allocation. Since bihash manages its own @@ -118,7 +117,6 @@ typedef CLIB_PACKED (struct { volatile u32 ready; u64 pad[1]; }) BVT (clib_bihash_shared_header); -/* *INDENT-ON* */ STATIC_ASSERT_SIZEOF (BVT (clib_bihash_shared_header), 8 * sizeof (u64)); @@ -282,9 +280,7 @@ static inline void BV (clib_bihash_alloc_unlock) (BVT (clib_bihash) * h) static inline void BV (clib_bihash_lock_bucket) (BVT (clib_bihash_bucket) * b) { - /* *INDENT-OFF* */ BVT (clib_bihash_bucket) mask = { .lock = 1 }; - /* *INDENT-ON* */ u64 old; try_again: @@ -410,16 +406,15 @@ BV (clib_bihash_get_bucket) (BVT (clib_bihash) * h, u64 hash) static inline int BV (clib_bihash_search_inline_with_hash) (BVT (clib_bihash) * h, u64 hash, BVT (clib_bihash_kv) * key_result) { + BVT (clib_bihash_kv) rv; BVT (clib_bihash_value) * v; BVT (clib_bihash_bucket) * b; int i, limit; - /* *INDENT-OFF* */ static const BVT (clib_bihash_bucket) mask = { .linear_search = 1, .log2_pages = -1 }; - /* *INDENT-ON* */ #if BIHASH_LAZY_INSTANTIATE if (PREDICT_FALSE (h->instantiated == 0)) @@ -455,7 +450,10 @@ static inline int BV (clib_bihash_search_inline_with_hash) { if (BV (clib_bihash_key_compare) (v->kvp[i].key, key_result->key)) { - *key_result = v->kvp[i]; + rv = v->kvp[i]; + if (BV (clib_bihash_is_free) (&rv)) + return -1; + *key_result = rv; return 0; } } @@ -509,16 +507,15 @@ static inline int BV (clib_bihash_search_inline_2_with_hash) (BVT (clib_bihash) * h, u64 hash, BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep) { + BVT (clib_bihash_kv) rv; BVT (clib_bihash_value) * v; BVT (clib_bihash_bucket) * b; int i, limit; -/* *INDENT-OFF* */ static const BVT (clib_bihash_bucket) mask = { .linear_search = 1, .log2_pages = -1 }; -/* *INDENT-ON* */ ASSERT (valuep); @@ -556,7 +553,10 @@ static inline int BV (clib_bihash_search_inline_2_with_hash) { if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key)) { - *valuep = v->kvp[i]; + rv = v->kvp[i]; + if (BV (clib_bihash_is_free) (&rv)) + return -1; + *valuep = rv; return 0; } } |