summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_common_mac.cc
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-03-01 23:18:15 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-03-01 23:18:15 +0000
commit6e1f23078c1acc44295065d28167043c4d31ddd1 (patch)
treef823394d0e28b952263528298bb023e7fd9ed9e5 /lib/lsan/lsan_common_mac.cc
parentf8ff7e585134196e8482e4dd8752cd4c22cf027a (diff)
downloadcompiler-rt-6e1f23078c1acc44295065d28167043c4d31ddd1.tar.gz
Use pthreads for thread-local lsan allocator cache on darwin
Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29994 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@296707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_common_mac.cc')
-rw-r--r--lib/lsan/lsan_common_mac.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/lsan/lsan_common_mac.cc b/lib/lsan/lsan_common_mac.cc
index 7f5e0550d..f70ebdd0e 100644
--- a/lib/lsan/lsan_common_mac.cc
+++ b/lib/lsan/lsan_common_mac.cc
@@ -12,12 +12,14 @@
//
//===----------------------------------------------------------------------===//
-#include "sanitizer_common/sanitizer_allocator_internal.h"
#include "sanitizer_common/sanitizer_platform.h"
#include "lsan_common.h"
#if CAN_SANITIZE_LEAKS && SANITIZER_MAC
+#include "sanitizer_common/sanitizer_allocator_internal.h"
+#include "lsan_allocator.h"
+
#include <pthread.h>
namespace __lsan {
@@ -25,6 +27,7 @@ namespace __lsan {
typedef struct {
int disable_counter;
u32 current_thread_id;
+ AllocatorCache cache;
} thread_local_data_t;
static pthread_key_t key;
@@ -40,6 +43,7 @@ static thread_local_data_t *get_tls_val() {
ptr = (thread_local_data_t *)InternalAlloc(sizeof(*ptr));
ptr->disable_counter = 0;
ptr->current_thread_id = kInvalidTid;
+ ptr->cache = AllocatorCache();
pthread_setspecific(key, ptr);
}
@@ -62,6 +66,8 @@ u32 GetCurrentThread() { return get_tls_val()->current_thread_id; }
void SetCurrentThread(u32 tid) { get_tls_val()->current_thread_id = tid; }
+AllocatorCache *GetAllocatorCache() { return &get_tls_val()->cache; }
+
void InitializePlatformSpecificModules() {
CHECK(0 && "unimplemented");
}