]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: port assert.cc to seastar
authorKefu Chai <kchai@redhat.com>
Fri, 31 Aug 2018 13:59:03 +0000 (21:59 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 6 Sep 2018 14:03:33 +0000 (22:03 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/CMakeLists.txt
src/crimson/common/assert.cc [new file with mode: 0644]

index 020fea969ed50eb24d31104f4378ef8acec554b4..39c6615529f085aa5dda5a0fed48ff6e4f24574a 100644 (file)
@@ -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 (file)
index 0000000..9b34cb5
--- /dev/null
@@ -0,0 +1,56 @@
+#include <cstdarg>
+
+#include <seastar/util/backtrace.hh>
+#include <seastar/core/reactor.hh>
+
+#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();
+  }
+}