summaryrefslogtreecommitdiff
path: root/lib/tsan
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-12-09 22:32:38 +0000
committerYabin Cui <yabinc@google.com>2015-12-09 22:32:38 +0000
commit607c20146eb8523832630a54ccfc665cdc011736 (patch)
tree17360ed2e49894e667377bf71ccfc0c28afe4936 /lib/tsan
parentfa0131d59ed91ae119f5e2bbc576bd2c3943b8d3 (diff)
[tsan] Use REAL(malloc) instead of __libc_malloc for Android.
Summary: Android doesn't have __libc_malloc and related allocation functions. As its dynamic linker doesn't use malloc, so we can use REAL(malloc) to replace __libc_malloc safely. Reviewers: kcc, eugenis, dvyukov Subscribers: llvm-commits, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D15297 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan')
-rw-r--r--lib/tsan/rtl/tsan_interceptors.cc11
-rw-r--r--lib/tsan/rtl/tsan_new_delete.cc2
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc
index f2c28de1e..91dc8c65f 100644
--- a/lib/tsan/rtl/tsan_interceptors.cc
+++ b/lib/tsan/rtl/tsan_interceptors.cc
@@ -48,6 +48,13 @@ using namespace __tsan; // NOLINT
#define __libc_realloc REAL(realloc)
#define __libc_calloc REAL(calloc)
#define __libc_free REAL(free)
+#elif SANITIZER_ANDROID
+#define __errno_location __errno
+#define __libc_malloc REAL(malloc)
+#define __libc_realloc REAL(realloc)
+#define __libc_calloc REAL(calloc)
+#define __libc_free REAL(free)
+#define mallopt(a, b)
#endif
#if SANITIZER_LINUX || SANITIZER_FREEBSD
@@ -105,10 +112,12 @@ extern "C" void *pthread_self();
extern "C" void _exit(int status);
extern "C" int *__errno_location();
extern "C" int fileno_unlocked(void *stream);
+#if !SANITIZER_ANDROID
extern "C" void *__libc_calloc(uptr size, uptr n);
extern "C" void *__libc_realloc(void *ptr, uptr size);
+#endif
extern "C" int dirfd(void *dirp);
-#if !SANITIZER_FREEBSD
+#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID
extern "C" int mallopt(int param, int value);
#endif
extern __sanitizer_FILE *stdout, *stderr;
diff --git a/lib/tsan/rtl/tsan_new_delete.cc b/lib/tsan/rtl/tsan_new_delete.cc
index ecbdb62b0..ebb422cf2 100644
--- a/lib/tsan/rtl/tsan_new_delete.cc
+++ b/lib/tsan/rtl/tsan_new_delete.cc
@@ -23,7 +23,7 @@ struct nothrow_t {};
DECLARE_REAL(void *, malloc, uptr size)
DECLARE_REAL(void, free, void *ptr)
-#if SANITIZER_MAC
+#if SANITIZER_MAC || SANITIZER_ANDROID
#define __libc_malloc REAL(malloc)
#define __libc_free REAL(free)
#endif