From c32082c94ae35f3b30258394dfc9e275c92aceae Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 27 Apr 2026 19:48:53 -0500 Subject: [PATCH] atomic: Fix and cleanup SDL_UnlockSpinlock() - Add missing SDL_MemoryBarrierRelease() in the generic codepath - Remove Watcom and MSVC x86/x64 cases which are now identical to the generic codepath - Fix Solaris barrier to ensure prior stores are visible before unlocking (cherry picked from commit 3ebdcc5b1ce83fcbd0c8b683c1ca0669fe829f2a) --- src/atomic/SDL_spinlock.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 3f58d26554..2f1f0ae3a5 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -192,20 +192,13 @@ void SDL_AtomicUnlock(SDL_SpinLock *lock) #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) _InterlockedExchange_rel(lock, 0); -#elif defined(_MSC_VER) - _ReadWriteBarrier(); - *lock = 0; - -#elif defined(__WATCOMC__) && defined(__386__) - SDL_CompilerBarrier(); - *lock = 0; - #elif defined(__SOLARIS__) /* Used for Solaris when not using gcc. */ - *lock = 0; membar_producer(); + *lock = 0; #else + SDL_MemoryBarrierRelease(); *lock = 0; #endif }