9 #ifndef BOTAN_ASSERTION_CHECKING_H_ 10 #define BOTAN_ASSERTION_CHECKING_H_ 12 #include <botan/build.h> 13 #include <botan/compiler.h> 23 const
char* assertion_made,
37 #define BOTAN_ARG_CHECK(expr, msg) \ 38 do { if(!(expr)) Botan::throw_invalid_argument(msg, __func__, __FILE__); } while(0) 49 #define BOTAN_STATE_CHECK(expr) \ 50 do { if(!(expr)) Botan::throw_invalid_state(#expr, __func__, __FILE__); } while(0) 55 #define BOTAN_ASSERT(expr, assertion_made) \ 58 Botan::assertion_failure(#expr, \ 68 #define BOTAN_ASSERT_NOMSG(expr) \ 71 Botan::assertion_failure(#expr, \ 81 #define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made) \ 83 if((expr1) != (expr2)) \ 84 Botan::assertion_failure(#expr1 " == " #expr2, \ 94 #define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg) \ 96 if((expr1) && !(expr2)) \ 97 Botan::assertion_failure(#expr1 " implies " #expr2, \ 107 #define BOTAN_ASSERT_NONNULL(ptr) \ 109 if((ptr) == nullptr) \ 110 Botan::assertion_failure(#ptr " is not null", \ 117 #if defined(BOTAN_ENABLE_DEBUG_ASSERTS) 119 #define BOTAN_DEBUG_ASSERT(expr) BOTAN_ASSERT_NOMSG(expr) 123 #define BOTAN_DEBUG_ASSERT(expr) do {} while(0) 131 #define _BOTAN_UNUSED_IMPL1(a) static_cast<void>(a) 132 #define _BOTAN_UNUSED_IMPL2(a, b) static_cast<void>(a); _BOTAN_UNUSED_IMPL1(b) 133 #define _BOTAN_UNUSED_IMPL3(a, b, c) static_cast<void>(a); _BOTAN_UNUSED_IMPL2(b, c) 134 #define _BOTAN_UNUSED_IMPL4(a, b, c, d) static_cast<void>(a); _BOTAN_UNUSED_IMPL3(b, c, d) 135 #define _BOTAN_UNUSED_IMPL5(a, b, c, d, e) static_cast<void>(a); _BOTAN_UNUSED_IMPL4(b, c, d, e) 136 #define _BOTAN_UNUSED_IMPL6(a, b, c, d, e, f) static_cast<void>(a); _BOTAN_UNUSED_IMPL5(b, c, d, e, f) 137 #define _BOTAN_UNUSED_IMPL7(a, b, c, d, e, f, g) static_cast<void>(a); _BOTAN_UNUSED_IMPL6(b, c, d, e, f, g) 138 #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) 139 #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) 140 #define _BOTAN_UNUSED_GET_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, IMPL_NAME, ...) IMPL_NAME 142 #define BOTAN_UNUSED(...) _BOTAN_UNUSED_GET_IMPL(__VA_ARGS__, \ 143 _BOTAN_UNUSED_IMPL9, \ 144 _BOTAN_UNUSED_IMPL8, \ 145 _BOTAN_UNUSED_IMPL7, \ 146 _BOTAN_UNUSED_IMPL6, \ 147 _BOTAN_UNUSED_IMPL5, \ 148 _BOTAN_UNUSED_IMPL4, \ 149 _BOTAN_UNUSED_IMPL3, \ 150 _BOTAN_UNUSED_IMPL2, \ 151 _BOTAN_UNUSED_IMPL1, \ 152 unused dummy rest value \ #define BOTAN_UNSTABLE_API
#define BOTAN_PUBLIC_API(maj, min)
void throw_invalid_argument(const char *message, const char *func, const char *file)
void assertion_failure(const char *expr_str, const char *assertion_made, const char *func, const char *file, int line)
void throw_invalid_state(const char *expr, const char *func, const char *file)