diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | lib/int_lib.h | 12 | ||||
-rw-r--r-- | lib/int_util.c | 32 | ||||
-rw-r--r-- | lib/int_util.h | 29 | ||||
-rw-r--r-- | make/config.mk | 5 |
5 files changed, 70 insertions, 9 deletions
@@ -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. |