|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
61 #ifndef included_heap_h
62 #define included_heap_h
82 #define HEAP_ELT_FREE_BIT (1 << 31)
118 #define HEAP_LOG2_SMALL_BINS (5)
119 #define HEAP_SMALL_BINS (1 << HEAP_LOG2_SMALL_BINS)
120 #define HEAP_N_BINS (2 * HEAP_SMALL_BINS)
154 #define HEAP_IS_STATIC (1)
158 #define HEAP_DATA_ALIGN (CLIB_CACHE_LINE_BYTES)
184 new->small_free_elt_free_index =
vec_dup (
new->small_free_elt_free_index);
188 #define heap_dup(v) _heap_dup(v, vec_len (v) * sizeof (v[0]))
191 _heap_dup (
void *v_old,
uword v_bytes)
203 _vec_resize (v_new, _vec_len (v_old), v_bytes,
sizeof (
heap_header_t),
215 return h->used_count;
223 void *v = _vec_resize ((
void *) 0,
len, (
uword)
len * n_elt_bytes,
230 #define heap_new(v) (v) = _heap_new (0, sizeof ((v)[0]))
259 if (max_len * elt_bytes <
sizeof (
h[0]))
264 h->max_len = max_len;
265 h->elt_bytes = elt_bytes;
274 #define heap_foreach(var,len,heap,body) \
276 if (vec_len (heap) > 0) \
278 heap_header_t * _h = heap_header (heap); \
279 heap_elt_t * _e = _h->elts + _h->head; \
280 heap_elt_t * _end = _h->elts + _h->tail; \
283 if (! heap_is_free (_e)) \
285 (var) = (heap) + heap_offset (_e); \
286 (len) = heap_elt_size ((heap), _e); \
287 do { body; } while (0); \
291 _e = heap_next (_e); \
296 #define heap_elt_at_index(v,index) vec_elt_at_index(v,index)
307 #define heap_elt_with_handle(v,handle) \
309 heap_elt_t * _e = heap_get_elt ((v), (handle)); \
310 (v) + heap_offset (_e); \
327 #define heap_alloc_aligned(v,size,align,handle) \
330 uword _a = (align); \
332 (v) = _heap_alloc ((v), _s, _a, sizeof ((v)[0]), &_o, &_h); \
337 #define heap_alloc(v,size,handle) heap_alloc_aligned((v),(size),0,(handle))
345 void *_heap_free (
void *v);
347 #define heap_free(v) (v)=_heap_free(v)
static heap_elt_t * heap_get_elt(void *v, uword handle)
static uword heap_elts(void *v)
static void * heap_create_from_memory(void *memory, uword max_len, uword elt_bytes)
static uword heap_is_free_handle(void *v, uword heap_handle)
#define HEAP_ELT_FREE_BIT
static void heap_set_format(void *v, format_function_t *format_elt)
static uword heap_offset(heap_elt_t *e)
uword heap_len(void *v, word handle)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static heap_header_t * heap_header(void *v)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword heap_elt_size(void *v, heap_elt_t *e)
static void heap_set_max_len(void *v, uword max_len)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vhost_user_memory_t memory
static uword heap_get_max_len(void *v)
static heap_elt_t * heap_prev(heap_elt_t *e)
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
uword heap_bytes(void *v)
vl_api_cnat_endpoint_t new
template key/value backing page structure
u8 * format_heap(u8 *s, va_list *va)
static heap_elt_t * heap_next(heap_elt_t *e)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static uword heap_header_bytes()
static uword heap_is_free(heap_elt_t *e)
void heap_dealloc(void *v, uword handle)
static uword vec_header_bytes(uword header_bytes)
static void heap_dup_header(heap_header_t *old, heap_header_t *new)
void heap_validate(void *v)
#define clib_bitmap_dup(v)
Duplicate a bitmap.