diff options
| author | babenko <[email protected]> | 2022-02-10 16:49:19 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:19 +0300 |
| commit | f31097c96270919a1f49360bdaaa69ea4f3fefab (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/assert | |
| parent | cec37806d8847aa3db53bafc9e251d4aaf325c12 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/assert')
| -rw-r--r-- | library/cpp/yt/assert/assert.cpp | 58 | ||||
| -rw-r--r-- | library/cpp/yt/assert/assert.h | 152 | ||||
| -rw-r--r-- | library/cpp/yt/assert/ya.make | 18 |
3 files changed, 114 insertions, 114 deletions
diff --git a/library/cpp/yt/assert/assert.cpp b/library/cpp/yt/assert/assert.cpp index 0c393c2511f..095357cdfa8 100644 --- a/library/cpp/yt/assert/assert.cpp +++ b/library/cpp/yt/assert/assert.cpp @@ -1,29 +1,29 @@ -#include "assert.h" - -#include <util/system/yassert.h> -#include <util/system/compiler.h> - -namespace NYT::NDetail { - -//////////////////////////////////////////////////////////////////////////////// - -Y_WEAK void AssertTrapImpl( - TStringBuf trapType, - TStringBuf expr, - TStringBuf file, - int line, - TStringBuf function) -{ - // Map to Arcadia assert, poorly... - ::NPrivate::Panic( - ::NPrivate::TStaticBuf(file.data(), file.length()), - line, - function.data(), - expr.data(), - "%s", - trapType.data()); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NDetail +#include "assert.h" + +#include <util/system/yassert.h> +#include <util/system/compiler.h> + +namespace NYT::NDetail { + +//////////////////////////////////////////////////////////////////////////////// + +Y_WEAK void AssertTrapImpl( + TStringBuf trapType, + TStringBuf expr, + TStringBuf file, + int line, + TStringBuf function) +{ + // Map to Arcadia assert, poorly... + ::NPrivate::Panic( + ::NPrivate::TStaticBuf(file.data(), file.length()), + line, + function.data(), + expr.data(), + "%s", + trapType.data()); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NDetail diff --git a/library/cpp/yt/assert/assert.h b/library/cpp/yt/assert/assert.h index 40f1d5d829a..7a9e761a3a9 100644 --- a/library/cpp/yt/assert/assert.h +++ b/library/cpp/yt/assert/assert.h @@ -1,76 +1,76 @@ -#pragma once - -#include <util/system/compiler.h> -#include <util/system/src_root.h> - -#include <util/generic/strbuf.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -namespace NDetail { - -[[noreturn]] -void AssertTrapImpl( - TStringBuf trapType, - TStringBuf expr, - TStringBuf file, - int line, - TStringBuf function); - -} // namespace NDetail - -#ifdef __GNUC__ - #define YT_BUILTIN_TRAP() __builtin_trap() -#else - #define YT_BUILTIN_TRAP() std::terminate() -#endif - -#define YT_ASSERT_TRAP(trapType, expr) \ - ::NYT::NDetail::AssertTrapImpl(TStringBuf(trapType), TStringBuf(expr), __SOURCE_FILE_IMPL__.As<TStringBuf>(), __LINE__, TStringBuf(__FUNCTION__)); \ - Y_UNREACHABLE() \ - -#ifdef NDEBUG - #define YT_ASSERT(expr) \ - do { \ - if (false) { \ - (void) (expr); \ - } \ - } while (false) -#else - #define YT_ASSERT(expr) \ - do { \ - if (Y_UNLIKELY(!(expr))) { \ - YT_ASSERT_TRAP("YT_ASSERT", #expr); \ - } \ - } while (false) -#endif - -//! Same as |YT_ASSERT| but evaluates and checks the expression in both release and debug mode. -#define YT_VERIFY(expr) \ - do { \ - if (Y_UNLIKELY(!(expr))) { \ - YT_ASSERT_TRAP("YT_VERIFY", #expr); \ - } \ - } while (false) - -//! Fatal error code marker. Abnormally terminates the current process. -#ifdef YT_COMPILING_UDF - #define YT_ABORT() __YT_BUILTIN_ABORT() -#else - #define YT_ABORT() \ - do { \ - YT_ASSERT_TRAP("YT_ABORT", ""); \ - } while (false) -#endif - -//! Unimplemented code marker. Abnormally terminates the current process. -#define YT_UNIMPLEMENTED() \ - do { \ - YT_ASSERT_TRAP("YT_UNIMPLEMENTED", ""); \ - } while (false) - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#pragma once + +#include <util/system/compiler.h> +#include <util/system/src_root.h> + +#include <util/generic/strbuf.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +namespace NDetail { + +[[noreturn]] +void AssertTrapImpl( + TStringBuf trapType, + TStringBuf expr, + TStringBuf file, + int line, + TStringBuf function); + +} // namespace NDetail + +#ifdef __GNUC__ + #define YT_BUILTIN_TRAP() __builtin_trap() +#else + #define YT_BUILTIN_TRAP() std::terminate() +#endif + +#define YT_ASSERT_TRAP(trapType, expr) \ + ::NYT::NDetail::AssertTrapImpl(TStringBuf(trapType), TStringBuf(expr), __SOURCE_FILE_IMPL__.As<TStringBuf>(), __LINE__, TStringBuf(__FUNCTION__)); \ + Y_UNREACHABLE() \ + +#ifdef NDEBUG + #define YT_ASSERT(expr) \ + do { \ + if (false) { \ + (void) (expr); \ + } \ + } while (false) +#else + #define YT_ASSERT(expr) \ + do { \ + if (Y_UNLIKELY(!(expr))) { \ + YT_ASSERT_TRAP("YT_ASSERT", #expr); \ + } \ + } while (false) +#endif + +//! Same as |YT_ASSERT| but evaluates and checks the expression in both release and debug mode. +#define YT_VERIFY(expr) \ + do { \ + if (Y_UNLIKELY(!(expr))) { \ + YT_ASSERT_TRAP("YT_VERIFY", #expr); \ + } \ + } while (false) + +//! Fatal error code marker. Abnormally terminates the current process. +#ifdef YT_COMPILING_UDF + #define YT_ABORT() __YT_BUILTIN_ABORT() +#else + #define YT_ABORT() \ + do { \ + YT_ASSERT_TRAP("YT_ABORT", ""); \ + } while (false) +#endif + +//! Unimplemented code marker. Abnormally terminates the current process. +#define YT_UNIMPLEMENTED() \ + do { \ + YT_ASSERT_TRAP("YT_UNIMPLEMENTED", ""); \ + } while (false) + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/assert/ya.make b/library/cpp/yt/assert/ya.make index 19358ca0185..df74a4f1fa6 100644 --- a/library/cpp/yt/assert/ya.make +++ b/library/cpp/yt/assert/ya.make @@ -1,9 +1,9 @@ -LIBRARY() - -OWNER(g:yt) - -SRCS( - assert.cpp -) - -END() +LIBRARY() + +OWNER(g:yt) + +SRCS( + assert.cpp +) + +END() |
