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.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.h')
-rw-r--r-- | util/system/atomic.h | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/util/system/atomic.h b/util/system/atomic.h index 80265babfd..aa3dcfff52 100644 --- a/util/system/atomic.h +++ b/util/system/atomic.h @@ -1,51 +1,51 @@ #pragma once -#include "defaults.h" - +#include "defaults.h" + using TAtomicBase = intptr_t; using TAtomic = volatile TAtomicBase; - -#if defined(__GNUC__) - #include "atomic_gcc.h" -#elif defined(_MSC_VER) - #include "atomic_win.h" + +#if defined(__GNUC__) + #include "atomic_gcc.h" +#elif defined(_MSC_VER) + #include "atomic_win.h" #else - #error unsupported platform + #error unsupported platform #endif -#if !defined(ATOMIC_COMPILER_BARRIER) - #define ATOMIC_COMPILER_BARRIER() -#endif - -static inline TAtomicBase AtomicSub(TAtomic& a, TAtomicBase v) { - return AtomicAdd(a, -v); -} - +#if !defined(ATOMIC_COMPILER_BARRIER) + #define ATOMIC_COMPILER_BARRIER() +#endif + +static inline TAtomicBase AtomicSub(TAtomic& a, TAtomicBase v) { + return AtomicAdd(a, -v); +} + static inline TAtomicBase AtomicGetAndSub(TAtomic& a, TAtomicBase v) { return AtomicGetAndAdd(a, -v); } -#if defined(USE_GENERIC_SETGET) -static inline TAtomicBase AtomicGet(const TAtomic& a) { - return a; -} - -static inline void AtomicSet(TAtomic& a, TAtomicBase v) { - a = v; -} -#endif - -static inline bool AtomicTryLock(TAtomic* a) { - return AtomicCas(a, 1, 0); -} - -static inline bool AtomicTryAndTryLock(TAtomic* a) { - return (AtomicGet(*a) == 0) && AtomicTryLock(a); -} - -static inline void AtomicUnlock(TAtomic* a) { - ATOMIC_COMPILER_BARRIER(); - AtomicSet(*a, 0); -} - -#include "atomic_ops.h" +#if defined(USE_GENERIC_SETGET) +static inline TAtomicBase AtomicGet(const TAtomic& a) { + return a; +} + +static inline void AtomicSet(TAtomic& a, TAtomicBase v) { + a = v; +} +#endif + +static inline bool AtomicTryLock(TAtomic* a) { + return AtomicCas(a, 1, 0); +} + +static inline bool AtomicTryAndTryLock(TAtomic* a) { + return (AtomicGet(*a) == 0) && AtomicTryLock(a); +} + +static inline void AtomicUnlock(TAtomic* a) { + ATOMIC_COMPILER_BARRIER(); + AtomicSet(*a, 0); +} + +#include "atomic_ops.h" |