From 65f03c5e6250ba193ee9a05e10242c320a594830 Mon Sep 17 00:00:00 2001 From: James Benton Date: Wed, 30 May 2018 13:10:38 +0100 Subject: [PATCH] coreinit: Add OSDynLoad_Error. --- include/coreinit/dynload.h | 52 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/include/coreinit/dynload.h b/include/coreinit/dynload.h index eed23d3..61c5373 100644 --- a/include/coreinit/dynload.h +++ b/include/coreinit/dynload.h @@ -13,35 +13,33 @@ extern "C" { #endif +typedef enum OSDynLoad_Error +{ + OS_DYNLOAD_OK = 0, + OS_DYNLOAD_OUT_OF_MEMORY = 0xBAD10002, + OS_DYNLOAD_INVALID_NOTIFY_PTR = 0xBAD1000E, + OS_DYNLOAD_INVALID_MODULE_NAME_PTR = 0xBAD1000F, + OS_DYNLOAD_INVALID_MODULE_NAME = 0xBAD10010, + OS_DYNLOAD_INVALID_ACQUIRE_PTR = 0xBAD10011, + OS_DYNLOAD_EMPTY_MODULE_NAME = 0xBAD10012, + OS_DYNLOAD_INVALID_ALLOCATOR_PTR = 0xBAD10017, + OS_DYNLOAD_OUT_OF_SYSTEM_MEMORY = 0xBAD1002F, + OS_DYNLOAD_TLS_ALLOCATOR_LOCKED = 0xBAD10031, +} OSDynLoad_Error; + typedef void *OSDynLoadModule; -typedef int (*OSDynLoadAllocFn)(int size, int align, void **outAddr); +typedef OSDynLoad_Error (*OSDynLoadAllocFn)(int32_t size, int32_t align, void **outAddr); typedef void (*OSDynLoadFreeFn)(void *addr); -/** - * Set the allocator function to use for dynamic loading. - */ -int32_t -OSDynLoad_SetAllocator(OSDynLoadAllocFn allocFn, - OSDynLoadFreeFn freeFn); - - -/** - * Get the allocator function used for dynamic loading. - */ -int32_t -OSDynLoad_GetAllocator(OSDynLoadAllocFn *outAllocFn, - OSDynLoadFreeFn *outFreeFn); - - /** * Load a module. * * If the module is already loaded, increase reference count. * Similar to LoadLibrary on Windows. */ -int32_t +OSDynLoad_Error OSDynLoad_Acquire(char const *name, OSDynLoadModule *outModule); @@ -51,7 +49,7 @@ OSDynLoad_Acquire(char const *name, * * Similar to GetProcAddress on Windows. */ -int32_t +OSDynLoad_Error OSDynLoad_FindExport(OSDynLoadModule module, BOOL isData, char const *name, @@ -67,6 +65,22 @@ OSDynLoad_FindExport(OSDynLoadModule module, void OSDynLoad_Release(OSDynLoadModule module); + +/** + * Set the allocator functions to use for dynamic loading. + */ +OSDynLoad_Error +OSDynLoad_SetAllocator(OSDynLoadAllocFn allocFn, + OSDynLoadFreeFn freeFn); + + +/** + * Get the allocator functions used for dynamic loading. + */ +OSDynLoad_Error +OSDynLoad_GetAllocator(OSDynLoadAllocFn *outAllocFn, + OSDynLoadFreeFn *outFreeFn); + #ifdef __cplusplus } #endif