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) 150 #define _vec_numa(v) (_vec_find(v)->numa_id) 155 #define vec_numa(v) ((v) ? _vec_numa(v) : 0) 160 #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) 164 #define vec_capacity(v,b) \ 166 void * _vec_capacity_v = (void *) (v); \ 167 uword _vec_capacity_b = (b); \ 168 _vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \ 169 _vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \ 173 #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) 177 #define vec_set_len(v, l) do { \ 179 ASSERT((l) <= vec_max_len(v)); \ 180 CLIB_MEM_POISON_LEN((void *)(v), _vec_len(v) * sizeof((v)[0]), (l) * sizeof((v)[0])); \ 184 #define vec_set_len(v, l) do { \ 192 #define vec_reset_length(v) do { if (v) vec_set_len (v, 0); } while (0) 195 #define vec_end(v) ((v) + vec_len (v)) 198 #define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v)) 201 #define vec_elt_at_index(v,i) \ 203 ASSERT ((i) < vec_len (v)); \ 208 #define vec_elt(v,i) (vec_elt_at_index(v,i))[0] 211 #define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++) 214 #define vec_foreach_backwards(var,vec) \ 215 for (var = vec_end (vec) - 1; var >= (vec); var--) 218 #define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (var)++) 221 #define vec_foreach_index_backwards(var,v) \ 222 for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)
static uword vec_header_bytes(uword header_bytes)
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.