SDL: atomic: Use __atomic_signal_fence() for SDL_CompilerBarrier() (dd1e0)

From dd1e04eedfdac61d2e243a4bcf34d68224860a9e Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Sun, 26 Apr 2026 22:07:57 -0500
Subject: [PATCH] atomic: Use __atomic_signal_fence() for SDL_CompilerBarrier()

This is the (slightly) more standard way to accomplish it.
---
 include/SDL_atomic.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h
index 014829044348f..b6def304a2722 100644
--- a/include/SDL_atomic.h
+++ b/include/SDL_atomic.h
@@ -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()