aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authoralbert <albert@yandex-team.ru>2022-02-10 16:48:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:15 +0300
commita817f5de12611ec73085eba17f8ec7740a46bdb7 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util/system
parent9f25ef3232c288ca664ceee6c376cf64e4349a2e (diff)
downloadydb-a817f5de12611ec73085eba17f8ec7740a46bdb7.tar.gz
Restoring authorship annotation for <albert@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/atomic_ut.cpp142
-rw-r--r--util/system/cpu_id.cpp18
-rw-r--r--util/system/file_ut.cpp4
-rw-r--r--util/system/maxlen.h8
-rw-r--r--util/system/platform.h2
-rw-r--r--util/system/tls.h78
6 files changed, 126 insertions, 126 deletions
diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp
index a0a0d60608..07211ffba7 100644
--- a/util/system/atomic_ut.cpp
+++ b/util/system/atomic_ut.cpp
@@ -4,10 +4,10 @@
#include <util/generic/ylimits.h>
-template <typename TAtomic>
-class TAtomicTest
+template <typename TAtomic>
+class TAtomicTest
: public TTestBase {
- UNIT_TEST_SUITE(TAtomicTest);
+ UNIT_TEST_SUITE(TAtomicTest);
UNIT_TEST(TestAtomicInc1)
UNIT_TEST(TestAtomicInc2)
UNIT_TEST(TestAtomicGetAndInc)
@@ -24,30 +24,30 @@ class TAtomicTest
UNIT_TEST(TestCAS)
UNIT_TEST(TestGetAndCAS)
UNIT_TEST(TestLockUnlock)
- UNIT_TEST_SUITE_END();
-
-private:
- inline void TestLockUnlock() {
- TAtomic v = 0;
-
- UNIT_ASSERT(AtomicTryLock(&v));
- UNIT_ASSERT(!AtomicTryLock(&v));
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- AtomicUnlock(&v);
- UNIT_ASSERT_VALUES_EQUAL(v, 0);
- }
-
- inline void TestCAS() {
- TAtomic v = 0;
-
- UNIT_ASSERT(AtomicCas(&v, 1, 0));
- UNIT_ASSERT(!AtomicCas(&v, 1, 0));
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT(AtomicCas(&v, 0, 1));
- UNIT_ASSERT_VALUES_EQUAL(v, 0);
- UNIT_ASSERT(AtomicCas(&v, Max<intptr_t>(), 0));
- UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
- }
+ UNIT_TEST_SUITE_END();
+
+private:
+ inline void TestLockUnlock() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT(AtomicTryLock(&v));
+ UNIT_ASSERT(!AtomicTryLock(&v));
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ AtomicUnlock(&v);
+ UNIT_ASSERT_VALUES_EQUAL(v, 0);
+ }
+
+ inline void TestCAS() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT(AtomicCas(&v, 1, 0));
+ UNIT_ASSERT(!AtomicCas(&v, 1, 0));
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT(AtomicCas(&v, 0, 1));
+ UNIT_ASSERT_VALUES_EQUAL(v, 0);
+ UNIT_ASSERT(AtomicCas(&v, Max<intptr_t>(), 0));
+ UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
+ }
inline void TestGetAndCAS() {
TAtomic v = 0;
@@ -61,23 +61,23 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
}
- inline void TestAtomicInc1() {
- TAtomic v = 0;
+ inline void TestAtomicInc1() {
+ TAtomic v = 0;
- UNIT_ASSERT(AtomicAdd(v, 1));
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT(AtomicAdd(v, 10));
- UNIT_ASSERT_VALUES_EQUAL(v, 11);
- }
+ UNIT_ASSERT(AtomicAdd(v, 1));
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT(AtomicAdd(v, 10));
+ UNIT_ASSERT_VALUES_EQUAL(v, 11);
+ }
- inline void TestAtomicInc2() {
- TAtomic v = 0;
+ inline void TestAtomicInc2() {
+ TAtomic v = 0;
- UNIT_ASSERT(AtomicIncrement(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT(AtomicIncrement(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 2);
- }
+ UNIT_ASSERT(AtomicIncrement(v));
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT(AtomicIncrement(v));
+ UNIT_ASSERT_VALUES_EQUAL(v, 2);
+ }
inline void TestAtomicGetAndInc() {
TAtomic v = 0;
@@ -88,14 +88,14 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, 2);
}
- inline void TestAtomicDec() {
- TAtomic v = 2;
+ inline void TestAtomicDec() {
+ TAtomic v = 2;
- UNIT_ASSERT(AtomicDecrement(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 1);
- UNIT_ASSERT(!AtomicDecrement(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 0);
- }
+ UNIT_ASSERT(AtomicDecrement(v));
+ UNIT_ASSERT_VALUES_EQUAL(v, 1);
+ UNIT_ASSERT(!AtomicDecrement(v));
+ UNIT_ASSERT_VALUES_EQUAL(v, 0);
+ }
inline void TestAtomicGetAndDec() {
TAtomic v = 2;
@@ -106,15 +106,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, 0);
}
- inline void TestAtomicAdd() {
- TAtomic v = 0;
+ inline void TestAtomicAdd() {
+ TAtomic v = 0;
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, 1), 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, 2), 3);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, -4), -1);
+ UNIT_ASSERT_VALUES_EQUAL(v, -1);
+ }
- UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, 1), 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, 2), 3);
- UNIT_ASSERT_VALUES_EQUAL(AtomicAdd(v, -4), -1);
- UNIT_ASSERT_VALUES_EQUAL(v, -1);
- }
-
inline void TestAtomicGetAndAdd() {
TAtomic v = 0;
@@ -125,13 +125,13 @@ private:
}
inline void TestAtomicSub() {
- TAtomic v = 4;
+ TAtomic v = 4;
- UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 1), 3);
- UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 2), 1);
- UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 3), -2);
- UNIT_ASSERT_VALUES_EQUAL(v, -2);
- }
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 1), 3);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSub(v, 3), -2);
+ UNIT_ASSERT_VALUES_EQUAL(v, -2);
+ }
inline void TestAtomicGetAndSub() {
TAtomic v = 4;
@@ -142,15 +142,15 @@ private:
UNIT_ASSERT_VALUES_EQUAL(v, -2);
}
- inline void TestAtomicSwap() {
- TAtomic v = 0;
+ inline void TestAtomicSwap() {
+ TAtomic v = 0;
UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 3), 0);
UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 5), 3);
UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, -7), 5);
UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, Max<intptr_t>()), -7);
- UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
- }
+ UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
+ }
inline void TestAtomicOr() {
TAtomic v = 0xf0;
@@ -191,26 +191,26 @@ private:
UNIT_TEST_SUITE_REGISTRATION(TAtomicTest<TAtomic>);
#ifndef _MSC_VER
-// chooses type *other than* T1
+// chooses type *other than* T1
template <typename T1, typename T2, typename T3>
struct TChooser {
using TdType = T2;
-};
+};
template <typename T1, typename T2>
struct TChooser<T1, T1, T2> {
using TdType = T2;
-};
+};
template <typename T1>
struct TChooser<T1, T1, T1> {};
-
+
#if defined(__IOS__) && defined(_32_)
using TAltAtomic = int;
#else
using TAltAtomic = volatile TChooser<TAtomicBase, long, long long>::TdType;
#endif
-
+
class TTTest: public TAtomicTest<TAltAtomic> {
public:
TString Name() const noexcept override {
diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp
index 0ae06b2868..598c71f4d9 100644
--- a/util/system/cpu_id.cpp
+++ b/util/system/cpu_id.cpp
@@ -60,8 +60,8 @@ bool NX86::CpuId(ui32 op, ui32* res) noexcept {
return false;
#endif
-}
-
+}
+
namespace {
union TX86CpuInfo {
ui32 Info[4];
@@ -80,11 +80,11 @@ namespace {
inline TX86CpuInfo(ui32 op, ui32 subOp) noexcept {
NX86::CpuId(op, subOp, Info);
}
- };
+ };
static_assert(sizeof(TX86CpuInfo) == 16, "please, fix me");
}
-
+
// https://en.wikipedia.org/wiki/CPUID
bool NX86::HaveRDTSCP() noexcept {
return (TX86CpuInfo(0x80000001).EDX >> 27) & 1u;
@@ -96,8 +96,8 @@ bool NX86::HaveSSE() noexcept {
bool NX86::HaveSSE2() noexcept {
return (TX86CpuInfo(0x1).EDX >> 26) & 1u;
-}
-
+}
+
bool NX86::HaveSSE3() noexcept {
return TX86CpuInfo(0x1).ECX & 1u;
}
@@ -116,8 +116,8 @@ bool NX86::HaveSSE41() noexcept {
bool NX86::HaveSSE42() noexcept {
return (TX86CpuInfo(0x1).ECX >> 20) & 1u;
-}
-
+}
+
bool NX86::HaveF16C() noexcept {
return (TX86CpuInfo(0x1).ECX >> 29) & 1u;
}
@@ -253,7 +253,7 @@ const char* CpuBrand(ui32* store) noexcept {
#endif
return (const char*)store;
-}
+}
#define Y_DEF_NAME(X) \
bool NX86::CachedHave##X() noexcept { \
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 4e8ada2d9a..941e6a50f3 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -175,7 +175,7 @@ void TFileTest::TestRW() {
f1.Flush();
ui32 v;
f1.Load(&v, sizeof(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 3u);
+ UNIT_ASSERT_VALUES_EQUAL(v, 3u);
UNIT_ASSERT_VALUES_EQUAL(f1.GetPosition(), 16);
TFile f2 = f1;
@@ -189,7 +189,7 @@ void TFileTest::TestRW() {
UNIT_ASSERT_VALUES_EQUAL(f1.Seek(-4, sCur), 16);
v = 0;
f1.Load(&v, sizeof(v));
- UNIT_ASSERT_VALUES_EQUAL(v, 3u);
+ UNIT_ASSERT_VALUES_EQUAL(v, 3u);
f1.Close();
UNIT_ASSERT(!f1.IsOpen());
UNIT_ASSERT(!f2.IsOpen());
diff --git a/util/system/maxlen.h b/util/system/maxlen.h
index 49efad8a23..e1ff7f5008 100644
--- a/util/system/maxlen.h
+++ b/util/system/maxlen.h
@@ -2,11 +2,11 @@
#include <cstdlib>
-// http://support.microsoft.com/kb/208427
-#ifndef URL_MAXLEN
+// http://support.microsoft.com/kb/208427
+#ifndef URL_MAXLEN
#define URL_MAXLEN 2083
-#endif
-
+#endif
+
#define HOST_MAX 260
#ifndef URL_MAX
#define URL_MAX 1024
diff --git a/util/system/platform.h b/util/system/platform.h
index 512d940123..58f310ab34 100644
--- a/util/system/platform.h
+++ b/util/system/platform.h
@@ -240,7 +240,7 @@
#define SIZEOF_LONG_LONG 8
#define SIZEOF_UNSIGNED_LONG_LONG 8
-#undef SIZEOF_SIZE_T // in case we include <Python.h> which defines it, too
+#undef SIZEOF_SIZE_T // in case we include <Python.h> which defines it, too
#define SIZEOF_SIZE_T SIZEOF_PTR
// clang-format on
diff --git a/util/system/tls.h b/util/system/tls.h
index b42508143c..3c4f56dbeb 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -178,42 +178,42 @@ namespace NTls {
template <class T>
class TValue: public TMoveOnly {
- class TConstructor {
- public:
+ class TConstructor {
+ public:
TConstructor() noexcept = default;
virtual ~TConstructor() = default;
- virtual T* Construct(void* ptr) const = 0;
- };
+ virtual T* Construct(void* ptr) const = 0;
+ };
- class TDefaultConstructor: public TConstructor {
- public:
+ class TDefaultConstructor: public TConstructor {
+ public:
~TDefaultConstructor() override = default;
T* Construct(void* ptr) const override {
//memset(ptr, 0, sizeof(T));
return ::new (ptr) T();
- }
- };
+ }
+ };
- template <class T1>
- class TCopyConstructor: public TConstructor {
- public:
- inline TCopyConstructor(const T1& value)
- : Value(value)
- {
- }
+ template <class T1>
+ class TCopyConstructor: public TConstructor {
+ public:
+ inline TCopyConstructor(const T1& value)
+ : Value(value)
+ {
+ }
~TCopyConstructor() override = default;
T* Construct(void* ptr) const override {
return ::new (ptr) T(Value);
- }
+ }
- private:
- T1 Value;
- };
+ private:
+ T1 Value;
+ };
public:
inline TValue()
@@ -239,30 +239,30 @@ namespace NTls {
}
inline operator T&() {
- return Get();
- }
-
+ return Get();
+ }
+
inline const T& operator->() const {
return Get();
}
- inline T& operator->() {
- return Get();
- }
-
- inline const T* operator&() const {
- return GetPtr();
- }
-
- inline T* operator&() {
- return GetPtr();
- }
-
+ inline T& operator->() {
+ return Get();
+ }
+
+ inline const T* operator&() const {
+ return GetPtr();
+ }
+
+ inline T* operator&() {
+ return GetPtr();
+ }
+
inline T& Get() const {
- return *GetPtr();
- }
-
- inline T* GetPtr() const {
+ return *GetPtr();
+ }
+
+ inline T* GetPtr() const {
T* val = static_cast<T*>(Key_.Get());
if (!val) {
@@ -274,7 +274,7 @@ namespace NTls {
val = newval.Release();
}
- return val;
+ return val;
}
private: