[llvm-commits] [compiler-rt] r144751 - in /compiler-rt/trunk: Makefile lib/int_lib.h lib/int_util.c lib/int_util.h make/config.mk

Daniel Dunbar daniel at zuster.org
Tue Nov 15 17:19:20 PST 2011


Author: ddunbar
Date: Tue Nov 15 19:19:19 2011
New Revision: 144751

URL: http://llvm.org/viewvc/llvm-project?rev=144751&view=rev
Log:
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.

Added:
    compiler-rt/trunk/lib/int_util.c
    compiler-rt/trunk/lib/int_util.h
Modified:
    compiler-rt/trunk/Makefile
    compiler-rt/trunk/lib/int_lib.h
    compiler-rt/trunk/make/config.mk

Modified: compiler-rt/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=144751&r1=144750&r2=144751&view=diff
==============================================================================
--- compiler-rt/trunk/Makefile (original)
+++ compiler-rt/trunk/Makefile Tue Nov 15 19:19:19 2011
@@ -164,6 +164,7 @@
 $(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))))

Modified: compiler-rt/trunk/lib/int_lib.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_lib.h?rev=144751&r1=144750&r2=144751&view=diff
==============================================================================
--- compiler-rt/trunk/lib/int_lib.h (original)
+++ compiler-rt/trunk/lib/int_lib.h Tue Nov 15 19:19:19 2011
@@ -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 @@
 /* Include the commonly used internal type definitions. */
 #include "int_types.h"
 
+/* Include internal utility function declarations. */
+#include "int_util.h"
+
 #endif /* INT_LIB_H */

Added: compiler-rt/trunk/lib/int_util.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_util.c?rev=144751&view=auto
==============================================================================
--- compiler-rt/trunk/lib/int_util.c (added)
+++ compiler-rt/trunk/lib/int_util.c Tue Nov 15 19:19:19 2011
@@ -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

Added: compiler-rt/trunk/lib/int_util.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_util.h?rev=144751&view=auto
==============================================================================
--- compiler-rt/trunk/lib/int_util.h (added)
+++ compiler-rt/trunk/lib/int_util.h Tue Nov 15 19:19:19 2011
@@ -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 */

Modified: compiler-rt/trunk/make/config.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=144751&r1=144750&r2=144751&view=diff
==============================================================================
--- compiler-rt/trunk/make/config.mk (original)
+++ compiler-rt/trunk/make/config.mk Tue Nov 15 19:19:19 2011
@@ -8,6 +8,11 @@
 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.
 





More information about the llvm-commits mailing list