16 #ifndef included_ring_h 17 #define included_ring_h 41 v = _vec_resize ((
void *) 0,
53 #define clib_ring_new_aligned(ring, size, align) \ 54 { clib_ring_new_inline ((void **)&(ring), sizeof(ring[0]), size, align); } 56 #define clib_ring_new(ring, size) \ 57 { clib_ring_new_inline ((void **)&(ring), sizeof(ring[0]), size, 0);} 59 #define clib_ring_free(f) vec_free_h((f), sizeof(clib_ring_header_t)) 76 if (h->
n_enq == _vec_len (v))
81 if (h->
next == _vec_len (v))
88 slot = h->
next == 0 ? _vec_len (v) - 1 : h->
next - 1;
91 return (
void *) ((
u8 *) v + elt_bytes * slot);
94 #define clib_ring_enq(ring) \ 95 clib_ring_get_last_inline (ring, sizeof(ring[0]), 1) 97 #define clib_ring_get_last(ring) \ 98 clib_ring_get_last_inline (ring, sizeof(ring[0]), 0) 110 slot = _vec_len (v) + h->
next - h->
n_enq;
117 return (
void *) ((
u8 *) v + elt_bytes * slot);
120 #define clib_ring_deq(ring) \ 121 clib_ring_get_first_inline (ring, sizeof(ring[0]), 1) 123 #define clib_ring_get_first(ring) \ 124 clib_ring_get_first_inline (ring, sizeof(ring[0]), 0)
static void * vec_aligned_header(void *v, uword header_bytes, uword align)
static u32 clib_ring_n_enq(void *v)
static void clib_ring_new_inline(void **p, u32 elt_bytes, u32 size, u32 align)
static clib_ring_header_t * clib_ring_header(void *v)
static void * clib_ring_get_first_inline(void *v, u32 elt_bytes, int dequeue)
static void * clib_ring_get_last_inline(void *v, u32 elt_bytes, int enqueue)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".