diff options
author | somov <somov@yandex-team.ru> | 2022-02-10 16:45:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:49 +0300 |
commit | 7489e4682331202b9c7d863c0898eb83d7b12c2b (patch) | |
tree | 9142afc54d335ea52910662635b898e79e192e49 /util/system | |
parent | a5950576e397b1909261050b8c7da16db58f10b1 (diff) | |
download | ydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz |
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r-- | util/system/compat.cpp | 18 | ||||
-rw-r--r-- | util/system/compat.h | 10 | ||||
-rw-r--r-- | util/system/compiler.h | 20 | ||||
-rw-r--r-- | util/system/context.h | 4 | ||||
-rw-r--r-- | util/system/defaults.h | 10 | ||||
-rw-r--r-- | util/system/file_ut.cpp | 4 | ||||
-rw-r--r-- | util/system/filemap.h | 12 | ||||
-rw-r--r-- | util/system/mktemp.cpp | 10 | ||||
-rw-r--r-- | util/system/platform.h | 32 | ||||
-rw-r--r-- | util/system/sanitizers.cpp | 14 | ||||
-rw-r--r-- | util/system/sanitizers.h | 4 | ||||
-rw-r--r-- | util/system/shmat.cpp | 36 | ||||
-rw-r--r-- | util/system/thread.cpp | 24 | ||||
-rw-r--r-- | util/system/tls.h | 6 | ||||
-rw-r--r-- | util/system/winint.h | 4 | ||||
-rw-r--r-- | util/system/yassert.h | 24 |
16 files changed, 116 insertions, 116 deletions
diff --git a/util/system/compat.cpp b/util/system/compat.cpp index f1ea393ea7..18fbfa296a 100644 --- a/util/system/compat.cpp +++ b/util/system/compat.cpp @@ -23,15 +23,15 @@ const char* getprogname() { #endif #ifdef _win_ - -void sleep(i64 len) { - Sleep((unsigned long)len * 1000); -} - -void usleep(i64 len) { - Sleep((unsigned long)len / 1000); -} - + +void sleep(i64 len) { + Sleep((unsigned long)len * 1000); +} + +void usleep(i64 len) { + Sleep((unsigned long)len / 1000); +} + #include <fcntl.h> int ftruncate(int fd, i64 length) { return _chsize_s(fd, length); diff --git a/util/system/compat.h b/util/system/compat.h index ef91de58ae..c53dbcca17 100644 --- a/util/system/compat.h +++ b/util/system/compat.h @@ -62,14 +62,14 @@ extern "C" { #endif #ifdef _win_ - + #ifdef sleep // may be defined by perl #undef sleep #endif - -void sleep(i64 len); -void usleep(i64 len); - + +void sleep(i64 len); +void usleep(i64 len); + #endif #ifdef _win_ diff --git a/util/system/compiler.h b/util/system/compiler.h index f473deab05..b373edcc46 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -307,26 +307,26 @@ _YandexAbort(); #if defined(_MSC_VER) #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif - -#if defined(__GNUC__) + +#if defined(__GNUC__) #define Y_WEAK __attribute__((weak)) -#else +#else #define Y_WEAK -#endif +#endif -#if defined(__CUDACC_VER_MAJOR__) +#if defined(__CUDACC_VER_MAJOR__) #define Y_CUDA_AT_LEAST(x, y) (__CUDACC_VER_MAJOR__ > x || (__CUDACC_VER_MAJOR__ == x && __CUDACC_VER_MINOR__ >= y)) -#else +#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) +// 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) #define noexcept throw() #endif -#endif - +#endif + #if defined(__GNUC__) #define Y_COLD __attribute__((cold)) #define Y_LEAF __attribute__((leaf)) diff --git a/util/system/context.h b/util/system/context.h index 8bb2adaa32..d2a349bfc5 100644 --- a/util/system/context.h +++ b/util/system/context.h @@ -11,7 +11,7 @@ #define STACK_ALIGN (8 * PLATFORM_DATA_ALIGN) -#if defined(_x86_64_) || defined(_i386_) || defined(_arm_) || defined(_ppc64_) +#if defined(_x86_64_) || defined(_i386_) || defined(_arm_) || defined(_ppc64_) #define STACK_GROW_DOWN 1 #else #error todo @@ -26,7 +26,7 @@ #define USE_UCONTEXT_CONT #elif defined(_win_) #define USE_FIBER_CONT -#elif (defined(_i386_) || defined(_x86_64_) || defined(_arm64_)) && !defined(_k1om_) +#elif (defined(_i386_) || defined(_x86_64_) || defined(_arm64_)) && !defined(_k1om_) #define USE_JUMP_CONT #else #define USE_UCONTEXT_CONT diff --git a/util/system/defaults.h b/util/system/defaults.h index e889b71fce..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -19,16 +19,16 @@ #include <sys/param.h> #endif -#if defined(BSD) || defined(_android_) - +#if defined(BSD) || defined(_android_) + #if defined(BSD) #include <machine/endian.h> #endif - + #if defined(_android_) #include <endian.h> #endif - + #if (BYTE_ORDER == LITTLE_ENDIAN) #define _little_endian_ #elif (BYTE_ORDER == BIG_ENDIAN) @@ -36,7 +36,7 @@ #else #error unknown endian not supported #endif - + #elif (defined(_sun_) && !defined(__i386__)) || defined(_hpux_) || defined(WHATEVER_THAT_HAS_BIG_ENDIAN) #define _big_endian_ #else diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index df987972b7..941e6a50f3 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -194,8 +194,8 @@ void TFileTest::TestRW() { UNIT_ASSERT(!f1.IsOpen()); UNIT_ASSERT(!f2.IsOpen()); UNIT_ASSERT(unlink("f1.txt") == 0); -} - +} + #ifdef _unix_ #include <locale.h> #endif diff --git a/util/system/filemap.h b/util/system/filemap.h index e28a37da4c..11be64bff4 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -265,11 +265,11 @@ public: } const T* Begin() const noexcept { return Ptr_; - } + } /// for STL compatibility only, End() usage is recommended const T* end() const noexcept { return End_; - } + } const T* End() const noexcept { return End_; } @@ -367,11 +367,11 @@ public: return ((T*)Ptr())[pos]; } T* begin() { - return (T*)Ptr(); - } + return (T*)Ptr(); + } T* end() { - return (T*)((char*)Ptr() + MappedSize()); - } + return (T*)((char*)Ptr() + MappedSize()); + } size_t size() const { return MappedSize() / sizeof(T); } diff --git a/util/system/mktemp.cpp b/util/system/mktemp.cpp index ab993d5f43..505b7b4a4b 100644 --- a/util/system/mktemp.cpp +++ b/util/system/mktemp.cpp @@ -1,7 +1,7 @@ #include "tempfile.h" -#include <util/folder/dirut.h> -#include <util/generic/yexception.h> +#include <util/folder/dirut.h> +#include <util/generic/yexception.h> #include <util/stream/file.h> #include <cerrno> @@ -21,11 +21,11 @@ TString MakeTempName(const char* wrkDir, const char* prefix, const char* extensi #ifndef _win32_ TString filePath; - if (wrkDir && *wrkDir) { + if (wrkDir && *wrkDir) { filePath += wrkDir; - } else { + } else { filePath += GetSystemTempDir(); - } + } if (filePath.back() != '/') { filePath += '/'; diff --git a/util/system/platform.h b/util/system/platform.h index 26010d8569..58f310ab34 100644 --- a/util/system/platform.h +++ b/util/system/platform.h @@ -69,7 +69,7 @@ #define _win_ #endif -#if defined(__arm__) || defined(__ARM__) || defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM) +#if defined(__arm__) || defined(__ARM__) || defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM) #if defined(__arm64) || defined(__arm64__) || defined(__aarch64__) #define _arm64_ #else @@ -99,15 +99,15 @@ #define _ia64_ #endif -#if defined(__powerpc__) +#if defined(__powerpc__) #define _ppc_ -#endif - -#if defined(__powerpc64__) +#endif + +#if defined(__powerpc64__) #define _ppc64_ -#endif - -#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_) +#endif + +#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_) #error "platform not defined, please, define one" #endif @@ -115,11 +115,11 @@ #define _x86_ #endif -#if defined(__MIC__) +#if defined(__MIC__) #define _mic_ #define _k1om_ -#endif - +#endif + // stdio or MessageBox #if defined(__CONSOLE__) || defined(_CONSOLE) #define _console_ @@ -183,7 +183,7 @@ #endif // 16, 32 or 64 -#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_) +#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_) #define _64_ #else #define _32_ @@ -214,11 +214,11 @@ #endif #define SIZEOF_CHAR 1 -#define SIZEOF_UNSIGNED_CHAR 1 +#define SIZEOF_UNSIGNED_CHAR 1 #define SIZEOF_SHORT 2 -#define SIZEOF_UNSIGNED_SHORT 2 +#define SIZEOF_UNSIGNED_SHORT 2 #define SIZEOF_INT 4 -#define SIZEOF_UNSIGNED_INT 4 +#define SIZEOF_UNSIGNED_INT 4 #if defined(_32_) #define SIZEOF_LONG 4 @@ -238,7 +238,7 @@ #endif #define SIZEOF_LONG_LONG 8 -#define SIZEOF_UNSIGNED_LONG_LONG 8 +#define SIZEOF_UNSIGNED_LONG_LONG 8 #undef SIZEOF_SIZE_T // in case we include <Python.h> which defines it, too #define SIZEOF_SIZE_T SIZEOF_PTR diff --git a/util/system/sanitizers.cpp b/util/system/sanitizers.cpp index 744ec6ce87..bb799a9e2e 100644 --- a/util/system/sanitizers.cpp +++ b/util/system/sanitizers.cpp @@ -114,15 +114,15 @@ void TFiberContext::BeforeSwitch(TFiberContext* old) noexcept { void TFiberContext::AfterSwitch() noexcept { #if defined(_asan_enabled_) - __sanitizer_finish_switch_fiber(Token_, nullptr, nullptr); + __sanitizer_finish_switch_fiber(Token_, nullptr, nullptr); +#endif +} + +void TFiberContext::AfterStart() noexcept { +#if defined(_asan_enabled_) + __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr); #endif } - -void TFiberContext::AfterStart() noexcept { -#if defined(_asan_enabled_) - __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr); -#endif -} #if defined(_tsan_enabled_) extern "C" { diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h index 94f7fff6ee..965e5c751e 100644 --- a/util/system/sanitizers.h +++ b/util/system/sanitizers.h @@ -28,8 +28,8 @@ namespace NSan { void BeforeSwitch(TFiberContext* old) noexcept; void AfterSwitch() noexcept; - static void AfterStart() noexcept; - + static void AfterStart() noexcept; + private: void* Token_; const void* Stack_; diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp index 65fbf3a6da..07ff0d6caa 100644 --- a/util/system/shmat.cpp +++ b/util/system/shmat.cpp @@ -61,30 +61,30 @@ namespace { static int shmdt(const void* addr) { return syscall(__NR_shmdt, addr); } - + #else #define IPCOP_shmat 21 #define IPCOP_shmdt 22 #define IPCOP_shmget 23 #define IPCOP_shmctl 24 - - static int shmget(key_t key, size_t size, int flag) { - return syscall(__NR_ipc, IPCOP_shmget, key, size, flag, 0); - } - - static void* shmat(int id, const void* addr, int flag) { - void* retval; - long res = syscall(__NR_ipc, IPCOP_shmat, id, flag, (long)&retval, addr); + + static int shmget(key_t key, size_t size, int flag) { + return syscall(__NR_ipc, IPCOP_shmget, key, size, flag, 0); + } + + static void* shmat(int id, const void* addr, int flag) { + void* retval; + long res = syscall(__NR_ipc, IPCOP_shmat, id, flag, (long)&retval, addr); return (res >= 0) ? retval : (void*)-1; - } - - static int shmctl(int id, int cmd, void* buf) { - return syscall(__NR_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf); - } - - static int shmdt(const void* addr) { - return syscall(__NR_ipc, IPCOP_shmdt, 0, 0, 0, addr); - } + } + + static int shmctl(int id, int cmd, void* buf) { + return syscall(__NR_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf); + } + + static int shmdt(const void* addr) { + return syscall(__NR_ipc, IPCOP_shmdt, 0, 0, 0, addr); + } #endif } #endif diff --git a/util/system/thread.cpp b/util/system/thread.cpp index f10d79113f..6236746c2d 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -530,27 +530,27 @@ TCurrentThreadLimits::TCurrentThreadLimits() noexcept StackBegin = pthread_get_stackaddr_np(pthread_self()); StackLength = pthread_get_stacksize_np(pthread_self()); #elif defined(_MSC_VER) - + #if _WIN32_WINNT >= _WIN32_WINNT_WIN8 ULONG_PTR b = 0; ULONG_PTR e = 0; - GetCurrentThreadStackLimits(&b, &e); + GetCurrentThreadStackLimits(&b, &e); StackBegin = (const void*)b; StackLength = e - b; - + #else - // Copied from https://github.com/llvm-mirror/compiler-rt/blob/release_40/lib/sanitizer_common/sanitizer_win.cc#L91 - void* place_on_stack = alloca(16); - MEMORY_BASIC_INFORMATION memory_info; - Y_VERIFY(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info))); - - StackBegin = memory_info.AllocationBase; - StackLength = static_cast<const char*>(memory_info.BaseAddress) + memory_info.RegionSize - static_cast<const char*>(StackBegin); - + // Copied from https://github.com/llvm-mirror/compiler-rt/blob/release_40/lib/sanitizer_common/sanitizer_win.cc#L91 + void* place_on_stack = alloca(16); + MEMORY_BASIC_INFORMATION memory_info; + Y_VERIFY(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info))); + + StackBegin = memory_info.AllocationBase; + StackLength = static_cast<const char*>(memory_info.BaseAddress) + memory_info.RegionSize - static_cast<const char*>(StackBegin); + #endif - + #else #error port me #endif diff --git a/util/system/tls.h b/util/system/tls.h index 542cdf31e8..3c4f56dbeb 100644 --- a/util/system/tls.h +++ b/util/system/tls.h @@ -15,10 +15,10 @@ #define Y_DISABLE_THRKEY_OPTIMIZATION #endif -#if defined(__GNUC__) && defined(__ANDROID__) && defined(__i686__) // https://st.yandex-team.ru/DEVTOOLS-3352 +#if defined(__GNUC__) && defined(__ANDROID__) && defined(__i686__) // https://st.yandex-team.ru/DEVTOOLS-3352 #define Y_DISABLE_THRKEY_OPTIMIZATION -#endif - +#endif + /** @def Y_THREAD(TType) diff --git a/util/system/winint.h b/util/system/winint.h index b9be6d0bdf..ebeaefb3d2 100644 --- a/util/system/winint.h +++ b/util/system/winint.h @@ -7,11 +7,11 @@ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif - + #ifndef NOMINMAX #define NOMINMAX #endif - + #include <windows.h> #undef GetFreeSpace diff --git a/util/system/yassert.h b/util/system/yassert.h index bdd0f7b150..529823440c 100644 --- a/util/system/yassert.h +++ b/util/system/yassert.h @@ -22,10 +22,10 @@ #include <cassert> #endif -#if !defined(_MSC_VER) - #if defined(__has_builtin) && __has_builtin(__debugbreak) +#if !defined(_MSC_VER) + #if defined(__has_builtin) && __has_builtin(__debugbreak) // Do nothing, use __debugbreak builtin - #else + #else inline void __debugbreak() { #if defined(__x86_64__) || defined(__i386__) __asm__ volatile("int $3\n"); @@ -33,27 +33,27 @@ inline void __debugbreak() { assert(0); #endif } - #endif - + #endif + inline bool YaIsDebuggerPresent() { return false; } #else // __debugbreak is intrinsic in MSVC - + extern "C" { __declspec(dllimport) int __stdcall IsDebuggerPresent(); } - + inline bool YaIsDebuggerPresent() { return IsDebuggerPresent() != 0; } -#endif - -inline void YaDebugBreak() { - __debugbreak(); +#endif + +inline void YaDebugBreak() { + __debugbreak(); } - + #undef Y_ASSERT #if !defined(NDEBUG) && !defined(__GCCXML__) |