xref: /f-stack/dpdk/lib/librte_acl/tb_mem.h (revision d30ea906)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _TB_MEM_H_
6 #define _TB_MEM_H_
7 
8 /**
9  * @file
10  *
11  * RTE ACL temporary (build phase) memory management.
12  * Contains structures and functions to manage temporary (used by build only)
13  * memory. Memory allocated in large blocks to speed 'free' when trie is
14  * destructed (finish of build phase).
15  */
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <rte_acl_osdep.h>
22 #include <setjmp.h>
23 
24 struct tb_mem_block {
25 	struct tb_mem_block *next;
26 	struct tb_mem_pool  *pool;
27 	size_t               size;
28 	uint8_t             *mem;
29 };
30 
31 struct tb_mem_pool {
32 	struct tb_mem_block *block;
33 	size_t               alignment;
34 	size_t               min_alloc;
35 	size_t               alloc;
36 	/* jump target in case of memory allocation failure. */
37 	sigjmp_buf           fail;
38 };
39 
40 void *tb_alloc(struct tb_mem_pool *pool, size_t size);
41 void tb_free_pool(struct tb_mem_pool *pool);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif /* _TB_MEM_H_ */
48