|
|
|
@ -36,7 +36,8 @@ template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bit |
|
|
|
|
struct hb_cache_t |
|
|
|
|
{ |
|
|
|
|
static_assert ((key_bits >= cache_bits), ""); |
|
|
|
|
static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (unsigned int)), ""); |
|
|
|
|
static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (hb_atomic_int_t)), ""); |
|
|
|
|
static_assert (sizeof (hb_atomic_int_t) == sizeof (unsigned int)); |
|
|
|
|
|
|
|
|
|
inline void init (void) { clear (); } |
|
|
|
|
inline void fini (void) {} |
|
|
|
@ -51,7 +52,8 @@ struct hb_cache_t |
|
|
|
|
{ |
|
|
|
|
unsigned int k = key & ((1u<<cache_bits)-1); |
|
|
|
|
unsigned int v = values[k].get_relaxed (); |
|
|
|
|
if ((v >> value_bits) != (key >> cache_bits)) |
|
|
|
|
if ((key_bits + value_bits - cache_bits == 8 * sizeof (hb_atomic_int_t) && v == (unsigned int) -1) || |
|
|
|
|
(v >> value_bits) != (key >> cache_bits)) |
|
|
|
|
return false; |
|
|
|
|
*value = v & ((1u<<value_bits)-1); |
|
|
|
|
return true; |
|
|
|
|