diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/atomic_ops.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/atomic_ops.h b/src/common/atomic_ops.h index b94d73c7a..b963e7b99 100644 --- a/src/common/atomic_ops.h +++ b/src/common/atomic_ops.h | |||
| @@ -46,6 +46,13 @@ namespace Common { | |||
| 46 | reinterpret_cast<__int64*>(expected.data())) != 0; | 46 | reinterpret_cast<__int64*>(expected.data())) != 0; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | [[nodiscard]] inline u128 AtomicLoad128(volatile u64* pointer) { | ||
| 50 | u128 result{}; | ||
| 51 | _InterlockedCompareExchange128(reinterpret_cast<volatile __int64*>(pointer), result[1], | ||
| 52 | result[0], reinterpret_cast<__int64*>(result.data())); | ||
| 53 | return result; | ||
| 54 | } | ||
| 55 | |||
| 49 | #else | 56 | #else |
| 50 | 57 | ||
| 51 | [[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected) { | 58 | [[nodiscard]] inline bool AtomicCompareAndSwap(volatile u8* pointer, u8 value, u8 expected) { |
| @@ -72,6 +79,16 @@ namespace Common { | |||
| 72 | return __sync_bool_compare_and_swap((unsigned __int128*)pointer, expected_a, value_a); | 79 | return __sync_bool_compare_and_swap((unsigned __int128*)pointer, expected_a, value_a); |
| 73 | } | 80 | } |
| 74 | 81 | ||
| 82 | [[nodiscard]] inline u128 AtomicLoad128(volatile u64* pointer) { | ||
| 83 | unsigned __int128 zeros_a = 0; | ||
| 84 | unsigned __int128 result_a = | ||
| 85 | __sync_val_compare_and_swap((unsigned __int128*)pointer, zeros_a, zeros_a); | ||
| 86 | |||
| 87 | u128 result; | ||
| 88 | std::memcpy(result.data(), &result_a, sizeof(u128)); | ||
| 89 | return result; | ||
| 90 | } | ||
| 91 | |||
| 75 | #endif | 92 | #endif |
| 76 | 93 | ||
| 77 | } // namespace Common | 94 | } // namespace Common |