FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
heap.h File Reference
+ Include dependency graph for heap.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  heap_elt_t
 
struct  heap_header_t
 

Macros

#define HEAP_ELT_FREE_BIT   (1 << 31)
 
#define HEAP_LOG2_SMALL_BINS   (5)
 
#define HEAP_SMALL_BINS   (1 << HEAP_LOG2_SMALL_BINS)
 
#define HEAP_N_BINS   (2 * HEAP_SMALL_BINS)
 
#define HEAP_IS_STATIC   (1)
 
#define HEAP_DATA_ALIGN   (CLIB_CACHE_LINE_BYTES)
 
#define heap_dup(v)   _heap_dup(v, vec_len (v) * sizeof (v[0]))
 
#define heap_new(v)   (v) = _heap_new (0, sizeof ((v)[0]))
 
#define heap_foreach(var, len, heap, body)
 
#define heap_elt_at_index(v, index)   vec_elt_at_index(v,index)
 
#define heap_elt_with_handle(v, handle)
 
#define heap_alloc_aligned(v, size, align, handle)
 
#define heap_alloc(v, size, handle)   heap_alloc_aligned((v),(size),0,(handle))
 
#define heap_free(v)   (v)=_heap_free(v)
 

Functions

static uword heap_is_free (heap_elt_t *e)
 
static uword heap_offset (heap_elt_t *e)
 
static heap_elt_theap_next (heap_elt_t *e)
 
static heap_elt_theap_prev (heap_elt_t *e)
 
static uword heap_elt_size (void *v, heap_elt_t *e)
 
static heap_header_theap_header (void *v)
 
static uword heap_header_bytes ()
 
static void heap_dup_header (heap_header_t *old, heap_header_t *new)
 
static uword heap_elts (void *v)
 
uword heap_bytes (void *v)
 
static void heap_set_format (void *v, format_function_t *format_elt)
 
static void heap_set_max_len (void *v, uword max_len)
 
static uword heap_get_max_len (void *v)
 
static void * heap_create_from_memory (void *memory, uword max_len, uword elt_bytes)
 
static heap_elt_theap_get_elt (void *v, uword handle)
 
static uword heap_is_free_handle (void *v, uword heap_handle)
 
uword heap_len (void *v, word handle)
 
void heap_dealloc (void *v, uword handle)
 
void heap_validate (void *v)
 
u8format_heap (u8 *s, va_list *va)
 

Macro Definition Documentation

◆ heap_alloc

#define heap_alloc (   v,
  size,
  handle 
)    heap_alloc_aligned((v),(size),0,(handle))

Definition at line 337 of file heap.h.

◆ heap_alloc_aligned

#define heap_alloc_aligned (   v,
  size,
  align,
  handle 
)
Value:
({ \
uword _o, _h; \
uword _a = (align); \
uword _s = (size); \
(v) = _heap_alloc ((v), _s, _a, sizeof ((v)[0]), &_o, &_h); \
(handle) = _h; \
_o; \
})
u32 size
Definition: vhost_user.h:106

Definition at line 327 of file heap.h.

◆ HEAP_DATA_ALIGN

#define HEAP_DATA_ALIGN   (CLIB_CACHE_LINE_BYTES)

Definition at line 158 of file heap.h.

◆ heap_dup

#define heap_dup (   v)    _heap_dup(v, vec_len (v) * sizeof (v[0]))

Definition at line 188 of file heap.h.

◆ heap_elt_at_index

#define heap_elt_at_index (   v,
  index 
)    vec_elt_at_index(v,index)

Definition at line 296 of file heap.h.

◆ HEAP_ELT_FREE_BIT

#define HEAP_ELT_FREE_BIT   (1 << 31)

Definition at line 82 of file heap.h.

◆ heap_elt_with_handle

#define heap_elt_with_handle (   v,
  handle 
)
Value:
({ \
heap_elt_t * _e = heap_get_elt ((v), (handle)); \
(v) + heap_offset (_e); \
})
static heap_elt_t * heap_get_elt(void *v, uword handle)
Definition: heap.h:299
static uword heap_offset(heap_elt_t *e)
Definition: heap.h:91

Definition at line 307 of file heap.h.

◆ heap_foreach

