Skip to content

Commit

Permalink
include/assert: define ceph_assert[f]_always
Browse files Browse the repository at this point in the history
These variants we promise never to compile out based on NDEBUG.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Jun 28, 2016
1 parent ae99910 commit 59ddf4d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/include/assert.h
Expand Up @@ -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, ...) \
Expand All @@ -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__))

0 comments on commit 59ddf4d

Please sign in to comment.