New upstream version 18.08
[deb_dpdk.git] / lib / librte_eal / common / include / rte_malloc_heap.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _RTE_MALLOC_HEAP_H_
6 #define _RTE_MALLOC_HEAP_H_
7
8 #include <stddef.h>
9 #include <sys/queue.h>
10 #include <rte_spinlock.h>
11 #include <rte_memory.h>
12
13 /* Number of free lists per heap, grouped by size. */
14 #define RTE_HEAP_NUM_FREELISTS  13
15
16 /* dummy definition, for pointers */
17 struct malloc_elem;
18
19 /**
20  * Structure to hold malloc heap
21  */
22 struct malloc_heap {
23         rte_spinlock_t lock;
24         LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS];
25         struct malloc_elem *volatile first;
26         struct malloc_elem *volatile last;
27
28         unsigned alloc_count;
29         size_t total_size;
30 } __rte_cache_aligned;
31
32 #endif /* _RTE_MALLOC_HEAP_H_ */