From: Adam C. Emerson Date: Thu, 23 Aug 2018 17:23:41 +0000 (-0400) Subject: include,common: Remove assert and clobber-foo X-Git-Tag: v14.0.1~475^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=34164d55c839acd35bbb1be5279e3e23e3bec1fd;p=ceph-ci.git include,common: Remove assert and clobber-foo Since everything is using the ceph_assert macro, get rid of the assert macro in include/assert.h . As that is no longer a concern, get of macros to break the compile if our macro gets replaced with the system assert. Signed-off-by: Adam C. Emerson --- diff --git a/src/common/dout.h b/src/common/dout.h index 0c2069bf340..d9b3acfec48 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -109,10 +109,8 @@ struct is_dynamic> : public std::true_type {}; #define ldlog_p1(cct, sub, lvl) \ (cct->_conf->subsys.should_gather((sub), (lvl))) -// NOTE: depend on magic value in _ASSERT_H so that we detect when -// /usr/include/assert.h clobbers our fancier version. #define dendl_impl std::flush; \ - _ASSERT_H->_log->submit_entry(_dout_e); \ + _dout_cct->_log->submit_entry(_dout_e); \ } \ } while (0) diff --git a/src/include/assert.h b/src/include/assert.h index 7bfa28c86ab..93a45e85dbb 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -22,13 +22,11 @@ # include "acconfig.h" #endif -#ifdef __cplusplus class CephContext; namespace ceph { struct BackTrace; -#endif /* * For GNU, test specific version features. Otherwise (e.g. LLVM) we'll use @@ -62,9 +60,7 @@ struct BackTrace; # define __CEPH_ASSERT_FUNCTION ((__const char *) 0) #endif -#ifdef __cplusplus extern void register_assert_context(CephContext *cct); -#endif struct assert_data { const char *assertion; @@ -82,31 +78,17 @@ extern void __ceph_assertf_fail(const char *assertion, const char *file, int lin __attribute__ ((__noreturn__)); extern void __ceph_assert_warn(const char *assertion, const char *file, int line, const char *function); -#ifndef CEPH_ASSERT_FAIL_DEPR -#define CEPH_ASSERT_FAIL_DEPR -[[deprecated, noreturn]] -void inline __ceph_assert_fail_depr(const assert_data &ctx) { - __ceph_assert_fail(ctx); -} -#endif - -#ifdef __cplusplus -# define _CEPH_ASSERT_VOID_CAST static_cast -#else -# define _CEPH_ASSERT_VOID_CAST (void) -#endif +#define _CEPH_ASSERT_VOID_CAST static_cast #define assert_warn(expr) \ ((expr) \ ? _CEPH_ASSERT_VOID_CAST (0) \ : __ceph_assert_warn (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION)) -#ifdef __cplusplus } using namespace ceph; -#endif /* * ceph_abort aborts the program with a nice backtrace. @@ -121,31 +103,6 @@ using namespace ceph; abort(); \ } -#endif - -// wipe any prior assert definition -#ifdef assert -# 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 - -// make __ASSERT_FUNCTION empty (/usr/include/assert.h makes it a function) -// and make our encoding macros break if it non-empty. -#undef __ASSERT_FUNCTION -#define __ASSERT_FUNCTION - -#define assert(expr) \ - do { static const ceph::assert_data assert_data_ctx = \ - {__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \ - ((expr) \ - ? _CEPH_ASSERT_VOID_CAST (0) \ - : __ceph_assert_fail_depr(assert_data_ctx)); } while(false) - #define ceph_assert(expr) \ do { static const ceph::assert_data assert_data_ctx = \ {__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \ @@ -179,3 +136,5 @@ using namespace ceph; ((expr) \ ? _CEPH_ASSERT_VOID_CAST (0) \ : __ceph_assertf_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION, __VA_ARGS__)) + +#endif diff --git a/src/include/encoding.h b/src/include/encoding.h index 757bde705c7..81e86a0103a 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -79,7 +79,7 @@ inline void decode_raw(T& t, bufferlist::const_iterator &p) #define WRITE_RAW_ENCODER(type) \ inline void encode(const type &v, ::ceph::bufferlist& bl, uint64_t features=0) { ::ceph::encode_raw(v, bl); } \ - inline void decode(type &v, ::ceph::bufferlist::const_iterator& p) { __ASSERT_FUNCTION ::ceph::decode_raw(v, p); } + inline void decode(type &v, ::ceph::bufferlist::const_iterator& p) { ::ceph::decode_raw(v, p); } WRITE_RAW_ENCODER(__u8) #ifndef _CHAR_IS_SIGNED