Annotate callback functions with __stdcall on Windows

Fixes crash on exit on Windows x86.
This commit is contained in:
Frederik Seiffert 2021-08-07 22:19:09 +02:00 committed by Frederik Seiffert
parent 55da62c1c1
commit 35ef9423e0
3 changed files with 18 additions and 2 deletions

View file

@ -337,6 +337,13 @@ typedef struct {
# undef BOOL
#endif
/* Used to annotate callback functions with __stdcall on Windows. */
#if defined(_WIN32)
#define GS_WINAPI WINAPI
#else
#define GS_WINAPI
#endif
/* Include the blocks runtime header if it's available (It shouldn't matter
* that this doesn't work on compilers that don't support __has_include(),
* because they also don't support blocks).

View file

@ -256,10 +256,18 @@ static id gs_objc_proxy_lookup(id receiver, SEL op)
}
#endif
#ifdef __GNUSTEP_RUNTIME__
static void GS_WINAPI
exitedThread(void *slot)
{
free(slot);
}
#endif
+ (void) load
{
#ifdef __GNUSTEP_RUNTIME__
GS_THREAD_KEY_INIT(thread_slot_key, free);
GS_THREAD_KEY_INIT(thread_slot_key, exitedThread);
__objc_msg_forward3 = gs_objc_msg_forward3;
__objc_msg_forward2 = gs_objc_msg_forward2;
objc_proxy_lookup = gs_objc_proxy_lookup;

View file

@ -642,7 +642,8 @@ unregisterActiveThread(NSThread *thread);
* we must not call into NSAutoreleasePool unless the NSThread object can still
* be found using GSCurrentThread()
*/
static void exitedThread(void *thread)
static void GS_WINAPI
exitedThread(void *thread)
{
if (thread != defaultThread)
{