Skip to content

Commit c4a00ed

Browse files
committed
[NFC][compiler-rt][hwasan] Move GetCurrentThread to hwasan.cpp
We can reuse the same implementation for getting the current thread on fuchsia. Differential Revision: https://reviews.llvm.org/D104824
1 parent a985404 commit c4a00ed

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

compiler-rt/lib/hwasan/hwasan.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame,
228228
__builtin_unreachable();
229229
}
230230

231+
Thread *GetCurrentThread() {
232+
uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
233+
if (UNLIKELY(*ThreadLongPtr == 0))
234+
return nullptr;
235+
auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
236+
return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
237+
}
238+
231239
} // namespace __hwasan
232240

233241
using namespace __hwasan;

compiler-rt/lib/hwasan/hwasan_linux.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,6 @@ void AndroidTestTlsSlot() {
338338
void AndroidTestTlsSlot() {}
339339
#endif
340340

341-
Thread *GetCurrentThread() {
342-
uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
343-
if (UNLIKELY(*ThreadLongPtr == 0))
344-
return nullptr;
345-
auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
346-
return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
347-
}
348-
349341
static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
350342
// Access type is passed in a platform dependent way (see below) and encoded
351343
// as 0xXY, where X&1 is 1 for store, 0 for load, and X&2 is 1 if the error is

0 commit comments

Comments
 (0)