38 #ifndef included_clib_vec_bootstrap_h 39 #define included_clib_vec_bootstrap_h 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) 148 #define vec_reset_length(v) do { if (v) _vec_len (v) = 0; } while (0) 152 #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) 156 #define vec_capacity(v,b) \ 158 void * _vec_capacity_v = (void *) (v); \ 159 uword _vec_capacity_b = (b); \ 160 _vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \ 161 _vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \ 165 #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) 168 #define vec_end(v) ((v) + vec_len (v)) 171 #define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v)) 174 #define vec_elt_at_index(v,i) \ 176 ASSERT ((i) < vec_len (v)); \ 181 #define vec_elt(v,i) (vec_elt_at_index(v,i))[0] 184 #define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++) 187 #define vec_foreach_backwards(var,vec) \ 188 for (var = vec_end (vec) - 1; var >= (vec); var--) 191 #define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (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.