summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Merry2024-01-27 21:42:16 +0000
committerGravatar Merry2024-01-27 21:42:16 +0000
commit5a20d07c21b74181b88d76fda16fd83a4718ec49 (patch)
tree2fb00f327dcf51093b3c0a8c937c6104f3b834e4 /src
parentatomic_ops: Remove volatile qualifier (diff)
downloadyuzu-5a20d07c21b74181b88d76fda16fd83a4718ec49.tar.gz
yuzu-5a20d07c21b74181b88d76fda16fd83a4718ec49.tar.xz
yuzu-5a20d07c21b74181b88d76fda16fd83a4718ec49.zip
atomic_ops: Fix MSVC
Diffstat (limited to 'src')
-rw-r--r--src/common/atomic_ops.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/common/atomic_ops.h b/src/common/atomic_ops.h
index 885fe3c4e..9bf6f2f81 100644
--- a/src/common/atomic_ops.h
+++ b/src/common/atomic_ops.h
@@ -20,28 +20,29 @@ template <typename T>
20template <typename T> 20template <typename T>
21[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected, T& actual); 21[[nodiscard]] inline bool AtomicCompareAndSwap(T* pointer, T value, T expected, T& actual);
22 22
23template [[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected) { 23template <>
24[[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected) {
24 const u8 result = 25 const u8 result =
25 _InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected); 26 _InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected);
26 return result == expected; 27 return result == expected;
27} 28}
28 29
29template [[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, 30template <>
30 u16 expected) { 31[[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, u16 expected) {
31 const u16 result = 32 const u16 result =
32 _InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected); 33 _InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected);
33 return result == expected; 34 return result == expected;
34} 35}
35 36
36template [[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, 37template <>
37 u32 expected) { 38[[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, u32 expected) {
38 const u32 result = 39 const u32 result =
39 _InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected); 40 _InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected);
40 return result == expected; 41 return result == expected;
41} 42}
42 43
43template [[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, 44template <>
44 u64 expected) { 45[[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, u64 expected) {
45 const u64 result = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer), 46 const u64 result = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer),
46 value, expected); 47 value, expected);
47 return result == expected; 48 return result == expected;
@@ -53,29 +54,32 @@ template [[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 v
53 reinterpret_cast<__int64*>(expected.data())) != 0; 54 reinterpret_cast<__int64*>(expected.data())) != 0;
54} 55}
55 56
56template [[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected, 57template <>
57 u8& actual) { 58[[nodiscard]] inline bool AtomicCompareAndSwap<u8>(u8* pointer, u8 value, u8 expected, u8& actual) {
58 actual = 59 actual =
59 _InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected); 60 _InterlockedCompareExchange8(reinterpret_cast<volatile char*>(pointer), value, expected);
60 return actual == expected; 61 return actual == expected;
61} 62}
62 63
63template [[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, u16 expected, 64template <>
64 u16& actual) { 65[[nodiscard]] inline bool AtomicCompareAndSwap<u16>(u16* pointer, u16 value, u16 expected,
66 u16& actual) {
65 actual = 67 actual =
66 _InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected); 68 _InterlockedCompareExchange16(reinterpret_cast<volatile short*>(pointer), value, expected);
67 return actual == expected; 69 return actual == expected;
68} 70}
69 71
70template [[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, u32 expected, 72template <>
71 u32& actual) { 73[[nodiscard]] inline bool AtomicCompareAndSwap<u32>(u32* pointer, u32 value, u32 expected,
74 u32& actual) {
72 actual = 75 actual =
73 _InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected); 76 _InterlockedCompareExchange(reinterpret_cast<volatile long*>(pointer), value, expected);
74 return actual == expected; 77 return actual == expected;
75} 78}
76 79
77template [[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, u64 expected, 80template <>
78 u64& actual) { 81[[nodiscard]] inline bool AtomicCompareAndSwap<u64>(u64* pointer, u64 value, u64 expected,
82 u64& actual) {
79 actual = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer), value, 83 actual = _InterlockedCompareExchange64(reinterpret_cast<volatile __int64*>(pointer), value,
80 expected); 84 expected);
81 return actual == expected; 85 return actual == expected;