mirror of
https://github.com/wiiu-env/WiiUModuleSystem.git
synced 2024-11-25 19:26:53 +01:00
Make sure wut_get_thread_specific has been overriden properly
This commit is contained in:
parent
84d6b15d83
commit
004f7f76e8
@ -165,11 +165,22 @@ typedef struct wums_relocs_done_args_t {
|
|||||||
__EXTERN_C_MACRO void __fini_wut_socket(); \
|
__EXTERN_C_MACRO void __fini_wut_socket(); \
|
||||||
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_SOCKETS, __fini_wut_socket)
|
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_SOCKETS, __fini_wut_socket)
|
||||||
|
|
||||||
#define WUMS___INIT_WRAPPER() \
|
#ifdef __cplusplus
|
||||||
__EXTERN_C_MACRO void __init(); \
|
extern "C" uint32_t __attribute__((weak)) wut_get_thread_specific(int id);
|
||||||
void __init_wrapper() { \
|
extern "C" const char wums_meta_info_linking_order[];
|
||||||
__init(); \
|
#else
|
||||||
} \
|
extern uint32_t __attribute__((weak)) wut_get_thread_specific(int id);
|
||||||
|
extern const char wums_meta_info_linking_order[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WUMS___INIT_WRAPPER() \
|
||||||
|
__EXTERN_C_MACRO void __init(); \
|
||||||
|
void __init_wrapper() { \
|
||||||
|
if (wut_get_thread_specific(0x13371337) != 0x42424242) { \
|
||||||
|
OSFatal(wums_meta_info_linking_order); \
|
||||||
|
} \
|
||||||
|
__init(); \
|
||||||
|
} \
|
||||||
WUMS_HOOK_EX(WUMS_HOOK_INIT_WRAPPER, __init_wrapper);
|
WUMS_HOOK_EX(WUMS_HOOK_INIT_WRAPPER, __init_wrapper);
|
||||||
|
|
||||||
#define WUMS___FINI_WRAPPER() \
|
#define WUMS___FINI_WRAPPER() \
|
||||||
|
@ -41,26 +41,30 @@ extern "C" {
|
|||||||
|
|
||||||
#define WUMS_VERSION "0.3.2"
|
#define WUMS_VERSION "0.3.2"
|
||||||
|
|
||||||
#define WUMS_MODULE_EXPORT_NAME(__module_name) \
|
#define WUMS_MODULE_EXPORT_NAME(__module_name) \
|
||||||
WUMS_META(export_name, __module_name); \
|
WUMS_META(export_name, __module_name); \
|
||||||
WUMS_META(wums, WUMS_VERSION); \
|
WUMS_META(wums, WUMS_VERSION); \
|
||||||
WUMS_USE_WUT_MALLOC(); \
|
WUMS_USE_WUT_MALLOC(); \
|
||||||
WUMS_USE_WUT_SOCKETS(); \
|
WUMS_USE_WUT_SOCKETS(); \
|
||||||
WUMS_USE_WUT_NEWLIB(); \
|
WUMS_USE_WUT_NEWLIB(); \
|
||||||
WUMS_USE_WUT_STDCPP(); \
|
WUMS_USE_WUT_STDCPP(); \
|
||||||
WUMS___INIT_WRAPPER(); \
|
WUMS___INIT_WRAPPER(); \
|
||||||
WUMS___FINI_WRAPPER(); \
|
WUMS___FINI_WRAPPER(); \
|
||||||
__EXTERN_C_MACRO void abort(); \
|
__EXTERN_C_MACRO void abort(); \
|
||||||
void abort() { \
|
void abort() { \
|
||||||
OSFatal(__module_name ": abort() called. Uncaught exception?"); \
|
OSFatal(__module_name ": abort() called. Uncaught exception?"); \
|
||||||
while (1) \
|
while (1) \
|
||||||
; \
|
; \
|
||||||
} \
|
} \
|
||||||
WUMS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
WUMS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
||||||
extern const char wums_meta_info_dump[] WUMS_SECTION("meta"); \
|
extern const char wums_meta_info_dump[] WUMS_SECTION("meta"); \
|
||||||
const char wums_meta_info_dump[] = "(module: " __module_name ";" \
|
const char wums_meta_info_dump[] = "(module: " __module_name ";" \
|
||||||
"wums " WUMS_VERSION ";" \
|
"wums " WUMS_VERSION ";" \
|
||||||
"buildtime: " __DATE__ " " __TIME__ ")"
|
"buildtime: " __DATE__ " " __TIME__ ")"; \
|
||||||
|
extern const char wums_meta_info_linking_order[] WUMS_SECTION("meta"); \
|
||||||
|
const char wums_meta_info_linking_order[] = "Loading module \"" __module_name "\" failed.\n" \
|
||||||
|
"Function \"wut_get_thread_specific\" returned unexpected value.\n" \
|
||||||
|
"Please check linking order (expected \"-lwums -lwut\")";
|
||||||
|
|
||||||
#define WUMS_MODULE_AUTHOR(x) WUMS_META(author, x)
|
#define WUMS_MODULE_AUTHOR(x) WUMS_META(author, x)
|
||||||
#define WUMS_MODULE_VERSION(x) WUMS_META(version, x)
|
#define WUMS_MODULE_VERSION(x) WUMS_META(version, x)
|
||||||
|
@ -43,6 +43,8 @@ void *wums_get_thread_specific(__wut_thread_specific_id id) {
|
|||||||
return thread->reserved[3];
|
return thread->reserved[3];
|
||||||
} else if (id == WUT_THREAD_SPECIFIC_1) {
|
} else if (id == WUT_THREAD_SPECIFIC_1) {
|
||||||
return thread->reserved[4];
|
return thread->reserved[4];
|
||||||
|
} else if ((uint32_t) id == 0x13371337) { // Mechanism to detect if the function was overridden properly
|
||||||
|
return (void *) 0x42424242;
|
||||||
} else {
|
} else {
|
||||||
OSReport("[%s] wums_get_thread_specific: invalid id\n", wums_meta_info_dump);
|
OSReport("[%s] wums_get_thread_specific: invalid id\n", wums_meta_info_dump);
|
||||||
OSFatal("wums_get_thread_specific: invalid id");
|
OSFatal("wums_get_thread_specific: invalid id");
|
||||||
|
Loading…
Reference in New Issue
Block a user