Skip to content

Commit b62548a

Browse files
committed
Add hooks for setting a custom rpl allocator
1 parent 152135c commit b62548a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

include/wums/hooks.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,19 @@ typedef enum wums_hook_type_t {
6464
WUMS_HOOK_ALL_APPLICATION_STARTS_DONE,
6565
WUMS_HOOK_ALL_APPLICATION_ENDS_DONE,
6666
WUMS_HOOK_ALL_APPLICATION_REQUESTS_EXIT_DONE,
67+
// Introduced in 0.3.4
68+
WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR, // for internal usage only
69+
WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY // for internal usage only
6770
} wums_hook_type_t;
6871

72+
typedef uint32_t (*WUMSRPLAllocatorAllocFn)(int32_t size, int32_t align, void **outAddr);
73+
typedef void (*WUMSRPLAllocatorFreeFn)(void *addr);
74+
75+
typedef struct wums_internal_custom_rpl_allocator_t {
76+
WUMSRPLAllocatorAllocFn allocFn;
77+
WUMSRPLAllocatorFreeFn freeFn;
78+
} wums_internal_custom_rpl_allocator_t;
79+
6980
typedef struct wums_hook_t {
7081
wums_hook_type_t type; /* Defines the type of the hook */
7182
const void *target; /* Address of our own, new function */
@@ -124,6 +135,16 @@ typedef struct wums_relocs_done_args_t {
124135
WUMS_HOOK_EX(WUMS_HOOK_ALL_APPLICATION_ENDS_DONE, __wums_all_ends_done); \
125136
void __wums_all_ends_done()
126137

138+
#define WUMS_INTERNAL_GET_CUSTOM_RPL_ALLOCATOR() \
139+
wums_internal_custom_rpl_allocator_t __wums_get_custom_rpl_allocator(void); \
140+
WUMS_HOOK_EX(WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR, __wums_get_custom_rpl_allocator); \
141+
wums_internal_custom_rpl_allocator_t __wums_get_custom_rpl_allocator()
142+
143+
#define WUMS_INTERNAL_HOOK_CLEAR_ALLOCATED_RPL_MEMORY() \
144+
void __wums_clear_allocated_rpl_memory(void); \
145+
WUMS_HOOK_EX(WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY, __wums_clear_allocated_rpl_memory); \
146+
void __wums_clear_allocated_rpl_memory()
147+
127148
#ifdef __cplusplus
128149
#define __EXTERN_C_MACRO extern "C"
129150
#else

0 commit comments

Comments
 (0)