@@ -50,13 +50,14 @@ struct assert_data {
5050 const char *function;
5151};
5252
53- extern void __ceph_assert_fail (const char *assertion, const char *file, int line, const char *function)
54- __attribute__ ((__noreturn__));
55- extern void __ceph_assert_fail (const assert_data &ctx)
56- __attribute__ ((__noreturn__));
53+ extern void __ceph_assert_fail (const char *assertion, const char *file, int line, const char *function);
54+ extern void __ceph_assert_fail (const assert_data &ctx);
55+ template <const assert_data* AssertCtxV>
56+ [[gnu::noinline, gnu::cold]] static void __ceph_assert_fail () {
57+ __ceph_assert_fail (*AssertCtxV);
58+ }
5759
58- extern void __ceph_assertf_fail (const char *assertion, const char *file, int line, const char *function, const char * msg, ...)
59- __attribute__ ((__noreturn__));
60+ extern void __ceph_assertf_fail (const char *assertion, const char *file, int line, const char *function, const char * msg, ...);
6061extern void __ceph_assert_warn (const char *assertion, const char *file, int line, const char *function);
6162
6263[[noreturn]] void __ceph_abort (const char *file, int line, const char *func,
@@ -101,11 +102,14 @@ using namespace ceph;
101102 } while (false )
102103#else
103104#define ceph_assert (expr ) \
104- do { static const ceph::assert_data assert_data_ctx = \
105- {__STRING (expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \
106- ((expr) \
107- ? _CEPH_ASSERT_VOID_CAST (0 ) \
108- : ::ceph::__ceph_assert_fail (assert_data_ctx)); } while (false )
105+ do { \
106+ static const auto func_name = __CEPH_ASSERT_FUNCTION; \
107+ [] (const bool eval) { \
108+ static const ceph::assert_data assert_data_ctx = \
109+ {__STRING (expr), __FILE__, __LINE__, func_name}; \
110+ ((eval) \
111+ ? _CEPH_ASSERT_VOID_CAST (0 ) \
112+ : ::ceph::__ceph_assert_fail<&assert_data_ctx>()); }((bool )(expr)); } while (false )
109113#endif
110114
111115// this variant will *never* get compiled out to NDEBUG in the future.
@@ -119,11 +123,14 @@ using namespace ceph;
119123 } while (false )
120124#else
121125#define ceph_assert_always (expr ) \
122- do { static const ceph::assert_data assert_data_ctx = \
123- {__STRING (expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \
124- ((expr) \
125- ? _CEPH_ASSERT_VOID_CAST (0 ) \
126- : ::ceph::__ceph_assert_fail (assert_data_ctx)); } while (false )
126+ do { \
127+ static const auto func_name = __CEPH_ASSERT_FUNCTION; \
128+ [] (const bool eval) { \
129+ static const ceph::assert_data assert_data_ctx = \
130+ {__STRING (expr), __FILE__, __LINE__, func_name}; \
131+ ((eval) \
132+ ? _CEPH_ASSERT_VOID_CAST (0 ) \
133+ : ::ceph::__ceph_assert_fail<&assert_data_ctx>()); }((bool )(expr)); } while (false )
127134#endif
128135
129136// Named by analogy with printf. Along with an expression, takes a format
0 commit comments