瀏覽代碼

atomic: Fix and cleanup SDL_UnlockSpinlock()

- Add missing SDL_MemoryBarrierRelease() in the generic codepath
- Remove MSVC x86/x64 case which is now identical to the generic codepath
- Fix Solaris barrier to ensure prior stores are visible before unlocking
Cameron Gutman 2 周之前
父節點
當前提交
95ae0c194e
共有 1 個文件被更改,包括 2 次插入5 次删除
  1. 2 5
      src/atomic/SDL_spinlock.c

+ 2 - 5
src/atomic/SDL_spinlock.c

@@ -171,16 +171,13 @@ void SDL_UnlockSpinlock(SDL_SpinLock *lock)
     SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
     SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
     _InterlockedExchange_rel((long *)lock, 0);
     _InterlockedExchange_rel((long *)lock, 0);
 
 
-#elif defined(_MSC_VER)
-    _ReadWriteBarrier();
-    *lock = 0;
-
 #elif defined(SDL_PLATFORM_SOLARIS)
 #elif defined(SDL_PLATFORM_SOLARIS)
     // Used for Solaris when not using gcc.
     // Used for Solaris when not using gcc.
-    *lock = 0;
     membar_producer();
     membar_producer();
+    *lock = 0;
 
 
 #else
 #else
+    SDL_MemoryBarrierRelease();
     *lock = 0;
     *lock = 0;
 #endif
 #endif
 }
 }