diff options
author | bunnei <bunneidev@gmail.com> | 2014-09-04 20:36:21 -0400 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-09-04 20:36:21 -0400 |
commit | 5d95d038a0e5d203a568223da12b57c30d048a8c (patch) | |
tree | 7aaaa7f594244f81c2fc813d40e099a5bbc1a9e8 /src/common/atomic_win32.h | |
parent | fda291816b4b86ace15a210d66143a2dadc769e0 (diff) | |
parent | 4795a64fc8ff59fced28735e627deb7c3b4575ed (diff) |
Merge pull request #88 from archshift/remove-atomic
Removed common/atomic, instead using std::atomic
Diffstat (limited to 'src/common/atomic_win32.h')
-rw-r--r-- | src/common/atomic_win32.h | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/common/atomic_win32.h b/src/common/atomic_win32.h deleted file mode 100644 index 0808905f0d..0000000000 --- a/src/common/atomic_win32.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include "common/common.h" -#include <intrin.h> -#include <Windows.h> - -// Atomic operations are performed in a single step by the CPU. It is -// impossible for other threads to see the operation "half-done." -// -// Some atomic operations can be combined with different types of memory -// barriers called "Acquire semantics" and "Release semantics", defined below. -// -// Acquire semantics: Future memory accesses cannot be relocated to before the -// operation. -// -// Release semantics: Past memory accesses cannot be relocated to after the -// operation. -// -// These barriers affect not only the compiler, but also the CPU. -// -// NOTE: Acquire and Release are not differentiated right now. They perform a -// full memory barrier instead of a "one-way" memory barrier. The newest -// Windows SDK has Acquire and Release versions of some Interlocked* functions. - -namespace Common -{ - -inline void AtomicAdd(volatile u32& target, u32 value) { - InterlockedExchangeAdd((volatile LONG*)&target, (LONG)value); -} - -inline void AtomicAnd(volatile u32& target, u32 value) { - _InterlockedAnd((volatile LONG*)&target, (LONG)value); -} - -inline void AtomicIncrement(volatile u32& target) { - InterlockedIncrement((volatile LONG*)&target); -} - -inline void AtomicDecrement(volatile u32& target) { - InterlockedDecrement((volatile LONG*)&target); -} - -inline u32 AtomicLoad(volatile u32& src) { - return src; // 32-bit reads are always atomic. -} -inline u32 AtomicLoadAcquire(volatile u32& src) { - u32 result = src; // 32-bit reads are always atomic. - _ReadBarrier(); // Compiler instruction only. x86 loads always have acquire semantics. - return result; -} - -inline void AtomicOr(volatile u32& target, u32 value) { - _InterlockedOr((volatile LONG*)&target, (LONG)value); -} - -inline void AtomicStore(volatile u32& dest, u32 value) { - dest = value; // 32-bit writes are always atomic. -} -inline void AtomicStoreRelease(volatile u32& dest, u32 value) { - _WriteBarrier(); // Compiler instruction only. x86 stores always have release semantics. - dest = value; // 32-bit writes are always atomic. -} - -} |