From 2f140c564f351db4348d02148c490c291325e6d8 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 3 Sep 2022 18:40:26 +0800 Subject: [PATCH] c11: Remove the code for Windows XP We already require Windows Vista or later before this commit; So the code for Windows XP can be removed. Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/c11/impl/threads_win32.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/c11/impl/threads_win32.c b/src/c11/impl/threads_win32.c index af2add0839f..e8f79b4e12c 100644 --- a/src/c11/impl/threads_win32.c +++ b/src/c11/impl/threads_win32.c @@ -44,29 +44,12 @@ /* Configuration macro: - - EMULATED_THREADS_USE_NATIVE_CALL_ONCE - Use native WindowsAPI one-time initialization function. - (requires WinVista or later) - Otherwise emulate by mtx_trylock() + *busy loop* for WinXP. - EMULATED_THREADS_TSS_DTOR_SLOTNUM Max registerable TSS dtor number. */ -#if _WIN32_WINNT >= 0x0600 -// Prefer native WindowsAPI on newer environment. -#if !defined(__MINGW32__) -#define EMULATED_THREADS_USE_NATIVE_CALL_ONCE -#endif -#endif #define EMULATED_THREADS_TSS_DTOR_SLOTNUM 64 // see TLS_MINIMUM_AVAILABLE -// check configuration -#if defined(EMULATED_THREADS_USE_NATIVE_CALL_ONCE) && (_WIN32_WINNT < 0x0600) -#error EMULATED_THREADS_USE_NATIVE_CALL_ONCE requires _WIN32_WINNT>=0x0600 -#endif - static_assert(sizeof(cnd_t) == sizeof(CONDITION_VARIABLE), "The size of cnd_t must equal to CONDITION_VARIABLE"); static_assert(sizeof(thrd_t) == sizeof(HANDLE), "The size of thrd_t must equal to HANDLE"); @@ -76,8 +59,6 @@ static_assert(sizeof(once_flag) == sizeof(INIT_ONCE), "The size of once_flag mus /* Implementation limits: - - Conditionally emulation for "Initialization functions" - (see EMULATED_THREADS_USE_NATIVE_CALL_ONCE macro) - Emulated `mtx_timelock()' with mtx_trylock() + *busy loop* */ @@ -122,7 +103,6 @@ static DWORD impl_abs2relmsec(const struct timespec *abs_time) return rel_ms; } -#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE struct impl_call_once_param { void (*func)(void); }; static BOOL CALLBACK impl_call_once_callback(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) { @@ -131,7 +111,6 @@ static BOOL CALLBACK impl_call_once_callback(PINIT_ONCE InitOnce, PVOID Paramete ((void)InitOnce); ((void)Context); // suppress warning return TRUE; } -#endif // ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE static struct impl_tss_dtor_entry { tss_t key; @@ -171,23 +150,9 @@ void call_once(once_flag *flag, void (*func)(void)) { assert(flag && func); -#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE - { struct impl_call_once_param param; param.func = func; InitOnceExecuteOnce((PINIT_ONCE)flag, impl_call_once_callback, (PVOID)¶m, NULL); - } -#else - if (InterlockedCompareExchangePointer((PVOID volatile *)&flag->status, (PVOID)1, (PVOID)0) == 0) { - (func)(); - InterlockedExchangePointer((PVOID volatile *)&flag->status, (PVOID)2); - } else { - while (flag->status == 1) { - // busy loop! - thrd_yield(); - } - } -#endif }