summaryrefslogtreecommitdiffstats
path: root/lib/libcompiler_rt/int_util.c
diff options
context:
space:
mode:
authorpascal <pascal@openbsd.org>2016-09-05 11:36:10 +0000
committerpascal <pascal@openbsd.org>2016-09-05 11:36:10 +0000
commita303f987e7ef7d1b60e04cf8b1f06edb794137d8 (patch)
tree45f1c146ea15009060dad6a1d72c753f0dbba747 /lib/libcompiler_rt/int_util.c
parentMissing local. (diff)
downloadwireguard-openbsd-a303f987e7ef7d1b60e04cf8b1f06edb794137d8.tar.xz
wireguard-openbsd-a303f987e7ef7d1b60e04cf8b1f06edb794137d8.zip
Import libcompiler_rt 3.9.0, LLVM's replacement for libgcc.
This is the lib/builtin directory of the compiler-rt source tarball. comments/ok patrick@, ok kettenis@
Diffstat (limited to 'lib/libcompiler_rt/int_util.c')
-rw-r--r--lib/libcompiler_rt/int_util.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/libcompiler_rt/int_util.c b/lib/libcompiler_rt/int_util.c
new file mode 100644
index 00000000000..420d1e237aa
--- /dev/null
+++ b/lib/libcompiler_rt/int_util.c
@@ -0,0 +1,61 @@
+/* ===-- int_util.c - Implement internal utilities --------------------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include "int_lib.h"
+#include "int_util.h"
+
+/* NOTE: The definitions in this file are declared weak because we clients to be
+ * able to arbitrarily package individual functions into separate .a files. If
+ * we did not declare these weak, some link situations might end up seeing
+ * duplicate strong definitions of the same symbol.
+ *
+ * We can't use this solution for kernel use (which may not support weak), but
+ * currently expect that when built for kernel use all the functionality is
+ * packaged into a single library.
+ */
+
+#ifdef KERNEL_USE
+
+NORETURN extern void panic(const char *, ...);
+#ifndef _WIN32
+__attribute__((visibility("hidden")))
+#endif
+void compilerrt_abort_impl(const char *file, int line, const char *function) {
+ panic("%s:%d: abort in %s", file, line, function);
+}
+
+#elif __APPLE__
+
+/* from libSystem.dylib */
+NORETURN extern void __assert_rtn(const char *func, const char *file, int line,
+ const char *message);
+
+#ifndef _WIN32
+__attribute__((weak))
+__attribute__((visibility("hidden")))
+#endif
+void compilerrt_abort_impl(const char *file, int line, const char *function) {
+ __assert_rtn(function, file, line, "libcompiler_rt abort");
+}
+
+#else
+
+/* Get the system definition of abort() */
+#include <stdlib.h>
+
+#ifndef _WIN32
+__attribute__((weak))
+__attribute__((visibility("hidden")))
+#endif
+void compilerrt_abort_impl(const char *file, int line, const char *function) {
+ abort();
+}
+
+#endif