aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authoragri <agri@yandex-team.ru>2022-02-10 16:48:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:12 +0300
commit2909866fbc652492b7d7cab3023cb19489dc4fd8 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util
parentd3530b2692e400bd4d29bd4f07cafaee139164e7 (diff)
downloadydb-2909866fbc652492b7d7cab3023cb19489dc4fd8.tar.gz
Restoring authorship annotation for <agri@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/generic/ptr.h60
-rw-r--r--util/generic/refcount.h30
-rw-r--r--util/stream/input.cpp14
-rw-r--r--util/system/align.h14
-rw-r--r--util/system/atomic.h8
-rw-r--r--util/system/atomic_gcc.h36
-rw-r--r--util/system/atomic_ops.h90
-rw-r--r--util/system/atomic_ut.cpp106
-rw-r--r--util/system/atomic_win.h62
-rw-r--r--util/system/compiler.h8
-rw-r--r--util/system/datetime.h14
-rw-r--r--util/system/file.cpp12
-rw-r--r--util/system/shellcommand.cpp62
-rw-r--r--util/thread/lfqueue.h14
14 files changed, 265 insertions, 265 deletions
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index fd1cd162b1..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -366,19 +366,19 @@ public:
inline ~TRefCounted() = default;
inline void Ref(TAtomicBase d) noexcept {
- auto resultCount = Counter_.Add(d);
- Y_ASSERT(resultCount >= d);
- (void)resultCount;
+ auto resultCount = Counter_.Add(d);
+ Y_ASSERT(resultCount >= d);
+ (void)resultCount;
}
inline void Ref() noexcept {
- auto resultCount = Counter_.Inc();
- Y_ASSERT(resultCount != 0);
- (void)resultCount;
+ auto resultCount = Counter_.Inc();
+ Y_ASSERT(resultCount != 0);
+ (void)resultCount;
}
inline void UnRef(TAtomicBase d) noexcept {
- auto resultCount = Counter_.Sub(d);
+ auto resultCount = Counter_.Sub(d);
Y_ASSERT(resultCount >= 0);
if (resultCount == 0) {
D::Destroy(static_cast<T*>(this));
@@ -389,14 +389,14 @@ public:
UnRef(1);
}
- inline TAtomicBase RefCount() const noexcept {
+ inline TAtomicBase RefCount() const noexcept {
return Counter_.Val();
}
inline void DecRef() noexcept {
- auto resultCount = Counter_.Dec();
- Y_ASSERT(resultCount >= 0);
- (void)resultCount;
+ auto resultCount = Counter_.Dec();
+ Y_ASSERT(resultCount >= 0);
+ (void)resultCount;
}
TRefCounted(const TRefCounted&)
@@ -543,11 +543,11 @@ public:
return *this;
}
- // Effectively replace both:
- // Reset(const TIntrusivePtr&)
- // Reset(TIntrusivePtr&&)
- inline void Reset(TIntrusivePtr t) noexcept {
- Swap(t);
+ // Effectively replace both:
+ // Reset(const TIntrusivePtr&)
+ // Reset(TIntrusivePtr&&)
+ inline void Reset(TIntrusivePtr t) noexcept {
+ Swap(t);
}
inline void Reset() noexcept {
@@ -663,11 +663,11 @@ public:
return *this;
}
- // Effectively replace both:
- // Reset(const TIntrusiveConstPtr&)
- // Reset(TIntrusiveConstPtr&&)
- inline void Reset(TIntrusiveConstPtr t) noexcept {
- Swap(t);
+ // Effectively replace both:
+ // Reset(const TIntrusiveConstPtr&)
+ // Reset(TIntrusiveConstPtr&&)
+ inline void Reset(TIntrusiveConstPtr t) noexcept {
+ Swap(t);
}
inline void Reset() noexcept {
@@ -783,11 +783,11 @@ template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args>
return new T{std::forward<Args>(args)...};
}
-template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args>
+template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args>
[[nodiscard]] TIntrusiveConstPtr<T, Ops> MakeIntrusiveConst(Args&&... args) {
- return new T{std::forward<Args>(args)...};
-}
-
+ return new T{std::forward<Args>(args)...};
+}
+
template <class T, class C, class D>
class TSharedPtr: public TPointerBase<TSharedPtr<T, C, D>, T> {
template <class TT, class CC, class DD>
@@ -862,11 +862,11 @@ public:
return *this;
}
- // Effectively replace both:
- // Reset(const TSharedPtr& t)
- // Reset(TSharedPtr&& t)
- inline void Reset(TSharedPtr t) noexcept {
- Swap(t);
+ // Effectively replace both:
+ // Reset(const TSharedPtr& t)
+ // Reset(TSharedPtr&& t)
+ inline void Reset(TSharedPtr t) noexcept {
+ Swap(t);
}
inline void Reset() noexcept {
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index bcee5a7860..966e853b77 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -19,21 +19,21 @@ public:
Check();
}
- inline TAtomicBase Add(TAtomicBase d) noexcept {
+ inline TAtomicBase Add(TAtomicBase d) noexcept {
Check();
- return Counter_ += d;
+ return Counter_ += d;
}
- inline TAtomicBase Inc() noexcept {
- return Add(1);
+ inline TAtomicBase Inc() noexcept {
+ return Add(1);
}
- inline TAtomicBase Sub(TAtomicBase d) noexcept {
+ inline TAtomicBase Sub(TAtomicBase d) noexcept {
Check();
return Counter_ -= d;
}
- inline TAtomicBase Dec() noexcept {
+ inline TAtomicBase Dec() noexcept {
return Sub(1);
}
@@ -43,17 +43,17 @@ public:
}
Inc();
- Y_ASSERT(Counter_ != 0);
-
+ Y_ASSERT(Counter_ != 0);
+
return true;
}
- inline TAtomicBase Val() const noexcept {
+ inline TAtomicBase Val() const noexcept {
return Counter_;
}
private:
- TAtomicBase Counter_;
+ TAtomicBase Counter_;
};
class TNoCheckPolicy {
@@ -109,12 +109,12 @@ public:
inline ~TAtomicCounter() = default;
- inline TAtomicBase Add(TAtomicBase d) noexcept {
- return AtomicAdd(Counter_, d);
+ inline TAtomicBase Add(TAtomicBase d) noexcept {
+ return AtomicAdd(Counter_, d);
}
- inline TAtomicBase Inc() noexcept {
- return Add(1);
+ inline TAtomicBase Inc() noexcept {
+ return Add(1);
}
inline TAtomicBase Sub(TAtomicBase d) noexcept {
@@ -138,7 +138,7 @@ public:
}
intptr_t newValue = curValue + 1;
- Y_ASSERT(newValue != 0);
+ Y_ASSERT(newValue != 0);
if (AtomicCas(&Counter_, newValue, curValue)) {
return true;
diff --git a/util/stream/input.cpp b/util/stream/input.cpp
index 494ece8c25..6e8170f2f9 100644
--- a/util/stream/input.cpp
+++ b/util/stream/input.cpp
@@ -128,21 +128,21 @@ size_t IInputStream::DoSkip(size_t sz) {
return Load(alloca(sz), sz);
}
- TTempBuf buf;
- size_t total = 0;
+ TTempBuf buf;
+ size_t total = 0;
while (sz) {
const size_t lresult = Read(buf.Data(), Min<size_t>(sz, buf.Size()));
if (lresult == 0) {
- return total;
+ return total;
}
- total += lresult;
- sz -= lresult;
+ total += lresult;
+ sz -= lresult;
}
-
- return total;
+
+ return total;
}
TString IInputStream::ReadAll() {
diff --git a/util/system/align.h b/util/system/align.h
index e2e2dbef79..ea0bbc5b46 100644
--- a/util/system/align.h
+++ b/util/system/align.h
@@ -2,19 +2,19 @@
#include "yassert.h"
#include "defaults.h"
-#include <util/generic/bitops.h>
+#include <util/generic/bitops.h>
template <class T>
static inline T AlignDown(T len, T align) noexcept {
- Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
+ Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
return len & ~(align - 1);
}
template <class T>
static inline T AlignUp(T len, T align) noexcept {
- const T alignedResult = AlignDown(len + (align - 1), align);
- Y_ASSERT(alignedResult >= len); // check for overflow
- return alignedResult;
+ const T alignedResult = AlignDown(len + (align - 1), align);
+ Y_ASSERT(alignedResult >= len); // check for overflow
+ return alignedResult;
}
template <class T>
@@ -25,12 +25,12 @@ static inline T AlignUpSpace(T len, T align) noexcept {
template <class T>
static inline T* AlignUp(T* ptr, size_t align) noexcept {
- return (T*)AlignUp((uintptr_t)ptr, align);
+ return (T*)AlignUp((uintptr_t)ptr, align);
}
template <class T>
static inline T* AlignDown(T* ptr, size_t align) noexcept {
- return (T*)AlignDown((uintptr_t)ptr, align);
+ return (T*)AlignDown((uintptr_t)ptr, align);
}
template <class T>
diff --git a/util/system/atomic.h b/util/system/atomic.h
index 680754d6b3..80265babfd 100644
--- a/util/system/atomic.h
+++ b/util/system/atomic.h
@@ -21,10 +21,10 @@ static inline TAtomicBase AtomicSub(TAtomic& a, TAtomicBase v) {
return AtomicAdd(a, -v);
}
-static inline TAtomicBase AtomicGetAndSub(TAtomic& a, TAtomicBase v) {
- return AtomicGetAndAdd(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;
diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h
index 88c1943575..ed8dc2bdc5 100644
--- a/util/system/atomic_gcc.h
+++ b/util/system/atomic_gcc.h
@@ -35,26 +35,26 @@ 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 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 AtomicGetAndDecrement(TAtomic& p) {
- return __atomic_fetch_sub(&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 AtomicGetAndAdd(TAtomic& p, intptr_t v) {
- return __atomic_fetch_add(&p, v, __ATOMIC_SEQ_CST);
-}
-
+static inline intptr_t AtomicGetAndAdd(TAtomic& p, intptr_t v) {
+ return __atomic_fetch_add(&p, v, __ATOMIC_SEQ_CST);
+}
+
static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) {
(void)p; // disable strange 'parameter set but not used' warning on gcc
intptr_t ret;
@@ -67,12 +67,12 @@ static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
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);
- return compare;
-}
-
+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);
+ return compare;
+}
+
static inline intptr_t AtomicOr(TAtomic& a, intptr_t b) {
return __atomic_or_fetch(&a, b, __ATOMIC_SEQ_CST);
}
diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h
index 532e5b5bcb..76766b4a0a 100644
--- a/util/system/atomic_ops.h
+++ b/util/system/atomic_ops.h
@@ -40,41 +40,41 @@ inline TEnableIfCastable<T, T> AtomicIncrement(T volatile& target) {
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGetAndIncrement(T volatile& target) {
- return static_cast<T>(AtomicGetAndIncrement(*AsAtomicPtr(&target)));
-}
-
-template <typename T>
+inline TEnableIfCastable<T, T> AtomicGetAndIncrement(T volatile& target) {
+ return static_cast<T>(AtomicGetAndIncrement(*AsAtomicPtr(&target)));
+}
+
+template <typename T>
inline TEnableIfCastable<T, T> AtomicDecrement(T volatile& target) {
return static_cast<T>(AtomicDecrement(*AsAtomicPtr(&target)));
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGetAndDecrement(T volatile& target) {
- return static_cast<T>(AtomicGetAndDecrement(*AsAtomicPtr(&target)));
-}
-
-template <typename T>
+inline TEnableIfCastable<T, T> AtomicGetAndDecrement(T volatile& target) {
+ return static_cast<T>(AtomicGetAndDecrement(*AsAtomicPtr(&target)));
+}
+
+template <typename T>
inline TEnableIfCastable<T, T> AtomicAdd(T volatile& target, TAtomicBase value) {
return static_cast<T>(AtomicAdd(*AsAtomicPtr(&target), value));
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGetAndAdd(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicGetAndAdd(*AsAtomicPtr(&target), value));
-}
-
-template <typename T>
+inline TEnableIfCastable<T, T> AtomicGetAndAdd(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicGetAndAdd(*AsAtomicPtr(&target), value));
+}
+
+template <typename T>
inline TEnableIfCastable<T, T> AtomicSub(T volatile& target, TAtomicBase value) {
return static_cast<T>(AtomicSub(*AsAtomicPtr(&target), value));
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGetAndSub(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicGetAndSub(*AsAtomicPtr(&target), value));
-}
-
-template <typename T>
+inline TEnableIfCastable<T, T> AtomicGetAndSub(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicGetAndSub(*AsAtomicPtr(&target), value));
+}
+
+template <typename T>
inline TEnableIfCastable<T, T> AtomicSwap(T volatile* target, TAtomicBase exchange) {
return static_cast<T>(AtomicSwap(AsAtomicPtr(target), exchange));
}
@@ -85,11 +85,11 @@ inline TEnableIfCastable<T, bool> AtomicCas(T volatile* target, TAtomicBase exch
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGetAndCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
- return static_cast<T>(AtomicGetAndCas(AsAtomicPtr(target), exchange, compare));
-}
-
-template <typename T>
+inline TEnableIfCastable<T, T> AtomicGetAndCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
+ return static_cast<T>(AtomicGetAndCas(AsAtomicPtr(target), exchange, compare));
+}
+
+template <typename T>
inline TEnableIfCastable<T, bool> AtomicTryLock(T volatile* target) {
return AtomicTryLock(AsAtomicPtr(target));
}
@@ -154,36 +154,36 @@ inline bool AtomicCas(T* volatile* target, T* exchange, T* compare) {
}
template <typename T>
-inline T* AtomicGetAndCas(T* volatile* target, T* exchange, T* compare) {
- return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare)));
-}
-
-template <typename T>
+inline T* AtomicGetAndCas(T* volatile* target, T* exchange, T* compare) {
+ return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare)));
+}
+
+template <typename T>
inline bool AtomicCas(T* volatile* target, T* exchange, TNullPtr) {
return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0);
}
template <typename T>
-inline T* AtomicGetAndCas(T* volatile* target, T* exchange, TNullPtr) {
- return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0));
-}
-
-template <typename T>
+inline T* AtomicGetAndCas(T* volatile* target, T* exchange, TNullPtr) {
+ return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0));
+}
+
+template <typename T>
inline bool AtomicCas(T* volatile* target, TNullPtr, T* compare) {
return AtomicCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare));
}
template <typename T>
-inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, T* compare) {
- return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare)));
-}
-
-template <typename T>
+inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, T* compare) {
+ return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare)));
+}
+
+template <typename T>
inline bool AtomicCas(T* volatile* target, TNullPtr, TNullPtr) {
return AtomicCas(AsAtomicPtr(target), 0, 0);
}
-
-template <typename T>
-inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, TNullPtr) {
- return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, 0));
-}
+
+template <typename T>
+inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, TNullPtr) {
+ return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, 0));
+}
diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp
index 746853228f..07211ffba7 100644
--- a/util/system/atomic_ut.cpp
+++ b/util/system/atomic_ut.cpp
@@ -10,19 +10,19 @@ class TAtomicTest
UNIT_TEST_SUITE(TAtomicTest);
UNIT_TEST(TestAtomicInc1)
UNIT_TEST(TestAtomicInc2)
- UNIT_TEST(TestAtomicGetAndInc)
+ UNIT_TEST(TestAtomicGetAndInc)
UNIT_TEST(TestAtomicDec)
- UNIT_TEST(TestAtomicGetAndDec)
+ UNIT_TEST(TestAtomicGetAndDec)
UNIT_TEST(TestAtomicAdd)
- UNIT_TEST(TestAtomicGetAndAdd)
+ UNIT_TEST(TestAtomicGetAndAdd)
UNIT_TEST(TestAtomicSub)
- UNIT_TEST(TestAtomicGetAndSub)
+ UNIT_TEST(TestAtomicGetAndSub)
UNIT_TEST(TestAtomicSwap)
UNIT_TEST(TestAtomicOr)
UNIT_TEST(TestAtomicAnd)
UNIT_TEST(TestAtomicXor)
UNIT_TEST(TestCAS)
- UNIT_TEST(TestGetAndCAS)
+ UNIT_TEST(TestGetAndCAS)
UNIT_TEST(TestLockUnlock)
UNIT_TEST_SUITE_END();
@@ -49,18 +49,18 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
}
- inline void TestGetAndCAS() {
- TAtomic v = 0;
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 1, 0), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 2, 0), 1);
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 0, 1), 1);
- UNIT_ASSERT_VALUES_EQUAL(v, 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, Max<intptr_t>(), 0), 0);
- UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
- }
-
+ inline void TestGetAndCAS() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 1, 0), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 2, 0), 1);
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, 0, 1), 1);
+ UNIT_ASSERT_VALUES_EQUAL(v, 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndCas(&v, Max<intptr_t>(), 0), 0);
+ UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
+ }
+
inline void TestAtomicInc1() {
TAtomic v = 0;
@@ -79,15 +79,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, 2);
}
- inline void TestAtomicGetAndInc() {
- TAtomic v = 0;
-
- UNIT_ASSERT_EQUAL(AtomicGetAndIncrement(v), 0);
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT_EQUAL(AtomicGetAndIncrement(v), 1);
- UNIT_ASSERT_VALUES_EQUAL(v, 2);
- }
-
+ inline void TestAtomicGetAndInc() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT_EQUAL(AtomicGetAndIncrement(v), 0);
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT_EQUAL(AtomicGetAndIncrement(v), 1);
+ UNIT_ASSERT_VALUES_EQUAL(v, 2);
+ }
+
inline void TestAtomicDec() {
TAtomic v = 2;
@@ -97,15 +97,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, 0);
}
- inline void TestAtomicGetAndDec() {
- TAtomic v = 2;
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndDecrement(v), 2);
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndDecrement(v), 1);
- UNIT_ASSERT_VALUES_EQUAL(v, 0);
- }
-
+ inline void TestAtomicGetAndDec() {
+ TAtomic v = 2;
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndDecrement(v), 2);
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndDecrement(v), 1);
+ UNIT_ASSERT_VALUES_EQUAL(v, 0);
+ }
+
inline void TestAtomicAdd() {
TAtomic v = 0;
@@ -115,15 +115,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, -1);
}
- inline void TestAtomicGetAndAdd() {
- TAtomic v = 0;
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, 1), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, 2), 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, -4), 3);
- UNIT_ASSERT_VALUES_EQUAL(v, -1);
- }
-
+ inline void TestAtomicGetAndAdd() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, 1), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, 2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndAdd(v, -4), 3);
+ UNIT_ASSERT_VALUES_EQUAL(v, -1);
+ }
+
inline void TestAtomicSub() {
TAtomic v = 4;
@@ -133,15 +133,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, -2);
}
- inline void TestAtomicGetAndSub() {
- TAtomic v = 4;
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 1), 4);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 2), 3);
- UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 3), 1);
- UNIT_ASSERT_VALUES_EQUAL(v, -2);
- }
-
+ inline void TestAtomicGetAndSub() {
+ TAtomic v = 4;
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 1), 4);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 2), 3);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGetAndSub(v, 3), 1);
+ UNIT_ASSERT_VALUES_EQUAL(v, -2);
+ }
+
inline void TestAtomicSwap() {
TAtomic v = 0;
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h
index 40bcdad6b4..65c290e6cc 100644
--- a/util/system/atomic_win.h
+++ b/util/system/atomic_win.h
@@ -16,26 +16,26 @@ 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 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 AtomicGetAndDecrement(TAtomic& a) {
- return _InterlockedDecrement((volatile long*)&a) + 1;
-}
-
+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 AtomicGetAndAdd(TAtomic& a, intptr_t b) {
- return _InterlockedExchangeAdd((volatile long*)&a, 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);
}
@@ -45,9 +45,9 @@ static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
}
static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
- return _InterlockedCompareExchange((volatile long*)a, exchange, compare);
-}
-
+ return _InterlockedCompareExchange((volatile long*)a, exchange, compare);
+}
+
#else // _x86_64_
#pragma intrinsic(_InterlockedIncrement64)
@@ -60,26 +60,26 @@ 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 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 AtomicGetAndDecrement(TAtomic& a) {
- return _InterlockedDecrement64((volatile __int64*)&a) + 1;
-}
-
+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 AtomicGetAndAdd(TAtomic& a, intptr_t b) {
- return _InterlockedExchangeAdd64((volatile __int64*)&a, b);
-}
-
+static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) {
+ return _InterlockedExchangeAdd64((volatile __int64*)&a, b);
+}
+
static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
return _InterlockedExchange64((volatile __int64*)a, b);
}
@@ -88,10 +88,10 @@ 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) {
- return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare);
-}
-
+static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
+ return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare);
+}
+
static inline intptr_t AtomicOr(TAtomic& a, intptr_t b) {
return _InterlockedOr64(&a, b) | b;
}
diff --git a/util/system/compiler.h b/util/system/compiler.h
index cec05dd024..b373edcc46 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -319,7 +319,7 @@ _YandexAbort();
#else
#define Y_CUDA_AT_LEAST(x, y) 0
#endif
-
+
// NVidia CUDA C++ Compiler did not know about noexcept keyword until version 9.0
#if !Y_CUDA_AT_LEAST(9, 0)
#if defined(__CUDACC__) && !defined(noexcept)
@@ -327,15 +327,15 @@ _YandexAbort();
#endif
#endif
-#if defined(__GNUC__)
+#if defined(__GNUC__)
#define Y_COLD __attribute__((cold))
#define Y_LEAF __attribute__((leaf))
#define Y_WRAPPER __attribute__((artificial))
-#else
+#else
#define Y_COLD
#define Y_LEAF
#define Y_WRAPPER
-#endif
+#endif
/**
* @def Y_PRAGMA
diff --git a/util/system/datetime.h b/util/system/datetime.h
index 9cc7d7fd60..aa009974e0 100644
--- a/util/system/datetime.h
+++ b/util/system/datetime.h
@@ -36,14 +36,14 @@ void NanoSleep(ui64 ns) noexcept;
// GetCycleCount guarantees to return synchronous values on different cores
// and provide constant rate only on modern Intel and AMD processors
-// NOTE: rdtscp is used to prevent out of order execution
-// rdtsc can be reordered, while rdtscp cannot be reordered
-// with preceding instructions
-// PERFORMANCE: rdtsc - 15 cycles per call , rdtscp - 19 cycles per call
-// WARNING: following instruction can be executed out-of-order
+// NOTE: rdtscp is used to prevent out of order execution
+// rdtsc can be reordered, while rdtscp cannot be reordered
+// with preceding instructions
+// PERFORMANCE: rdtsc - 15 cycles per call , rdtscp - 19 cycles per call
+// WARNING: following instruction can be executed out-of-order
Y_FORCE_INLINE ui64 GetCycleCount() noexcept {
#if defined(_MSC_VER)
- // Generates the rdtscp instruction, which returns the processor time stamp.
+ // Generates the rdtscp instruction, which returns the processor time stamp.
// The processor time stamp records the number of clock cycles since the last reset.
extern const bool HaveRdtscp;
@@ -82,7 +82,7 @@ Y_FORCE_INLINE ui64 GetCycleCount() noexcept {
#elif defined(_darwin_)
return mach_absolute_time();
#elif defined(__clang__) && !defined(_arm_)
- return __builtin_readcyclecounter();
+ return __builtin_readcyclecounter();
#elif defined(_arm32_)
return MicroSeconds();
#elif defined(_arm64_)
diff --git a/util/system/file.cpp b/util/system/file.cpp
index ce62a3ccab..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -599,12 +599,12 @@ int TFileHandle::Duplicate2Posix(int dstHandle) const noexcept {
bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
#if defined(_unix_)
- while (dup2(fh.Fd_, Fd_) == -1) {
- if (errno != EINTR) {
- return false;
- }
- }
- return true;
+ while (dup2(fh.Fd_, Fd_) == -1) {
+ if (errno != EINTR) {
+ return false;
+ }
+ }
+ return true;
#elif defined(_win_)
TFileHandle nh(fh.Duplicate());
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index 31538ac9aa..b1989b5c8c 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -738,10 +738,10 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const*
afterFork();
}
- if (envp == nullptr) {
- execvp(argv[0], argv);
+ if (envp == nullptr) {
+ execvp(argv[0], argv);
} else {
- execve(argv[0], argv, envp);
+ execve(argv[0], argv, envp);
}
Cerr << "Process was not created: " << LastSystemErrorText() << Endl;
} catch (const std::exception& error) {
@@ -782,52 +782,52 @@ void TShellCommand::TImpl::Run() {
ythrow TSystemError() << "Cannot block all signals in parent";
}
- /* arguments holders */
+ /* arguments holders */
TString shellArg;
TVector<char*> qargv;
- /*
- Following "const_cast"s are safe:
- http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
- */
- if (UseShell) {
- shellArg = GetQuotedCommand();
- qargv.reserve(4);
- qargv.push_back(const_cast<char*>("/bin/sh"));
- qargv.push_back(const_cast<char*>("-c"));
- // two args for 'sh -c -- ',
- // one for program name, and one for NULL at the end
+ /*
+ Following "const_cast"s are safe:
+ http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
+ */
+ if (UseShell) {
+ shellArg = GetQuotedCommand();
+ qargv.reserve(4);
+ qargv.push_back(const_cast<char*>("/bin/sh"));
+ qargv.push_back(const_cast<char*>("-c"));
+ // two args for 'sh -c -- ',
+ // one for program name, and one for NULL at the end
qargv.push_back(const_cast<char*>(shellArg.data()));
- } else {
- qargv.reserve(Arguments.size() + 2);
+ } else {
+ qargv.reserve(Arguments.size() + 2);
qargv.push_back(const_cast<char*>(Command.data()));
for (auto& i : Arguments) {
qargv.push_back(const_cast<char*>(i.data()));
- }
- }
-
- qargv.push_back(nullptr);
-
+ }
+ }
+
+ qargv.push_back(nullptr);
+
TVector<TString> envHolder;
TVector<char*> envp;
- if (!Environment.empty()) {
+ if (!Environment.empty()) {
for (auto& env : Environment) {
- envHolder.emplace_back(env.first + '=' + env.second);
+ envHolder.emplace_back(env.first + '=' + env.second);
envp.push_back(const_cast<char*>(envHolder.back().data()));
- }
- envp.push_back(nullptr);
- }
-
+ }
+ envp.push_back(nullptr);
+ }
+
pid_t pid = fork();
if (pid == -1) {
AtomicSet(ExecutionStatus, SHELL_ERROR);
/// @todo check if pipes are still open
ythrow TSystemError() << "Cannot fork";
} else if (pid == 0) { // child
- if (envp.size() != 0) {
+ if (envp.size() != 0) {
OnFork(pipes, oldmask, qargv.data(), envp.data(), FuncAfterFork);
- } else {
+ } else {
OnFork(pipes, oldmask, qargv.data(), nullptr, FuncAfterFork);
- }
+ }
} else { // parent
// restore signal mask
if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) {
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h
index dcb1c0cd0a..ab523631e4 100644
--- a/util/thread/lfqueue.h
+++ b/util/thread/lfqueue.h
@@ -76,16 +76,16 @@ class TLockFreeQueue: public TNonCopyable {
alignas(64) TRootNode* volatile FreePtr;
void TryToFreeAsyncMemory() {
- TAtomic keepCounter = AtomicAdd(FreeingTaskCounter, 0);
+ TAtomic keepCounter = AtomicAdd(FreeingTaskCounter, 0);
TRootNode* current = AtomicGet(FreePtr);
if (current == nullptr)
return;
if (AtomicAdd(FreememCounter, 0) == 1) {
// we are the last thread, try to cleanup
- // check if another thread have cleaned up
- if (keepCounter != AtomicAdd(FreeingTaskCounter, 0)) {
- return;
- }
+ // check if another thread have cleaned up
+ if (keepCounter != AtomicAdd(FreeingTaskCounter, 0)) {
+ return;
+ }
if (AtomicCas(&FreePtr, (TRootNode*)nullptr, current)) {
// free list
while (current) {
@@ -94,7 +94,7 @@ class TLockFreeQueue: public TNonCopyable {
delete current;
current = p;
}
- AtomicAdd(FreeingTaskCounter, 1);
+ AtomicAdd(FreeingTaskCounter, 1);
}
}
}
@@ -228,7 +228,7 @@ public:
TLockFreeQueue()
: JobQueue(new TRootNode)
, FreememCounter(0)
- , FreeingTaskCounter(0)
+ , FreeingTaskCounter(0)
, FreePtr(nullptr)
{
}