summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-06-20 10:17:42 +0200
committerArne Juul <arnej@yahoo-inc.com>2018-06-20 10:17:42 +0200
commit2915ddaa1c176a47d6c62d3b25bad9bb369c1448 (patch)
tree3706af052360b9ef219d34ebf041d788cb92dd3d /vespalib
parent44fc1380b66867958f89c47ac8752926b3787a4d (diff)
add and use HDR_ABORT instead
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/CMakeLists.txt7
-rw-r--r--vespalib/src/vespa/vespalib/util/hdr_abort.cpp23
-rw-r--r--vespalib/src/vespa/vespalib/util/hdr_abort.h13
3 files changed, 40 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
index 58739ee4df6..f71a5fa26e9 100644
--- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt
+++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
@@ -23,6 +23,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT
generationhandler.cpp
generationholder.cpp
hashmap.cpp
+ hdr_abort.cpp
host_name.cpp
joinable.cpp
left_right_heap.cpp
@@ -42,12 +43,12 @@ vespa_add_library(vespalib_vespalib_util OBJECT
simple_thread_bundle.cpp
slaveproc.cpp
stash.cpp
- string_hash.cpp
stringfmt.cpp
- thread.cpp
+ string_hash.cpp
thread_bundle.cpp
- threadstackexecutor.cpp
+ thread.cpp
threadstackexecutorbase.cpp
+ threadstackexecutor.cpp
time_tracker.cpp
valgrind.cpp
zstdcompressor.cpp
diff --git a/vespalib/src/vespa/vespalib/util/hdr_abort.cpp b/vespalib/src/vespa/vespalib/util/hdr_abort.cpp
new file mode 100644
index 00000000000..e0c46992f3b
--- /dev/null
+++ b/vespalib/src/vespa/vespalib/util/hdr_abort.cpp
@@ -0,0 +1,23 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "hdr_abort.h"
+#include <cstdlib>
+#include <cstdio>
+
+#include <vespa/log/log.h>
+LOG_SETUP(".vespalib");
+
+namespace vespalib {
+
+void hdr_abort(const char *message,
+ const char *file,
+ unsigned int line)
+{
+ LOG(error, "%s:%d: Abort called. Reason: %s",
+ file, line, message);
+ fprintf(stderr, "%s:%d: Abort called. Reason: %s\n",
+ file, line, message);
+ abort();
+}
+
+} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/util/hdr_abort.h b/vespalib/src/vespa/vespalib/util/hdr_abort.h
new file mode 100644
index 00000000000..f6fbb8ffbb0
--- /dev/null
+++ b/vespalib/src/vespa/vespalib/util/hdr_abort.h
@@ -0,0 +1,13 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+namespace vespalib {
+
+extern void hdr_abort(const char *message,
+ const char *file,
+ unsigned int line) __attribute__((__noreturn__));
+
+#define HDR_ABORT(msg) \
+ (vespalib::hdr_abort(msg, __FILE__, __LINE__))
+
+} // namespace vespalib