diff --git a/src/coreclr/debug/di/rsmain.cpp b/src/coreclr/debug/di/rsmain.cpp index 379330ebeb4101..d717b30a5489fe 100644 --- a/src/coreclr/debug/di/rsmain.cpp +++ b/src/coreclr/debug/di/rsmain.cpp @@ -71,11 +71,7 @@ const char * GetDebugCodeName(DWORD dwCode) // Per-thread state for Debug builds... //----------------------------------------------------------------------------- #ifdef RSCONTRACTS -#ifndef __GNUC__ -__declspec(thread) DbgRSThread* DbgRSThread::t_pCurrent; -#else // !__GNUC__ -__thread DbgRSThread* DbgRSThread::t_pCurrent; -#endif // !__GNUC__ +thread_local DbgRSThread* DbgRSThread::t_pCurrent; LONG DbgRSThread::s_Total = 0; diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index 356c5e6ebee154..53e732ee1c8c29 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -11228,11 +11228,7 @@ class DbgRSThread DbgRSThread(); // The TLS slot that we'll put this thread object in. -#ifndef __GNUC__ - static __declspec(thread) DbgRSThread* t_pCurrent; -#else // !__GNUC__ - static __thread DbgRSThread* t_pCurrent; -#endif // !__GNUC__ + static thread_local DbgRSThread* t_pCurrent; static LONG s_Total; // Total count of thread objects diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index f501c6837a6496..0b3bb7b8828551 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -3125,7 +3125,7 @@ HRESULT CordbUnmanagedThread::SetTlsSlot(DWORD slot, REMOTE_PTR value) return S_OK; } -// gets the value of gCurrentThreadInfo.m_pThread +// gets the value of t_CurrentThreadInfo.m_pThread DWORD_PTR CordbUnmanagedThread::GetEEThreadValue() { DWORD_PTR ret = NULL; @@ -3152,7 +3152,7 @@ DWORD_PTR CordbUnmanagedThread::GetEEThreadValue() return ret; } -// returns the remote address of gCurrentThreadInfo +// returns the remote address of t_CurrentThreadInfo HRESULT CordbUnmanagedThread::GetClrModuleTlsDataAddress(REMOTE_PTR* pAddress) { *pAddress = NULL; @@ -3721,14 +3721,14 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync() LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: hijackCtx started as:\n")); LogContext(GetHijackCtx()); - // Save the thread's full context + DT_CONTEXT_EXTENDED_REGISTERS + // Save the thread's full context + DT_CONTEXT_EXTENDED_REGISTERS // to avoid getting incomplete information and corrupt the thread context DT_CONTEXT context; -#if defined(DT_CONTEXT_EXTENDED_REGISTERS) +#if defined(DT_CONTEXT_EXTENDED_REGISTERS) context.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS; #else context.ContextFlags = DT_CONTEXT_FULL; -#endif +#endif BOOL succ = DbiGetThreadContext(m_handle, &context); _ASSERTE(succ); // for debugging when GetThreadContext fails @@ -3741,7 +3741,7 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync() GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS; #else GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL; -#endif +#endif CORDbgCopyThreadContext(GetHijackCtx(), &context); LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: thread=0x%x Hijacking for sync. Original context is:\n", this)); LogContext(GetHijackCtx()); diff --git a/src/coreclr/inc/palclr.h b/src/coreclr/inc/palclr.h index 410c0a7c06d12c..b138dde991dcf5 100644 --- a/src/coreclr/inc/palclr.h +++ b/src/coreclr/inc/palclr.h @@ -8,12 +8,11 @@ // =========================================================================== - -#if defined(HOST_WINDOWS) - #ifndef __PALCLR_H__ #define __PALCLR_H__ +#if defined(HOST_WINDOWS) + // This macro is used to standardize the wide character string literals between UNIX and Windows. // Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size // of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined @@ -602,9 +601,9 @@ #define __clr_reserved __reserved -#endif // __PALCLR_H__ - -#include "palclr_win.h" +// Native system libray handle. +// In Windows, NATIVE_LIBRARY_HANDLE is the same as HMODULE. +typedef HMODULE NATIVE_LIBRARY_HANDLE; #ifndef IMAGE_FILE_MACHINE_LOONGARCH64 #define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 // LOONGARCH64. @@ -615,3 +614,5 @@ #endif #endif // defined(HOST_WINDOWS) + +#endif // __PALCLR_H__ diff --git a/src/coreclr/inc/palclr_win.h b/src/coreclr/inc/palclr_win.h deleted file mode 100644 index be0b725e1a6896..00000000000000 --- a/src/coreclr/inc/palclr_win.h +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// =========================================================================== -// File: palclr.h -// -// Various macros and constants that are necessary to make the CLR portable. -// - -// =========================================================================== - -#ifndef __PALCLR_WIN_H__ -#define __PALCLR_WIN_H__ - -// PAL SEH -// Macros for portable exception handling. The Win32 SEH is emulated using -// these macros and setjmp/longjmp on Unix -// -// Usage notes: -// -// - The filter has to be a function taking two parameters: -// LONG MyFilter(PEXCEPTION_POINTERS *pExceptionInfo, PVOID pv) -// -// - It is not possible to directly use the local variables in the filter. -// All the local information that the filter has to need to know about should -// be passed through pv parameter -// -// - Do not use goto to jump out of the PAL_TRY block -// (jumping out of the try block is not a good idea even on Win32, because of -// it causes stack unwind) -// -// -// Simple examples: -// -// PAL_TRY { -// .... -// } WIN_PAL_FINALLY { -// .... -// } -// WIN_PAL_ENDTRY -// -// -// PAL_TRY { -// .... -// } WIN_PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { -// .... -// } -// WIN_PAL_ENDTRY -// -// -// LONG MyFilter(PEXCEPTION_POINTERS *pExceptionInfo, PVOID pv) -// { -// ... -// } -// PAL_TRY { -// .... -// } WIN_PAL_EXCEPT_FILTER(MyFilter, NULL) { -// .... -// } -// WIN_PAL_ENDTRY -// -// -// Complex example: -// -// struct MyParams -// { -// ... -// } params; -// -// PAL_TRY { -// PAL_TRY { -// ... -// if (error) goto Done; -// ... -// Done: ; -// } WIN_PAL_EXCEPT_FILTER(OtherFilter, ¶ms) { -// ... -// } -// WIN_PAL_ENDTRY -// } -// WIN_PAL_FINALLY { -// } -// WIN_PAL_ENDTRY -// - - - -#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(HOST_ARM) // @ARMTODO -#define WIN_PAL_TRY_HANDLER_DBG_BEGIN \ - BOOL ___oldOkayToThrowValue = FALSE; \ - ClrDebugState *___pState = GetClrDebugState(); \ - __try \ - { \ - ___oldOkayToThrowValue = ___pState->IsOkToThrow(); \ - ___pState->SetOkToThrow(TRUE); \ - ANNOTATION_TRY_BEGIN; - -// Special version that avoids touching the debug state after doing work in a DllMain for process or thread detach. -#define WIN_PAL_TRY_HANDLER_DBG_BEGIN_DLLMAIN(_reason) \ - BOOL ___oldOkayToThrowValue = FALSE; \ - BOOL ___oldSOTolerantState = FALSE; \ - ClrDebugState *___pState = CheckClrDebugState(); \ - __try \ - { \ - if (___pState) \ - { \ - ___oldOkayToThrowValue = ___pState->IsOkToThrow(); \ - ___pState->SetOkToThrow(TRUE); \ - } \ - if ((_reason == DLL_PROCESS_DETACH) || (_reason == DLL_THREAD_DETACH)) \ - { \ - ___pState = NULL; \ - } \ - ANNOTATION_TRY_BEGIN; - -#define WIN_PAL_TRY_HANDLER_DBG_END \ - ANNOTATION_TRY_END; \ - } \ - __finally \ - { \ - if (___pState != NULL) \ - { \ - _ASSERTE(___pState == CheckClrDebugState()); \ - ___pState->SetOkToThrow(___oldOkayToThrowValue); \ - ___pState->SetSOTolerance(___oldSOTolerantState); \ - } \ - } - -#define WIN_PAL_ENDTRY_NAKED_DBG - -#else -#define WIN_PAL_TRY_HANDLER_DBG_BEGIN ANNOTATION_TRY_BEGIN; -#define WIN_PAL_TRY_HANDLER_DBG_BEGIN_DLLMAIN(_reason) ANNOTATION_TRY_BEGIN; -#define WIN_PAL_TRY_HANDLER_DBG_END ANNOTATION_TRY_END; -#define WIN_PAL_ENDTRY_NAKED_DBG -#endif // defined(ENABLE_CONTRACTS_IMPL) - -#if defined(HOST_WINDOWS) -// Native system libray handle. -// In Windows, NATIVE_LIBRARY_HANDLE is the same as HMODULE. -typedef HMODULE NATIVE_LIBRARY_HANDLE; -#endif // HOST_WINDOWS - -#endif // __PALCLR_WIN_H__ diff --git a/src/coreclr/pal/src/exception/seh.cpp b/src/coreclr/pal/src/exception/seh.cpp index bff76ad159f36d..d1a949601f91b9 100644 --- a/src/coreclr/pal/src/exception/seh.cpp +++ b/src/coreclr/pal/src/exception/seh.cpp @@ -175,7 +175,7 @@ PAL_ThrowExceptionFromContext(CONTEXT* context, PAL_SEHException* ex) // We need to make a copy of the exception off stack, since the "ex" is located in one of the stack // frames that will become obsolete by the ThrowExceptionFromContextInternal and the ThrowExceptionHelper // could overwrite the "ex" object by stack e.g. when allocating the low level exception object for "throw". - static __thread BYTE threadLocalExceptionStorage[sizeof(PAL_SEHException)]; + static thread_local BYTE threadLocalExceptionStorage[sizeof(PAL_SEHException)]; ThrowExceptionFromContextInternal(context, new (threadLocalExceptionStorage) PAL_SEHException(std::move(*ex))); } @@ -372,12 +372,7 @@ bool CatchHardwareExceptionHolder::IsEnabled() --*/ -#if defined(__GNUC__) -static __thread -#else // __GNUC__ -__declspec(thread) static -#endif // !__GNUC__ -NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr; +static thread_local NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr; extern "C" NativeExceptionHolderBase ** diff --git a/src/coreclr/vm/amd64/AsmMacros.inc b/src/coreclr/vm/amd64/AsmMacros.inc index 2d14b9c31e8fca..ed370b0a31466b 100644 --- a/src/coreclr/vm/amd64/AsmMacros.inc +++ b/src/coreclr/vm/amd64/AsmMacros.inc @@ -191,17 +191,17 @@ Section ends ; Inlined version of GetThread ; Trashes rax and r11 ; -gCurrentThreadInfo TEXTEQU +t_CurrentThreadInfo TEXTEQU INLINE_GETTHREAD macro Reg EXTERN _tls_index : DWORD - EXTERN gCurrentThreadInfo:DWORD + EXTERN t_CurrentThreadInfo:DWORD mov r11d, [_tls_index] mov rax, gs:[OFFSET__TEB__ThreadLocalStoragePointer] mov rax, [rax + r11 * 8] - mov r11d, SECTIONREL gCurrentThreadInfo + mov r11d, SECTIONREL t_CurrentThreadInfo mov Reg, [rax + r11] endm diff --git a/src/coreclr/vm/arm/asmmacros.h b/src/coreclr/vm/arm/asmmacros.h index db1a6a7cd3c011..51cc3c8cf4d3d7 100644 --- a/src/coreclr/vm/arm/asmmacros.h +++ b/src/coreclr/vm/arm/asmmacros.h @@ -160,8 +160,8 @@ __PWTB_StackAlloc SETA __PWTB_TransitionBlock ; __tls_array equ 0x2C ;; offsetof(TEB, ThreadLocalStoragePointer) - GBLS __SECTIONREL_gCurrentThreadInfo -__SECTIONREL_gCurrentThreadInfo SETS "SECTIONREL_gCurrentThreadInfo" + GBLS __SECTIONREL_t_CurrentThreadInfo +__SECTIONREL_t_CurrentThreadInfo SETS "SECTIONREL_t_CurrentThreadInfo" MACRO INLINE_GETTHREAD $destReg, $trashReg @@ -172,8 +172,8 @@ __SECTIONREL_gCurrentThreadInfo SETS "SECTIONREL_gCurrentThreadInfo" mrc p15, 0, $trashReg, c13, c0, 2 ldr $trashReg, [$trashReg, #__tls_array] ldr $destReg, [$trashReg, $destReg, lsl #2] - ldr $trashReg, $__SECTIONREL_gCurrentThreadInfo - ldr $destReg,[$destReg, $trashReg] ; return gCurrentThreadInfo.m_pThread + ldr $trashReg, $__SECTIONREL_t_CurrentThreadInfo + ldr $destReg,[$destReg, $trashReg] ; return t_CurrentThreadInfo.m_pThread MEND ;----------------------------------------------------------------------------- @@ -181,15 +181,15 @@ __SECTIONREL_gCurrentThreadInfo SETS "SECTIONREL_gCurrentThreadInfo" ; INLINE_GETTHREAD. Optionally, it can be also used after any function that used INLINE_GETTHREAD ; to improve density, or to reduce distance between the constant pool and its use. ; - SETALIAS gCurrentThreadInfo, ?gCurrentThreadInfo@@3UThreadLocalInfo@@A + SETALIAS t_CurrentThreadInfo, ?t_CurrentThreadInfo@@3UThreadLocalInfo@@A MACRO INLINE_GETTHREAD_CONSTANT_POOL - EXTERN $gCurrentThreadInfo + EXTERN $t_CurrentThreadInfo -$__SECTIONREL_gCurrentThreadInfo - DCDU $gCurrentThreadInfo +$__SECTIONREL_t_CurrentThreadInfo + DCDU $t_CurrentThreadInfo RELOC 15 ;; SECREL -__SECTIONREL_gCurrentThreadInfo SETS "$__SECTIONREL_gCurrentThreadInfo":CC:"_" +__SECTIONREL_t_CurrentThreadInfo SETS "$__SECTIONREL_t_CurrentThreadInfo":CC:"_" MEND diff --git a/src/coreclr/vm/arm64/asmmacros.h b/src/coreclr/vm/arm64/asmmacros.h index 8dd56dc59045cd..ed1792ca971d3f 100644 --- a/src/coreclr/vm/arm64/asmmacros.h +++ b/src/coreclr/vm/arm64/asmmacros.h @@ -345,13 +345,13 @@ TrashRegister32Bit SETS "w":CC:("$TrashRegister32Bit":RIGHT:((:LEN:TrashRegister ;; ;; Macro to get a pointer to the Thread* object for the currently executing thread ;; - SETALIAS gCurrentThreadInfo, ?gCurrentThreadInfo@@3UThreadLocalInfo@@A + SETALIAS t_CurrentThreadInfo, ?t_CurrentThreadInfo@@3UThreadLocalInfo@@A MACRO INLINE_GETTHREAD $destReg, $trashReg - EXTERN $gCurrentThreadInfo + EXTERN $t_CurrentThreadInfo - INLINE_GET_TLS_VAR $destReg, $trashReg, $gCurrentThreadInfo - ldr $destReg, [$destReg] ;; return gCurrentThreadInfo.m_pThread + INLINE_GET_TLS_VAR $destReg, $trashReg, $t_CurrentThreadInfo + ldr $destReg, [$destReg] ;; return t_CurrentThreadInfo.m_pThread MEND diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 8d39015b31fea3..db012c7c106e0e 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -874,7 +874,7 @@ void EEStartupHelper() #endif // This isn't done as part of InitializeGarbageCollector() above because - // debugger must be initialized before creating EE thread objects + // debugger must be initialized before creating EE thread objects FinalizerThread::FinalizerThreadCreate(); InitPreStubManager(); @@ -1735,7 +1735,7 @@ static uint32_t g_flsIndex = FLS_OUT_OF_INDEXES; #define FLS_STATE_ARMED 1 #define FLS_STATE_INVOKED 2 -static __declspec(thread) byte t_flsState; +static thread_local byte t_flsState; // This is called when each *fiber* is destroyed. When the home fiber of a thread is destroyed, // it means that the thread itself is destroyed. diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp index b1bc04c80c8dd6..668a1b5e83fe7b 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.cpp +++ b/src/coreclr/vm/eedbginterfaceimpl.cpp @@ -1331,7 +1331,7 @@ void EEDbgInterfaceImpl::GetRuntimeOffsets(SIZE_T *pTLSIndex, #ifdef TARGET_WINDOWS *pTLSIndex = _tls_index; - *pTLSEEThreadOffset = Thread::GetOffsetOfThreadStatic(&gCurrentThreadInfo.m_pThread); + *pTLSEEThreadOffset = Thread::GetOffsetOfThreadStatic(&t_CurrentThreadInfo.m_pThread); *pTLSIsSpecialOffset = Thread::GetOffsetOfThreadStatic(&t_ThreadType); *pTLSCantStopOffset = Thread::GetOffsetOfThreadStatic(&t_CantStopCount); #else diff --git a/src/coreclr/vm/i386/AsmMacros.inc b/src/coreclr/vm/i386/AsmMacros.inc index ba6cc7e81a2854..79345b6d18b56d 100644 --- a/src/coreclr/vm/i386/AsmMacros.inc +++ b/src/coreclr/vm/i386/AsmMacros.inc @@ -7,18 +7,18 @@ __tls_array equ 2Ch ;; offsetof(TEB, ThreadLocalStoragePointer) -gCurrentThreadInfo TEXTEQU +t_CurrentThreadInfo TEXTEQU INLINE_GETTHREAD macro destReg, trashReg ASSUME fs : NOTHING EXTERN __tls_index:DWORD - EXTERN gCurrentThreadInfo:DWORD + EXTERN t_CurrentThreadInfo:DWORD mov destReg, [__tls_index] mov trashReg, fs:[__tls_array] mov trashReg, [trashReg + destReg * 4] - add trashReg, SECTIONREL gCurrentThreadInfo + add trashReg, SECTIONREL t_CurrentThreadInfo mov destReg, [trashReg] endm diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 57f21032b58b00..0734859b1b2c26 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -329,9 +329,10 @@ HCIMPLEND // Define the t_ThreadStatics variable here, so that these helpers can use // the most optimal TLS access pattern for the platform when inlining the -// GetThreadLocalStaticBaseIfExistsAndInitialized function +// GetThreadLocalStaticBaseIfExistsAndInitialized function. +// Using compiler specific thread local storage directives due to linkage issues. #ifdef _MSC_VER -__declspec(selectany) __declspec(thread) ThreadLocalData t_ThreadStatics; +__declspec(selectany) __declspec(thread) ThreadLocalData t_ThreadStatics; #else __thread ThreadLocalData t_ThreadStatics; #endif // _MSC_VER @@ -1337,7 +1338,7 @@ HCIMPL1(void, IL_Throw, Object* obj) #ifdef FEATURE_EH_FUNCLETS Thread *pThread = GetThread(); - + SoftwareExceptionFrame exceptionFrame; #ifdef TARGET_X86 exceptionFrame.UpdateContextFromTransitionBlock(transitionBlock); @@ -2934,7 +2935,7 @@ HCIMPL3_RAW(void, JIT_ReversePInvokeEnterTrackTransitions, ReversePInvokeFrame* frame->record.m_pEntryFrame = frame->currentThread->GetFrame(); frame->record.m_ExReg.Handler = (PEXCEPTION_ROUTINE)FastNExportExceptHandler; INSTALL_EXCEPTION_HANDLING_RECORD(&frame->record.m_ExReg); -#else +#else frame->m_ExReg.Handler = (PEXCEPTION_ROUTINE)ProcessCLRException; INSTALL_SEH_RECORD(&frame->m_ExReg); #endif @@ -2972,7 +2973,7 @@ HCIMPL1_RAW(void, JIT_ReversePInvokeEnter, ReversePInvokeFrame* frame) frame->record.m_pEntryFrame = frame->currentThread->GetFrame(); frame->record.m_ExReg.Handler = (PEXCEPTION_ROUTINE)FastNExportExceptHandler; INSTALL_EXCEPTION_HANDLING_RECORD(&frame->record.m_ExReg); -#else +#else frame->m_ExReg.Handler = (PEXCEPTION_ROUTINE)ProcessCLRException; INSTALL_SEH_RECORD(&frame->m_ExReg); #endif diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index c1f89550056cca..daa9c4932e80eb 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -352,8 +352,8 @@ bool Thread::DetectHandleILStubsForDebugger() } #ifndef _MSC_VER -__thread ThreadLocalInfo gCurrentThreadInfo; -#endif +thread_local ThreadLocalInfo t_CurrentThreadInfo; +#endif // _MSC_VER #ifndef DACCESS_COMPILE @@ -361,8 +361,8 @@ void SetThread(Thread* t) { LIMITED_METHOD_CONTRACT - Thread* origThread = gCurrentThreadInfo.m_pThread; - gCurrentThreadInfo.m_pThread = t; + Thread* origThread = t_CurrentThreadInfo.m_pThread; + t_CurrentThreadInfo.m_pThread = t; if (t != NULL) { _ASSERTE(origThread == NULL); @@ -380,7 +380,7 @@ void SetThread(Thread* t) #endif // Clear or set the app domain to the one domain based on if the thread is being nulled out or set - gCurrentThreadInfo.m_pAppDomain = t == NULL ? NULL : AppDomain::GetCurrentDomain(); + t_CurrentThreadInfo.m_pAppDomain = t == NULL ? NULL : AppDomain::GetCurrentDomain(); } BOOL Thread::Alert () @@ -1159,12 +1159,12 @@ void InitThreadManager() #ifndef TARGET_UNIX _ASSERTE(GetThreadNULLOk() == NULL); - size_t offsetOfCurrentThreadInfo = Thread::GetOffsetOfThreadStatic(&gCurrentThreadInfo); + size_t offsetOfCurrentThreadInfo = Thread::GetOffsetOfThreadStatic(&t_CurrentThreadInfo); _ASSERTE(offsetOfCurrentThreadInfo < 0x8000); _ASSERTE(_tls_index < 0x10000); - // Save gCurrentThreadInfo location for debugger + // Save t_CurrentThreadInfo location for debugger SetIlsIndex((DWORD)(_tls_index + (offsetOfCurrentThreadInfo << 16) + 0x80000000)); _ASSERTE(g_TrapReturningThreads == 0); diff --git a/src/coreclr/vm/threads.inl b/src/coreclr/vm/threads.inl index b15b7bef0895ba..83683f62bf3648 100644 --- a/src/coreclr/vm/threads.inl +++ b/src/coreclr/vm/threads.inl @@ -27,19 +27,20 @@ EXTERN_C UINT32 _tls_index; #endif #ifdef _MSC_VER -__declspec(selectany) __declspec(thread) ThreadLocalInfo gCurrentThreadInfo; +__declspec(selectany) #else -EXTERN_C __thread ThreadLocalInfo gCurrentThreadInfo; +EXTERN_C #endif +thread_local ThreadLocalInfo t_CurrentThreadInfo; inline Thread* GetThreadNULLOk() { - return gCurrentThreadInfo.m_pThread; + return t_CurrentThreadInfo.m_pThread; } inline Thread* GetThread() { - Thread* pThread = gCurrentThreadInfo.m_pThread; + Thread* pThread = t_CurrentThreadInfo.m_pThread; _ASSERTE(pThread); return pThread; } diff --git a/src/coreclr/vm/threadstatics.h b/src/coreclr/vm/threadstatics.h index 4611d90d015c37..9bcc4e9a6a5f13 100644 --- a/src/coreclr/vm/threadstatics.h +++ b/src/coreclr/vm/threadstatics.h @@ -85,13 +85,14 @@ struct ThreadLocalData typedef DPTR(ThreadLocalData) PTR_ThreadLocalData; +// Using compiler specific thread local storage directives due to linkage issues. #ifndef DACCESS_COMPILE #ifdef _MSC_VER -extern __declspec(selectany) __declspec(thread) ThreadLocalData t_ThreadStatics; +extern __declspec(selectany) __declspec(thread) ThreadLocalData t_ThreadStatics; #else extern __thread ThreadLocalData t_ThreadStatics; #endif // _MSC_VER -#endif // DACCESS_COMPILE +#endif // !DACCESS_COMPILE #define NUMBER_OF_TLSOFFSETS_NOT_USED_IN_NONCOLLECTIBLE_ARRAY 2 @@ -199,8 +200,8 @@ class TLSIndexToMethodTableMap iterator operator++(int) { LIMITED_METHOD_CONTRACT; - iterator tmp = *this; - ++(*this); + iterator tmp = *this; + ++(*this); return tmp; } }; diff --git a/src/coreclr/vm/util.cpp b/src/coreclr/vm/util.cpp index 06216ef18fb9d8..e20abebbb5539f 100644 --- a/src/coreclr/vm/util.cpp +++ b/src/coreclr/vm/util.cpp @@ -25,7 +25,7 @@ void ClrFlsSetThreadType(TlsThreadTypeFlag flag) // The historic location of ThreadType slot kept for compatibility with SOS // TODO: Introduce DAC API to make this hack unnecessary - gCurrentThreadInfo.m_EETlsData = (void**)&t_ThreadType - TlsIdx_ThreadType; + t_CurrentThreadInfo.m_EETlsData = (void**)&t_ThreadType - TlsIdx_ThreadType; } void ClrFlsClearThreadType(TlsThreadTypeFlag flag)