38 #ifndef included_clib_vec_bootstrap_h 39 #define included_clib_vec_bootstrap_h 72 #define _vec_find(v) ((vec_header_t *) (v) - 1) 74 #define _vec_round_size(s) \ 75 (((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1)) 122 #define _vec_len(v) (_vec_find(v)->len) 130 #define vec_len(v) ((v) ? _vec_len(v) : 0) 136 #define vec_reset_length(v) do { if (v) _vec_len (v) = 0; } while (0) 140 #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) 144 #define vec_capacity(v,b) \ 146 void * _vec_capacity_v = (void *) (v); \ 147 uword _vec_capacity_b = (b); \ 148 _vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \ 149 _vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \ 153 #define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0])) 156 #define vec_end(v) ((v) + vec_len (v)) 159 #define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v)) 162 #define vec_elt_at_index(v,i) \ 164 ASSERT ((i) < vec_len (v)); \ 169 #define vec_elt(v,i) (vec_elt_at_index(v,i))[0] 172 #define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++) 175 #define vec_foreach_backwards(var,vec) \ 176 for (var = vec_end (vec) - 1; var >= (vec); var--) 179 #define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (var)++) always_inline uword round_pow2(uword x, uword pow2)
always_inline void * vec_aligned_header(void *v, uword header_bytes, uword align)
always_inline void * vec_aligned_header_end(void *v, uword header_bytes, uword align)
always_inline void * vec_header_end(void *v, uword header_bytes)
Find the end of user vector header.
always_inline void * vec_header(void *v, uword header_bytes)
Find a user vector header.
always_inline uword vec_aligned_header_bytes(uword header_bytes, uword align)
always_inline uword vec_header_bytes(uword header_bytes)