diff --git a/include/nn/diag.h b/include/nn/diag.h index 672ef21..6188fe7 100644 --- a/include/nn/diag.h +++ b/include/nn/diag.h @@ -23,8 +23,10 @@ enum AssertionType {}; namespace detail { // LOG void LogImpl(nn::diag::LogMetaData const&, char const*, ...); -void AbortImpl(char const*, char const*, char const*, int32_t); -void AbortImpl(char const*, char const*, char const*, int, Result); +[[noreturn]] void AbortImpl(const char*, const char*, const char*, int32_t); +[[noreturn]] void AbortImpl(const char*, const char*, const char*, int, const char*, ...); +[[noreturn]] void AbortImpl(const char*, const char*, const char*, int, const Result*, const char*, + ...); void OnAssertionFailure(nn::diag::AssertionType, char const*, char const*, char const*, int); } // namespace detail @@ -35,3 +37,12 @@ uint64_t GetRequiredBufferSizeForGetAllModuleInfo(); int32_t GetAllModuleInfo(nn::diag::ModuleInfo** out, void* buffer, uint64_t bufferSize); uint64_t GetSymbolSize(uint64_t addr); } // namespace nn::diag + +#define NN_ABORT nn::diag::detail::AbortImpl("", "", "", 0) + +#define NN_ABORT_IF_FAIL(arg1) \ + { \ + const nn::Result& nnDetailAssertArgValue_arg1 = arg1; \ + if (nnDetailAssertArgValue_arg1.IsFailure()) \ + nn::diag::detail::AbortImpl("", "", "", 0, &nnDetailAssertArgValue_arg1, ""); \ + }