diff options
author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/yassert.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 2 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 ee5f166ee91..529823440cb 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 |