Procházet zdrojové kódy

atomic: Use __atomic_signal_fence() for SDL_CompilerBarrier()

This is the (slightly) more standard way to accomplish it.
Cameron Gutman před 2 týdny
rodič
revize
dd1e04eedf
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      include/SDL_atomic.h

+ 3 - 1
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()