mirror of
https://github.com/wiiu-env/WiiUModuleSystem.git
synced 2026-08-20 23:44:03 -05:00
Move reent logic into WUMSLoader
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "defines/module_defines.h"
|
||||
#include "reent_internal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -68,7 +69,9 @@ typedef enum wums_hook_type_t {
|
||||
WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR, // for internal usage only
|
||||
WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY, // for internal usage only
|
||||
// Introduced in 0.3.5
|
||||
WUMS_HOOK_INIT_WUT_THREAD // for internal usage only
|
||||
WUMS_HOOK_INIT_WUT_THREAD, // for internal usage only
|
||||
// Introduced in 0.3.6
|
||||
WUMS_HOOK_INIT_REENT_FUNCTIONS // for internal usage only
|
||||
} wums_hook_type_t;
|
||||
|
||||
typedef uint32_t (*WUMSRPLAllocatorAllocFn)(int32_t size, int32_t align, void **outAddr);
|
||||
@@ -196,6 +199,14 @@ typedef struct wums_relocs_done_args_t {
|
||||
} \
|
||||
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_THREAD, on_init_wut_thread);
|
||||
|
||||
#define WUMS_INIT_REENT_FUNCTIONS() \
|
||||
__EXTERN_C_MACRO void WUMSReentAPI_InitInternal(wums_loader_init_reent_args_t_); \
|
||||
void wums_init_reent_functions(wums_loader_init_reent_args_t_ args); \
|
||||
WUMS_HOOK_EX(WUMS_HOOK_INIT_REENT_FUNCTIONS, wums_init_reent_functions); \
|
||||
void wums_init_reent_functions(wums_loader_init_reent_args_t_ args) { \
|
||||
return WUMSReentAPI_InitInternal(args); \
|
||||
}
|
||||
|
||||
#define WUMS_USE_WUT_SOCKETS() \
|
||||
__EXTERN_C_MACRO void __init_wut_socket(); \
|
||||
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_SOCKETS, __init_wut_socket); \
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUMS_VERSION "0.3.5"
|
||||
#define WUMS_VERSION "0.3.6"
|
||||
|
||||
#define WUMS_MODULE_EXPORT_NAME(__module_name) \
|
||||
WUMS_META(export_name, __module_name); \
|
||||
@@ -50,6 +50,7 @@ extern "C" {
|
||||
WUMS_USE_WUT_THREAD(); \
|
||||
WUMS___INIT_WRAPPER(); \
|
||||
WUMS___FINI_WRAPPER(); \
|
||||
WUMS_INIT_REENT_FUNCTIONS(); \
|
||||
WUMS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
||||
extern const char wums_meta_module_name[] WUMS_SECTION("meta"); \
|
||||
const char wums_meta_module_name[] = __module_name; \
|
||||
|
||||
35
include/wums/reent_internal.h
Normal file
35
include/wums/reent_internal.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum wums_loader_init_reent_errors_t_ {
|
||||
WUMSReent_ERROR_NONE = 0,
|
||||
WUMSReent_ERROR_GLOBAL_REENT_REQUESTED = 1,
|
||||
WUMSReent_ERROR_NO_THREAD = 2,
|
||||
} wums_loader_init_reent_errors_t_;
|
||||
|
||||
typedef void *(*WUMSReent_GetReentContext)(const void *moduleId, wums_loader_init_reent_errors_t_ *outError);
|
||||
typedef void *(*WUMSReent_SetSentinel)();
|
||||
typedef void (*WUMSReent_RestoreHead)(void *oldHead);
|
||||
typedef bool (*WUMSReent_AddReentContext)(const void *moduleId, void *reentPtr, void (*cleanupFn)(void *), void *oldHead);
|
||||
|
||||
typedef uint32_t WUMS_REENT_API_VERSION;
|
||||
|
||||
#define WUMS_REENT_CUR_API_VERSION 0x01
|
||||
|
||||
typedef struct wums_loader_init_reent_args_t_ {
|
||||
WUMS_REENT_API_VERSION version;
|
||||
WUMSReent_GetReentContext get_context_ptr;
|
||||
WUMSReent_SetSentinel set_sentinel_ptr;
|
||||
WUMSReent_RestoreHead restore_head_ptr;
|
||||
WUMSReent_AddReentContext add_reent_context_ptr;
|
||||
} wums_loader_init_reent_args_t_;
|
||||
|
||||
void WUMSReentAPI_InitInternal(wums_loader_init_reent_args_t_ args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,25 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
#define WUMS_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
|
||||
|
||||
#else // not __GNUC__ and not __clang__
|
||||
|
||||
#define WUMS_FORMAT_PRINTF(fmt, args)
|
||||
|
||||
#endif //__GNUC__ or __clang__
|
||||
|
||||
extern "C" void OSReport(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void OSReport(const char *fmt, ...) WUMS_FORMAT_PRINTF(1, 2);
|
||||
#endif
|
||||
|
||||
extern const char wums_meta_info_dump[];
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -31,4 +16,4 @@ extern const char wums_meta_info_dump[];
|
||||
#define WUMS_DEBUG_REPORT(fmt, ...)
|
||||
#endif
|
||||
|
||||
#define WUMS_DEBUG_WARN(fmt, ...) OSReport("[%s] " fmt, wums_meta_info_dump, ##__VA_ARGS__)
|
||||
#define WUMS_DEBUG_WARN(fmt, ...) OSReport("\033[33m[%s] " fmt "\033[0m", wums_meta_info_dump, ##__VA_ARGS__)
|
||||
Reference in New Issue
Block a user