57 memset (sp, 0,
sizeof (sp[0]));
61 sp->
seed = 0xdeaddabe;
77 int level, comp_result;
95 _vec_len (sp->
path) = level + 1;
99 u32 next_index_this_level;
106 prefetch_elt = sp->
elts +
112 comp_result = (search_elt == head_elt) ? 1 :
137 if (comp_result == 0)
144 if (need_full_path && level > 0)
151 sp->
path[level] = search_elt - sp->
elts;
152 _vec_len (sp->
path) = level + 1;
159 sp->
path[level] = search_elt - sp->
elts;
163 if (next_index_this_level == (
u32)~0)
211 for (level = 0; level <
vec_len(sp->
path); level++)
214 u32 prev_elt_next_index_this_level;
219 (prev_elt_this_level, level);
256 return search_result;
261 for (level = 0; level <
vec_len (sp->
path)-1; level++)
264 u32 path_elt_next_index;
270 if (path_elt_next_index == del_elt - sp->
elts)
279 if (! (del_elt->
n.
next0[0] & 1))
288 int verbose = va_arg (*args,
int);
292 s =
format (s,
"slist 0x%x, %u items, branching_factor %.2f\n", sl,
304 if (verbose && head_elt->
n.
nexts[i] != (
u32)~0)
313 ASSERT(next_index != 0x7fffffff);
314 if (next_index == (
u32)~0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
word( clib_slist_key_compare_function_t)(void *key, u32 elt_pool_index)
clib_error_t * clib_slist_init(clib_slist_t *sp, f64 branching_factor, clib_slist_key_compare_function_t compare, format_function_t format_user_element)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
clib_slist_key_compare_function_t * compare
clib_slist_search_result_t
always_inline uword pool_elts(void *v)
static u32 clib_slist_get_next_at_level(clib_slist_elt_t *elt, int level)
#define pool_elt_at_index(p, i)
always_inline f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
static clib_slist_search_result_t slist_search_internal(clib_slist_t *sp, void *key, int need_full_path)
format_function_t * format_user_element
#define CLIB_PREFETCH(addr, size, type)
u8 * format_slist(u8 *s, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
void clib_slist_add(clib_slist_t *sp, void *key, u32 user_pool_index)
static void clib_slist_set_next_at_level(clib_slist_elt_t *elt, u32 index, int level)
u32 clib_slist_search(clib_slist_t *sp, void *key, u32 *ncompares)
union clib_slist_elt_t::@23 n
clib_slist_search_result_t clib_slist_del(clib_slist_t *sp, void *key)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define CLIB_CACHE_LINE_BYTES