aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-14 08:03:28 -0400
committerJack Lloyd <[email protected]>2018-03-14 08:03:28 -0400
commite4487e872877cb13a03974f741744eff847de801 (patch)
tree9c0e399238a5df614813e7d15a2deb04e0ea4425 /src/lib/utils
parentea0ce769791640e883ec4b7f73dcbce4b0399783 (diff)
Add a facility for debug-mode assertions
When we want to check something but it is to expensive to do so in normal builds.
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/assert.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/utils/assert.h b/src/lib/utils/assert.h
index 8211ec262..d23558cd0 100644
--- a/src/lib/utils/assert.h
+++ b/src/lib/utils/assert.h
@@ -1,6 +1,6 @@
/*
* Runtime assertion checking
-* (C) 2010 Jack Lloyd
+* (C) 2010,2018 Jack Lloyd
* 2017 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
@@ -17,11 +17,12 @@ namespace Botan {
/**
* Called when an assertion fails
*/
-BOTAN_NORETURN void BOTAN_PUBLIC_API(2,0) assertion_failure(const char* expr_str,
- const char* assertion_made,
- const char* func,
- const char* file,
- int line);
+BOTAN_NORETURN void BOTAN_PUBLIC_API(2,0)
+ assertion_failure(const char* expr_str,
+ const char* assertion_made,
+ const char* func,
+ const char* file,
+ int line);
/**
* Make an assertion
@@ -88,6 +89,16 @@ BOTAN_NORETURN void BOTAN_PUBLIC_API(2,0) assertion_failure(const char* expr_str
__LINE__); \
} while(0)
+#if defined(BOTAN_ENABLE_DEBUG_ASSERTS)
+
+#define BOTAN_DEBUG_ASSERT(expr) BOTAN_ASSERT_NOMSG(expr)
+
+#else
+
+#define BOTAN_DEBUG_ASSERT(expr) do {} while(0)
+
+#endif
+
/**
* Mark variable as unused. Takes between 1 and 9 arguments and marks all as unused,
* e.g. BOTAN_UNUSED(a); or BOTAN_UNUSED(x, y, z);