38 #ifndef included_clib_vec_bootstrap_h 39 #define included_clib_vec_bootstrap_h 63 #define VEC_NUMA_UNSPECIFIED (0xFF) 73 #define _vec_find(v) ((vec_header_t *) (v) - 1) 75 #define _vec_round_size(s) \ 76 (((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1)) 134 #define _vec_len(v) (_vec_find(v)->len) 142 #define vec_len(v) ((v) ? _vec_len(v) : 0) 151 #define _vec_numa(v) (_vec_find(v)->numa_id) 156 #define vec_numa(v) ((v) ? _vec_numa(v) : 0) 161 #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) 165 #define vec_capacity(v,b) \ 167 void * _vec_capacity_v = (void *) (v); \ 168 uword _vec_capacity_b = (b); \ 169 _vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \ 170 _vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \ 174 #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) 178 #define vec_set_len(v, l) do { \ 180 ASSERT((l) <= vec_max_len(v)); \ 181 CLIB_MEM_POISON_LEN((void *)(v), _vec_len(v) * sizeof((v)[0]), (l) * sizeof((v)[0])); \ 185 #define vec_set_len(v, l) do { \ 193 #define vec_reset_length(v) do { if (v) vec_set_len (v, 0); } while (0) 196 #define vec_end(v) ((v) + vec_len (v)) 199 #define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v)) 202 #define vec_elt_at_index(v,i) \ 204 ASSERT ((i) < vec_len (v)); \ 209 #define vec_elt(v,i) (vec_elt_at_index(v,i))[0] 212 #define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++) 215 #define vec_foreach_backwards(var,vec) \ 216 for (var = vec_end (vec) - 1; var >= (vec); var--) 219 #define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (var)++) 222 #define vec_foreach_index_backwards(var,v) \ 223 for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)
static uword vec_header_bytes(uword header_bytes)
u32 vec_len_not_inline(void *v)
static uword vec_get_numa(void *v)
return the NUMA index for a vector
static uword vec_aligned_header_bytes(uword header_bytes, uword align)
static void * vec_aligned_header(void *v, uword header_bytes, uword align)
static uword round_pow2(uword x, uword pow2)
static void * vec_aligned_header_end(void *v, uword header_bytes, uword align)
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
static void * vec_header_end(void *v, uword header_bytes)
Find the end of user vector header.