diff options
Diffstat (limited to 'lib/Support')
| -rw-r--r-- | lib/Support/Android.mk | 109 | ||||
| -rw-r--r-- | lib/Support/Atomic.cpp | 16 | ||||
| -rw-r--r-- | lib/Support/DynamicLibrary.cpp | 2 | ||||
| -rw-r--r-- | lib/Support/LockFileManager.cpp | 3 | ||||
| -rw-r--r-- | lib/Support/Memory.cpp | 2 | ||||
| -rw-r--r-- | lib/Support/Unix/PathV2.inc | 2 | ||||
| -rw-r--r-- | lib/Support/Unix/Signals.inc | 4 |
7 files changed, 133 insertions, 5 deletions
diff --git a/lib/Support/Android.mk b/lib/Support/Android.mk new file mode 100644 index 0000000..62400ba --- /dev/null +++ b/lib/Support/Android.mk @@ -0,0 +1,109 @@ +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 \ + 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 \ + 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..015b9c5 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 "sys/atomics.h" +#endif using namespace llvm; @@ -43,6 +46,8 @@ 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 __atomic_cmpxchg(old_value, 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 +61,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 __atomic_inc((volatile int*)ptr); #elif defined(__GNUC__) return __sync_add_and_fetch(ptr, 1); #elif defined(_MSC_VER) @@ -69,6 +76,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 __atomic_dec((volatile int*)ptr); #elif defined(__GNUC__) return __sync_sub_and_fetch(ptr, 1); #elif defined(_MSC_VER) @@ -82,6 +91,13 @@ 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) + sys::cas_flag original, result; + do { + original = *ptr; + result = original + val; + } while (__atomic_cmpxchg(original, result, (volatile int*)ptr) != original); + return result; #elif defined(__GNUC__) return __sync_add_and_fetch(ptr, val); #elif defined(_MSC_VER) diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp index fb02c07..2d8ddd9 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -160,7 +160,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { // On linux we have a weird situation. The stderr/out/in symbols are both // macros and global variables because of standards requirements. So, we // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. -#if defined(__linux__) +#if defined(__linux__) && !defined(__android__) { EXPLICIT_SYMBOL(stderr); EXPLICIT_SYMBOL(stdout); diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp index 64404a1..8cb9857 100644 --- a/lib/Support/LockFileManager.cpp +++ b/lib/Support/LockFileManager.cpp @@ -49,7 +49,8 @@ LockFileManager::readLockFile(StringRef LockFileName) { } bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) { -#if LLVM_ON_UNIX +// getsid not supported in Android bionic library +#if LLVM_ON_UNIX && !defined(ANDROID_TARGET_BUILD) char MyHostname[256]; MyHostname[255] = 0; MyHostname[0] = 0; diff --git a/lib/Support/Memory.cpp b/lib/Support/Memory.cpp index 2a1642a..6806c1d 100644 --- a/lib/Support/Memory.cpp +++ b/lib/Support/Memory.cpp @@ -71,7 +71,7 @@ void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr, char *End = Start + Len; __clear_cache(Start, End); # elif defined(__mips__) - cacheflush((char*)Addr, Len, BCACHE); + cacheflush((intptr_t)Addr, Len, BCACHE); # endif #endif // end apple diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index edb101e..7d259a3 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -51,6 +51,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 c9ec9fc..399f686 100644 --- a/lib/Support/Unix/Signals.inc +++ b/lib/Support/Unix/Signals.inc @@ -266,7 +266,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(); @@ -292,7 +292,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> |
