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.

llvm-svn: 144751
This commit is contained in:
Daniel Dunbar 2011-11-16 01:19:19 +00:00
parent 2f9c1404dd
commit 2b88e03404
5 changed files with 70 additions and 9 deletions

View File

@ -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))))

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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.