Skip to content

Conversation

@jakeegan
Copy link
Member

tid_t is also defined in the AIX header /usr/include/sys/types.h which is included by system pthread.h. The use of tid_t by AIX is conforming according to POSIX:

Implementations may add symbols to the headers shown in the following table [ ... ]

@jakeegan jakeegan changed the title [sanitizer_common][nfc] Rename tid_t to avoid conflicting duplicate declarations [sanitizer_common][nfc] Rename tid_t to avoid conflicting duplicate declarations Jul 16, 2025
@github-actions
Copy link

github-actions bot commented Jul 16, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@jakeegan jakeegan changed the title [sanitizer_common][nfc] Rename tid_t to avoid conflicting duplicate declarations [sanitizer_common][nfc] Rename tid_t to avoid conflicting declarations Jul 16, 2025
@jakeegan jakeegan marked this pull request as ready for review July 16, 2025 03:14
@llvmbot llvmbot added compiler-rt compiler-rt:asan Address sanitizer compiler-rt:tsan Thread sanitizer xray compiler-rt:hwasan Hardware-assisted address sanitizer PGO Profile Guided Optimizations compiler-rt:lsan Leak sanitizer compiler-rt:sanitizer labels Jul 16, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Jake Egan (jakeegan)

Changes

tid_t is also defined in the AIX header /usr/include/sys/types.h which is included by system pthread.h. The use of tid_t by AIX is conforming according to POSIX:
> Implementations may add symbols to the headers shown in the following table [ ... ]


Patch is 46.29 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149011.diff

