Embedded Wireless Framework
ewf_allocator_threadx.h
Go to the documentation of this file.
1 /************************************************************************/
10 #ifndef __ewf_allocator_threadx__h__included__
11 #define __ewf_allocator_threadx__h__included__
12 
13 #include "ewf_allocator.h"
14 
15 #include "tx_api.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /************************************************************************/
31 typedef struct _ewf_allocator_threadx
32 {
33  TX_BLOCK_POOL block_pool;
34  VOID * block_pool_buffer_ptr;
35  ULONG pool_size;
38 
39 ewf_result ewf_allocator_threadx_start(ewf_allocator* allocator_ptr);
40 
41 ewf_result ewf_allocator_threadx_stop(ewf_allocator* allocator_ptr);
42 
43 ewf_result ewf_allocator_threadx_allocate(ewf_allocator* allocator_ptr, void** p);
44 
45 ewf_result ewf_allocator_threadx_release(ewf_allocator* allocator_ptr, void* p);
46 
47 #ifdef EWF_PARAMETER_CHECKING
48 #define EWF_ALLOCATOR_THREADX_INITIALIZE_HEADER(allocator_ptr) \
49 do { \
50 (allocator_ptr)->struct_magic = EWF_ALLOCATOR_STRUCT_MAGIC; \
51 (allocator_ptr)->struct_size = EWF_ALLOCATOR_STRUCT_SIZE; \
52 (allocator_ptr)->struct_version = EWF_ALLOCATOR_VERSION; \
53 (allocator_ptr)->struct_type = EWF_ALLOCATOR_TYPE_THREADX; \
54 } while(0)
55 #else
56 #define EWF_ALLOCATOR_THREADX_INITIALIZE_HEADER(allocator_ptr)
57 #endif /* EWF_PARAMETER_CHECKING */
58 
66 #define EWF_ALLOCATOR_THREADX_STATIC_DECLARE(allocator_ptr, allocator_name_symb, block_count_param, block_size_param) \
67 do { \
68 static ULONG block_pool_buffer__##allocator_name_symb[(block_count_param * (block_size_param + sizeof(void*))) / sizeof(ULONG)]; \
69 static ewf_allocator_threadx ewf_allocator_threadx__##allocator_name_symb = {0}; \
70 static ewf_allocator ewf_allocator__##allocator_name_symb = {0}; \
71 ewf_allocator_threadx__##allocator_name_symb.block_pool_buffer_ptr = block_pool_buffer__##allocator_name_symb; \
72 ewf_allocator_threadx__##allocator_name_symb.pool_size = sizeof(block_pool_buffer__##allocator_name_symb); \
73 ewf_allocator__##allocator_name_symb.block_count = (ULONG) block_count_param; \
74 ewf_allocator__##allocator_name_symb.block_size = (ULONG) block_size_param; \
75 ewf_allocator__##allocator_name_symb.start = ewf_allocator_threadx_start; \
76 ewf_allocator__##allocator_name_symb.stop = ewf_allocator_threadx_stop; \
77 ewf_allocator__##allocator_name_symb.allocate = ewf_allocator_threadx_allocate; \
78 ewf_allocator__##allocator_name_symb.release = ewf_allocator_threadx_release; \
79 ewf_allocator__##allocator_name_symb.implementation_ptr = &(ewf_allocator_threadx__##allocator_name_symb); \
80 allocator_ptr = &(ewf_allocator__##allocator_name_symb); \
81 EWF_ALLOCATOR_THREADX_INITIALIZE_HEADER(allocator_ptr); \
82 } while(0)
83 
84 /************************************************************************/
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* __ewf_allocator_threadx__h__included__ */
struct _ewf_allocator_threadx ewf_allocator_threadx
ThreadX allocator implementation type.
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
ThreadX allocator implementation type.
Definition: ewf_allocator_threadx.h:32
TX_BLOCK_POOL block_pool
Definition: ewf_allocator_threadx.h:33
ULONG pool_size
Definition: ewf_allocator_threadx.h:35
The allocator structure definition.
Definition: ewf_allocator.h:27