FD.io VPP  v16.06
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

always_inline uword heap_is_free (heap_elt_t *e)
 
always_inline uword heap_offset (heap_elt_t *e)
 
always_inline heap_elt_theap_next (heap_elt_t *e)
 
always_inline heap_elt_theap_prev (heap_elt_t *e)
 
always_inline uword heap_elt_size (void *v, heap_elt_t *e)
 
always_inline heap_header_theap_header (void *v)
 
always_inline uword heap_header_bytes ()
 
always_inline void heap_dup_header (heap_header_t *old, heap_header_t *new)
 
always_inline uword heap_elts (void *v)
 
uword heap_bytes (void *v)
 
always_inline void heap_set_format (void *v, format_function_t *format_elt)
 
always_inline void heap_set_max_len (void *v, uword max_len)
 
always_inline uword heap_get_max_len (void *v)
 
always_inline voidheap_create_from_memory (void *memory, uword max_len, uword elt_bytes)
 
always_inline heap_elt_theap_get_elt (void *v, uword handle)
 
always_inline 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

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

Definition at line 309 of file heap.h.

#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:74
u64 uword
Definition: types.h:112

Definition at line 299 of file heap.h.

#define HEAP_DATA_ALIGN   (CLIB_CACHE_LINE_BYTES)

Definition at line 143 of file heap.h.

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

Definition at line 166 of file heap.h.

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

Definition at line 267 of file heap.h.

#define HEAP_ELT_FREE_BIT   (1 << 31)

Definition at line 81 of file heap.h.

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

Definition at line 278 of file heap.h.

#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)
always_inline heap_elt_t * heap_next(heap_elt_t *e)
Definition: heap.h:89
always_inline uword heap_is_free(heap_elt_t *e)
Definition: heap.h:83
always_inline heap_header_t * heap_header(void *v)
Definition: heap.h:145
always_inline uword heap_offset(heap_elt_t *e)
Definition: heap.h:86
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline uword heap_elt_size(void *v, heap_elt_t *e)
Definition: heap.h:95

Definition at line 245 of file heap.h.

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

Definition at line 319 of file heap.h.

#define HEAP_IS_STATIC   (1)

Definition at line 139 of file heap.h.

#define HEAP_LOG2_SMALL_BINS   (5)

Definition at line 104 of file heap.h.

#define HEAP_N_BINS   (2 * HEAP_SMALL_BINS)

Definition at line 106 of file heap.h.

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

Definition at line 204 of file heap.h.

#define HEAP_SMALL_BINS   (1 << HEAP_LOG2_SMALL_BINS)

Definition at line 105 of file heap.h.

Function Documentation

u8* format_heap ( u8 s,
va_list *  va 
)

Definition at line 669 of file heap.c.

+ Here is the call graph for this function:

uword heap_bytes ( void v)

Definition at line 605 of file heap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void* heap_create_from_memory ( void memory,
uword  max_len,
uword  elt_bytes 
)

Definition at line 225 of file heap.h.

+ Here is the call graph for this function:

void heap_dealloc ( void v,
uword  handle 
)

Definition at line 478 of file heap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void heap_dup_header ( heap_header_t old,
heap_header_t new 
)

Definition at line 151 of file heap.h.

always_inline uword heap_elt_size ( void v,
heap_elt_t e 
)

Definition at line 95 of file heap.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword heap_elts ( void v)

Definition at line 187 of file heap.h.

+ Here is the call graph for this function:

always_inline heap_elt_t* heap_get_elt ( void v,
uword  handle 
)

Definition at line 270 of file heap.h.

+ Here is the call graph for this function:

always_inline uword heap_get_max_len ( void v)

Definition at line 220 of file heap.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline heap_header_t* heap_header ( void v)

Definition at line 145 of file heap.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword heap_header_bytes ( )

Definition at line 148 of file heap.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword heap_is_free ( heap_elt_t e)

Definition at line 83 of file heap.h.

+ Here is the caller graph for this function:

always_inline uword heap_is_free_handle ( void v,
uword  heap_handle 
)

Definition at line 285 of file heap.h.

+ Here is the call graph for this function:

uword heap_len ( void v,
word  handle 
)

Definition at line 576 of file heap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline heap_elt_t* heap_next ( heap_elt_t e)

Definition at line 89 of file heap.h.

+ Here is the caller graph for this function:

always_inline uword heap_offset ( heap_elt_t e)

Definition at line 86 of file heap.h.

+ Here is the caller graph for this function:

always_inline heap_elt_t* heap_prev ( heap_elt_t e)

Definition at line 92 of file heap.h.

+ Here is the caller graph for this function:

always_inline void heap_set_format ( void v,
format_function_t format_elt 
)

Definition at line 207 of file heap.h.

+ Here is the call graph for this function:

always_inline void heap_set_max_len ( void v,
uword  max_len 
)

Definition at line 214 of file heap.h.

+ Here is the call graph for this function:

void heap_validate ( void v)

Definition at line 695 of file heap.c.

+ Here is the call graph for this function: