|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
41 #ifndef CLIB_VECTOR_GROW_BY_ONE
42 #define CLIB_VECTOR_GROW_BY_ONE 0
49 word length_increment,
55 uword old_alloc_bytes, new_alloc_bytes;
61 data_bytes += header_bytes;
77 v =
new + header_bytes;
78 _vec_len (v) = length_increment;
79 _vec_numa (v) = numa_id;
85 vh->
len += length_increment;
86 old = v - header_bytes;
94 if (data_bytes <= old_alloc_bytes)
102 #if CLIB_VECTOR_GROW_BY_ONE > 0
103 new_alloc_bytes = data_bytes;
105 new_alloc_bytes = (old_alloc_bytes * 3) / 2;
106 if (new_alloc_bytes < data_bytes)
107 new_alloc_bytes = data_bytes;
118 (
"vec_resize fails, length increment %d, data bytes %d, alignment %d",
119 length_increment, data_bytes, data_align);
131 memset (v + old_alloc_bytes, 0, new_alloc_bytes - old_alloc_bytes);
134 _vec_numa ((v + header_bytes)) = numa_id;
138 return v + header_bytes;
166 main (
int argc,
char *argv[])
168 word n = atoi (argv[1]);
176 FOO *foos = vec_init (FOO, 10), *
f;
182 for (
i = 0;
i < n;
i++)
#define VEC_NUMA_UNSPECIFIED
__clib_export void * vec_resize_allocate_memory(void *v, word length_increment, uword data_bytes, uword header_bytes, uword data_align, uword numa_id)
Low-level resize allocation function, usually not called directly.
#define CLIB_MEM_POISON(a, s)
static void clib_mem_free(void *p)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void * clib_mem_get_per_numa_heap(u32 numa_id)
static clib_mem_heap_t * clib_mem_get_per_cpu_heap(void)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static uword clib_mem_size(void *p)
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
sll srl srl sll sra u16x4 i
__clib_export void vec_free_not_inline(void *v)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define vec_free(V)
Free vector's memory (no header).
__clib_export u32 vec_len_not_inline(void *v)
int main(int argc, char **argv)
__clib_export uword clib_mem_is_vec_h(void *v, uword header_bytes)
Predicate function, says whether the supplied vector is a clib heap object (general version).
#define CLIB_MEM_UNPOISON(a, s)
static void * clib_mem_set_per_cpu_heap(void *new_heap)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
#define clib_panic(format, args...)
static uword vec_header_bytes(uword header_bytes)
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header,...
static uword clib_mem_is_heap_object(void *p)