aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Kernel/OVR_Atomic.h
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-09-04 14:32:18 -0700
committerBrad Davis <[email protected]>2014-09-04 14:32:18 -0700
commit32dc394487af8e4fb1b43fb852f1d5448eaf7f31 (patch)
treebe53f49e96e8e2bba1dada04197cf508b60b4eaf /LibOVR/Src/Kernel/OVR_Atomic.h
parent85d370840fa4d49a63331a203460fe763288d417 (diff)
Updating to windows 0.4.2
Diffstat (limited to 'LibOVR/Src/Kernel/OVR_Atomic.h')
-rw-r--r--LibOVR/Src/Kernel/OVR_Atomic.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Atomic.h b/LibOVR/Src/Kernel/OVR_Atomic.h
index 6ef862d..47e76e0 100644
--- a/LibOVR/Src/Kernel/OVR_Atomic.h
+++ b/LibOVR/Src/Kernel/OVR_Atomic.h
@@ -42,6 +42,10 @@ limitations under the License.
#include <pthread.h>
#endif
+#ifdef OVR_CC_MSVC
+#include <intrin.h>
+#pragma intrinsic(_ReadBarrier, _WriteBarrier, _ReadWriteBarrier)
+#endif
namespace OVR {
@@ -118,7 +122,6 @@ struct AtomicOpsRawBase
struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { asm volatile("dmb\n"); } };
struct ReleaseSync { inline ReleaseSync() { asm volatile("dmb\n"); } };
-
#elif defined(OVR_CC_GNU) && (__GNUC__ >= 4)
// __sync functions are already full sync
struct FullSync { inline FullSync() { } };
@@ -138,7 +141,7 @@ struct AtomicOpsRaw_4ByteImpl : public AtomicOpsRawBase
// *** Thread - Safe Atomic Versions.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
// Use special defined for VC6, where volatile is not used and
// InterlockedCompareExchange is declared incorrectly.
@@ -403,7 +406,7 @@ struct AtomicOpsRaw_8ByteImpl : public AtomicOpsRawBase
typedef uint64_t T;
// *** Thread - Safe OS specific versions.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
// This is only for 64-bit systems.
typedef LONG64 T;
@@ -537,7 +540,22 @@ struct AtomicOpsRaw_DefImpl : public O
#else
inline static void Store_Release(volatile O_T* p, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); *p = val; }
#endif
- inline static O_T Load_Acquire(const volatile O_T* p) { O_AcquireSync sync; OVR_UNUSED(sync); return *p; }
+ inline static O_T Load_Acquire(const volatile O_T* p)
+ {
+ O_AcquireSync sync;
+ OVR_UNUSED(sync);
+
+#if defined(OVR_CC_MSVC)
+ _ReadBarrier(); // Compiler fence and load barrier
+#elif defined(OVR_CC_INTEL)
+ __memory_barrier(); // Compiler fence
+#else
+ // GCC-compatible:
+ asm volatile ("" : : : "memory"); // Compiler fence
+#endif
+
+ return *p;
+ }
};
@@ -819,7 +837,7 @@ public:
inline void Unlock() { }
// Windows.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
CRITICAL_SECTION cs;
public: