mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-26 12:59:18 +01:00
spinlock: Favor gcc-style atomics over MSVC interfaces.
This resolves a problem when using Clang on Windows. Fixes #4346.
This commit is contained in:
parent
9bcb5e7b94
commit
f4eb7f329e
@ -72,6 +72,9 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||||
|
return (__sync_lock_test_and_set(lock, 1) == 0);
|
||||||
|
|
||||||
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||||
return (_InterlockedExchange_acq(lock, 1) == 0);
|
return (_InterlockedExchange_acq(lock, 1) == 0);
|
||||||
|
|
||||||
@ -82,9 +85,6 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
#elif defined(__WATCOMC__) && defined(__386__)
|
#elif defined(__WATCOMC__) && defined(__386__)
|
||||||
return _SDL_xchg_watcom(lock, 1) == 0;
|
return _SDL_xchg_watcom(lock, 1) == 0;
|
||||||
|
|
||||||
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
|
||||||
return (__sync_lock_test_and_set(lock, 1) == 0);
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) && defined(__arm__) && \
|
#elif defined(__GNUC__) && defined(__arm__) && \
|
||||||
(defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || \
|
(defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || \
|
||||||
defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \
|
defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \
|
||||||
@ -176,8 +176,12 @@ SDL_AtomicLock(SDL_SpinLock *lock)
|
|||||||
void
|
void
|
||||||
SDL_AtomicUnlock(SDL_SpinLock *lock)
|
SDL_AtomicUnlock(SDL_SpinLock *lock)
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||||
|
__sync_lock_release(lock);
|
||||||
|
|
||||||
|
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||||
_InterlockedExchange_rel(lock, 0);
|
_InterlockedExchange_rel(lock, 0);
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
_ReadWriteBarrier();
|
_ReadWriteBarrier();
|
||||||
*lock = 0;
|
*lock = 0;
|
||||||
@ -186,9 +190,6 @@ SDL_AtomicUnlock(SDL_SpinLock *lock)
|
|||||||
SDL_CompilerBarrier ();
|
SDL_CompilerBarrier ();
|
||||||
*lock = 0;
|
*lock = 0;
|
||||||
|
|
||||||
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
|
||||||
__sync_lock_release(lock);
|
|
||||||
|
|
||||||
#elif defined(__SOLARIS__)
|
#elif defined(__SOLARIS__)
|
||||||
/* Used for Solaris when not using gcc. */
|
/* Used for Solaris when not using gcc. */
|
||||||
*lock = 0;
|
*lock = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user