Skip to content

Commit 8e072b9

Browse files
authored
[sanitizer_common][nfc] Rename tid_t to avoid conflicting declarations (#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 [ ... ]
1 parent 43db6c5 commit 8e072b9

39 files changed

+127
-127
lines changed

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void AsanThread::Init(const InitOptions *options) {
282282
// asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls.
283283
#if !SANITIZER_FUCHSIA
284284

285-
void AsanThread::ThreadStart(tid_t os_id) {
285+
void AsanThread::ThreadStart(ThreadID os_id) {
286286
Init();
287287
asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr);
288288

@@ -469,7 +469,7 @@ void EnsureMainThreadIDIsCorrect() {
469469
context->os_id = GetTid();
470470
}
471471

472-
__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) {
472+
__asan::AsanThread *GetAsanThreadByOsIDLocked(ThreadID os_id) {
473473
__asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>(
474474
__asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id));
475475
if (!context)
@@ -497,7 +497,7 @@ static ThreadRegistry *GetAsanThreadRegistryLocked() {
497497

498498
void EnsureMainThreadIDIsCorrect() { __asan::EnsureMainThreadIDIsCorrect(); }
499499

500-
bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
500+
bool GetThreadRangesLocked(ThreadID os_id, uptr *stack_begin, uptr *stack_end,
501501
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
502502
uptr *cache_end, DTLS **dtls) {
503503
__asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id);
@@ -516,7 +516,7 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
516516

517517
void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {}
518518

519-
void GetThreadExtraStackRangesLocked(tid_t os_id,
519+
void GetThreadExtraStackRangesLocked(ThreadID os_id,
520520
InternalMmapVector<Range> *ranges) {
521521
__asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id);
522522
if (!t)
@@ -546,11 +546,11 @@ void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) {
546546
__asan::asanThreadArgRetval().GetAllPtrsLocked(ptrs);
547547
}
548548

549-
void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
549+
void GetRunningThreadsLocked(InternalMmapVector<ThreadID> *threads) {
550550
GetAsanThreadRegistryLocked()->RunCallbackForEachThreadLocked(
551551
[](ThreadContextBase *tctx, void *threads) {
552552
if (tctx->status == ThreadStatusRunning)
553-
reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back(
553+
reinterpret_cast<InternalMmapVector<ThreadID> *>(threads)->push_back(
554554
tctx->os_id);
555555
},
556556
threads);

compiler-rt/lib/asan/asan_thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class AsanThread {
7575
struct InitOptions;
7676
void Init(const InitOptions *options = nullptr);
7777

78-
void ThreadStart(tid_t os_id);
78+
void ThreadStart(ThreadID os_id);
7979
thread_return_t RunThread();
8080

8181
uptr stack_top();

compiler-rt/lib/hwasan/hwasan_thread.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static __hwasan::HwasanThreadList *GetHwasanThreadListLocked() {
174174
return &tl;
175175
}
176176

177-
static __hwasan::Thread *GetThreadByOsIDLocked(tid_t os_id) {
177+
static __hwasan::Thread *GetThreadByOsIDLocked(ThreadID os_id) {
178178
return GetHwasanThreadListLocked()->FindThreadLocked(
179179
[os_id](__hwasan::Thread *t) { return t->os_id() == os_id; });
180180
}
@@ -191,7 +191,7 @@ void UnlockThreads() {
191191

192192
void EnsureMainThreadIDIsCorrect() { __hwasan::EnsureMainThreadIDIsCorrect(); }
193193

194-
bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
194+
bool GetThreadRangesLocked(ThreadID os_id, uptr *stack_begin, uptr *stack_end,
195195
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
196196
uptr *cache_end, DTLS **dtls) {
197197
auto *t = GetThreadByOsIDLocked(os_id);
@@ -210,15 +210,15 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
210210

211211
void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {}
212212

213-
void GetThreadExtraStackRangesLocked(tid_t os_id,
213+
void GetThreadExtraStackRangesLocked(ThreadID os_id,
214214
InternalMmapVector<Range> *ranges) {}
215215
void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {}
216216

217217
void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) {
218218
__hwasan::hwasanThreadArgRetval().GetAllPtrsLocked(ptrs);
219219
}
220220

221-
void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
221+
void GetRunningThreadsLocked(InternalMmapVector<ThreadID> *threads) {
222222
// TODO: implement.
223223
}
224224
void PrintThreads() {

compiler-rt/lib/hwasan/hwasan_thread.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class Thread {
6969
Print("Thread: ");
7070
}
7171

72-
tid_t os_id() const { return os_id_; }
73-
void set_os_id(tid_t os_id) { os_id_ = os_id; }
72+
ThreadID os_id() const { return os_id_; }
73+
void set_os_id(ThreadID os_id) { os_id_ = os_id; }
7474

7575
uptr &vfork_spill() { return vfork_spill_; }
7676

@@ -96,7 +96,7 @@ class Thread {
9696

9797
u32 unique_id_; // counting from zero.
9898

99-
tid_t os_id_;
99+
ThreadID os_id_;
100100

101101
u32 tagging_disabled_; // if non-zero, malloc uses zero tag in this thread.
102102

compiler-rt/lib/lsan/lsan_common.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges,
412412
# if SANITIZER_FUCHSIA
413413

414414
// Fuchsia handles all threads together with its own callback.
415-
static void ProcessThreads(SuspendedThreadsList const &, Frontier *, tid_t,
415+
static void ProcessThreads(SuspendedThreadsList const &, Frontier *, ThreadID,
416416
uptr) {}
417417

418418
# else
@@ -445,7 +445,7 @@ static void ProcessThreadRegistry(Frontier *frontier) {
445445

446446
// Scans thread data (stacks and TLS) for heap pointers.
447447
template <class Accessor>
448-
static void ProcessThread(tid_t os_id, uptr sp,
448+
static void ProcessThread(ThreadID os_id, uptr sp,
449449
const InternalMmapVector<uptr> &registers,
450450
InternalMmapVector<Range> &extra_ranges,
451451
Frontier *frontier, Accessor &accessor) {
@@ -556,16 +556,16 @@ static void ProcessThread(tid_t os_id, uptr sp,
556556
}
557557

558558
static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
559-
Frontier *frontier, tid_t caller_tid,
559+
Frontier *frontier, ThreadID caller_tid,
560560
uptr caller_sp) {
561-
InternalMmapVector<tid_t> done_threads;
561+
InternalMmapVector<ThreadID> done_threads;
562562
InternalMmapVector<uptr> registers;
563563
InternalMmapVector<Range> extra_ranges;
564564
for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) {
565565
registers.clear();
566566
extra_ranges.clear();
567567

568-
const tid_t os_id = suspended_threads.GetThreadID(i);
568+
const ThreadID os_id = suspended_threads.GetThreadID(i);
569569
uptr sp = 0;
570570
PtraceRegistersStatus have_registers =
571571
suspended_threads.GetRegistersAndSP(i, &registers, &sp);
@@ -589,10 +589,10 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
589589

590590
if (flags()->use_detached) {
591591
CopyMemoryAccessor accessor;
592-
InternalMmapVector<tid_t> known_threads;
592+
InternalMmapVector<ThreadID> known_threads;
593593
GetRunningThreadsLocked(&known_threads);
594594
Sort(done_threads.data(), done_threads.size());
595-
for (tid_t os_id : known_threads) {
595+
for (ThreadID os_id : known_threads) {
596596
registers.clear();
597597
extra_ranges.clear();
598598

@@ -712,7 +712,7 @@ static void CollectIgnoredCb(uptr chunk, void *arg) {
712712

713713
// Sets the appropriate tag on each chunk.
714714
static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads,
715-
Frontier *frontier, tid_t caller_tid,
715+
Frontier *frontier, ThreadID caller_tid,
716716
uptr caller_sp) {
717717
const InternalMmapVector<u32> &suppressed_stacks =
718718
GetSuppressionContext()->GetSortedSuppressedStacks();
@@ -790,13 +790,13 @@ static bool ReportUnsuspendedThreads(const SuspendedThreadsList &) {
790790

791791
static bool ReportUnsuspendedThreads(
792792
const SuspendedThreadsList &suspended_threads) {
793-
InternalMmapVector<tid_t> threads(suspended_threads.ThreadCount());
793+
InternalMmapVector<ThreadID> threads(suspended_threads.ThreadCount());
794794
for (uptr i = 0; i < suspended_threads.ThreadCount(); ++i)
795795
threads[i] = suspended_threads.GetThreadID(i);
796796

797797
Sort(threads.data(), threads.size());
798798

799-
InternalMmapVector<tid_t> known_threads;
799+
InternalMmapVector<ThreadID> known_threads;
800800
GetRunningThreadsLocked(&known_threads);
801801

802802
bool succeded = true;

compiler-rt/lib/lsan/lsan_common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ void UnlockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS;
102102
// where leak checking is initiated from a non-main thread).
103103
void EnsureMainThreadIDIsCorrect();
104104

105-
bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
105+
bool GetThreadRangesLocked(ThreadID os_id, uptr *stack_begin, uptr *stack_end,
106106
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
107107
uptr *cache_end, DTLS **dtls);
108108
void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches);
109109
void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges);
110-
void GetThreadExtraStackRangesLocked(tid_t os_id,
110+
void GetThreadExtraStackRangesLocked(ThreadID os_id,
111111
InternalMmapVector<Range> *ranges);
112112
void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs);
113-
void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads);
113+
void GetRunningThreadsLocked(InternalMmapVector<ThreadID> *threads);
114114
void PrintThreads();
115115

116116
//// --------------------------------------------------------------------------
@@ -247,7 +247,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier);
247247
struct CheckForLeaksParam {
248248
Frontier frontier;
249249
LeakedChunks leaks;
250-
tid_t caller_tid;
250+
ThreadID caller_tid;
251251
uptr caller_sp;
252252
bool success = false;
253253
};

compiler-rt/lib/lsan/lsan_interceptors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,12 @@ INTERCEPTOR(void, _lwp_exit) {
385385
#endif
386386

387387
#if SANITIZER_INTERCEPT_THR_EXIT
388-
INTERCEPTOR(void, thr_exit, tid_t *state) {
388+
INTERCEPTOR(void, thr_exit, ThreadID *state) {
389389
ENSURE_LSAN_INITED;
390390
ThreadFinish();
391391
REAL(thr_exit)(state);
392392
}
393-
#define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit)
393+
# define LSAN_MAYBE_INTERCEPT_THR_EXIT INTERCEPT_FUNCTION(thr_exit)
394394
#else
395395
#define LSAN_MAYBE_INTERCEPT_THR_EXIT
396396
#endif

compiler-rt/lib/lsan/lsan_posix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ThreadContext::OnStarted(void *arg) {
4848
dtls_ = args->dtls;
4949
}
5050

51-
void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) {
51+
void ThreadStart(u32 tid, ThreadID os_id, ThreadType thread_type) {
5252
OnStartedArgs args;
5353
GetThreadStackAndTls(tid == kMainTid, &args.stack_begin, &args.stack_end,
5454
&args.tls_begin, &args.tls_end);
@@ -57,7 +57,7 @@ void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type) {
5757
ThreadContextLsanBase::ThreadStart(tid, os_id, thread_type, &args);
5858
}
5959

60-
bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
60+
bool GetThreadRangesLocked(ThreadID os_id, uptr *stack_begin, uptr *stack_end,
6161
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
6262
uptr *cache_end, DTLS **dtls) {
6363
ThreadContext *context = static_cast<ThreadContext *>(

compiler-rt/lib/lsan/lsan_posix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ThreadContext final : public ThreadContextLsanBase {
4141
DTLS *dtls_ = nullptr;
4242
};
4343

44-
void ThreadStart(u32 tid, tid_t os_id,
44+
void ThreadStart(u32 tid, ThreadID os_id,
4545
ThreadType thread_type = ThreadType::Regular);
4646

4747
} // namespace __lsan

compiler-rt/lib/lsan/lsan_thread.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ u32 ThreadCreate(u32 parent_tid, bool detached, void *arg) {
6666
return thread_registry->CreateThread(0, detached, parent_tid, arg);
6767
}
6868

69-
void ThreadContextLsanBase::ThreadStart(u32 tid, tid_t os_id,
69+
void ThreadContextLsanBase::ThreadStart(u32 tid, ThreadID os_id,
7070
ThreadType thread_type, void *arg) {
7171
thread_registry->StartThread(tid, os_id, thread_type, arg);
7272
}
@@ -80,7 +80,7 @@ void EnsureMainThreadIDIsCorrect() {
8080

8181
///// Interface to the common LSan module. /////
8282

83-
void GetThreadExtraStackRangesLocked(tid_t os_id,
83+
void GetThreadExtraStackRangesLocked(ThreadID os_id,
8484
InternalMmapVector<Range> *ranges) {}
8585
void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {}
8686

@@ -99,11 +99,11 @@ ThreadRegistry *GetLsanThreadRegistryLocked() {
9999
return thread_registry;
100100
}
101101

102-
void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {
102+
void GetRunningThreadsLocked(InternalMmapVector<ThreadID> *threads) {
103103
GetLsanThreadRegistryLocked()->RunCallbackForEachThreadLocked(
104104
[](ThreadContextBase *tctx, void *threads) {
105105
if (tctx->status == ThreadStatusRunning) {
106-
reinterpret_cast<InternalMmapVector<tid_t> *>(threads)->push_back(
106+
reinterpret_cast<InternalMmapVector<ThreadID> *>(threads)->push_back(
107107
tctx->os_id);
108108
}
109109
},

0 commit comments

Comments
 (0)