summaryrefslogtreecommitdiff
path: root/src/include/assert.h
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-06-06 16:06:28 -0700
committerSage Weil <sage@inktank.com>2012-06-06 16:07:04 -0700
commita30601a1b69c3f1ac5cfa592050877aec8b5be9d (patch)
treedfa1f69e89a4447ce08ec14c4a7a585f461f21a7 /src/include/assert.h
parent2be716cfcb68cb9390261261debd296a1c158a13 (diff)
downloadceph-a30601a1b69c3f1ac5cfa592050877aec8b5be9d.tar.gz
assert: detect when /usr/include/assert.h clobbers us
The normal assert.h is very rude in that it clobbers any existing assert define and replaces it with its own. An sadly, lots of things we include include the generic version. Be extra rude in response. Clobber any existing assert #define, and also #define _ASSERT_H to be a magic value that our commonly-used dendl #define depends on. This way we get a compile error if the system version replaces out own. This is imperfect, since we will only detect their rudeness when we use the debug macros. I'm not coming up with something that is more widely used that would work better, however. Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'src/include/assert.h')
-rw-r--r--src/include/assert.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/include/assert.h b/src/include/assert.h
index 08a13daa2d4..81a37a84be6 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -105,9 +105,14 @@ using namespace ceph;
# undef assert
#endif
+// make _ASSERT_H something that *must* have a value other than what
+// /usr/include/assert.h gives it (nothing!), so that we detect when
+// our assert is clobbered.
+#undef _ASSERT_H
+#define _ASSERT_H _dout_cct
+
#define assert(expr) \
((expr) \
? __CEPH_ASSERT_VOID_CAST (0) \
: __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
-#undef _ASSERT_H