Atomic_Win32: Replace deprecated (and since been removed) barrier intrinsics

As of VS 15.7, these seem to have been removed. Given we shouldn't have
been using these for some time, just replace them with the standard
library equivalent.

This fixes building on Windows with VS 15.7
This commit is contained in:
Lioncash 2018-05-09 11:33:11 -04:00
parent 5cd02f0853
commit 593bad3253
1 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@
#include <Windows.h> #include <Windows.h>
#include <atomic>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
// Atomic operations are performed in a single step by the CPU. It is // Atomic operations are performed in a single step by the CPU. It is
@ -64,8 +65,10 @@ inline T AtomicLoad(volatile T& src)
template <typename T> template <typename T>
inline T AtomicLoadAcquire(volatile T& src) inline T AtomicLoadAcquire(volatile T& src)
{ {
T result = src; // 32-bit reads are always atomic. // 32-bit reads are always atomic.
_ReadBarrier(); // Compiler instruction only. x86 loads always have acquire semantics. T result = src;
// Compiler instruction only. x86 loads always have acquire semantics.
std::atomic_thread_fence(std::memory_order_acquire);
return result; return result;
} }
@ -78,7 +81,8 @@ inline void AtomicStore(volatile T& dest, U value)
template <typename T, typename U> template <typename T, typename U>
inline void AtomicStoreRelease(volatile T& dest, U value) inline void AtomicStoreRelease(volatile T& dest, U value)
{ {
_WriteBarrier(); // Compiler instruction only. x86 stores always have release semantics. // Compiler instruction only. x86 stores always have release semantics.
std::atomic_thread_fence(std::memory_order_release);
dest = (T)value; // 32-bit writes are always atomic. dest = (T)value; // 32-bit writes are always atomic.
} }