9#ifndef BOTAN_ASSERTION_CHECKING_H_
10#define BOTAN_ASSERTION_CHECKING_H_
12#include <botan/build.h>
22 const
char* assertion_made,
36#define BOTAN_ARG_CHECK(expr, msg) \
37 do { if(!(expr)) Botan::throw_invalid_argument(msg, __func__, __FILE__); } while(0)
48#define BOTAN_STATE_CHECK(expr) \
49 do { if(!(expr)) Botan::throw_invalid_state(#expr, __func__, __FILE__); } while(0)
54#define BOTAN_ASSERT(expr, assertion_made) \
57 Botan::assertion_failure(#expr, \
67#define BOTAN_ASSERT_NOMSG(expr) \
70 Botan::assertion_failure(#expr, \
80#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made) \
82 if((expr1) != (expr2)) \
83 Botan::assertion_failure(#expr1 " == " #expr2, \
93#define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg) \
95 if((expr1) && !(expr2)) \
96 Botan::assertion_failure(#expr1 " implies " #expr2, \
106#define BOTAN_ASSERT_NONNULL(ptr) \
108 if((ptr) == nullptr) \
109 Botan::assertion_failure(#ptr " is not null", \
116#if defined(BOTAN_ENABLE_DEBUG_ASSERTS)
118#define BOTAN_DEBUG_ASSERT(expr) BOTAN_ASSERT_NOMSG(expr)
122#define BOTAN_DEBUG_ASSERT(expr) do {} while(0)
130#define _BOTAN_UNUSED_IMPL1(a) static_cast<void>(a)
131#define _BOTAN_UNUSED_IMPL2(a, b) static_cast<void>(a); _BOTAN_UNUSED_IMPL1(b)
132#define _BOTAN_UNUSED_IMPL3(a, b, c) static_cast<void>(a); _BOTAN_UNUSED_IMPL2(b, c)
133#define _BOTAN_UNUSED_IMPL4(a, b, c, d) static_cast<void>(a); _BOTAN_UNUSED_IMPL3(b, c, d)
134#define _BOTAN_UNUSED_IMPL5(a, b, c, d, e) static_cast<void>(a); _BOTAN_UNUSED_IMPL4(b, c, d, e)
135#define _BOTAN_UNUSED_IMPL6(a, b, c, d, e, f) static_cast<void>(a); _BOTAN_UNUSED_IMPL5(b, c, d, e, f)
136#define _BOTAN_UNUSED_IMPL7(a, b, c, d, e, f, g) static_cast<void>(a); _BOTAN_UNUSED_IMPL6(b, c, d, e, f, g)
137#define _BOTAN_UNUSED_IMPL8(a, b, c, d, e, f, g, h) static_cast<void>(a); _BOTAN_UNUSED_IMPL7(b, c, d, e, f, g, h)
138#define _BOTAN_UNUSED_IMPL9(a, b, c, d, e, f, g, h, i) static_cast<void>(a); _BOTAN_UNUSED_IMPL8(b, c, d, e, f, g, h, i)
139#define _BOTAN_UNUSED_GET_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, IMPL_NAME, ...) IMPL_NAME
141#define BOTAN_UNUSED(...) _BOTAN_UNUSED_GET_IMPL(__VA_ARGS__, \
142 _BOTAN_UNUSED_IMPL9, \
143 _BOTAN_UNUSED_IMPL8, \
144 _BOTAN_UNUSED_IMPL7, \
145 _BOTAN_UNUSED_IMPL6, \
146 _BOTAN_UNUSED_IMPL5, \
147 _BOTAN_UNUSED_IMPL4, \
148 _BOTAN_UNUSED_IMPL3, \
149 _BOTAN_UNUSED_IMPL2, \
150 _BOTAN_UNUSED_IMPL1, \
151 unused dummy rest value \
162#if BOTAN_COMPILER_HAS_BUILTIN(__builtin_unreachable)
163 __builtin_unreachable();
164#elif defined(_MSC_VER)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FORCE_INLINE
#define BOTAN_UNSTABLE_API
void throw_invalid_state(const char *expr, const char *func, const char *file)
void throw_invalid_argument(const char *message, const char *func, const char *file)
BOTAN_FORCE_INLINE void unreachable()
void assertion_failure(const char *expr_str, const char *assertion_made, const char *func, const char *file, int line)