diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/atomic_win.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/atomic_win.h')
-rw-r--r-- | util/system/atomic_win.h | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h index 65c290e6cc..fa21bd4b9b 100644 --- a/util/system/atomic_win.h +++ b/util/system/atomic_win.h @@ -1,79 +1,79 @@ #pragma once -#include <intrin.h> - +#include <intrin.h> + #define USE_GENERIC_SETGET #if defined(_i386_) + + #pragma intrinsic(_InterlockedIncrement) + #pragma intrinsic(_InterlockedDecrement) + #pragma intrinsic(_InterlockedExchangeAdd) + #pragma intrinsic(_InterlockedExchange) + #pragma intrinsic(_InterlockedCompareExchange) - #pragma intrinsic(_InterlockedIncrement) - #pragma intrinsic(_InterlockedDecrement) - #pragma intrinsic(_InterlockedExchangeAdd) - #pragma intrinsic(_InterlockedExchange) - #pragma intrinsic(_InterlockedCompareExchange) - -static inline intptr_t AtomicIncrement(TAtomic& a) { - return _InterlockedIncrement((volatile long*)&a); +static inline intptr_t AtomicIncrement(TAtomic& a) { + return _InterlockedIncrement((volatile long*)&a); } - + static inline intptr_t AtomicGetAndIncrement(TAtomic& a) { return _InterlockedIncrement((volatile long*)&a) - 1; } -static inline intptr_t AtomicDecrement(TAtomic& a) { - return _InterlockedDecrement((volatile long*)&a); +static inline intptr_t AtomicDecrement(TAtomic& a) { + return _InterlockedDecrement((volatile long*)&a); } - + static inline intptr_t AtomicGetAndDecrement(TAtomic& a) { return _InterlockedDecrement((volatile long*)&a) + 1; } -static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) { - return _InterlockedExchangeAdd((volatile long*)&a, b) + b; +static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) { + return _InterlockedExchangeAdd((volatile long*)&a, b) + b; } - + static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) { return _InterlockedExchangeAdd((volatile long*)&a, b); } static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) { return _InterlockedExchange((volatile long*)a, b); -} - -static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { - return _InterlockedCompareExchange((volatile long*)a, exchange, compare) == compare; -} +} +static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { + return _InterlockedCompareExchange((volatile long*)a, exchange, compare) == compare; +} + static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) { return _InterlockedCompareExchange((volatile long*)a, exchange, compare); } #else // _x86_64_ - #pragma intrinsic(_InterlockedIncrement64) - #pragma intrinsic(_InterlockedDecrement64) - #pragma intrinsic(_InterlockedExchangeAdd64) - #pragma intrinsic(_InterlockedExchange64) - #pragma intrinsic(_InterlockedCompareExchange64) + #pragma intrinsic(_InterlockedIncrement64) + #pragma intrinsic(_InterlockedDecrement64) + #pragma intrinsic(_InterlockedExchangeAdd64) + #pragma intrinsic(_InterlockedExchange64) + #pragma intrinsic(_InterlockedCompareExchange64) -static inline intptr_t AtomicIncrement(TAtomic& a) { - return _InterlockedIncrement64((volatile __int64*)&a); +static inline intptr_t AtomicIncrement(TAtomic& a) { + return _InterlockedIncrement64((volatile __int64*)&a); } static inline intptr_t AtomicGetAndIncrement(TAtomic& a) { return _InterlockedIncrement64((volatile __int64*)&a) - 1; } -static inline intptr_t AtomicDecrement(TAtomic& a) { - return _InterlockedDecrement64((volatile __int64*)&a); +static inline intptr_t AtomicDecrement(TAtomic& a) { + return _InterlockedDecrement64((volatile __int64*)&a); } static inline intptr_t AtomicGetAndDecrement(TAtomic& a) { return _InterlockedDecrement64((volatile __int64*)&a) + 1; } -static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) { - return _InterlockedExchangeAdd64((volatile __int64*)&a, b) + b; +static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) { + return _InterlockedExchangeAdd64((volatile __int64*)&a, b) + b; } static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) { @@ -84,8 +84,8 @@ static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) { return _InterlockedExchange64((volatile __int64*)a, b); } -static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { - return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare) == compare; +static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { + return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare) == compare; } static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) { @@ -105,10 +105,10 @@ static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) { } #endif // _x86_ - -//TODO -static inline void AtomicBarrier() { - TAtomic val = 0; - + +//TODO +static inline void AtomicBarrier() { + TAtomic val = 0; + AtomicSwap(&val, 0); -} +} |