summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2016-04-21 14:38:41 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2016-04-21 14:38:41 +0000
commitfc1463ac75cfc8712f0ed30148758871938aafb1 (patch)
treee166d7d3117000f5846abe234dc69499bead2ec8 /lib
parent075c251640c88f5431dd291e86f1ca2b9c266ce4 (diff)
[sanitizer] Use pthread_threadid_np as thread ID on OS X
Let's use pthread_threadid_np which returns a more reasonable ID than pthread_self (which is actually a stack pointer). The numbers from pthread_threadid_np are already used in other tools, e.g. in LLDB, and often appear in logs, so it's much more useful than pthread_self. Differential Revision: http://reviews.llvm.org/D18951 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266991 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_mac.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc
index c2e8b1ec3..5fbb14729 100644
--- a/lib/sanitizer_common/sanitizer_mac.cc
+++ b/lib/sanitizer_common/sanitizer_mac.cc
@@ -230,7 +230,10 @@ bool FileExists(const char *filename) {
}
uptr GetTid() {
- return reinterpret_cast<uptr>(pthread_self());
+ // FIXME: This can potentially get truncated on 32-bit, where uptr is 4 bytes.
+ uint64_t tid;
+ pthread_threadid_np(nullptr, &tid);
+ return tid;
}
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,