mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-23 15:49:16 +02:00
gthread-win32: use __stdcall markers where needed
The "unknown reason" that the native thread implementation was broken is because functions in kernel32.dll are (obviously) following Microsoft's __stdcall ABI, not the GCC ABI. Change our function pointers to be __stdcall pointers and change our emulated implementation to match.
This commit is contained in:
parent
835c9b75c8
commit
e00bcfcdec
@ -99,22 +99,22 @@ g_thread_abort (gint status,
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
void (* CallThisOnThreadExit) (void); /* fake */
|
void (__stdcall * CallThisOnThreadExit) (void); /* fake */
|
||||||
|
|
||||||
void (* InitializeSRWLock) (gpointer lock);
|
void (__stdcall * InitializeSRWLock) (gpointer lock);
|
||||||
void (* DeleteSRWLock) (gpointer lock); /* fake */
|
void (__stdcall * DeleteSRWLock) (gpointer lock); /* fake */
|
||||||
void (* AcquireSRWLockExclusive) (gpointer lock);
|
void (__stdcall * AcquireSRWLockExclusive) (gpointer lock);
|
||||||
BOOLEAN (* TryAcquireSRWLockExclusive) (gpointer lock);
|
BOOLEAN (__stdcall * TryAcquireSRWLockExclusive) (gpointer lock);
|
||||||
void (* ReleaseSRWLockExclusive) (gpointer lock);
|
void (__stdcall * ReleaseSRWLockExclusive) (gpointer lock);
|
||||||
|
|
||||||
void (* InitializeConditionVariable) (gpointer cond);
|
void (__stdcall * InitializeConditionVariable) (gpointer cond);
|
||||||
void (* DeleteConditionVariable) (gpointer cond); /* fake */
|
void (__stdcall * DeleteConditionVariable) (gpointer cond); /* fake */
|
||||||
BOOL (* SleepConditionVariableSRW) (gpointer cond,
|
BOOL (__stdcall * SleepConditionVariableSRW) (gpointer cond,
|
||||||
gpointer lock,
|
gpointer lock,
|
||||||
DWORD timeout,
|
DWORD timeout,
|
||||||
ULONG flags);
|
ULONG flags);
|
||||||
void (* WakeAllConditionVariable) (gpointer cond);
|
void (__stdcall * WakeAllConditionVariable) (gpointer cond);
|
||||||
void (* WakeConditionVariable) (gpointer cond);
|
void (__stdcall * WakeConditionVariable) (gpointer cond);
|
||||||
} GThreadImplVtable;
|
} GThreadImplVtable;
|
||||||
|
|
||||||
static GThreadImplVtable g_thread_impl_vtable;
|
static GThreadImplVtable g_thread_impl_vtable;
|
||||||
@ -534,7 +534,7 @@ g_thread_xp_waiter_get (void)
|
|||||||
return waiter;
|
return waiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_CallThisOnThreadExit (void)
|
g_thread_xp_CallThisOnThreadExit (void)
|
||||||
{
|
{
|
||||||
GThreadXpWaiter *waiter;
|
GThreadXpWaiter *waiter;
|
||||||
@ -555,13 +555,13 @@ typedef struct
|
|||||||
CRITICAL_SECTION critical_section;
|
CRITICAL_SECTION critical_section;
|
||||||
} GThreadSRWLock;
|
} GThreadSRWLock;
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_InitializeSRWLock (gpointer mutex)
|
g_thread_xp_InitializeSRWLock (gpointer mutex)
|
||||||
{
|
{
|
||||||
*(GThreadSRWLock * volatile *) mutex = NULL;
|
*(GThreadSRWLock * volatile *) mutex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_DeleteSRWLock (gpointer mutex)
|
g_thread_xp_DeleteSRWLock (gpointer mutex)
|
||||||
{
|
{
|
||||||
GThreadSRWLock *lock = *(GThreadSRWLock * volatile *) mutex;
|
GThreadSRWLock *lock = *(GThreadSRWLock * volatile *) mutex;
|
||||||
@ -573,7 +573,7 @@ g_thread_xp_DeleteSRWLock (gpointer mutex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GThreadSRWLock *
|
static GThreadSRWLock * __stdcall
|
||||||
g_thread_xp_get_srwlock (GThreadSRWLock * volatile *lock)
|
g_thread_xp_get_srwlock (GThreadSRWLock * volatile *lock)
|
||||||
{
|
{
|
||||||
GThreadSRWLock *result;
|
GThreadSRWLock *result;
|
||||||
@ -603,7 +603,7 @@ g_thread_xp_get_srwlock (GThreadSRWLock * volatile *lock)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_AcquireSRWLockExclusive (gpointer mutex)
|
g_thread_xp_AcquireSRWLockExclusive (gpointer mutex)
|
||||||
{
|
{
|
||||||
GThreadSRWLock *lock = g_thread_xp_get_srwlock (mutex);
|
GThreadSRWLock *lock = g_thread_xp_get_srwlock (mutex);
|
||||||
@ -611,7 +611,7 @@ g_thread_xp_AcquireSRWLockExclusive (gpointer mutex)
|
|||||||
EnterCriticalSection (&lock->critical_section);
|
EnterCriticalSection (&lock->critical_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN __stdcall
|
||||||
g_thread_xp_TryAcquireSRWLockExclusive (gpointer mutex)
|
g_thread_xp_TryAcquireSRWLockExclusive (gpointer mutex)
|
||||||
{
|
{
|
||||||
GThreadSRWLock *lock = g_thread_xp_get_srwlock (mutex);
|
GThreadSRWLock *lock = g_thread_xp_get_srwlock (mutex);
|
||||||
@ -619,7 +619,7 @@ g_thread_xp_TryAcquireSRWLockExclusive (gpointer mutex)
|
|||||||
return TryEnterCriticalSection (&lock->critical_section);
|
return TryEnterCriticalSection (&lock->critical_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_ReleaseSRWLockExclusive (gpointer mutex)
|
g_thread_xp_ReleaseSRWLockExclusive (gpointer mutex)
|
||||||
{
|
{
|
||||||
GThreadSRWLock *lock = *(GThreadSRWLock * volatile *) mutex;
|
GThreadSRWLock *lock = *(GThreadSRWLock * volatile *) mutex;
|
||||||
@ -638,13 +638,13 @@ typedef struct
|
|||||||
volatile GThreadXpWaiter **last_ptr;
|
volatile GThreadXpWaiter **last_ptr;
|
||||||
} GThreadXpCONDITION_VARIABLE;
|
} GThreadXpCONDITION_VARIABLE;
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_InitializeConditionVariable (gpointer cond)
|
g_thread_xp_InitializeConditionVariable (gpointer cond)
|
||||||
{
|
{
|
||||||
*(GThreadXpCONDITION_VARIABLE * volatile *) cond = NULL;
|
*(GThreadXpCONDITION_VARIABLE * volatile *) cond = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_DeleteConditionVariable (gpointer cond)
|
g_thread_xp_DeleteConditionVariable (gpointer cond)
|
||||||
{
|
{
|
||||||
GThreadXpCONDITION_VARIABLE *cv = *(GThreadXpCONDITION_VARIABLE * volatile *) cond;
|
GThreadXpCONDITION_VARIABLE *cv = *(GThreadXpCONDITION_VARIABLE * volatile *) cond;
|
||||||
@ -653,7 +653,7 @@ g_thread_xp_DeleteConditionVariable (gpointer cond)
|
|||||||
free (cv);
|
free (cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GThreadXpCONDITION_VARIABLE *
|
static GThreadXpCONDITION_VARIABLE * __stdcall
|
||||||
g_thread_xp_get_condition_variable (GThreadXpCONDITION_VARIABLE * volatile *cond)
|
g_thread_xp_get_condition_variable (GThreadXpCONDITION_VARIABLE * volatile *cond)
|
||||||
{
|
{
|
||||||
GThreadXpCONDITION_VARIABLE *result;
|
GThreadXpCONDITION_VARIABLE *result;
|
||||||
@ -685,7 +685,7 @@ g_thread_xp_get_condition_variable (GThreadXpCONDITION_VARIABLE * volatile *cond
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL __stdcall
|
||||||
g_thread_xp_SleepConditionVariableSRW (gpointer cond,
|
g_thread_xp_SleepConditionVariableSRW (gpointer cond,
|
||||||
gpointer mutex,
|
gpointer mutex,
|
||||||
DWORD timeout,
|
DWORD timeout,
|
||||||
@ -713,7 +713,7 @@ g_thread_xp_SleepConditionVariableSRW (gpointer cond,
|
|||||||
return status == WAIT_OBJECT_0;
|
return status == WAIT_OBJECT_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_WakeConditionVariable (gpointer cond)
|
g_thread_xp_WakeConditionVariable (gpointer cond)
|
||||||
{
|
{
|
||||||
GThreadXpCONDITION_VARIABLE *cv = g_thread_xp_get_condition_variable (cond);
|
GThreadXpCONDITION_VARIABLE *cv = g_thread_xp_get_condition_variable (cond);
|
||||||
@ -733,7 +733,7 @@ g_thread_xp_WakeConditionVariable (gpointer cond)
|
|||||||
SetEvent (waiter->event);
|
SetEvent (waiter->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __stdcall
|
||||||
g_thread_xp_WakeAllConditionVariable (gpointer cond)
|
g_thread_xp_WakeAllConditionVariable (gpointer cond)
|
||||||
{
|
{
|
||||||
GThreadXpCONDITION_VARIABLE *cv = g_thread_xp_get_condition_variable (cond);
|
GThreadXpCONDITION_VARIABLE *cv = g_thread_xp_get_condition_variable (cond);
|
||||||
@ -854,12 +854,9 @@ g_thread_lookup_native_funcs (void)
|
|||||||
G_GNUC_INTERNAL void
|
G_GNUC_INTERNAL void
|
||||||
g_thread_DllMain (void)
|
g_thread_DllMain (void)
|
||||||
{
|
{
|
||||||
/* XXX This is broken right now for some unknown reason...
|
|
||||||
|
|
||||||
if (g_thread_lookup_native_funcs ())
|
if (g_thread_lookup_native_funcs ())
|
||||||
fprintf (stderr, "(debug) GThread using native mode\n");
|
fprintf (stderr, "(debug) GThread using native mode\n");
|
||||||
else
|
else
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(debug) GThread using Windows XP mode\n");
|
fprintf (stderr, "(debug) GThread using Windows XP mode\n");
|
||||||
g_thread_xp_init ();
|
g_thread_xp_init ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user