mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
atomic: Use __atomic_thread_fence() when available
This avoids requiring inline assembly for each architecture.
It also fixes some weakly ordered architectures which lacked
said inline assembly (RISC-V, MIPS, LoongArch, etc) and were
thus disasterously broken.
(cherry picked from commit c3b0e62850)
This commit is contained in:
parent
f32c6d977c
commit
4bce8906fc
1 changed files with 4 additions and 1 deletions
|
|
@ -174,7 +174,10 @@ extern __inline void SDL_CompilerBarrier(void);
|
|||
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
|
||||
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
|
||||
|
||||
#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
#if _SDL_HAS_BUILTIN(__atomic_thread_fence) || (defined(__GNUC__) && (__GNUC__ >= 5))
|
||||
#define SDL_MemoryBarrierRelease() __atomic_thread_fence(__ATOMIC_RELEASE)
|
||||
#define SDL_MemoryBarrierAcquire() __atomic_thread_fence(__ATOMIC_ACQUIRE)
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")
|
||||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")
|
||||
#elif defined(__GNUC__) && defined(__aarch64__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue