[PATCH] D18951: [sanitizer] Use pthread_threadid_np as thread ID on OS X

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 11:36:08 PDT 2016


dvyukov accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: lib/sanitizer_common/sanitizer_mac.cc:233
@@ -232,2 +232,3 @@
 uptr GetTid() {
-  return reinterpret_cast<uptr>(pthread_self());
+  uint64_t tid;
+  pthread_threadid_np(nullptr, &tid);
----------------
kubabrecka wrote:
> dvyukov wrote:
> > Is it OK that the value is potentially truncated?
> Hm.  It's really just an incrementing thread counter in the kernel.  Truncating this can only be an issue after the system created 2^32 threads.  This sounds unlikely.
> 
> On the other hand, would it be a problem to change GetTid to return u64?
Yeah, it's probably unlikely on a 32-bit system. And I think we use it only for reporting, so a truncated id should not break anything. Up to you.


http://reviews.llvm.org/D18951





More information about the llvm-commits mailing list