diff options
author | swarmer <swarmer@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
commit | 317da38588b7898a99fd9168571408123350012b (patch) | |
tree | 25eebc31526019ad39a6c1b13f492963d97ba439 /util/system | |
parent | 3b2241461d41d41ba1a706b0750c4f0f55c344f6 (diff) | |
download | ydb-317da38588b7898a99fd9168571408123350012b.tar.gz |
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system')
-rw-r--r-- | util/system/atexit.cpp | 32 | ||||
-rw-r--r-- | util/system/benchmark/cpu_id/metrics/ya.make | 2 | ||||
-rw-r--r-- | util/system/benchmark/cpu_id/ya.make | 2 | ||||
-rw-r--r-- | util/system/benchmark/create_destroy_thread/metrics/ya.make | 2 | ||||
-rw-r--r-- | util/system/benchmark/rdtsc/ya.make | 2 | ||||
-rw-r--r-- | util/system/benchmark/ya.make | 2 | ||||
-rw-r--r-- | util/system/guard_ut.cpp | 16 | ||||
-rw-r--r-- | util/system/sanitizers.h | 6 | ||||
-rw-r--r-- | util/system/src_location.h | 10 | ||||
-rw-r--r-- | util/system/src_location_ut.cpp | 6 | ||||
-rw-r--r-- | util/system/src_root.h | 62 | ||||
-rw-r--r-- | util/system/src_root_ut.cpp | 28 | ||||
-rw-r--r-- | util/system/ut/stdin_osfhandle/ya.make | 2 | ||||
-rw-r--r-- | util/system/ut/ya.make | 2 | ||||
-rw-r--r-- | util/system/ya.make | 10 | ||||
-rw-r--r-- | util/system/yassert.cpp | 38 |
16 files changed, 111 insertions, 111 deletions
diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp index 74fb10b6b1..9f77f07a06 100644 --- a/util/system/atexit.cpp +++ b/util/system/atexit.cpp @@ -1,5 +1,5 @@ #include "atexit.h" -#include "atomic.h" +#include "atomic.h" #include "yassert.h" #include "spinlock.h" #include "thread.h" @@ -77,29 +77,29 @@ namespace { }; static TAtomic atExitLock = 0; - static TAtExit* volatile atExitPtr = nullptr; + static TAtExit* volatile atExitPtr = nullptr; alignas(TAtExit) static char atExitMem[sizeof(TAtExit)]; static void OnExit() { - if (TAtExit* const atExit = AtomicGet(atExitPtr)) { + if (TAtExit* const atExit = AtomicGet(atExitPtr)) { atExit->Finish(); atExit->~TAtExit(); - AtomicSet(atExitPtr, nullptr); + AtomicSet(atExitPtr, nullptr); } } static inline TAtExit* Instance() { - if (TAtExit* const atExit = AtomicGet(atExitPtr)) { - return atExit; - } + if (TAtExit* const atExit = AtomicGet(atExitPtr)) { + return atExit; + } with_lock (atExitLock) { - if (TAtExit* const atExit = AtomicGet(atExitPtr)) { - return atExit; + if (TAtExit* const atExit = AtomicGet(atExitPtr)) { + return atExit; } - atexit(OnExit); - TAtExit* const atExit = new (atExitMem) TAtExit; - AtomicSet(atExitPtr, atExit); - return atExit; + atexit(OnExit); + TAtExit* const atExit = new (atExitMem) TAtExit; + AtomicSet(atExitPtr, atExit); + return atExit; } } } @@ -109,10 +109,10 @@ void ManualRunAtExitFinalizers() { } bool ExitStarted() { - if (TAtExit* const atExit = AtomicGet(atExitPtr)) { - return atExit->FinishStarted(); + if (TAtExit* const atExit = AtomicGet(atExitPtr)) { + return atExit->FinishStarted(); } - return false; + return false; } void AtExit(TAtExitFunc func, void* ctx, size_t priority) { diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make index 8c55def99b..f22decac96 100644 --- a/util/system/benchmark/cpu_id/metrics/ya.make +++ b/util/system/benchmark/cpu_id/metrics/ya.make @@ -2,7 +2,7 @@ OWNER( yazevnul g:util ) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) PY2TEST() diff --git a/util/system/benchmark/cpu_id/ya.make b/util/system/benchmark/cpu_id/ya.make index 976977014f..7ba0dcee94 100644 --- a/util/system/benchmark/cpu_id/ya.make +++ b/util/system/benchmark/cpu_id/ya.make @@ -2,7 +2,7 @@ OWNER( yazevnul g:util ) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) Y_BENCHMARK() diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make index d526487e1a..0576c4d9cf 100644 --- a/util/system/benchmark/create_destroy_thread/metrics/ya.make +++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make @@ -2,7 +2,7 @@ OWNER( yazevnul g:util ) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) PY2TEST() diff --git a/util/system/benchmark/rdtsc/ya.make b/util/system/benchmark/rdtsc/ya.make index 7059abc3a4..5628d4fb8a 100644 --- a/util/system/benchmark/rdtsc/ya.make +++ b/util/system/benchmark/rdtsc/ya.make @@ -1,7 +1,7 @@ Y_BENCHMARK() OWNER(g:util) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) SRCS( main.cpp diff --git a/util/system/benchmark/ya.make b/util/system/benchmark/ya.make index 12fa9af9d6..dc009eea23 100644 --- a/util/system/benchmark/ya.make +++ b/util/system/benchmark/ya.make @@ -2,7 +2,7 @@ OWNER( yazevnul g:util ) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) RECURSE( cpu_id diff --git a/util/system/guard_ut.cpp b/util/system/guard_ut.cpp index 404ede99ab..6cb9079211 100644 --- a/util/system/guard_ut.cpp +++ b/util/system/guard_ut.cpp @@ -14,7 +14,7 @@ struct TTestGuard: public TTestBase { UNIT_TEST(TestUnguard) UNIT_TEST(TestTryReadGuard) UNIT_TEST(TestWithLock) - UNIT_TEST(TestWithLockScope); + UNIT_TEST(TestWithLockScope); UNIT_TEST_SUITE_END(); struct TGuardChecker { @@ -167,14 +167,14 @@ struct TTestGuard: public TTestBase { UNIT_ASSERT(!m.guarded); UNIT_ASSERT_EQUAL(n, 43); } - - void TestWithLockScope() { - auto Guard = [](auto) { UNIT_FAIL("Non global Guard used"); return 0; }; - TGuardChecker m; + + void TestWithLockScope() { + auto Guard = [](auto) { UNIT_FAIL("Non global Guard used"); return 0; }; + TGuardChecker m; with_lock (m) { - Y_UNUSED(Guard); - } - } + Y_UNUSED(Guard); + } + } }; UNIT_TEST_SUITE_REGISTRATION(TTestGuard) diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h index 965e5c751e..501693535d 100644 --- a/util/system/sanitizers.h +++ b/util/system/sanitizers.h @@ -55,7 +55,7 @@ namespace NSan { } // Determines if asan present - inline constexpr static bool ASanIsOn() noexcept { + inline constexpr static bool ASanIsOn() noexcept { #if defined(_asan_enabled_) return true; #else @@ -64,7 +64,7 @@ namespace NSan { } // Determines if tsan present - inline constexpr static bool TSanIsOn() noexcept { + inline constexpr static bool TSanIsOn() noexcept { #if defined(_tsan_enabled_) return true; #else @@ -73,7 +73,7 @@ namespace NSan { } // Determines if msan present - inline constexpr static bool MSanIsOn() noexcept { + inline constexpr static bool MSanIsOn() noexcept { #if defined(_msan_enabled_) return true; #else diff --git a/util/system/src_location.h b/util/system/src_location.h index 12ba6e063e..0117cdebf8 100644 --- a/util/system/src_location.h +++ b/util/system/src_location.h @@ -15,11 +15,11 @@ struct TSourceLocation { int Line; }; -// __SOURCE_FILE__ should be used instead of __FILE__ -#if !defined(__NVCC__) +// __SOURCE_FILE__ should be used instead of __FILE__ +#if !defined(__NVCC__) #define __SOURCE_FILE__ (__SOURCE_FILE_IMPL__.As<TStringBuf>()) -#else +#else #define __SOURCE_FILE__ (__SOURCE_FILE_IMPL__.template As<TStringBuf>()) -#endif - +#endif + #define __LOCATION__ ::TSourceLocation(__SOURCE_FILE__, __LINE__) diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp index 5b86cb86ef..5e880d950b 100644 --- a/util/system/src_location_ut.cpp +++ b/util/system/src_location_ut.cpp @@ -11,8 +11,8 @@ static inline TString GenLoc() { Y_UNIT_TEST_SUITE(TestLocation) { Y_UNIT_TEST(Test1) { UNIT_ASSERT_VALUES_EQUAL(GenLoc(), "util/system/src_location_ut.cpp:8"); - - static constexpr TSourceLocation location = __LOCATION__; - static_assert(location.Line >= 0, "__LOCATION__ can be used at compile time expressions"); + + static constexpr TSourceLocation location = __LOCATION__; + static_assert(location.Line >= 0, "__LOCATION__ can be used at compile time expressions"); } } diff --git a/util/system/src_root.h b/util/system/src_root.h index 4f2d9f5ee6..17bea82be5 100644 --- a/util/system/src_root.h +++ b/util/system/src_root.h @@ -3,8 +3,8 @@ #include "compiler.h" #include "defaults.h" -#include <type_traits> - +#include <type_traits> + namespace NPrivate { struct TStaticBuf { constexpr TStaticBuf(const char* data, unsigned len) noexcept @@ -32,37 +32,37 @@ namespace NPrivate { constexpr TStaticBuf ArcRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_ROOT)); constexpr TStaticBuf BuildRoot = STATIC_BUF(Y_STRINGIZE(ARCADIA_BUILD_ROOT)); - constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept { - if (prefix.Len < string.Len) { - for (unsigned i = prefix.Len; i-- > 0;) { - if (prefix.Data[i] != string.Data[i]) { - return false; - } - } - return true; - } else { - return false; - } - } - - constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept { - if (IsProperPrefix(ArcRoot, f)) { - return ArcRoot.Len + 1; + constexpr Y_FORCE_INLINE bool IsProperPrefix(const TStaticBuf prefix, const TStaticBuf string) noexcept { + if (prefix.Len < string.Len) { + for (unsigned i = prefix.Len; i-- > 0;) { + if (prefix.Data[i] != string.Data[i]) { + return false; + } + } + return true; + } else { + return false; + } + } + + constexpr unsigned RootPrefixLength(const TStaticBuf& f) noexcept { + if (IsProperPrefix(ArcRoot, f)) { + return ArcRoot.Len + 1; } - if (IsProperPrefix(BuildRoot, f)) { - return BuildRoot.Len + 1; + if (IsProperPrefix(BuildRoot, f)) { + return BuildRoot.Len + 1; } - return 0; - } - - constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept { - return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength); - } - - //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp - constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept { - return StripRoot(f, RootPrefixLength(f)); + return 0; } + + constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f, unsigned prefixLength) noexcept { + return TStaticBuf(f.Data + prefixLength, f.Len - prefixLength); + } + + //$(SRC_ROOT)/prj/blah.cpp -> prj/blah.cpp + constexpr Y_FORCE_INLINE TStaticBuf StripRoot(const TStaticBuf& f) noexcept { + return StripRoot(f, RootPrefixLength(f)); + } } -#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value) +#define __SOURCE_FILE_IMPL__ ::NPrivate::StripRoot(STATIC_BUF(__FILE__), std::integral_constant<unsigned, ::NPrivate::RootPrefixLength(STATIC_BUF(__FILE__))>::value) diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp index e9a675eb9a..852f9dd668 100644 --- a/util/system/src_root_ut.cpp +++ b/util/system/src_root_ut.cpp @@ -9,19 +9,19 @@ Y_UNIT_TEST_SUITE(TestSourceRoot) { const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct(); UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp"); } - - Y_UNIT_TEST(TestPrivateChopPrefixRoutine) { - static constexpr const char str[] = ":\0:\0: It's unlikely that this string has an ARCADIA_ROOT as its prefix :\0:\0:"; - static constexpr const auto strStaticBuf = STATIC_BUF(str); + + Y_UNIT_TEST(TestPrivateChopPrefixRoutine) { + static constexpr const char str[] = ":\0:\0: It's unlikely that this string has an ARCADIA_ROOT as its prefix :\0:\0:"; + static constexpr const auto strStaticBuf = STATIC_BUF(str); UNIT_ASSERT_VALUES_EQUAL(TStringBuf(str, sizeof(str) - 1), ::NPrivate::StripRoot(strStaticBuf).As<TStringBuf>()); - UNIT_ASSERT_VALUES_EQUAL(0, ::NPrivate::RootPrefixLength(strStaticBuf)); - - static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("foo"), STATIC_BUF("foobar")), R"(IsProperPrefix("foo", "foobar") failed)"); - static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("foobar"), STATIC_BUF("foo")), R"(IsProperPrefix("foobar", "foo") failed)"); - static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name")), R"(IsProperPrefix("name", "name") failed)"); - static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name/")), R"(IsProperPrefix("name", "name/") failed)"); - static_assert(::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("foobar")), R"(IsProperPrefix("", "foobar") failed)"); - static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("")), R"(IsProperPrefix("", "") failed)"); - static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("dir"), STATIC_BUF("dir/file")), R"(IsProperPrefix("dir", "dir/file") failed)"); - } + UNIT_ASSERT_VALUES_EQUAL(0, ::NPrivate::RootPrefixLength(strStaticBuf)); + + static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("foo"), STATIC_BUF("foobar")), R"(IsProperPrefix("foo", "foobar") failed)"); + static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("foobar"), STATIC_BUF("foo")), R"(IsProperPrefix("foobar", "foo") failed)"); + static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name")), R"(IsProperPrefix("name", "name") failed)"); + static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("name"), STATIC_BUF("name/")), R"(IsProperPrefix("name", "name/") failed)"); + static_assert(::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("foobar")), R"(IsProperPrefix("", "foobar") failed)"); + static_assert(!::NPrivate::IsProperPrefix(STATIC_BUF(""), STATIC_BUF("")), R"(IsProperPrefix("", "") failed)"); + static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("dir"), STATIC_BUF("dir/file")), R"(IsProperPrefix("dir", "dir/file") failed)"); + } } diff --git a/util/system/ut/stdin_osfhandle/ya.make b/util/system/ut/stdin_osfhandle/ya.make index d71ab22e69..5d3701adf0 100644 --- a/util/system/ut/stdin_osfhandle/ya.make +++ b/util/system/ut/stdin_osfhandle/ya.make @@ -1,7 +1,7 @@ PROGRAM() OWNER(g:util) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) SRCS( main.cpp diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make index 127e7c261e..6b758d2f48 100644 --- a/util/system/ut/ya.make +++ b/util/system/ut/ya.make @@ -1,7 +1,7 @@ UNITTEST_FOR(util) OWNER(g:util) -SUBSCRIBER(g:util-subscribers) +SUBSCRIBER(g:util-subscribers) FORK_TESTS() diff --git a/util/system/ya.make b/util/system/ya.make index 79c9498ddd..24723ab579 100644 --- a/util/system/ya.make +++ b/util/system/ya.make @@ -1,6 +1,6 @@ OWNER(g:util) -SUBSCRIBER(g:util-subscribers) - -RECURSE_FOR_TESTS( - ut -) +SUBSCRIBER(g:util-subscribers) + +RECURSE_FOR_TESTS( + ut +) diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp index 0f586648b7..60dbe4c04a 100644 --- a/util/system/yassert.cpp +++ b/util/system/yassert.cpp @@ -7,7 +7,7 @@ #include <util/datetime/base.h> #include <util/generic/singleton.h> -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> #include <util/stream/output.h> #include <util/stream/str.h> @@ -34,9 +34,9 @@ namespace { struct TPanicLockHolder: public TAdaptiveLock { }; } -namespace NPrivate { - [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept; -} +namespace NPrivate { + [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept; +} void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, const char* expr, const char* format, ...) noexcept { try { @@ -51,18 +51,18 @@ void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, c vsprintf(errorMsg, format[0] == ' ' ? format + 1 : format, args); va_end(args); - constexpr int abiPlaceholder = 0; - ::NPrivate::InternalPanicImpl(line, function, expr, abiPlaceholder, abiPlaceholder, abiPlaceholder, file.As<TStringBuf>(), errorMsg.c_str(), errorMsg.size()); - } catch (...) { - // ¯\_(ツ)_/¯ - } - - abort(); -} - -namespace NPrivate { - [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try { - TStringBuf errorMsg{errorMessage, errorMessageSize}; + constexpr int abiPlaceholder = 0; + ::NPrivate::InternalPanicImpl(line, function, expr, abiPlaceholder, abiPlaceholder, abiPlaceholder, file.As<TStringBuf>(), errorMsg.c_str(), errorMsg.size()); + } catch (...) { + // ¯\_(ツ)_/¯ + } + + abort(); +} + +namespace NPrivate { + [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try { + TStringBuf errorMsg{errorMessage, errorMessageSize}; const TString now = TInstant::Now().ToStringLocal(); TString r; @@ -72,7 +72,7 @@ namespace NPrivate { } else { o << "FAIL (" << now << "): " << errorMsg << Endl; } - o << " " << file << ":" << line << Endl; + o << " " << file << ":" << line << Endl; if (expr) { o << " " << function << "(): requirement " << expr << " failed" << Endl; } else { @@ -87,8 +87,8 @@ namespace NPrivate { Cerr << "Failed to dump clang coverage" << Endl; } #endif - abort(); + abort(); } catch (...) { - abort(); + abort(); } } |