38 #ifndef included_clib_vec_bootstrap_h 39 #define included_clib_vec_bootstrap_h 74 #define _vec_find(v) ((vec_header_t *) (v) - 1) 76 #define _vec_round_size(s) \ 77 (((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1)) 135 #define _vec_len(v) (_vec_find(v)->len) 143 #define vec_len(v) ((v) ? _vec_len(v) : 0) 147 #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) 151 #define vec_capacity(v,b) \ 153 void * _vec_capacity_v = (void *) (v); \ 154 uword _vec_capacity_b = (b); \ 155 _vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \ 156 _vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \ 160 #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) 164 #define vec_set_len(v, l) do { \ 166 ASSERT((l) <= vec_max_len(v)); \ 167 CLIB_MEM_POISON_LEN((void *)(v), _vec_len(v) * sizeof((v)[0]), (l) * sizeof((v)[0])); \ 171 #define vec_set_len(v, l) do { \ 179 #define vec_reset_length(v) do { if (v) vec_set_len (v, 0); } while (0) 182 #define vec_end(v) ((v) + vec_len (v)) 185 #define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v)) 188 #define vec_elt_at_index(v,i) \ 190 ASSERT ((i) < vec_len (v)); \ 195 #define vec_elt(v,i) (vec_elt_at_index(v,i))[0] 198 #define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++) 201 #define vec_foreach_backwards(var,vec) \ 202 for (var = vec_end (vec) - 1; var >= (vec); var--) 205 #define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (var)++) 208 #define vec_foreach_index_backwards(var,v) \ 209 for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)
static uword vec_header_bytes(uword header_bytes)
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.