diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/atomic_gcc.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/atomic_gcc.h')
-rw-r--r-- | util/system/atomic_gcc.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h index 4fc73bd5b2..ed8dc2bdc5 100644 --- a/util/system/atomic_gcc.h +++ b/util/system/atomic_gcc.h @@ -1,9 +1,9 @@ #pragma once -#define ATOMIC_COMPILER_BARRIER() __asm__ __volatile__("" \ - : \ - : \ - : "memory") +#define ATOMIC_COMPILER_BARRIER() __asm__ __volatile__("" \ + : \ + : \ + : "memory") static inline TAtomicBase AtomicGet(const TAtomic& a) { TAtomicBase tmp; @@ -31,26 +31,26 @@ static inline void AtomicSet(TAtomic& a, TAtomicBase v) { #endif } -static inline intptr_t AtomicIncrement(TAtomic& p) { +static inline intptr_t AtomicIncrement(TAtomic& p) { return __atomic_add_fetch(&p, 1, __ATOMIC_SEQ_CST); -} - +} + static inline intptr_t AtomicGetAndIncrement(TAtomic& p) { return __atomic_fetch_add(&p, 1, __ATOMIC_SEQ_CST); } -static inline intptr_t AtomicDecrement(TAtomic& p) { - return __atomic_sub_fetch(&p, 1, __ATOMIC_SEQ_CST); -} - +static inline intptr_t AtomicDecrement(TAtomic& p) { + return __atomic_sub_fetch(&p, 1, __ATOMIC_SEQ_CST); +} + static inline intptr_t AtomicGetAndDecrement(TAtomic& p) { return __atomic_fetch_sub(&p, 1, __ATOMIC_SEQ_CST); } -static inline intptr_t AtomicAdd(TAtomic& p, intptr_t v) { - return __atomic_add_fetch(&p, v, __ATOMIC_SEQ_CST); -} - +static inline intptr_t AtomicAdd(TAtomic& p, intptr_t v) { + return __atomic_add_fetch(&p, v, __ATOMIC_SEQ_CST); +} + static inline intptr_t AtomicGetAndAdd(TAtomic& p, intptr_t v) { return __atomic_fetch_add(&p, v, __ATOMIC_SEQ_CST); } @@ -60,13 +60,13 @@ static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) { intptr_t ret; __atomic_exchange(p, &v, &ret, __ATOMIC_SEQ_CST); return ret; -} +} -static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { +static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { (void)a; // disable strange 'parameter set but not used' warning on gcc return __atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); -} - +} + static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) { (void)a; // disable strange 'parameter set but not used' warning on gcc __atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); @@ -85,6 +85,6 @@ static inline intptr_t AtomicAnd(TAtomic& a, intptr_t b) { return __atomic_and_fetch(&a, b, __ATOMIC_SEQ_CST); } -static inline void AtomicBarrier() { - __sync_synchronize(); -} +static inline void AtomicBarrier() { + __sync_synchronize(); +} |