diff --git a/src/coreclr/gc/env/gcenv.structs.h b/src/coreclr/gc/env/gcenv.structs.h index e41ba3cfa67c1..9f287ec7bf8c2 100644 --- a/src/coreclr/gc/env/gcenv.structs.h +++ b/src/coreclr/gc/env/gcenv.structs.h @@ -15,15 +15,8 @@ struct GCSystemInfo typedef void * HANDLE; -// Across all platforms, NativeAOT Thread::GetPalThreadIdForLogging assumes that the thread -// ID is stored in the first 8 bytes of this structure. - #ifdef TARGET_UNIX -#ifdef FEATURE_NATIVEAOT -static_assert(sizeof(pthread_t) == sizeof(uint64_t), "EEThreadId layout mismatch"); -#endif - class EEThreadId { pthread_t m_id; diff --git a/src/coreclr/nativeaot/Runtime/thread.cpp b/src/coreclr/nativeaot/Runtime/thread.cpp index eb605aa7d9737..9e0f2a91c9e74 100644 --- a/src/coreclr/nativeaot/Runtime/thread.cpp +++ b/src/coreclr/nativeaot/Runtime/thread.cpp @@ -277,7 +277,7 @@ void Thread::Construct() m_pDeferredTransitionFrame = TOP_OF_STACK_MARKER; m_hPalThread = INVALID_HANDLE_VALUE; - m_threadId.SetToCurrentThread(); + m_threadId = PalGetCurrentOSThreadId(); HANDLE curProcessPseudo = PalGetCurrentProcess(); HANDLE curThreadPseudo = PalGetCurrentThread(); @@ -342,12 +342,7 @@ bool Thread::CatchAtSafePoint() uint64_t Thread::GetPalThreadIdForLogging() { - return *(uint64_t*)&m_threadId; -} - -bool Thread::IsCurrentThread() -{ - return m_threadId.IsCurrentThread(); + return m_threadId; } uint64_t Thread::s_DeadThreadsNonAllocBytes = 0; diff --git a/src/coreclr/nativeaot/Runtime/thread.h b/src/coreclr/nativeaot/Runtime/thread.h index 1de777edf87f9..c4b77e99b5d5a 100644 --- a/src/coreclr/nativeaot/Runtime/thread.h +++ b/src/coreclr/nativeaot/Runtime/thread.h @@ -102,7 +102,7 @@ struct ThreadBuffer GCFrameRegistration* m_pGCFrameRegistrations; PTR_VOID m_pStackLow; PTR_VOID m_pStackHigh; - EEThreadId m_threadId; // OS thread ID + uint64_t m_threadId; // OS thread ID PTR_VOID m_pThreadStressLog; // pointer to head of thread's StressLogChunks NATIVE_CONTEXT* m_interruptedContext; // context for an asynchronously interrupted thread. #ifdef FEATURE_SUSPEND_REDIRECTION @@ -215,7 +215,6 @@ class Thread : private ThreadBuffer gc_alloc_context * GetAllocContext(); uint64_t GetPalThreadIdForLogging(); - bool IsCurrentThread(); void GcScanRoots(ScanFunc* pfnEnumCallback, ScanContext * pvCallbackData);