From c5d4bc7581486a204f34f326d259de3b049f7185 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 20 Oct 2014 15:35:01 +0000 Subject: [PATCH] Fix checks for Android. __ANDROID__ is a define that comes from the toolchain when building for Android targets. ANDROID has a different meaning. ANDROID is defined for _every_ Android build, including those done for host modules. For host modules, we want to build the regular Linux sanitizers and builtins, not the one for Android devices. This hasn't been a problem until now because we only just started building the sanitizers for the host. llvm-svn: 220203 --- compiler-rt/lib/asan/tests/asan_test.cc | 8 ++++---- compiler-rt/lib/builtins/clear_cache.c | 8 ++++---- compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 2 +- compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index adf3948..91a7356 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -117,7 +117,7 @@ TEST(AddressSanitizer, CallocReturnsZeroMem) { } // No valloc on Windows or Android. -#if !defined(_WIN32) && !defined(ANDROID) && !defined(__ANDROID__) +#if !defined(_WIN32) && !defined(__ANDROID__) TEST(AddressSanitizer, VallocTest) { void *a = valloc(100); EXPECT_EQ(0U, (uintptr_t)a % kPageSize); @@ -769,7 +769,7 @@ char* MallocAndMemsetString(size_t size) { return MallocAndMemsetString(size, 'z'); } -#if defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__) +#if defined(__linux__) && !defined(__ANDROID__) #define READ_TEST(READ_N_BYTES) \ char *x = new char[10]; \ int fd = open("/proc/self/stat", O_RDONLY); \ @@ -792,7 +792,7 @@ TEST(AddressSanitizer, pread64) { TEST(AddressSanitizer, read) { READ_TEST(read(fd, x, 15)); } -#endif // defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__) +#endif // defined(__linux__) && !defined(__ANDROID__) // This test case fails // Clang optimizes memcpy/memset calls which lead to unaligned access @@ -1153,7 +1153,7 @@ TEST(AddressSanitizer, AttributeNoSanitizeAddressTest) { // https://code.google.com/p/address-sanitizer/issues/detail?id=131 // Windows support is tracked here: // https://code.google.com/p/address-sanitizer/issues/detail?id=309 -#if !defined(ANDROID) && !defined(__ANDROID__) && \ +#if !defined(__ANDROID__) && \ !defined(__APPLE__) && \ !defined(_WIN32) static string MismatchStr(const string &str) { diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c index e0bd8b0..86e68af 100644 --- a/compiler-rt/lib/builtins/clear_cache.c +++ b/compiler-rt/lib/builtins/clear_cache.c @@ -17,11 +17,11 @@ #include #endif -#if defined(ANDROID) && defined(__mips__) +#if defined(__ANDROID__) && defined(__mips__) #include #endif -#if defined(ANDROID) && defined(__arm__) +#if defined(__ANDROID__) && defined(__arm__) #include #endif @@ -46,7 +46,7 @@ void __clear_cache(void *start, void *end) { arg.len = (uintptr_t)end - (uintptr_t)start; sysarch(ARM_SYNC_ICACHE, &arg); - #elif defined(ANDROID) + #elif defined(__ANDROID__) const register int start_reg __asm("r0") = (int) (intptr_t) start; const register int end_reg __asm("r1") = (int) (intptr_t) end; const register int flags __asm("r2") = 0; @@ -59,7 +59,7 @@ void __clear_cache(void *start, void *end) { #else compilerrt_abort(); #endif -#elif defined(ANDROID) && defined(__mips__) +#elif defined(__ANDROID__) && defined(__mips__) const uintptr_t start_int = (uintptr_t) start; const uintptr_t end_int = (uintptr_t) end; _flush_cache(start, (end_int - start_int), BCACHE); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h index d9a7868..a369599 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -49,7 +49,7 @@ # define SANITIZER_WINDOWS 0 #endif -#if defined(__ANDROID__) || defined(ANDROID) +#if defined(__ANDROID__) # define SANITIZER_ANDROID 1 #else # define SANITIZER_ANDROID 0 diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h index db5d8fa..64db37f 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_utils.h @@ -95,13 +95,13 @@ static inline uint32_t my_rand() { // Set availability of platform-specific functions. -#if !defined(__APPLE__) && !defined(ANDROID) && !defined(__ANDROID__) && !defined(_WIN32) +#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) # define SANITIZER_TEST_HAS_POSIX_MEMALIGN 1 #else # define SANITIZER_TEST_HAS_POSIX_MEMALIGN 0 #endif -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(ANDROID) && \ +#if !defined(__APPLE__) && !defined(__FreeBSD__) && \ !defined(__ANDROID__) && !defined(_WIN32) # define SANITIZER_TEST_HAS_MEMALIGN 1 # define SANITIZER_TEST_HAS_PVALLOC 1 -- 2.7.4