#define heap_foreach (   var,
  len,
  heap,
  body 
)
Value:
do { \
if (vec_len (heap) > 0) \
{ \
heap_header_t * _h = heap_header (heap); \
heap_elt_t * _e = _h->elts + _h->head; \
heap_elt_t * _end = _h->elts + _h->tail; \
while (1) \
{ \
if (! heap_is_free (_e)) \
{ \
(var) = (heap) + heap_offset (_e); \
(len) = heap_elt_size ((heap), _e); \
do { body; } while (0); \
} \
if (_e == _end) \
break; \
_e = heap_next (_e); \
} \
} \
} while (0)
static uword heap_is_free(heap_elt_t *e)
Definition: heap.h:85
static heap_elt_t * heap_next(heap_elt_t *e)
Definition: heap.h:97
u8 len
Definition: ip_types.api:92
static uword heap_offset(heap_elt_t *e)
Definition: heap.h:91
static uword heap_elt_size(void *v, heap_elt_t *e)
Definition: heap.h:109
static heap_header_t * heap_header(void *v)
Definition: heap.h:161
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 274 of file heap.h.

◆ heap_free

#define heap_free (   v)    (v)=_heap_free(v)

Definition at line 347 of file heap.h.

◆ HEAP_IS_STATIC

#define HEAP_IS_STATIC   (1)

Definition at line 154 of file heap.h.

◆ HEAP_LOG2_SMALL_BINS

#define HEAP_LOG2_SMALL_BINS   (5)

Definition at line 118 of file heap.h.

◆ HEAP_N_BINS

#define HEAP_N_BINS   (2 * HEAP_SMALL_BINS)

Definition at line 120 of file heap.h.

◆ heap_new

#define heap_new (   v)    (v) = _heap_new (0, sizeof ((v)[0]))

Definition at line 230 of file heap.h.

◆ HEAP_SMALL_BINS

#define HEAP_SMALL_BINS   (1 << HEAP_LOG2_SMALL_BINS)

Definition at line 119 of file heap.h.

Function Documentation

◆ format_heap()

u8* format_heap ( u8 s,
va_list *  va 
)

Definition at line 698 of file heap.c.

+ Here is the call graph for this function:

◆ heap_bytes()

uword heap_bytes ( void *  v)

Definition at line 632 of file heap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_create_from_memory()

static void* heap_create_from_memory ( void *  memory,
uword  max_len,
uword  elt_bytes 
)
inlinestatic

Definition at line 254 of file heap.h.

+ Here is the call graph for this function:

◆ heap_dealloc()

void heap_dealloc ( void *  v,
uword  handle 
)

Definition at line 500 of file heap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_dup_header()

static void heap_dup_header ( heap_header_t old,
heap_header_t new 
)
inlinestatic

Definition at line 173 of file heap.h.

◆ heap_elt_size()

static uword heap_elt_size ( void *  v,
heap_elt_t e 
)
inlinestatic

Definition at line 109 of file heap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_elts()

static uword heap_elts ( void *  v)
inlinestatic

Definition at line 212 of file heap.h.

+ Here is the call graph for this function:

◆ heap_get_elt()

static heap_elt_t* heap_get_elt ( void *  v,
uword  handle 
)
inlinestatic

Definition at line 299 of file heap.h.

+ Here is the call graph for this function:

◆ heap_get_max_len()

static uword heap_get_max_len ( void *  v)
inlinestatic

Definition at line 247 of file heap.h.

+ Here is the call graph for this function:

◆ heap_header()

static heap_header_t* heap_header ( void *  v)
inlinestatic

Definition at line 161 of file heap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_header_bytes()

static uword heap_header_bytes ( )
inlinestatic

Definition at line 167 of file heap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_is_free()

static uword heap_is_free ( heap_elt_t e)
inlinestatic

Definition at line 85 of file heap.h.

+ Here is the caller graph for this function:

◆ heap_is_free_handle()

static uword heap_is_free_handle ( void *  v,
uword  heap_handle 
)
inlinestatic

Definition at line 314 of file heap.h.

+ Here is the call graph for this function:

◆ heap_len()

uword heap_len ( void *  v,
word  handle 
)

Definition at line 601 of file heap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heap_next()

static heap_elt_t* heap_next ( heap_elt_t e)
inlinestatic

Definition at line 97 of file heap.h.

+ Here is the caller graph for this function:

◆ heap_offset()

static uword heap_offset ( heap_elt_t e)
inlinestatic

Definition at line 91 of file heap.h.

+ Here is the caller graph for this function:

◆ heap_prev()

static heap_elt_t* heap_prev ( heap_elt_t e)
inlinestatic

Definition at line 103 of file heap.h.

+ Here is the caller graph for this function:

◆ heap_set_format()

static void heap_set_format ( void *  v,
format_function_t format_elt 
)
inlinestatic

Definition at line 233 of file heap.h.

+ Here is the call graph for this function:

◆ heap_set_max_len()

static void heap_set_max_len ( void *  v,
uword  max_len 
)
inlinestatic

Definition at line 240 of file heap.h.

+ Here is the call graph for this function:

◆ heap_validate()

void heap_validate ( void *  v)

Definition at line 726 of file heap.c.

+ Here is the call graph for this function: