diff options
Diffstat (limited to 'lib/Support')
| -rw-r--r-- | lib/Support/Android.mk | 111 | ||||
| -rw-r--r-- | lib/Support/Atomic.cpp | 12 | ||||
| -rw-r--r-- | lib/Support/Memory.cpp | 4 | ||||
| -rw-r--r-- | lib/Support/Unix/PathV2.inc | 2 | ||||
| -rw-r--r-- | lib/Support/Unix/Signals.inc | 8 |
5 files changed, 133 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 3001f6c..58497b9 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; @@ -43,6 +46,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(__GNUC__) return __sync_val_compare_and_swap(ptr, old_value, new_value); #elif defined(_MSC_VER) @@ -56,6 +62,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(__GNUC__) return __sync_add_and_fetch(ptr, 1); #elif defined(_MSC_VER) @@ -69,6 +77,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(__GNUC__) return __sync_sub_and_fetch(ptr, 1); #elif defined(_MSC_VER) @@ -82,6 +92,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(__GNUC__) return __sync_add_and_fetch(ptr, val); #elif defined(_MSC_VER) diff --git a/lib/Support/Memory.cpp b/lib/Support/Memory.cpp index 22f7494..8617365 100644 --- a/lib/Support/Memory.cpp +++ b/lib/Support/Memory.cpp @@ -70,6 +70,10 @@ void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr, const char *Start = static_cast<const char *>(Addr); const char *End = Start + Len; __clear_cache(const_cast<char *>(Start), const_cast<char *>(End)); +# elif defined(__mips__) && defined(ANDROID) + // NOTE: The declaration of "cacheflush" in bionic: + // extern int cacheflush(long start, long end, long flags); + cacheflush((long)Addr, (long)(Addr+Len), BCACHE); # elif defined(__mips__) const char *Start = static_cast<const char *>(Addr); cacheflush(const_cast<char *>(Start), Len, BCACHE); diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index d04f590..f59551e 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 b7f83b6..2f1e382 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 @@ -248,7 +248,7 @@ static void PrintStackTrace(void *) { // 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; @@ -298,7 +298,7 @@ static void PrintStackTrace(void *) { void llvm::sys::PrintStackTraceOnErrorSignal() { AddSignalHandler(PrintStackTrace, 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(); @@ -324,7 +324,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> |
