malloc: enable memory hotplug support
[dpdk.git] / lib / librte_eal / common / malloc_heap.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef MALLOC_HEAP_H_
6 #define MALLOC_HEAP_H_
7
8 #include <stdbool.h>
9
10 #include <rte_malloc.h>
11 #include <rte_malloc_heap.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 static inline unsigned
18 malloc_get_numa_socket(void)
19 {
20         unsigned socket_id = rte_socket_id();
21
22         if (socket_id == (unsigned)SOCKET_ID_ANY)
23                 return 0;
24
25         return socket_id;
26 }
27
28 void *
29 malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags,
30                 size_t align, size_t bound, bool contig);
31
32 int
33 malloc_heap_free(struct malloc_elem *elem);
34
35 int
36 malloc_heap_resize(struct malloc_elem *elem, size_t size);
37
38 int
39 malloc_heap_get_stats(struct malloc_heap *heap,
40                 struct rte_malloc_socket_stats *socket_stats);
41
42 void
43 malloc_heap_dump(struct malloc_heap *heap, FILE *f);
44
45 int
46 rte_eal_malloc_heap_init(void);
47
48 #ifdef __cplusplus
49 }
50 #endif
51
52 #endif /* MALLOC_HEAP_H_ */