5#ifndef BITCOIN_UTIL_CHECK_H
6#define BITCOIN_UTIL_CHECK_H
8#if defined(HAVE_CONFIG_H)
9#include <config/bitcoin-config.h>
18 using std::runtime_error::runtime_error;
21#define format_internal_error(msg, file, line, func, report) \
22 strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this " \
24 msg, file, line, func, report)
29 const char *func,
const char *
assertion) {
35 return std::forward<T>(val);
53#define CHECK_NONFATAL(condition) \
54 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
57#error "Cannot compile without assertions!"
65template <
bool IS_ASSERT,
typename T>
72#ifdef ABORT_ON_FAILED_ASSUME
80 return std::forward<T>(val);
85 inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
98 inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
106#define NONFATAL_UNREACHABLE() \
107 throw NonFatalCheckError(format_internal_error( \
108 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__, \
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
#define format_internal_error(msg, file, line, func, report)
T && inline_assertion_check(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for Assert()/Assume()
void assertion_fail(const char *file, int line, const char *func, const char *assertion)
Helper for Assert()
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...