atomic: Use __atomic_signal_fence() for SDL_CompilerBarrier()

This is the (slightly) more standard way to accomplish it.

(cherry picked from commit dd1e04eedf)
This commit is contained in:
Cameron Gutman 2026-04-26 22:07:57 -05:00
parent 01b0e1a407
commit 7b377a54b9

View file

@ -135,7 +135,9 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
* The compiler barrier prevents the compiler from reordering
* reads and writes to globally visible variables across the call.
*/
#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
#if _SDL_HAS_BUILTIN(__atomic_signal_fence) || (defined(__GNUC__) && (__GNUC__ >= 5))
#define SDL_CompilerBarrier() __atomic_signal_fence(__ATOMIC_SEQ_CST)
#elif defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
void _ReadWriteBarrier(void);
#pragma intrinsic(_ReadWriteBarrier)
#define SDL_CompilerBarrier() _ReadWriteBarrier()