aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-09 16:11:46 +0000
committerlloyd <[email protected]>2012-07-09 16:11:46 +0000
commit38f7ed8efb6621d55a705bb7af4ba5a21495113a (patch)
tree0d7bf772ae897e12aca2a2e70257d484a6fdc4dd /src/utils
parentc9ab9636bc9fa80203b8bd37c20e3817b6013a2d (diff)
Remove BOTAN_ASSERT_FUNCTION, use __func__ which is now standard in C++11
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/assert.cpp6
-rw-r--r--src/utils/assert.h70
2 files changed, 35 insertions, 41 deletions
diff --git a/src/utils/assert.cpp b/src/utils/assert.cpp
index 3747912d6..4b69b4420 100644
--- a/src/utils/assert.cpp
+++ b/src/utils/assert.cpp
@@ -12,7 +12,7 @@
namespace Botan {
void assertion_failure(const char* expr_str,
- const char* msg,
+ const char* assertion_made,
const char* func,
const char* file,
int line)
@@ -21,8 +21,8 @@ void assertion_failure(const char* expr_str,
format << "Assertion " << expr_str << " failed ";
- if(msg && msg[0] != 0)
- format << "(" << msg << ") ";
+ if(assertion_made && assertion_made[0] != 0)
+ format << "(" << assertion_made << ") ";
if(func)
format << "in " << func << " ";
diff --git a/src/utils/assert.h b/src/utils/assert.h
index d68f683a6..88d514b43 100644
--- a/src/utils/assert.h
+++ b/src/utils/assert.h
@@ -10,59 +10,53 @@
namespace Botan {
+/**
+* Called when an assertion fails
+*/
void assertion_failure(const char* expr_str,
- const char* msg,
+ const char* assertion_made,
const char* func,
const char* file,
int line);
-#define BOTAN_ASSERT(expr, msg) \
+/**
+* Make an assertion
+*/
+#define BOTAN_ASSERT(expr, assertion_made) \
do { \
if(!(expr)) \
Botan::assertion_failure(#expr, \
- msg, \
- BOTAN_ASSERT_FUNCTION, \
+ assertion_made, \
+ __func__, \
__FILE__, \
__LINE__); \
} while(0)
-#define BOTAN_ASSERT_EQUAL(value1, value2, msg) \
- do { \
- if(value1 != value2) \
- Botan::assertion_failure(#value1 " == " #value2, \
- msg, \
- BOTAN_ASSERT_FUNCTION, \
- __FILE__, \
- __LINE__); \
- } while(0)
-
-#define BOTAN_ASSERT_NONNULL(ptr) \
- do { \
- if(static_cast<bool>(ptr) == false) \
- Botan::assertion_failure(#ptr " is not null", \
- "", \
- BOTAN_ASSERT_FUNCTION, \
- __FILE__, \
- __LINE__); \
+/**
+* Assert that value1 == value2
+*/
+#define BOTAN_ASSERT_EQUAL(value1, value2, assertion_made) \
+ do { \
+ if(value1 != value2) \
+ Botan::assertion_failure(#value1 " == " #value2, \
+ assertion_made, \
+ __func__, \
+ __FILE__, \
+ __LINE__); \
} while(0)
-/*
-* Unfortunately getting the function name from the preprocessor
-* isn't standard in C++98 (C++0x uses C99's __func__)
+/**
+* Assert that a pointer is not null
*/
-#if defined(BOTAN_BUILD_COMPILER_IS_GCC) || \
- defined(BOTAN_BUILD_COMPILER_IS_CLANG) || \
- defined(BOTAN_BUILD_COMPILER_IS_INTEL)
-
- #define BOTAN_ASSERT_FUNCTION __PRETTY_FUNCTION__
-
-#elif defined(BOTAN_BUILD_COMPILER_IS_MSVC)
-
- #define BOTAN_ASSERT_FUNCTION __FUNCTION__
-
-#else
- #define BOTAN_ASSERT_FUNCTION ((const char*)0)
-#endif
+#define BOTAN_ASSERT_NONNULL(ptr) \
+ do { \
+ if(static_cast<bool>(ptr) == false) \
+ Botan::assertion_failure(#ptr " is not null", \
+ "", \
+ __func__, \
+ __FILE__, \
+ __LINE__); \
+ } while(0)
}