[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
This commit is contained in:
Leonard Chan 2021-06-23 16:18:44 -07:00
parent a9854045f6
commit c4a00ed851
2 changed files with 8 additions and 8 deletions

View File

@ -228,6 +228,14 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame,
__builtin_unreachable(); __builtin_unreachable();
} }
Thread *GetCurrentThread() {
uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
if (UNLIKELY(*ThreadLongPtr == 0))
return nullptr;
auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
}
} // namespace __hwasan } // namespace __hwasan
using namespace __hwasan; using namespace __hwasan;

View File

@ -338,14 +338,6 @@ void AndroidTestTlsSlot() {
void AndroidTestTlsSlot() {} void AndroidTestTlsSlot() {}
#endif #endif
Thread *GetCurrentThread() {
uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
if (UNLIKELY(*ThreadLongPtr == 0))
return nullptr;
auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
}
static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) { static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
// Access type is passed in a platform dependent way (see below) and encoded // Access type is passed in a platform dependent way (see below) and encoded
// as 0xXY, where X&1 is 1 for store, 0 for load, and X&2 is 1 if the error is // as 0xXY, where X&1 is 1 for store, 0 for load, and X&2 is 1 if the error is