44 return ((
u32 *) d)[0];
46 return ((
u16 *) d)[0] | (((
u8 *) d)[2] << 16);
48 return ((
u16 *) d)[0];
62 n_left = n_data_bytes;
93 #define foreach_mhash_key_size \ 94 _ (2) _ (3) _ (4) _ (5) _ (6) _ (7) \ 95 _ (8) _ (12) _ (16) _ (20) \ 96 _ (24) _ (28) _ (32) _ (36) \ 97 _ (40) _ (44) _ (48) _ (52) \ 100 #define _(N_KEY_BYTES) \ 102 mhash_key_sum_##N_KEY_BYTES (hash_t * h, uword key) \ 104 mhash_t * hv = uword_to_pointer (h->user, mhash_t *); \ 105 return mhash_key_sum_inline (mhash_key_to_mem (hv, key), \ 111 mhash_key_equal_##N_KEY_BYTES (hash_t * h, uword key1, uword key2) \ 113 mhash_t * hv = uword_to_pointer (h->user, mhash_t *); \ 114 void * k1 = mhash_key_to_mem (hv, key1); \ 115 void * k2 = mhash_key_to_mem (hv, key2); \ 116 return ! memcmp (k1, k2, (N_KEY_BYTES)); \ 135 return strcmp (k1, k2) == 0;
176 #define _(N_KEY_BYTES) \ 178 .key_sum = mhash_key_sum_##N_KEY_BYTES, \ 179 .key_equal = mhash_key_equal_##N_KEY_BYTES, \ 234 vec_add (key_tmp, key, strlen (key) + 1);
267 uword ikey,
i, l = 0, n_key_bytes, old_n_elts, key_alloc_from_free_list = 0;
277 n_key_bytes = is_c_string ? (strlen (key) + 1) :
vec_len (key);
284 sk->
vec.
len = n_key_bytes;
292 key_alloc_from_free_list = (l =
294 if (key_alloc_from_free_list)
312 h->
hash = _hash_set3 (h->
hash, ikey, new_value, old_value);
332 if (key_alloc_from_free_list)
378 u32 ki = va_arg (*va,
u32);
384 u32 l = is_c_string ? strlen (k) :
vec_len (k);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define foreach_mhash_key_size
static u32 load_partial_u32(void *d, uword n)
#define clib_memcpy_fast(a, b, c)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
format_function_t * format_key
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static u32 mhash_key_sum_inline(void *data, uword n_data_bytes, u32 seed)
static uword mhash_key_vector_is_heap(mhash_t *h)
#define hash_v3_mix32(a, b, c)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static uword key_sum(hash_t *h, uword key)
#define hash_get_pair(h, key)
static hash_t * hash_header(void *v)
static void mhash_sanitize_hash_user(mhash_t *mh)
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
u32 * key_vector_free_indices
uword() hash_key_equal_function_t(struct hash_header *, uword key1, uword key2)
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static uword mhash_key_sum_vec_string(hash_t *h, uword key)
#define uword_to_pointer(u, type)
static uword hash_elts(void *v)
static foreach_mhash_key_size uword mhash_key_sum_c_string(hash_t *h, uword key)
static uword mhash_set_tmp_key(mhash_t *h, const void *key)
uword() hash_key_sum_function_t(struct hash_header *, uword key)
#define hash_v3_finalize32(a, b, c)
void heap_dealloc(void *v, uword handle)
#define heap_alloc(v, size, handle)
static uword pointer_to_uword(const void *p)
static uword mhash_key_equal_c_string(hash_t *h, uword key1, uword key2)
#define hash_create2(_elts, _user, _value_bytes, _key_sum, _key_equal, _format_pair, _format_pair_arg)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword os_get_nthreads(void)
static_always_inline uword os_get_thread_index(void)
static void * mhash_key_to_mem(mhash_t *h, uword key)
#define MHASH_C_STRING_KEY
hash_pair_t * mhash_get_pair(mhash_t *h, const void *key)
#define MHASH_VEC_STRING_KEY
u8 * format_mhash_key(u8 *s, va_list *va)
static uword key_equal(hash_t *h, uword key1, uword key2)
#define hash_unset3(h, key, old_value)
static uword mhash_key_equal_vec_string(hash_t *h, uword key1, uword key2)