From: Kefu Chai Date: Fri, 31 Aug 2018 13:59:03 +0000 (+0800) Subject: crimson: port assert.cc to seastar X-Git-Tag: v14.0.1~345^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5793e1a6aff7041cc8ef60f5412800d67585e6e;p=ceph.git crimson: port assert.cc to seastar Signed-off-by: Kefu Chai --- diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index 020fea969ed50..39c6615529f08 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -8,6 +8,7 @@ set(crimson_thread_srcs thread/Throttle.cc) set(crimson_common_srcs common/config_proxy.cc + common/assert.cc common/log.cc) add_library(crimson STATIC ${crimson_common_srcs} diff --git a/src/crimson/common/assert.cc b/src/crimson/common/assert.cc new file mode 100644 index 0000000000000..9b34cb529029b --- /dev/null +++ b/src/crimson/common/assert.cc @@ -0,0 +1,56 @@ +#include + +#include +#include + +#include "include/assert.h" + +#include "crimson/common/log.h" + +namespace ceph { + [[gnu::cold]] void __ceph_assert_fail(const ceph::assert_data &ctx) + { + __ceph_assert_fail(ctx.assertion, ctx.file, ctx.line, ctx.function); + } + + [[gnu::cold]] void __ceph_assert_fail(const char* assertion, + const char* file, int line, + const char* func) + { + seastar::logger& logger = ceph::get_logger(0); + logger.error("{}:{} : In function '{}', ceph_assert(%s)\n" + "{}", + file, line, func, assertion, + seastar::current_backtrace()); + abort(); + } + [[gnu::cold]] void __ceph_assertf_fail(const char *assertion, + const char *file, int line, + const char *func, const char* msg, + ...) + { + char buf[8096]; + va_list args; + va_start(args, msg); + std::vsnprintf(buf, sizeof(buf), msg, args); + va_end(args); + + seastar::logger& logger = ceph::get_logger(0); + logger.error("{}:{} : In function '{}', ceph_assert(%s)\n" + "{}", + file, line, func, assertion, + seastar::current_backtrace()); + abort(); + } + + [[gnu::cold]] void __ceph_abort(const char* file, int line, + const char* func, const std::string& msg) + { + seastar::logger& logger = ceph::get_logger(0); + logger.error("{}:{} : In function '{}', abort(%s)\n" + "{}", + file, line, func, msg, + seastar::current_backtrace()); + abort(); + } +}