diff options
| author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-04-21 14:38:41 +0000 |
|---|---|---|
| committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-04-21 14:38:41 +0000 |
| commit | 586d93bd8b4bcb2664d6dab95293a333aa809246 (patch) | |
| tree | c4386e73b820815e5f60f734412884991d833214 /compiler-rt/lib | |
| parent | 9360c10a889f5b1409f8b3d136cc29142528f705 (diff) | |
| download | bcm5719-llvm-586d93bd8b4bcb2664d6dab95293a333aa809246.tar.gz bcm5719-llvm-586d93bd8b4bcb2664d6dab95293a333aa809246.zip | |
[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
llvm-svn: 266991
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_mac.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc index c2e8b1ec38f..5fbb147297c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc +++ b/compiler-rt/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, |

