diff options
author | Cthulhu <cthulhu@yandex-team.ru> | 2022-02-10 16:47:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:44 +0300 |
commit | 6aced6c854653b75aab9808d5995be5fc4d9fa53 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /util/system | |
parent | bcb3e9d0eb2a8188a6a9fe0907a8949ce4881a4e (diff) | |
download | ydb-6aced6c854653b75aab9808d5995be5fc4d9fa53.tar.gz |
Restoring authorship annotation for Cthulhu <cthulhu@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r-- | util/system/backtrace.cpp | 12 | ||||
-rw-r--r-- | util/system/backtrace.h | 6 | ||||
-rw-r--r-- | util/system/backtrace_ut.cpp | 24 | ||||
-rw-r--r-- | util/system/file.cpp | 24 | ||||
-rw-r--r-- | util/system/file_ut.cpp | 20 | ||||
-rw-r--r-- | util/system/hp_timer.cpp | 56 | ||||
-rw-r--r-- | util/system/sanitizers.h | 20 |
7 files changed, 81 insertions, 81 deletions
diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp index 854f107383..b77fe58fb1 100644 --- a/util/system/backtrace.cpp +++ b/util/system/backtrace.cpp @@ -245,12 +245,12 @@ void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtrac TFormatBackTraceFn FormatBackTraceFn = FormatBackTrace; -TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f) { - TFormatBackTraceFn prevFn = FormatBackTraceFn; - FormatBackTraceFn = f; - return prevFn; -} - +TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f) { + TFormatBackTraceFn prevFn = FormatBackTraceFn; + FormatBackTraceFn = f; + return prevFn; +} + void FormatBackTrace(IOutputStream* out) { void* array[300]; const size_t s = BackTrace(array, Y_ARRAY_SIZE(array)); diff --git a/util/system/backtrace.h b/util/system/backtrace.h index 2f93b6bc99..2fce7585c3 100644 --- a/util/system/backtrace.h +++ b/util/system/backtrace.h @@ -19,10 +19,10 @@ void FormatBackTrace(IOutputStream* out); void PrintBackTrace(); using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize); - -TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f); + +TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f); TFormatBackTraceFn GetFormatBackTraceFn(); - + using TBackTraceView = TArrayRef<void* const>; class TBackTrace { diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp index ae098ce0bf..9b5ead71bc 100644 --- a/util/system/backtrace_ut.cpp +++ b/util/system/backtrace_ut.cpp @@ -18,9 +18,9 @@ int Dbg2(void** buf, size_t len) { } void FormatBackTraceReplacement(IOutputStream* out, void* const*, size_t) { - *out << "WorksLikeACharm" << Endl; -} - + *out << "WorksLikeACharm" << Endl; +} + void SomeMethod() { TStringStream out; @@ -39,22 +39,22 @@ class TBackTraceTest: public TTestBase { UNIT_TEST(TestBackTrace) UNIT_TEST(TestBackTraceView) UNIT_TEST(TestPrintBackTrace) - UNIT_TEST(TestSetFormatBackTraceFn) + UNIT_TEST(TestSetFormatBackTraceFn) UNIT_TEST_SUITE_END(); void TestPrintBackTrace() { SomeMethod(); } - void TestSetFormatBackTraceFn() { - TFormatBackTraceFn prevFn = SetFormatBackTraceFn(FormatBackTraceReplacement); - TStringStream out; - FormatBackTrace(&out); - SetFormatBackTraceFn(prevFn); + void TestSetFormatBackTraceFn() { + TFormatBackTraceFn prevFn = SetFormatBackTraceFn(FormatBackTraceReplacement); + TStringStream out; + FormatBackTrace(&out); + SetFormatBackTraceFn(prevFn); UNIT_ASSERT(out.Str().Contains("WorksLikeACharm")); - TestPrintBackTrace(); - } - + TestPrintBackTrace(); + } + void TestBackTrace() { //PrintBackTrace(); void* buf1[100]; diff --git a/util/system/file.cpp b/util/system/file.cpp index 6a140dc446..4a261d020c 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -184,25 +184,25 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept { } */ #if defined(_freebsd_) - if (oMode & (Direct | DirectAligned)) { - fcMode |= O_DIRECT; - } - - if (oMode & Sync) { - fcMode |= O_SYNC; - } + if (oMode & (Direct | DirectAligned)) { + fcMode |= O_DIRECT; + } + + if (oMode & Sync) { + fcMode |= O_SYNC; + } #elif defined(_linux_) - if (oMode & DirectAligned) { + if (oMode & DirectAligned) { /* * O_DIRECT in Linux requires aligning request size and buffer address * to size of hardware sector (see hw_sector_size or ioctl BLKSSZGET). * Usually 512 bytes, but modern hardware works better with 4096 bytes. */ fcMode |= O_DIRECT; - } - if (oMode & Sync) { - fcMode |= O_SYNC; - } + } + if (oMode & Sync) { + fcMode |= O_SYNC; + } #endif #if defined(_linux_) diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index e8463f3382..941e6a50f3 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -10,7 +10,7 @@ class TFileTest: public TTestBase { UNIT_TEST_SUITE(TFileTest); UNIT_TEST(TestOpen); - UNIT_TEST(TestOpenSync); + UNIT_TEST(TestOpenSync); UNIT_TEST(TestRW); UNIT_TEST(TestReWrite); UNIT_TEST(TestAppend); @@ -28,7 +28,7 @@ class TFileTest: public TTestBase { public: void TestOpen(); - void TestOpenSync(); + void TestOpenSync(); void TestRW(); void TestLocale(); void TestFlush(); @@ -154,14 +154,14 @@ void TFileTest::TestOpen() { UNIT_ASSERT(unlink("f1.txt") == 0); } -void TFileTest::TestOpenSync() { - TFile f1("f1.txt", CreateNew | Sync); - UNIT_ASSERT(f1.IsOpen()); - f1.Close(); - UNIT_ASSERT(!f1.IsOpen()); - UNIT_ASSERT(unlink("f1.txt") == 0); -} - +void TFileTest::TestOpenSync() { + TFile f1("f1.txt", CreateNew | Sync); + UNIT_ASSERT(f1.IsOpen()); + f1.Close(); + UNIT_ASSERT(!f1.IsOpen()); + UNIT_ASSERT(unlink("f1.txt") == 0); +} + void TFileTest::TestRW() { TFile f1("f1.txt", CreateNew); UNIT_ASSERT(f1.IsOpen()); diff --git a/util/system/hp_timer.cpp b/util/system/hp_timer.cpp index cb80041ebf..e4c3f21e6b 100644 --- a/util/system/hp_timer.cpp +++ b/util/system/hp_timer.cpp @@ -21,43 +21,43 @@ namespace { static double EstimateCPUClock() { for (;;) { - ui64 startCycle = 0; - ui64 startMS = 0; - - for (;;) { - startMS = MicroSeconds(); - startCycle = GetCycleCount(); - - ui64 n = MicroSeconds(); - - if (n - startMS < 100) { - break; - } + ui64 startCycle = 0; + ui64 startMS = 0; + + for (;;) { + startMS = MicroSeconds(); + startCycle = GetCycleCount(); + + ui64 n = MicroSeconds(); + + if (n - startMS < 100) { + break; + } } - Sleep(TDuration::MicroSeconds(5000)); + Sleep(TDuration::MicroSeconds(5000)); - ui64 finishCycle = 0; - ui64 finishMS = 0; + ui64 finishCycle = 0; + ui64 finishMS = 0; - for (;;) { - finishMS = MicroSeconds(); + for (;;) { + finishMS = MicroSeconds(); - if (finishMS - startMS < 100) { - continue; - } + if (finishMS - startMS < 100) { + continue; + } - finishCycle = GetCycleCount(); + finishCycle = GetCycleCount(); - ui64 n = MicroSeconds(); + ui64 n = MicroSeconds(); - if (n - finishMS < 100) { - break; - } + if (n - finishMS < 100) { + break; + } + } + if (startMS < finishMS && startCycle < finishCycle) { + return (finishCycle - startCycle) * 1000000.0 / (finishMS - startMS); } - if (startMS < finishMS && startCycle < finishCycle) { - return (finishCycle - startCycle) * 1000000.0 / (finishMS - startMS); - } } } diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h index 18d8666e88..965e5c751e 100644 --- a/util/system/sanitizers.h +++ b/util/system/sanitizers.h @@ -1,5 +1,5 @@ -#pragma once - +#pragma once + #include "defaults.h" extern "C" { // sanitizers API @@ -69,18 +69,18 @@ namespace NSan { return true; #else return false; -#endif +#endif } - + // Determines if msan present inline constexpr static bool MSanIsOn() noexcept { #if defined(_msan_enabled_) return true; #else return false; -#endif +#endif } - + // Make memory region fully initialized (without changing its contents). inline static void Unpoison(const volatile void* a, size_t size) noexcept { #if defined(_msan_enabled_) @@ -90,18 +90,18 @@ namespace NSan { Y_UNUSED(size); #endif } - + // Make memory region fully uninitialized (without changing its contents). // This is a legacy interface that does not update origin information. Use __msan_allocated_memory() instead. inline static void Poison(const volatile void* a, size_t size) noexcept { #if defined(_msan_enabled_) __msan_poison(a, size); -#else +#else Y_UNUSED(a); Y_UNUSED(size); -#endif +#endif } - + // Checks that memory range is fully initialized, and reports an error if it is not. inline static void CheckMemIsInitialized(const volatile void* a, size_t size) noexcept { #if defined(_msan_enabled_) |