aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/Android.mk111
-rw-r--r--lib/Support/Atomic.cpp12
-rw-r--r--lib/Support/Unix/PathV2.inc2
-rw-r--r--lib/Support/Unix/Signals.inc8
4 files changed, 129 insertions, 4 deletions
diff --git a/lib/Support/Android.mk b/lib/Support/Android.mk
new file mode 100644
index 0000000..6983b29
--- /dev/null
+++ b/lib/Support/Android.mk
@@ -0,0 +1,111 @@
+LOCAL_PATH:= $(call my-dir)
+
+support_SRC_FILES := \
+ Allocator.cpp \
+ APFloat.cpp \
+ APInt.cpp \
+ APSInt.cpp \
+ Atomic.cpp \
+ BlockFrequency.cpp \
+ BranchProbability.cpp \
+ CommandLine.cpp \
+ ConstantRange.cpp \
+ CrashRecoveryContext.cpp \
+ DAGDeltaAlgorithm.cpp \
+ DataStream.cpp \
+ DataExtractor.cpp \
+ Debug.cpp \
+ DeltaAlgorithm.cpp \
+ Dwarf.cpp \
+ DynamicLibrary.cpp \
+ Errno.cpp \
+ ErrorHandling.cpp \
+ FileUtilities.cpp \
+ FoldingSet.cpp \
+ FormattedStream.cpp \
+ GraphWriter.cpp \
+ Hashing.cpp \
+ Host.cpp \
+ IntervalMap.cpp \
+ IntEqClasses.cpp \
+ IntrusiveRefCntPtr.cpp \
+ IsInf.cpp \
+ IsNAN.cpp \
+ Locale.cpp \
+ LockFileManager.cpp \
+ ManagedStatic.cpp \
+ Memory.cpp \
+ MemoryBuffer.cpp \
+ MemoryObject.cpp \
+ Mutex.cpp \
+ Path.cpp \
+ PathV2.cpp \
+ PluginLoader.cpp \
+ PrettyStackTrace.cpp \
+ Process.cpp \
+ Program.cpp \
+ Regex.cpp \
+ RWMutex.cpp \
+ SearchForAddressOfSpecialSymbol.cpp \
+ Signals.cpp \
+ SmallPtrSet.cpp \
+ SmallVector.cpp \
+ SourceMgr.cpp \
+ Statistic.cpp \
+ StreamableMemoryObject.cpp \
+ StringExtras.cpp \
+ StringMap.cpp \
+ StringPool.cpp \
+ StringRef.cpp \
+ SystemUtils.cpp \
+ TargetRegistry.cpp \
+ Threading.cpp \
+ ThreadLocal.cpp \
+ Timer.cpp \
+ TimeValue.cpp \
+ ToolOutputFile.cpp \
+ Triple.cpp \
+ Twine.cpp \
+ Valgrind.cpp \
+ circular_raw_ostream.cpp \
+ raw_os_ostream.cpp \
+ raw_ostream.cpp \
+ regcomp.c \
+ regerror.c \
+ regexec.c \
+ regfree.c \
+ regstrlcpy.c \
+ system_error.cpp
+
+# For the host
+# =====================================================
+include $(CLEAR_VARS)
+
+# FIXME: This only requires RTTI because tblgen uses it. Fix that.
+REQUIRES_RTTI := 1
+
+LOCAL_SRC_FILES := $(support_SRC_FILES)
+
+LOCAL_MODULE:= libLLVMSupport
+
+LOCAL_CFLAGS := -D__android__
+
+LOCAL_MODULE_TAGS := optional
+
+include $(LLVM_HOST_BUILD_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# For the device
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(support_SRC_FILES)
+
+LOCAL_MODULE:= libLLVMSupport
+
+LOCAL_CFLAGS := -D__android__
+
+LOCAL_MODULE_TAGS := optional
+
+include $(LLVM_DEVICE_BUILD_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/Support/Atomic.cpp b/lib/Support/Atomic.cpp
index 9559ad7..13d16d4 100644
--- a/lib/Support/Atomic.cpp
+++ b/lib/Support/Atomic.cpp
@@ -13,6 +13,9 @@
#include "llvm/Support/Atomic.h"
#include "llvm/Config/llvm-config.h"
+#if defined(ANDROID_TARGET_BUILD)
+#include "cutils/atomic.h"
+#endif
using namespace llvm;
@@ -47,6 +50,9 @@ sys::cas_flag sys::CompareAndSwap(volatile sys::cas_flag* ptr,
if (result == old_value)
*ptr = new_value;
return result;
+#elif defined(ANDROID_TARGET_BUILD)
+ return android_atomic_cmpxchg((int32_t)old_value, (int32_t)new_value,
+ (volatile int*)ptr);
#elif defined(GNU_ATOMICS)
return __sync_val_compare_and_swap(ptr, old_value, new_value);
#elif defined(_MSC_VER)
@@ -60,6 +66,8 @@ sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
#if LLVM_HAS_ATOMICS == 0
++(*ptr);
return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+ return android_atomic_inc((volatile int*)ptr);
#elif defined(GNU_ATOMICS)
return __sync_add_and_fetch(ptr, 1);
#elif defined(_MSC_VER)
@@ -73,6 +81,8 @@ sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
#if LLVM_HAS_ATOMICS == 0
--(*ptr);
return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+ return android_atomic_dec((volatile int*)ptr);
#elif defined(GNU_ATOMICS)
return __sync_sub_and_fetch(ptr, 1);
#elif defined(_MSC_VER)
@@ -86,6 +96,8 @@ sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
#if LLVM_HAS_ATOMICS == 0
*ptr += val;
return *ptr;
+#elif defined(ANDROID_TARGET_BUILD)
+ return android_atomic_add((int32_t)val, (volatile int*)ptr);
#elif defined(GNU_ATOMICS)
return __sync_add_and_fetch(ptr, val);
#elif defined(_MSC_VER)
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 741f44a..c343455 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/lib/Support/Unix/PathV2.inc
@@ -61,6 +61,8 @@
# define PATH_MAX 4096
#endif
+extern "C" int truncate (const char*, off_t);
+
using namespace llvm;
namespace {
diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc
index 66338f1..b8be623 100644
--- a/lib/Support/Unix/Signals.inc
+++ b/lib/Support/Unix/Signals.inc
@@ -27,7 +27,7 @@
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#if HAVE_DLFCN_H && __GNUG__
+#if HAVE_DLFCN_H && HAVE_CXXABI_H && __GNUG__
#include <dlfcn.h>
#include <cxxabi.h>
#endif
@@ -262,7 +262,7 @@ void llvm::sys::PrintStackTrace(FILE *FD) {
// Use backtrace() to output a backtrace on Linux systems with glibc.
int depth = backtrace(StackTrace,
static_cast<int>(array_lengthof(StackTrace)));
-#if HAVE_DLFCN_H && __GNUG__
+#if HAVE_DLFCN_H && HAVE_CXXABI_H && __GNUG__
int width = 0;
for (int i = 0; i < depth; ++i) {
Dl_info dlinfo;
@@ -320,7 +320,7 @@ static void PrintStackTraceSignalHandler(void *) {
void llvm::sys::PrintStackTraceOnErrorSignal() {
AddSignalHandler(PrintStackTraceSignalHandler, 0);
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(ANDROID)
// Environment variable to disable any kind of crash dialog.
if (getenv("LLVM_DISABLE_CRASH_REPORT")) {
mach_port_t self = mach_task_self();
@@ -346,7 +346,7 @@ void llvm::sys::PrintStackTraceOnErrorSignal() {
// the same linkage unit by just defining our own versions of the assert handler
// and abort.
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(ANDROID)
#include <signal.h>
#include <pthread.h>