summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-16 01:19:19 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-16 01:19:19 +0000
commit401f693a874c0f2fd9e37173e3ab7045a1bdeb3d (patch)
tree882c35bcad2dab8b3a021cdd2bbbd540051750c5
parentdbaa3974d4c012ad500a790be5e51ce66188d15c (diff)
downloadcompiler-rt-401f693a874c0f2fd9e37173e3ab7045a1bdeb3d.tar.gz
compiler-rt-401f693a874c0f2fd9e37173e3ab7045a1bdeb3d.tar.bz2
compiler-rt-401f693a874c0f2fd9e37173e3ab7045a1bdeb3d.tar.xz
lib: Add support for library wide utility functions, and make compilerrt_abort()
a real boy. - The utility module needs to be included into every produced library, because we don't have enough dependency tracking to know exactly which other modules might require the utilities. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@144751 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Makefile1
-rw-r--r--lib/int_lib.h12
-rw-r--r--lib/int_util.c32
-rw-r--r--lib/int_util.h29
-rw-r--r--make/config.mk5
5 files changed, 70 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 53059061..22013c0a 100644
--- a/Makefile
+++ b/Makefile
@@ -164,6 +164,7 @@ define PerPlatformConfigArch_template
$(call Set,Tmp.Arch,$(1))
$(call Set,Tmp.ObjPath,$(ProjObjRoot)/$(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch))
$(call Set,Tmp.Functions,$(strip \
+ $(AlwaysRequiredModules) \
$(call GetCNAVar,FUNCTIONS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
$(call Set,Tmp.Optimized,$(strip \
$(call GetCNAVar,OPTIMIZED,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
diff --git a/lib/int_lib.h b/lib/int_lib.h
index 3334a556..5ce20238 100644
--- a/lib/int_lib.h
+++ b/lib/int_lib.h
@@ -37,15 +37,6 @@
#include <stdbool.h>
#include <float.h>
-/* If compiling for kernel use, call panic() instead of abort(). */
-#ifdef KERNEL_USE
-extern void panic (const char *, ...);
-#define compilerrt_abort() \
- panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__)
-#else
-#define compilerrt_abort() abort()
-#endif
-
#if !defined(INFINITY) && defined(HUGE_VAL)
#define INFINITY HUGE_VAL
#endif /* INFINITY */
@@ -53,4 +44,7 @@ extern void panic (const char *, ...);
/* Include the commonly used internal type definitions. */
#include "int_types.h"
+/* Include internal utility function declarations. */
+#include "int_util.h"
+
#endif /* INT_LIB_H */
diff --git a/lib/int_util.c b/lib/int_util.c
new file mode 100644
index 00000000..2dc4d2ee
--- /dev/null
+++ b/lib/int_util.c
@@ -0,0 +1,32 @@
+/* ===-- 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_util.h"
+#include "int_lib.h"
+
+#ifdef KERNEL_USE
+
+extern void panic(const char *, ...) __attribute__((noreturn));
+__attribute__((visibility("hidden")))
+void compilerrt_abort_impl(const char *file, int line, const char *function) {
+ panic("%s:%d: abort in %s", file, line, function);
+}
+
+#else
+
+/* Get the system definition of abort() */
+#include <stdlib.h>
+
+__attribute__((visibility("hidden")))
+void compilerrt_abort_impl(const char *file, int line, const char *function) {
+ abort();
+}
+
+#endif
diff --git a/lib/int_util.h b/lib/int_util.h
new file mode 100644
index 00000000..797204f0
--- /dev/null
+++ b/lib/int_util.h
@@ -0,0 +1,29 @@
+/* ===-- int_util.h - internal utility functions ----------------------------===
+ *
+ * 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.
+ *
+ * ===-----------------------------------------------------------------------===
+ *
+ * This file is not part of the interface of this library.
+ *
+ * This file defines non-inline utilities which are available for use in the
+ * library. The function definitions themselves are all contained in int_util.c
+ * which will always be compiled into any compiler-rt library.
+ *
+ * ===-----------------------------------------------------------------------===
+ */
+
+#ifndef INT_UTIL_H
+#define INT_UTIL_H
+
+/** \brief Trigger a program abort (or panic for kernel code). */
+#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \
+ __FUNCTION__)
+void compilerrt_abort_impl(const char *file, int line,
+ const char *function)
+ __attribute__((noreturn)) __attribute__((visibility("hidden")));
+
+#endif /* INT_UTIL_H */
diff --git a/make/config.mk b/make/config.mk
index d96b1b43..bddc6f8f 100644
--- a/make/config.mk
+++ b/make/config.mk
@@ -8,6 +8,11 @@ OS := $(shell uname)
ProjSrcRoot := $(shell pwd)
ProjObjRoot := $(ProjSrcRoot)
+# The list of modules which are required to be built into every library. This
+# should only be used for internal utilities which could be used in any other
+# module. Any other cases the platform should be allowed to opt-in to.
+AlwaysRequiredModules := int_util
+
###
# Tool configuration variables.