39 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_thread.cpp (+6-6)
  • (modified) compiler-rt/lib/asan/asan_thread.h (+1-1)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.h (+3-3)
  • (modified) compiler-rt/lib/lsan/lsan_common.cpp (+10-10)
  • (modified) compiler-rt/lib/lsan/lsan_common.h (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_interceptors.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.h (+1-1)
  • (modified) compiler-rt/lib/lsan/lsan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_thread.h (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common.h (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+5-5)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.h (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp (+11-11)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp (+7-7)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h (+4-4)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_win.cpp (+1-3)
  • (modified) compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp (+18-18)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_debugging.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interface.h (+3-3)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_report.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/xray/xray_fdr_controller.h (+2-2)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.cpp (+3-3)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.h (+1-1)
diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp index 37fb6f2b07f27..1c4474a6826b4 100644 --- a/compiler-rt/lib/asan/asan_thread.cpp +++ b/compiler-rt/lib/asan/asan_thread.cpp @@ -282,7 +282,7 @@ void AsanThread::Init(const InitOptions *options) { // asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls. #if !SANITIZER_FUCHSIA -void AsanThread::ThreadStart(tid_t os_id) { +void AsanThread::ThreadStart(thid_t os_id) { Init(); asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr); @@ -469,7 +469,7 @@ void EnsureMainThreadIDIsCorrect() { context->os_id = GetTid(); } -__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) { +__asan::AsanThread *GetAsanThreadByOsIDLocked(thid_t os_id) { __asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>( __asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id)); if (!context) @@ -497,7 +497,7 @@ static ThreadRegistry *GetAsanThreadRegistryLocked() { void EnsureMainThreadIDIsCorrect() { __asan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); @@ -516,7 +516,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); if (!t) @@ -546,11 +546,11 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __asan::asanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetAsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); }, threads); diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index ad9e03d68fe96..3e2ba0aded049 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -75,7 +75,7 @@ class AsanThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - void ThreadStart(tid_t os_id); + void ThreadStart(thid_t os_id); thread_return_t RunThread(); uptr stack_top(); diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp index 8b32e4e760e2f..a19cbda56f7fb 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.cpp +++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp @@ -174,7 +174,7 @@ static __hwasan::HwasanThreadList *GetHwasanThreadListLocked() { return &tl; } -static __hwasan::Thread *GetThreadByOsIDLocked(tid_t os_id) { +static __hwasan::Thread *GetThreadByOsIDLocked(thid_t os_id) { return GetHwasanThreadListLocked()->FindThreadLocked( [os_id](__hwasan::Thread *t) { return t->os_id() == os_id; }); } @@ -191,7 +191,7 @@ void UnlockThreads() { void EnsureMainThreadIDIsCorrect() { __hwasan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { auto *t = GetThreadByOsIDLocked(os_id); @@ -210,7 +210,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -218,7 +218,7 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __hwasan::hwasanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { // TODO: implement. } void PrintThreads() { diff --git a/compiler-rt/lib/hwasan/hwasan_thread.h b/compiler-rt/lib/hwasan/hwasan_thread.h index 9e1b438e48f77..94773fdbcaa53 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.h +++ b/compiler-rt/lib/hwasan/hwasan_thread.h @@ -69,8 +69,8 @@ class Thread { Print("Thread: "); } - tid_t os_id() const { return os_id_; } - void set_os_id(tid_t os_id) { os_id_ = os_id; } + thid_t os_id() const { return os_id_; } + void set_os_id(thid_t os_id) { os_id_ = os_id; } uptr &vfork_spill() { return vfork_spill_; } @@ -96,7 +96,7 @@ class Thread { u32 unique_id_; // counting from zero. - tid_t os_id_; + thid_t os_id_; u32 tagging_disabled_; // if non-zero, malloc uses zero tag in this thread. diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp index b17a17e1193bc..4cbeb92328c5c 100644 --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -412,7 +412,7 @@ void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges, # if SANITIZER_FUCHSIA // Fuchsia handles all threads together with its own callback. -static void ProcessThreads(SuspendedThreadsList const &, Frontier *, tid_t, +static void ProcessThreads(SuspendedThreadsList const &, Frontier *, thid_t, uptr) {} # else @@ -445,7 +445,7 @@ static void ProcessThreadRegistry(Frontier *frontier) { // Scans thread data (stacks and TLS) for heap pointers. template <class Accessor> -static void ProcessThread(tid_t os_id, uptr sp, +static void ProcessThread(thid_t os_id, uptr sp, const InternalMmapVector<uptr> &registers, InternalMmapVector<Range> &extra_ranges, Frontier *frontier, Accessor &accessor) { @@ -556,16 +556,16 @@ static void ProcessThread(tid_t os_id, uptr sp, } static void ProcessThreads(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { - InternalMmapVector<tid_t> done_threads; + InternalMmapVector<thid_t> done_threads; InternalMmapVector<uptr> registers; InternalMmapVector<Range> extra_ranges; for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) { registers.clear(); extra_ranges.clear(); - const tid_t os_id = suspended_threads.GetThreadID(i); + const thid_t os_id = suspended_threads.GetThreadID(i); uptr sp = 0; PtraceRegistersStatus have_registers = suspended_threads.GetRegistersAndSP(i, &registers, &sp); @@ -589,10 +589,10 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads, if (flags()->use_detached) { CopyMemoryAccessor accessor; - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); Sort(done_threads.data(), done_threads.size()); - for (tid_t os_id : known_threads) { + for (thid_t os_id : known_threads) { registers.clear(); extra_ranges.clear(); @@ -712,7 +712,7 @@ static void CollectIgnoredCb(uptr chunk, void *arg) { // Sets the appropriate tag on each chunk. static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { const InternalMmapVector<u32> &suppressed_stacks = GetSuppressionContext()->GetSortedSuppressedStacks(); @@ -790,13 +790,13 @@ static bool ReportUnsuspendedThreads(const SuspendedThreadsList &) { static bool ReportUnsuspendedThreads( const SuspendedThreadsList &suspended_threads) { - InternalMmapVector<tid_t> threads(suspended_threads.ThreadCount()); + InternalMmapVector<thid_t> threads(suspended_threads.ThreadCount()); for (uptr i = 0; i < suspended_threads.ThreadCount(); ++i) threads[i] = suspended_threads.GetThreadID(i); Sort(threads.data(), threads.size()); - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); bool succeded = true; diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h index f990c7850497a..2423489b2c846 100644 --- a/compiler-rt/lib/lsan/lsan_common.h +++ b/compiler-rt/lib/lsan/lsan_common.h @@ -102,15 +102,15 @@ void UnlockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS; // where leak checking is initiated from a non-main thread). void EnsureMainThreadIDIsCorrect(); -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls); void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches); void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges); -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges); void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs); -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads); +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads); void PrintThreads(); //// -------------------------------------------------------------------------- @@ -247,7 +247,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier); struct CheckForLeaksParam { Frontier frontier; LeakedChunks leaks; - tid_t caller_tid; + thid_t caller_tid; uptr caller_sp; bool success = false; }; diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp index f9f83f6c0cc45..d97f64edda0b4 100644 --- a/compiler-rt/lib/lsan/lsan_interceptors.cpp +++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp @@ -385,12 +385,12 @@ INTERCEPTOR(void, _lwp_exit) { #endif #if SANITIZER_INTERCEPT_THR_EXIT -INTERCEPTOR(void, thr_exit, tid_t *state) { +INTERCEPTOR(void, thr_exit, thid_t *state) { ENSURE_LSAN_INITED; ThreadFinish(); REAL(thr_exit)(state); } -#define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) +# define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) #else #define LSAN_MAYBE_INTERCEPT_THR_EXIT #endif diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp index 593000b9eef99..0a6a8e7bfe2d1 100644 --- a/compiler-rt/lib/lsan/lsan_posix.cpp +++ b/compiler-rt/lib/lsan/lsan_posix.cpp @@ -48,7 +48,7 @@ void ThreadContext::OnStarted(void *arg) { dtls_ = args->dtls; } -void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type) { OnStartedArgs args; GetThreadStackAndTls(tid == kMainTid, &args.stack_begin, &args.stack_end, &args.tls_begin, &args.tls_end); @@ -57,7 +57,7 @@ void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { ThreadContextLsanBase::ThreadStart(tid, os_id, thread_type, &args); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { ThreadContext *context = static_cast<ThreadContext *>( diff --git a/compiler-rt/lib/lsan/lsan_posix.h b/compiler-rt/lib/lsan/lsan_posix.h index b1265f233f363..990ea18c25168 100644 --- a/compiler-rt/lib/lsan/lsan_posix.h +++ b/compiler-rt/lib/lsan/lsan_posix.h @@ -41,7 +41,7 @@ class ThreadContext final : public ThreadContextLsanBase { DTLS *dtls_ = nullptr; }; -void ThreadStart(u32 tid, tid_t os_id, +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type = ThreadType::Regular); } // namespace __lsan diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp index b66ea61a2de4e..8ac16142bc259 100644 --- a/compiler-rt/lib/lsan/lsan_thread.cpp +++ b/compiler-rt/lib/lsan/lsan_thread.cpp @@ -66,7 +66,7 @@ u32 ThreadCreate(u32 parent_tid, bool detached, void *arg) { return thread_registry->CreateThread(0, detached, parent_tid, arg); } -void ThreadContextLsanBase::ThreadStart(u32 tid, tid_t os_id, +void ThreadContextLsanBase::ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *arg) { thread_registry->StartThread(tid, os_id, thread_type, arg); } @@ -80,7 +80,7 @@ void EnsureMainThreadIDIsCorrect() { ///// Interface to the common LSan module. ///// -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -99,11 +99,11 @@ ThreadRegistry *GetLsanThreadRegistryLocked() { return thread_registry; } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetLsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) { - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); } }, diff --git a/compiler-rt/lib/lsan/lsan_thread.h b/compiler-rt/lib/lsan/lsan_thread.h index 222066ee93cd9..ba0002f78ae6e 100644 --- a/compiler-rt/lib/lsan/lsan_thread.h +++ b/compiler-rt/lib/lsan/lsan_thread.h @@ -30,7 +30,7 @@ class ThreadContextLsanBase : public ThreadContextBase { uptr cache_end() { return cache_end_; } // The argument is passed on to the subclass's OnStarted member function. - static void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type, + static void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *onstarted_arg); protected: diff --git a/compiler-rt/lib/memprof/memprof_thread.cpp b/compiler-rt/lib/memprof/memprof_thread.cpp index 4b9665ffc3fce..66150ed992dc0 100644 --- a/compiler-rt/lib/memprof/memprof_thread.cpp +++ b/compiler-rt/lib/memprof/memprof_thread.cpp @@ -131,7 +131,7 @@ void MemprofThread::Init(const InitOptions *options) { } thread_return_t -MemprofThread::ThreadStart(tid_t os_id, +MemprofThread::ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered) { Init(); memprofThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, diff --git a/compiler-rt/lib/memprof/memprof_thread.h b/compiler-rt/lib/memprof/memprof_thread.h index fb90dbf328a43..0e97fc87ca338 100644 --- a/compiler-rt/lib/memprof/memprof_thread.h +++ b/compiler-rt/lib/memprof/memprof_thread.h @@ -59,7 +59,7 @@ class MemprofThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - thread_return_t ThreadStart(tid_t os_id, + thread_return_t ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered); uptr stack_top(); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index 120c2861c1ac0..55067eece5f29 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -78,8 +78,8 @@ uptr GetMmapGranularity(); uptr GetMaxVirtualAddress(); uptr GetMaxUserVirtualAddress(); // Threads -tid_t GetTid(); -int TgKill(pid_t pid, tid_t tid, int sig); +thid_t GetTid(); +int TgKill(pid_t pid, thid_t tid, int sig); uptr GetThreadSelf(); void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, uptr *stack_bottom); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp index 1ca50eb186a34..4714bea3fd383 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp @@ -68,7 +68,7 @@ int internal_dlinfo(void *handle, int request, void *p) { UNIMPLEMENTED(); } uptr GetThreadSelf() { return reinterpret_cast<uptr>(thrd_current()); } -tid_t GetTid() { return GetThreadSelf(); } +thid_t GetTid() { return GetThreadSelf(); } void Abort() { abort(); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp index 7cf2437d5b755..f7c6c0475c40c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp @@ -231,12 +231,12 @@ uptr internal_execve(const char *filename, char *const argv[], } # if 0 -tid_t GetTid() { +thid_t GetTid() { DEFINE__REAL(int, _lwp_self); return _REAL(_lwp_self); } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { DEFINE__REAL(int, _lwp_kill, int a, int b); (void)pid; return _REAL(_lwp_kill, tid, sig); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index fff60c96f632f..8ef2fab573454 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -209,7 +209,7 @@ typedef long ssize; typedef sptr ssize; #endif -typedef u64 tid_t; +typedef u64 thid_t; // ----------- ATTENTION ------------- // This header should NOT include any other headers to avoid portability issues. diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index 16caf699a4c24..67253ed168cef 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -638,7 +638,7 @@ bool DirExists(const char *path) { } # if !SANITIZER_NETBSD -tid_t GetTid() { +thid_t GetTid() { # if SANITIZER_FREEBSD long Tid; thr_self(&Tid); @@ -652,7 +652,7 @@ tid_t GetTid() { # endif } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { # if SANITIZER_LINUX return internal_syscall(SYSCALL(tgkill), pid, tid, sig); # elif SANITIZER_FREEBSD @@ -1089,7 +1089,7 @@ ThreadLister::ThreadLister(pid_t pid) : buffer_(4096) { } ThreadLister::Result ThreadLister::ListThreads( - InternalMmapVector<tid_t> *threads) { + InternalMmapVector<thid_t> *threads) { int descriptor = internal_open(task_path_.data(), O_RDONLY | O_DIRECTORY); if (internal_iserror(descriptor)) { Report("Can't open %s for reading.\n", task_path_.data()); @@ -1144,7 +1144,7 @@ ThreadLister::Result ThreadLister::ListThreads( } } -const char *ThreadLister::LoadStatus(tid_t tid) { +const char *ThreadLister::LoadStatus(thid_t tid) { status_path_.clear(); status_path_.AppendF("%s/%llu/status", task_path_.data(), tid); auto cleanup = at_scope_exit([&] { @@ -1157,7 +1157,7 @@ const char *ThreadLister::LoadStatus(tid_t tid) { return buffer_.data(); } -bool ThreadLister::IsAlive(tid_t tid) { +bool ThreadLister::IsAlive(t... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2025

@llvm/pr-subscribers-xray

Author: Jake Egan (jakeegan)

Changes

tid_t is also defined in the AIX header /usr/include/sys/types.h which is included by system pthread.h. The use of tid_t by AIX is conforming according to POSIX:
> Implementations may add symbols to the headers shown in the following table [ ... ]


Patch is 46.29 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149011.diff

39 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_thread.cpp (+6-6)
  • (modified) compiler-rt/lib/asan/asan_thread.h (+1-1)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.h (+3-3)
  • (modified) compiler-rt/lib/lsan/lsan_common.cpp (+10-10)
  • (modified) compiler-rt/lib/lsan/lsan_common.h (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_interceptors.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.h (+1-1)
  • (modified) compiler-rt/lib/lsan/lsan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_thread.h (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common.h (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+5-5)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.h (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp (+11-11)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp (+7-7)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h (+4-4)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_win.cpp (+1-3)
  • (modified) compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp (+18-18)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_debugging.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interface.h (+3-3)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_report.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/xray/xray_fdr_controller.h (+2-2)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.cpp (+3-3)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.h (+1-1)
diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp index 37fb6f2b07f27..1c4474a6826b4 100644 --- a/compiler-rt/lib/asan/asan_thread.cpp +++ b/compiler-rt/lib/asan/asan_thread.cpp @@ -282,7 +282,7 @@ void AsanThread::Init(const InitOptions *options) { // asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls. #if !SANITIZER_FUCHSIA -void AsanThread::ThreadStart(tid_t os_id) { +void AsanThread::ThreadStart(thid_t os_id) { Init(); asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr); @@ -469,7 +469,7 @@ void EnsureMainThreadIDIsCorrect() { context->os_id = GetTid(); } -__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) { +__asan::AsanThread *GetAsanThreadByOsIDLocked(thid_t os_id) { __asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>( __asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id)); if (!context) @@ -497,7 +497,7 @@ static ThreadRegistry *GetAsanThreadRegistryLocked() { void EnsureMainThreadIDIsCorrect() { __asan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); @@ -516,7 +516,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); if (!t) @@ -546,11 +546,11 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __asan::asanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetAsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); }, threads); diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index ad9e03d68fe96..3e2ba0aded049 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -75,7 +75,7 @@ class AsanThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - void ThreadStart(tid_t os_id); + void ThreadStart(thid_t os_id); thread_return_t RunThread(); uptr stack_top(); diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp index 8b32e4e760e2f..a19cbda56f7fb 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.cpp +++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp @@ -174,7 +174,7 @@ static __hwasan::HwasanThreadList *GetHwasanThreadListLocked() { return &tl; } -static __hwasan::Thread *GetThreadByOsIDLocked(tid_t os_id) { +static __hwasan::Thread *GetThreadByOsIDLocked(thid_t os_id) { return GetHwasanThreadListLocked()->FindThreadLocked( [os_id](__hwasan::Thread *t) { return t->os_id() == os_id; }); } @@ -191,7 +191,7 @@ void UnlockThreads() { void EnsureMainThreadIDIsCorrect() { __hwasan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { auto *t = GetThreadByOsIDLocked(os_id); @@ -210,7 +210,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -218,7 +218,7 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __hwasan::hwasanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { // TODO: implement. } void PrintThreads() { diff --git a/compiler-rt/lib/hwasan/hwasan_thread.h b/compiler-rt/lib/hwasan/hwasan_thread.h index 9e1b438e48f77..94773fdbcaa53 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.h +++ b/compiler-rt/lib/hwasan/hwasan_thread.h @@ -69,8 +69,8 @@ class Thread { Print("Thread: "); } - tid_t os_id() const { return os_id_; } - void set_os_id(tid_t os_id) { os_id_ = os_id; } + thid_t os_id() const { return os_id_; } + void set_os_id(thid_t os_id) { os_id_ = os_id; } uptr &vfork_spill() { return vfork_spill_; } @@ -96,7 +96,7 @@ class Thread { u32 unique_id_; // counting from zero. - tid_t os_id_; + thid_t os_id_; u32 tagging_disabled_; // if non-zero, malloc uses zero tag in this thread. diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp index b17a17e1193bc..4cbeb92328c5c 100644 --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -412,7 +412,7 @@ void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges, # if SANITIZER_FUCHSIA // Fuchsia handles all threads together with its own callback. -static void ProcessThreads(SuspendedThreadsList const &, Frontier *, tid_t, +static void ProcessThreads(SuspendedThreadsList const &, Frontier *, thid_t, uptr) {} # else @@ -445,7 +445,7 @@ static void ProcessThreadRegistry(Frontier *frontier) { // Scans thread data (stacks and TLS) for heap pointers. template <class Accessor> -static void ProcessThread(tid_t os_id, uptr sp, +static void ProcessThread(thid_t os_id, uptr sp, const InternalMmapVector<uptr> &registers, InternalMmapVector<Range> &extra_ranges, Frontier *frontier, Accessor &accessor) { @@ -556,16 +556,16 @@ static void ProcessThread(tid_t os_id, uptr sp, } static void ProcessThreads(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { - InternalMmapVector<tid_t> done_threads; + InternalMmapVector<thid_t> done_threads; InternalMmapVector<uptr> registers; InternalMmapVector<Range> extra_ranges; for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) { registers.clear(); extra_ranges.clear(); - const tid_t os_id = suspended_threads.GetThreadID(i); + const thid_t os_id = suspended_threads.GetThreadID(i); uptr sp = 0; PtraceRegistersStatus have_registers = suspended_threads.GetRegistersAndSP(i, &registers, &sp); @@ -589,10 +589,10 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads, if (flags()->use_detached) { CopyMemoryAccessor accessor; - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); Sort(done_threads.data(), done_threads.size()); - for (tid_t os_id : known_threads) { + for (thid_t os_id : known_threads) { registers.clear(); extra_ranges.clear(); @@ -712,7 +712,7 @@ static void CollectIgnoredCb(uptr chunk, void *arg) { // Sets the appropriate tag on each chunk. static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { const InternalMmapVector<u32> &suppressed_stacks = GetSuppressionContext()->GetSortedSuppressedStacks(); @@ -790,13 +790,13 @@ static bool ReportUnsuspendedThreads(const SuspendedThreadsList &) { static bool ReportUnsuspendedThreads( const SuspendedThreadsList &suspended_threads) { - InternalMmapVector<tid_t> threads(suspended_threads.ThreadCount()); + InternalMmapVector<thid_t> threads(suspended_threads.ThreadCount()); for (uptr i = 0; i < suspended_threads.ThreadCount(); ++i) threads[i] = suspended_threads.GetThreadID(i); Sort(threads.data(), threads.size()); - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); bool succeded = true; diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h index f990c7850497a..2423489b2c846 100644 --- a/compiler-rt/lib/lsan/lsan_common.h +++ b/compiler-rt/lib/lsan/lsan_common.h @@ -102,15 +102,15 @@ void UnlockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS; // where leak checking is initiated from a non-main thread). void EnsureMainThreadIDIsCorrect(); -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls); void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches); void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges); -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges); void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs); -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads); +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads); void PrintThreads(); //// -------------------------------------------------------------------------- @@ -247,7 +247,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier); struct CheckForLeaksParam { Frontier frontier; LeakedChunks leaks; - tid_t caller_tid; + thid_t caller_tid; uptr caller_sp; bool success = false; }; diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp index f9f83f6c0cc45..d97f64edda0b4 100644 --- a/compiler-rt/lib/lsan/lsan_interceptors.cpp +++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp @@ -385,12 +385,12 @@ INTERCEPTOR(void, _lwp_exit) { #endif #if SANITIZER_INTERCEPT_THR_EXIT -INTERCEPTOR(void, thr_exit, tid_t *state) { +INTERCEPTOR(void, thr_exit, thid_t *state) { ENSURE_LSAN_INITED; ThreadFinish(); REAL(thr_exit)(state); } -#define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) +# define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) #else #define LSAN_MAYBE_INTERCEPT_THR_EXIT #endif diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp index 593000b9eef99..0a6a8e7bfe2d1 100644 --- a/compiler-rt/lib/lsan/lsan_posix.cpp +++ b/compiler-rt/lib/lsan/lsan_posix.cpp @@ -48,7 +48,7 @@ void ThreadContext::OnStarted(void *arg) { dtls_ = args->dtls; } -void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type) { OnStartedArgs args; GetThreadStackAndTls(tid == kMainTid, &args.stack_begin, &args.stack_end, &args.tls_begin, &args.tls_end); @@ -57,7 +57,7 @@ void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { ThreadContextLsanBase::ThreadStart(tid, os_id, thread_type, &args); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { ThreadContext *context = static_cast<ThreadContext *>( diff --git a/compiler-rt/lib/lsan/lsan_posix.h b/compiler-rt/lib/lsan/lsan_posix.h index b1265f233f363..990ea18c25168 100644 --- a/compiler-rt/lib/lsan/lsan_posix.h +++ b/compiler-rt/lib/lsan/lsan_posix.h @@ -41,7 +41,7 @@ class ThreadContext final : public ThreadContextLsanBase { DTLS *dtls_ = nullptr; }; -void ThreadStart(u32 tid, tid_t os_id, +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type = ThreadType::Regular); } // namespace __lsan diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp index b66ea61a2de4e..8ac16142bc259 100644 --- a/compiler-rt/lib/lsan/lsan_thread.cpp +++ b/compiler-rt/lib/lsan/lsan_thread.cpp @@ -66,7 +66,7 @@ u32 ThreadCreate(u32 parent_tid, bool detached, void *arg) { return thread_registry->CreateThread(0, detached, parent_tid, arg); } -void ThreadContextLsanBase::ThreadStart(u32 tid, tid_t os_id, +void ThreadContextLsanBase::ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *arg) { thread_registry->StartThread(tid, os_id, thread_type, arg); } @@ -80,7 +80,7 @@ void EnsureMainThreadIDIsCorrect() { ///// Interface to the common LSan module. ///// -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -99,11 +99,11 @@ ThreadRegistry *GetLsanThreadRegistryLocked() { return thread_registry; } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetLsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) { - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); } }, diff --git a/compiler-rt/lib/lsan/lsan_thread.h b/compiler-rt/lib/lsan/lsan_thread.h index 222066ee93cd9..ba0002f78ae6e 100644 --- a/compiler-rt/lib/lsan/lsan_thread.h +++ b/compiler-rt/lib/lsan/lsan_thread.h @@ -30,7 +30,7 @@ class ThreadContextLsanBase : public ThreadContextBase { uptr cache_end() { return cache_end_; } // The argument is passed on to the subclass's OnStarted member function. - static void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type, + static void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *onstarted_arg); protected: diff --git a/compiler-rt/lib/memprof/memprof_thread.cpp b/compiler-rt/lib/memprof/memprof_thread.cpp index 4b9665ffc3fce..66150ed992dc0 100644 --- a/compiler-rt/lib/memprof/memprof_thread.cpp +++ b/compiler-rt/lib/memprof/memprof_thread.cpp @@ -131,7 +131,7 @@ void MemprofThread::Init(const InitOptions *options) { } thread_return_t -MemprofThread::ThreadStart(tid_t os_id, +MemprofThread::ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered) { Init(); memprofThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, diff --git a/compiler-rt/lib/memprof/memprof_thread.h b/compiler-rt/lib/memprof/memprof_thread.h index fb90dbf328a43..0e97fc87ca338 100644 --- a/compiler-rt/lib/memprof/memprof_thread.h +++ b/compiler-rt/lib/memprof/memprof_thread.h @@ -59,7 +59,7 @@ class MemprofThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - thread_return_t ThreadStart(tid_t os_id, + thread_return_t ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered); uptr stack_top(); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index 120c2861c1ac0..55067eece5f29 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -78,8 +78,8 @@ uptr GetMmapGranularity(); uptr GetMaxVirtualAddress(); uptr GetMaxUserVirtualAddress(); // Threads -tid_t GetTid(); -int TgKill(pid_t pid, tid_t tid, int sig); +thid_t GetTid(); +int TgKill(pid_t pid, thid_t tid, int sig); uptr GetThreadSelf(); void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, uptr *stack_bottom); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp index 1ca50eb186a34..4714bea3fd383 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp @@ -68,7 +68,7 @@ int internal_dlinfo(void *handle, int request, void *p) { UNIMPLEMENTED(); } uptr GetThreadSelf() { return reinterpret_cast<uptr>(thrd_current()); } -tid_t GetTid() { return GetThreadSelf(); } +thid_t GetTid() { return GetThreadSelf(); } void Abort() { abort(); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp index 7cf2437d5b755..f7c6c0475c40c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp @@ -231,12 +231,12 @@ uptr internal_execve(const char *filename, char *const argv[], } # if 0 -tid_t GetTid() { +thid_t GetTid() { DEFINE__REAL(int, _lwp_self); return _REAL(_lwp_self); } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { DEFINE__REAL(int, _lwp_kill, int a, int b); (void)pid; return _REAL(_lwp_kill, tid, sig); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index fff60c96f632f..8ef2fab573454 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -209,7 +209,7 @@ typedef long ssize; typedef sptr ssize; #endif -typedef u64 tid_t; +typedef u64 thid_t; // ----------- ATTENTION ------------- // This header should NOT include any other headers to avoid portability issues. diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index 16caf699a4c24..67253ed168cef 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -638,7 +638,7 @@ bool DirExists(const char *path) { } # if !SANITIZER_NETBSD -tid_t GetTid() { +thid_t GetTid() { # if SANITIZER_FREEBSD long Tid; thr_self(&Tid); @@ -652,7 +652,7 @@ tid_t GetTid() { # endif } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { # if SANITIZER_LINUX return internal_syscall(SYSCALL(tgkill), pid, tid, sig); # elif SANITIZER_FREEBSD @@ -1089,7 +1089,7 @@ ThreadLister::ThreadLister(pid_t pid) : buffer_(4096) { } ThreadLister::Result ThreadLister::ListThreads( - InternalMmapVector<tid_t> *threads) { + InternalMmapVector<thid_t> *threads) { int descriptor = internal_open(task_path_.data(), O_RDONLY | O_DIRECTORY); if (internal_iserror(descriptor)) { Report("Can't open %s for reading.\n", task_path_.data()); @@ -1144,7 +1144,7 @@ ThreadLister::Result ThreadLister::ListThreads( } } -const char *ThreadLister::LoadStatus(tid_t tid) { +const char *ThreadLister::LoadStatus(thid_t tid) { status_path_.clear(); status_path_.AppendF("%s/%llu/status", task_path_.data(), tid); auto cleanup = at_scope_exit([&] { @@ -1157,7 +1157,7 @@ const char *ThreadLister::LoadStatus(tid_t tid) { return buffer_.data(); } -bool ThreadLister::IsAlive(tid_t tid) { +bool ThreadLister::IsAlive(t... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2025

@llvm/pr-subscribers-pgo

Author: Jake Egan (jakeegan)

Changes

tid_t is also defined in the AIX header /usr/include/sys/types.h which is included by system pthread.h. The use of tid_t by AIX is conforming according to POSIX:
> Implementations may add symbols to the headers shown in the following table [ ... ]


Patch is 46.29 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149011.diff

39 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_thread.cpp (+6-6)
  • (modified) compiler-rt/lib/asan/asan_thread.h (+1-1)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/hwasan/hwasan_thread.h (+3-3)
  • (modified) compiler-rt/lib/lsan/lsan_common.cpp (+10-10)
  • (modified) compiler-rt/lib/lsan/lsan_common.h (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_interceptors.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/lsan/lsan_posix.h (+1-1)
  • (modified) compiler-rt/lib/lsan/lsan_thread.cpp (+4-4)
  • (modified) compiler-rt/lib/lsan/lsan_thread.h (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/memprof/memprof_thread.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common.h (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+5-5)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.h (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld.h (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp (+11-11)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp (+7-7)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp (+2-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp (+3-3)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h (+4-4)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_win.cpp (+1-3)
  • (modified) compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp (+18-18)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_debugging.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_interface.h (+3-3)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_report.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.h (+1-1)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp (+1-1)
  • (modified) compiler-rt/lib/xray/xray_fdr_controller.h (+2-2)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.cpp (+3-3)
  • (modified) compiler-rt/lib/xray/xray_profile_collector.h (+1-1)
diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp index 37fb6f2b07f27..1c4474a6826b4 100644 --- a/compiler-rt/lib/asan/asan_thread.cpp +++ b/compiler-rt/lib/asan/asan_thread.cpp @@ -282,7 +282,7 @@ void AsanThread::Init(const InitOptions *options) { // asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls. #if !SANITIZER_FUCHSIA -void AsanThread::ThreadStart(tid_t os_id) { +void AsanThread::ThreadStart(thid_t os_id) { Init(); asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr); @@ -469,7 +469,7 @@ void EnsureMainThreadIDIsCorrect() { context->os_id = GetTid(); } -__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) { +__asan::AsanThread *GetAsanThreadByOsIDLocked(thid_t os_id) { __asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>( __asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id)); if (!context) @@ -497,7 +497,7 @@ static ThreadRegistry *GetAsanThreadRegistryLocked() { void EnsureMainThreadIDIsCorrect() { __asan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); @@ -516,7 +516,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) { __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id); if (!t) @@ -546,11 +546,11 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __asan::asanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetAsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); }, threads); diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index ad9e03d68fe96..3e2ba0aded049 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -75,7 +75,7 @@ class AsanThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - void ThreadStart(tid_t os_id); + void ThreadStart(thid_t os_id); thread_return_t RunThread(); uptr stack_top(); diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp index 8b32e4e760e2f..a19cbda56f7fb 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.cpp +++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp @@ -174,7 +174,7 @@ static __hwasan::HwasanThreadList *GetHwasanThreadListLocked() { return &tl; } -static __hwasan::Thread *GetThreadByOsIDLocked(tid_t os_id) { +static __hwasan::Thread *GetThreadByOsIDLocked(thid_t os_id) { return GetHwasanThreadListLocked()->FindThreadLocked( [os_id](__hwasan::Thread *t) { return t->os_id() == os_id; }); } @@ -191,7 +191,7 @@ void UnlockThreads() { void EnsureMainThreadIDIsCorrect() { __hwasan::EnsureMainThreadIDIsCorrect(); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { auto *t = GetThreadByOsIDLocked(os_id); @@ -210,7 +210,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {} -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -218,7 +218,7 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) { __hwasan::hwasanThreadArgRetval().GetAllPtrsLocked(ptrs); } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { // TODO: implement. } void PrintThreads() { diff --git a/compiler-rt/lib/hwasan/hwasan_thread.h b/compiler-rt/lib/hwasan/hwasan_thread.h index 9e1b438e48f77..94773fdbcaa53 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.h +++ b/compiler-rt/lib/hwasan/hwasan_thread.h @@ -69,8 +69,8 @@ class Thread { Print("Thread: "); } - tid_t os_id() const { return os_id_; } - void set_os_id(tid_t os_id) { os_id_ = os_id; } + thid_t os_id() const { return os_id_; } + void set_os_id(thid_t os_id) { os_id_ = os_id; } uptr &vfork_spill() { return vfork_spill_; } @@ -96,7 +96,7 @@ class Thread { u32 unique_id_; // counting from zero. - tid_t os_id_; + thid_t os_id_; u32 tagging_disabled_; // if non-zero, malloc uses zero tag in this thread. diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp index b17a17e1193bc..4cbeb92328c5c 100644 --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -412,7 +412,7 @@ void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges, # if SANITIZER_FUCHSIA // Fuchsia handles all threads together with its own callback. -static void ProcessThreads(SuspendedThreadsList const &, Frontier *, tid_t, +static void ProcessThreads(SuspendedThreadsList const &, Frontier *, thid_t, uptr) {} # else @@ -445,7 +445,7 @@ static void ProcessThreadRegistry(Frontier *frontier) { // Scans thread data (stacks and TLS) for heap pointers. template <class Accessor> -static void ProcessThread(tid_t os_id, uptr sp, +static void ProcessThread(thid_t os_id, uptr sp, const InternalMmapVector<uptr> &registers, InternalMmapVector<Range> &extra_ranges, Frontier *frontier, Accessor &accessor) { @@ -556,16 +556,16 @@ static void ProcessThread(tid_t os_id, uptr sp, } static void ProcessThreads(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { - InternalMmapVector<tid_t> done_threads; + InternalMmapVector<thid_t> done_threads; InternalMmapVector<uptr> registers; InternalMmapVector<Range> extra_ranges; for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) { registers.clear(); extra_ranges.clear(); - const tid_t os_id = suspended_threads.GetThreadID(i); + const thid_t os_id = suspended_threads.GetThreadID(i); uptr sp = 0; PtraceRegistersStatus have_registers = suspended_threads.GetRegistersAndSP(i, &registers, &sp); @@ -589,10 +589,10 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads, if (flags()->use_detached) { CopyMemoryAccessor accessor; - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); Sort(done_threads.data(), done_threads.size()); - for (tid_t os_id : known_threads) { + for (thid_t os_id : known_threads) { registers.clear(); extra_ranges.clear(); @@ -712,7 +712,7 @@ static void CollectIgnoredCb(uptr chunk, void *arg) { // Sets the appropriate tag on each chunk. static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads, - Frontier *frontier, tid_t caller_tid, + Frontier *frontier, thid_t caller_tid, uptr caller_sp) { const InternalMmapVector<u32> &suppressed_stacks = GetSuppressionContext()->GetSortedSuppressedStacks(); @@ -790,13 +790,13 @@ static bool ReportUnsuspendedThreads(const SuspendedThreadsList &) { static bool ReportUnsuspendedThreads( const SuspendedThreadsList &suspended_threads) { - InternalMmapVector<tid_t> threads(suspended_threads.ThreadCount()); + InternalMmapVector<thid_t> threads(suspended_threads.ThreadCount()); for (uptr i = 0; i < suspended_threads.ThreadCount(); ++i) threads[i] = suspended_threads.GetThreadID(i); Sort(threads.data(), threads.size()); - InternalMmapVector<tid_t> known_threads; + InternalMmapVector<thid_t> known_threads; GetRunningThreadsLocked(&known_threads); bool succeded = true; diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h index f990c7850497a..2423489b2c846 100644 --- a/compiler-rt/lib/lsan/lsan_common.h +++ b/compiler-rt/lib/lsan/lsan_common.h @@ -102,15 +102,15 @@ void UnlockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS; // where leak checking is initiated from a non-main thread). void EnsureMainThreadIDIsCorrect(); -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls); void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches); void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges); -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges); void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs); -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads); +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads); void PrintThreads(); //// -------------------------------------------------------------------------- @@ -247,7 +247,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier); struct CheckForLeaksParam { Frontier frontier; LeakedChunks leaks; - tid_t caller_tid; + thid_t caller_tid; uptr caller_sp; bool success = false; }; diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp index f9f83f6c0cc45..d97f64edda0b4 100644 --- a/compiler-rt/lib/lsan/lsan_interceptors.cpp +++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp @@ -385,12 +385,12 @@ INTERCEPTOR(void, _lwp_exit) { #endif #if SANITIZER_INTERCEPT_THR_EXIT -INTERCEPTOR(void, thr_exit, tid_t *state) { +INTERCEPTOR(void, thr_exit, thid_t *state) { ENSURE_LSAN_INITED; ThreadFinish(); REAL(thr_exit)(state); } -#define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) +# define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit) #else #define LSAN_MAYBE_INTERCEPT_THR_EXIT #endif diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp index 593000b9eef99..0a6a8e7bfe2d1 100644 --- a/compiler-rt/lib/lsan/lsan_posix.cpp +++ b/compiler-rt/lib/lsan/lsan_posix.cpp @@ -48,7 +48,7 @@ void ThreadContext::OnStarted(void *arg) { dtls_ = args->dtls; } -void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type) { OnStartedArgs args; GetThreadStackAndTls(tid == kMainTid, &args.stack_begin, &args.stack_end, &args.tls_begin, &args.tls_end); @@ -57,7 +57,7 @@ void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) { ThreadContextLsanBase::ThreadStart(tid, os_id, thread_type, &args); } -bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, +bool GetThreadRangesLocked(thid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, uptr *cache_end, DTLS **dtls) { ThreadContext *context = static_cast<ThreadContext *>( diff --git a/compiler-rt/lib/lsan/lsan_posix.h b/compiler-rt/lib/lsan/lsan_posix.h index b1265f233f363..990ea18c25168 100644 --- a/compiler-rt/lib/lsan/lsan_posix.h +++ b/compiler-rt/lib/lsan/lsan_posix.h @@ -41,7 +41,7 @@ class ThreadContext final : public ThreadContextLsanBase { DTLS *dtls_ = nullptr; }; -void ThreadStart(u32 tid, tid_t os_id, +void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type = ThreadType::Regular); } // namespace __lsan diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp index b66ea61a2de4e..8ac16142bc259 100644 --- a/compiler-rt/lib/lsan/lsan_thread.cpp +++ b/compiler-rt/lib/lsan/lsan_thread.cpp @@ -66,7 +66,7 @@ u32 ThreadCreate(u32 parent_tid, bool detached, void *arg) { return thread_registry->CreateThread(0, detached, parent_tid, arg); } -void ThreadContextLsanBase::ThreadStart(u32 tid, tid_t os_id, +void ThreadContextLsanBase::ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *arg) { thread_registry->StartThread(tid, os_id, thread_type, arg); } @@ -80,7 +80,7 @@ void EnsureMainThreadIDIsCorrect() { ///// Interface to the common LSan module. ///// -void GetThreadExtraStackRangesLocked(tid_t os_id, +void GetThreadExtraStackRangesLocked(thid_t os_id, InternalMmapVector<Range> *ranges) {} void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {} @@ -99,11 +99,11 @@ ThreadRegistry *GetLsanThreadRegistryLocked() { return thread_registry; } -void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) { +void GetRunningThreadsLocked(InternalMmapVector<thid_t> *threads) { GetLsanThreadRegistryLocked()->RunCallbackForEachThreadLocked( [](ThreadContextBase *tctx, void *threads) { if (tctx->status == ThreadStatusRunning) { - reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back( + reinterpret_cast<InternalMmapVector<thid_t> *>(threads)->push_back( tctx->os_id); } }, diff --git a/compiler-rt/lib/lsan/lsan_thread.h b/compiler-rt/lib/lsan/lsan_thread.h index 222066ee93cd9..ba0002f78ae6e 100644 --- a/compiler-rt/lib/lsan/lsan_thread.h +++ b/compiler-rt/lib/lsan/lsan_thread.h @@ -30,7 +30,7 @@ class ThreadContextLsanBase : public ThreadContextBase { uptr cache_end() { return cache_end_; } // The argument is passed on to the subclass's OnStarted member function. - static void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type, + static void ThreadStart(u32 tid, thid_t os_id, ThreadType thread_type, void *onstarted_arg); protected: diff --git a/compiler-rt/lib/memprof/memprof_thread.cpp b/compiler-rt/lib/memprof/memprof_thread.cpp index 4b9665ffc3fce..66150ed992dc0 100644 --- a/compiler-rt/lib/memprof/memprof_thread.cpp +++ b/compiler-rt/lib/memprof/memprof_thread.cpp @@ -131,7 +131,7 @@ void MemprofThread::Init(const InitOptions *options) { } thread_return_t -MemprofThread::ThreadStart(tid_t os_id, +MemprofThread::ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered) { Init(); memprofThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, diff --git a/compiler-rt/lib/memprof/memprof_thread.h b/compiler-rt/lib/memprof/memprof_thread.h index fb90dbf328a43..0e97fc87ca338 100644 --- a/compiler-rt/lib/memprof/memprof_thread.h +++ b/compiler-rt/lib/memprof/memprof_thread.h @@ -59,7 +59,7 @@ class MemprofThread { struct InitOptions; void Init(const InitOptions *options = nullptr); - thread_return_t ThreadStart(tid_t os_id, + thread_return_t ThreadStart(thid_t os_id, atomic_uintptr_t *signal_thread_is_registered); uptr stack_top(); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index 120c2861c1ac0..55067eece5f29 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -78,8 +78,8 @@ uptr GetMmapGranularity(); uptr GetMaxVirtualAddress(); uptr GetMaxUserVirtualAddress(); // Threads -tid_t GetTid(); -int TgKill(pid_t pid, tid_t tid, int sig); +thid_t GetTid(); +int TgKill(pid_t pid, thid_t tid, int sig); uptr GetThreadSelf(); void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, uptr *stack_bottom); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp index 1ca50eb186a34..4714bea3fd383 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp @@ -68,7 +68,7 @@ int internal_dlinfo(void *handle, int request, void *p) { UNIMPLEMENTED(); } uptr GetThreadSelf() { return reinterpret_cast<uptr>(thrd_current()); } -tid_t GetTid() { return GetThreadSelf(); } +thid_t GetTid() { return GetThreadSelf(); } void Abort() { abort(); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp index 7cf2437d5b755..f7c6c0475c40c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp @@ -231,12 +231,12 @@ uptr internal_execve(const char *filename, char *const argv[], } # if 0 -tid_t GetTid() { +thid_t GetTid() { DEFINE__REAL(int, _lwp_self); return _REAL(_lwp_self); } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { DEFINE__REAL(int, _lwp_kill, int a, int b); (void)pid; return _REAL(_lwp_kill, tid, sig); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index fff60c96f632f..8ef2fab573454 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -209,7 +209,7 @@ typedef long ssize; typedef sptr ssize; #endif -typedef u64 tid_t; +typedef u64 thid_t; // ----------- ATTENTION ------------- // This header should NOT include any other headers to avoid portability issues. diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index 16caf699a4c24..67253ed168cef 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -638,7 +638,7 @@ bool DirExists(const char *path) { } # if !SANITIZER_NETBSD -tid_t GetTid() { +thid_t GetTid() { # if SANITIZER_FREEBSD long Tid; thr_self(&Tid); @@ -652,7 +652,7 @@ tid_t GetTid() { # endif } -int TgKill(pid_t pid, tid_t tid, int sig) { +int TgKill(pid_t pid, thid_t tid, int sig) { # if SANITIZER_LINUX return internal_syscall(SYSCALL(tgkill), pid, tid, sig); # elif SANITIZER_FREEBSD @@ -1089,7 +1089,7 @@ ThreadLister::ThreadLister(pid_t pid) : buffer_(4096) { } ThreadLister::Result ThreadLister::ListThreads( - InternalMmapVector<tid_t> *threads) { + InternalMmapVector<thid_t> *threads) { int descriptor = internal_open(task_path_.data(), O_RDONLY | O_DIRECTORY); if (internal_iserror(descriptor)) { Report("Can't open %s for reading.\n", task_path_.data()); @@ -1144,7 +1144,7 @@ ThreadLister::Result ThreadLister::ListThreads( } } -const char *ThreadLister::LoadStatus(tid_t tid) { +const char *ThreadLister::LoadStatus(thid_t tid) { status_path_.clear(); status_path_.AppendF("%s/%llu/status", task_path_.data(), tid); auto cleanup = at_scope_exit([&] { @@ -1157,7 +1157,7 @@ const char *ThreadLister::LoadStatus(tid_t tid) { return buffer_.data(); } -bool ThreadLister::IsAlive(tid_t tid) { +bool ThreadLister::IsAlive(t... [truncated] 
@jakeegan jakeegan requested a review from vitalybuka July 17, 2025 04:23
@jakeegan jakeegan merged commit 8e072b9 into llvm:main Jul 23, 2025
9 checks passed
@jakeegan jakeegan deleted the rename_tid_t branch July 23, 2025 13:39
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
…ons (llvm#149011) `tid_t` is also defined in the AIX header `/usr/include/sys/types.h` which is included by system `pthread.h`. The use of `tid_t` by AIX is conforming according to [POSIX](https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html): > Implementations may add symbols to the headers shown in the following table [ ... ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler-rt:asan Address sanitizer compiler-rt:hwasan Hardware-assisted address sanitizer compiler-rt:lsan Leak sanitizer compiler-rt:sanitizer compiler-rt:tsan Thread sanitizer compiler-rt PGO Profile Guided Optimizations xray

3 participants