diff options
Diffstat (limited to 'lib/Support')
| -rw-r--r-- | lib/Support/Android.mk | 102 | ||||
| -rw-r--r-- | lib/Support/Atomic.cpp | 16 | ||||
| -rw-r--r-- | lib/Support/DynamicLibrary.cpp | 2 | ||||
| -rw-r--r-- | lib/Support/Unix/Host.inc | 1 | ||||
| -rw-r--r-- | lib/Support/Unix/PathV2.inc | 2 |
5 files changed, 122 insertions, 1 deletions
diff --git a/lib/Support/Android.mk b/lib/Support/Android.mk new file mode 100644 index 0000000..7af2025 --- /dev/null +++ b/lib/Support/Android.mk @@ -0,0 +1,102 @@ +LOCAL_PATH:= $(call my-dir) + +support_SRC_FILES := \ + Allocator.cpp \ + APFloat.cpp \ + APInt.cpp \ + APSInt.cpp \ + Atomic.cpp \ + CommandLine.cpp \ + ConstantRange.cpp \ + CrashRecoveryContext.cpp \ + DAGDeltaAlgorithm.cpp \ + Debug.cpp \ + DeltaAlgorithm.cpp \ + Dwarf.cpp \ + DynamicLibrary.cpp \ + Errno.cpp \ + ErrorHandling.cpp \ + FileUtilities.cpp \ + FoldingSet.cpp \ + FormattedStream.cpp \ + GraphWriter.cpp \ + Host.cpp \ + IntervalMap.cpp \ + IntEqClasses.cpp\ + IsInf.cpp \ + IsNAN.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 \ + 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 c7b4bff..05339f4 100644 --- a/lib/Support/Atomic.cpp +++ b/lib/Support/Atomic.cpp @@ -13,6 +13,9 @@ #include "llvm/Support/Atomic.h" #include "llvm/Config/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_MULTITHREADED==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_MULTITHREADED==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_MULTITHREADED==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 455c380..9bedfb5 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -141,7 +141,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/Unix/Host.inc b/lib/Support/Unix/Host.inc index 5fd0e5e..a286a15 100644 --- a/lib/Support/Unix/Host.inc +++ b/lib/Support/Unix/Host.inc @@ -22,6 +22,7 @@ #include <sys/utsname.h> #include <cctype> #include <string> +#include <ctype.h> using namespace llvm; diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 03ff283..15df8a2 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -43,6 +43,8 @@ #include <stdio.h> #endif +extern "C" int truncate (const char*, off_t); + using namespace llvm; namespace { |
