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

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 11:28:58 PDT 2016

kubabrecka added inline comments.

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);
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?


More information about the llvm-commits mailing list