mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-11-13 06:15:11 +01:00
Make sure wut_get_thread_specific has been overriden properly
This commit is contained in:
parent
0df3dd8066
commit
80a9893f56
@ -170,11 +170,22 @@ typedef struct wups_loader_hook_t {
|
||||
} \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_STDCPP, on_fini_wut_stdcpp)
|
||||
|
||||
#define WUPS___INIT_WRAPPER() \
|
||||
__EXTERN_C_MACRO void __init(); \
|
||||
void __init_wrapper() { \
|
||||
__init(); \
|
||||
} \
|
||||
#ifdef __cplusplus
|
||||
extern "C" uint32_t __attribute__((weak)) wut_get_thread_specific(int id);
|
||||
extern "C" const char wups_meta_info_linking_order[];
|
||||
#else
|
||||
extern uint32_t __attribute__((weak)) wut_get_thread_specific(int id);
|
||||
extern const char wups_meta_info_linking_order[];
|
||||
#endif
|
||||
|
||||
#define WUPS___INIT_WRAPPER() \
|
||||
__EXTERN_C_MACRO void __init(); \
|
||||
void __init_wrapper() { \
|
||||
if (wut_get_thread_specific(0x13371337) != 0x42424242) { \
|
||||
OSFatal(wups_meta_info_linking_order); \
|
||||
} \
|
||||
__init(); \
|
||||
} \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WRAPPER, __init_wrapper);
|
||||
|
||||
#define WUPS___FINI_WRAPPER() \
|
||||
|
@ -39,27 +39,31 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_VERSION_STR "0.7.1"
|
||||
#define WUPS_PLUGIN_NAME(__plugin_name) \
|
||||
WUPS_META(name, __plugin_name); \
|
||||
WUPS_META(wups, WUPS_VERSION_STR); \
|
||||
WUPS_USE_WUT_MALLOC(); \
|
||||
WUPS_USE_WUT_SOCKETS(); \
|
||||
WUPS_USE_WUT_NEWLIB(); \
|
||||
WUPS_USE_WUT_STDCPP(); \
|
||||
WUPS___INIT_WRAPPER(); \
|
||||
WUPS___FINI_WRAPPER(); \
|
||||
__EXTERN_C_MACRO void abort(); \
|
||||
__EXTERN_C_MACRO void OSFatal(const char *msg); \
|
||||
void abort() { \
|
||||
OSFatal(__plugin_name ": abort() called. Uncaught exception?"); \
|
||||
while (1) \
|
||||
; \
|
||||
} \
|
||||
WUPS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
||||
extern const char wups_meta_info_dump[] WUPS_SECTION("meta"); \
|
||||
const char wups_meta_info_dump[] = "(plugin: " __plugin_name ";" \
|
||||
"wups " WUPS_VERSION_STR ";" \
|
||||
"buildtime: " __DATE__ " " __TIME__ ")"
|
||||
#define WUPS_PLUGIN_NAME(__plugin_name) \
|
||||
WUPS_META(name, __plugin_name); \
|
||||
WUPS_META(wups, WUPS_VERSION_STR); \
|
||||
WUPS_USE_WUT_MALLOC(); \
|
||||
WUPS_USE_WUT_SOCKETS(); \
|
||||
WUPS_USE_WUT_NEWLIB(); \
|
||||
WUPS_USE_WUT_STDCPP(); \
|
||||
WUPS___INIT_WRAPPER(); \
|
||||
WUPS___FINI_WRAPPER(); \
|
||||
__EXTERN_C_MACRO void abort(); \
|
||||
__EXTERN_C_MACRO void OSFatal(const char *msg); \
|
||||
void abort() { \
|
||||
OSFatal(__plugin_name ": abort() called. Uncaught exception?"); \
|
||||
while (1) \
|
||||
; \
|
||||
} \
|
||||
WUPS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
||||
extern const char wups_meta_info_dump[] WUPS_SECTION("meta"); \
|
||||
const char wups_meta_info_dump[] = "(plugin: " __plugin_name ";" \
|
||||
"wups " WUPS_VERSION_STR ";" \
|
||||
"buildtime: " __DATE__ " " __TIME__ ")"; \
|
||||
extern const char wups_meta_info_linking_order[] WUPS_SECTION("meta"); \
|
||||
const char wups_meta_info_linking_order[] = "Loading \"" __plugin_name "\" failed.\n" \
|
||||
"Function \"wut_get_thread_specific\" returned unexpected value.\n" \
|
||||
"Please check linking order (expected \"-lwups -lwut\")";
|
||||
|
||||
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
|
||||
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
|
||||
|
@ -43,6 +43,8 @@ void *wups_get_thread_specific(__wut_thread_specific_id id) {
|
||||
return thread->reserved[3];
|
||||
} else if (id == WUT_THREAD_SPECIFIC_1) {
|
||||
return thread->reserved[4];
|
||||
} else if ((uint32_t) id == 0x13371337) { // Mechanism to detect if the function was overridden properly
|
||||
return (void *) 0x42424242;
|
||||
} else {
|
||||
OSReport("[%s] wups_get_thread_specific: invalid id\n", wups_meta_info_dump);
|
||||
OSFatal("wups_get_thread_specific: invalid id");
|
||||
|
Loading…
Reference in New Issue
Block a user