aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/atomic.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/atomic.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/atomic.h')
-rw-r--r--util/system/atomic.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/util/system/atomic.h b/util/system/atomic.h
index aa3dcfff52..80265babfd 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"