diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/yassert.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/yassert.h')
-rw-r--r-- | util/system/yassert.h | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/util/system/yassert.h b/util/system/yassert.h index 529823440c..ee5f166ee9 100644 --- a/util/system/yassert.h +++ b/util/system/yassert.h @@ -1,53 +1,53 @@ #pragma once -#include "defaults.h" -#include "src_root.h" +#include "defaults.h" +#include "src_root.h" #include "backtrace.h" -#if defined(_MSC_VER) - #include <new> - #if defined(_DEBUG) - #if defined(_CRTDBG_MAP_ALLOC) - #include <cstdlib> /* definitions for malloc/calloc */ - #include <malloc.h> /* must be before their redefinitions as _*_dbg() */ - #endif - #include <crtdbg.h> - #else - #endif - #include <cassert> -#elif defined(__GNUC__) - #ifdef _sun_ - #include <alloca.h> - #endif - #include <cassert> -#endif +#if defined(_MSC_VER) + #include <new> + #if defined(_DEBUG) + #if defined(_CRTDBG_MAP_ALLOC) + #include <cstdlib> /* definitions for malloc/calloc */ + #include <malloc.h> /* must be before their redefinitions as _*_dbg() */ + #endif + #include <crtdbg.h> + #else + #endif + #include <cassert> +#elif defined(__GNUC__) + #ifdef _sun_ + #include <alloca.h> + #endif + #include <cassert> +#endif #if !defined(_MSC_VER) #if defined(__has_builtin) && __has_builtin(__debugbreak) - // Do nothing, use __debugbreak builtin + // Do nothing, use __debugbreak builtin #else -inline void __debugbreak() { - #if defined(__x86_64__) || defined(__i386__) - __asm__ volatile("int $3\n"); - #else - assert(0); - #endif -} +inline void __debugbreak() { + #if defined(__x86_64__) || defined(__i386__) + __asm__ volatile("int $3\n"); + #else + assert(0); + #endif +} #endif -inline bool YaIsDebuggerPresent() { - return false; -} -#else -// __debugbreak is intrinsic in MSVC +inline bool YaIsDebuggerPresent() { + return false; +} +#else +// __debugbreak is intrinsic in MSVC -extern "C" { - __declspec(dllimport) int __stdcall IsDebuggerPresent(); -} +extern "C" { + __declspec(dllimport) int __stdcall IsDebuggerPresent(); +} -inline bool YaIsDebuggerPresent() { - return IsDebuggerPresent() != 0; -} +inline bool YaIsDebuggerPresent() { + return IsDebuggerPresent() != 0; +} #endif inline void YaDebugBreak() { @@ -57,36 +57,36 @@ inline void YaDebugBreak() { #undef Y_ASSERT #if !defined(NDEBUG) && !defined(__GCCXML__) - #define Y_ASSERT(a) \ - do { \ - try { \ - if (Y_UNLIKELY(!(a))) { \ - if (YaIsDebuggerPresent()) \ - __debugbreak(); \ - else { \ - PrintBackTrace(); \ + #define Y_ASSERT(a) \ + do { \ + try { \ + if (Y_UNLIKELY(!(a))) { \ + if (YaIsDebuggerPresent()) \ + __debugbreak(); \ + else { \ + PrintBackTrace(); \ /* NOLINTNEXTLINE */ \ - assert(false && (a)); \ - } \ - } \ - } catch (...) { \ - if (YaIsDebuggerPresent()) \ - __debugbreak(); \ - else { \ - PrintBackTrace(); \ + assert(false && (a)); \ + } \ + } \ + } catch (...) { \ + if (YaIsDebuggerPresent()) \ + __debugbreak(); \ + else { \ + PrintBackTrace(); \ /* NOLINTNEXTLINE */ \ - assert(false && "Exception during assert"); \ - } \ - } \ - } while (false) + assert(false && "Exception during assert"); \ + } \ + } \ + } while (false) #else - #define Y_ASSERT(a) \ - do { \ - if (false) { \ - auto __xxx = static_cast<bool>(a); \ - Y_UNUSED(__xxx); \ - } \ - } while (false) + #define Y_ASSERT(a) \ + do { \ + if (false) { \ + auto __xxx = static_cast<bool>(a); \ + Y_UNUSED(__xxx); \ + } \ + } while (false) #endif namespace NPrivate { @@ -96,10 +96,10 @@ namespace NPrivate { /// Assert that does not depend on NDEBUG macro and outputs message like printf #define Y_VERIFY(expr, ...) \ - do { \ - if (Y_UNLIKELY(!(expr))) { \ - ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ - } \ + do { \ + if (Y_UNLIKELY(!(expr))) { \ + ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ + } \ } while (false) #define Y_FAIL(...) \ @@ -108,19 +108,19 @@ namespace NPrivate { } while (false) #ifndef NDEBUG - /// Assert that depend on NDEBUG macro and outputs message like printf - #define Y_VERIFY_DEBUG(expr, ...) \ - do { \ - if (Y_UNLIKELY(!(expr))) { \ - ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ - } \ - } while (false) + /// Assert that depend on NDEBUG macro and outputs message like printf + #define Y_VERIFY_DEBUG(expr, ...) \ + do { \ + if (Y_UNLIKELY(!(expr))) { \ + ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ + } \ + } while (false) #else - #define Y_VERIFY_DEBUG(expr, ...) \ - do { \ - if (false) { \ - bool __xxx = static_cast<bool>(expr); \ - Y_UNUSED(__xxx); \ - } \ - } while (false) + #define Y_VERIFY_DEBUG(expr, ...) \ + do { \ + if (false) { \ + bool __xxx = static_cast<bool>(expr); \ + Y_UNUSED(__xxx); \ + } \ + } while (false) #endif |