diff --git a/compiler-rt/lib/lsan/lsan_fuchsia.cpp b/compiler-rt/lib/lsan/lsan_fuchsia.cpp --- a/compiler-rt/lib/lsan/lsan_fuchsia.cpp +++ b/compiler-rt/lib/lsan/lsan_fuchsia.cpp @@ -99,7 +99,7 @@ OnCreatedArgs args; args.stack_begin = reinterpret_cast(stack_base); args.stack_end = args.stack_begin + stack_size; - u32 parent_tid = GetCurrentThread(); + u32 parent_tid = GetCurrentThreadId(); u32 tid = ThreadCreate(parent_tid, detached, &args); return reinterpret_cast(static_cast(tid)); } diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp --- a/compiler-rt/lib/lsan/lsan_interceptors.cpp +++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp @@ -468,7 +468,7 @@ res = REAL(pthread_create)(th, attr, __lsan_thread_start_func, &p); } if (res == 0) { - int tid = ThreadCreate(GetCurrentThread(), IsStateDetached(detached)); + int tid = ThreadCreate(GetCurrentThreadId(), IsStateDetached(detached)); CHECK_NE(tid, kMainTid); atomic_store(&p.tid, tid, memory_order_release); while (atomic_load(&p.tid, memory_order_acquire) != 0) diff --git a/compiler-rt/lib/lsan/lsan_mac.cpp b/compiler-rt/lib/lsan/lsan_mac.cpp --- a/compiler-rt/lib/lsan/lsan_mac.cpp +++ b/compiler-rt/lib/lsan/lsan_mac.cpp @@ -67,7 +67,7 @@ ALWAYS_INLINE void lsan_register_worker_thread(int parent_tid) { - if (GetCurrentThread() == kInvalidTid) { + if (GetCurrentThreadId() == kInvalidTid) { u32 tid = ThreadCreate(parent_tid, true); ThreadStart(tid, GetTid()); } @@ -100,7 +100,7 @@ (lsan_block_context_t *)lsan_malloc(sizeof(lsan_block_context_t), stack); lsan_ctxt->block = ctxt; lsan_ctxt->func = func; - lsan_ctxt->parent_tid = GetCurrentThread(); + lsan_ctxt->parent_tid = GetCurrentThreadId(); return lsan_ctxt; } @@ -145,13 +145,13 @@ void (^work)(void)); } -#define GET_LSAN_BLOCK(work) \ - void (^lsan_block)(void); \ - int parent_tid = GetCurrentThread(); \ - lsan_block = ^(void) { \ - lsan_register_worker_thread(parent_tid); \ - work(); \ - } +# define GET_LSAN_BLOCK(work) \ + void (^lsan_block)(void); \ + int parent_tid = GetCurrentThreadId(); \ + lsan_block = ^(void) { \ + lsan_register_worker_thread(parent_tid); \ + work(); \ + } INTERCEPTOR(void, dispatch_async, dispatch_queue_t dq, void (^work)(void)) { GET_LSAN_BLOCK(work); diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp --- a/compiler-rt/lib/lsan/lsan_posix.cpp +++ b/compiler-rt/lib/lsan/lsan_posix.cpp @@ -89,7 +89,7 @@ } void LsanOnDeadlySignal(int signo, void *siginfo, void *context) { - HandleDeadlySignal(siginfo, context, GetCurrentThread(), &OnStackUnwind, + HandleDeadlySignal(siginfo, context, GetCurrentThreadId(), &OnStackUnwind, nullptr); } diff --git a/compiler-rt/lib/lsan/lsan_thread.h b/compiler-rt/lib/lsan/lsan_thread.h --- a/compiler-rt/lib/lsan/lsan_thread.h +++ b/compiler-rt/lib/lsan/lsan_thread.h @@ -52,6 +52,7 @@ void ThreadFinish(); u32 GetCurrentThread(); +inline u32 GetCurrentThreadId() { return GetCurrentThread(); } void SetCurrentThread(u32 tid); ThreadContext *CurrentThreadContext(); void EnsureMainThreadIDIsCorrect(); diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp --- a/compiler-rt/lib/lsan/lsan_thread.cpp +++ b/compiler-rt/lib/lsan/lsan_thread.cpp @@ -56,19 +56,20 @@ thread_registry->StartThread(tid, os_id, thread_type, arg); } -void ThreadFinish() { thread_registry->FinishThread(GetCurrentThread()); } +void ThreadFinish() { thread_registry->FinishThread(GetCurrentThreadId()); } ThreadContext *CurrentThreadContext() { if (!thread_registry) return nullptr; - if (GetCurrentThread() == kInvalidTid) + if (GetCurrentThreadId() == kInvalidTid) return nullptr; // No lock needed when getting current thread. - return (ThreadContext *)thread_registry->GetThreadLocked(GetCurrentThread()); + return (ThreadContext *)thread_registry->GetThreadLocked( + GetCurrentThreadId()); } void EnsureMainThreadIDIsCorrect() { - if (GetCurrentThread() == kMainTid) + if (GetCurrentThreadId() == kMainTid) CurrentThreadContext()->os_id = GetTid(); }