From 59ddf4d6191bb65d9b70306d1d714789a5472300 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 27 Jun 2016 11:24:49 -0700 Subject: [PATCH] include/assert: define ceph_assert[f]_always These variants we promise never to compile out based on NDEBUG. Signed-off-by: Sage Weil --- src/include/assert.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/include/assert.h b/src/include/assert.h index c52ccea4ea3..481f8bacfb3 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -129,6 +129,13 @@ using namespace ceph; ? __CEPH_ASSERT_VOID_CAST (0) \ : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION)) +// this variant will *never* get compiled out to NDEBUG in the future. +// (ceph_assert currently doesn't either, but in the future it might.) +#define ceph_assert_always(expr) \ + ((expr) \ + ? __CEPH_ASSERT_VOID_CAST (0) \ + : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION)) + // Named by analogy with printf. Along with an expression, takes a format // string and parameters which are printed if the assertion fails. #define assertf(expr, ...) \ @@ -139,3 +146,10 @@ using namespace ceph; ((expr) \ ? __CEPH_ASSERT_VOID_CAST (0) \ : __ceph_assertf_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION, __VA_ARGS__)) + +// this variant will *never* get compiled out to NDEBUG in the future. +// (ceph_assertf currently doesn't either, but in the future it might.) +#define ceph_assertf_always(expr, ...) \ + ((expr) \ + ? __CEPH_ASSERT_VOID_CAST (0) \ + : __ceph_assertf_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION, __VA_ARGS__)) -- 2.47.3