diff --git a/common/Console.cpp b/common/Console.cpp index a4fd650bdb..1e5eab7812 100644 --- a/common/Console.cpp +++ b/common/Console.cpp @@ -20,10 +20,10 @@ using namespace Threading; // thread-local console indentation setting. -static DeclareTls(int) conlog_Indent(0); +static thread_local int conlog_Indent(0); // thread-local console color storage. -static DeclareTls(ConsoleColors) conlog_Color(DefaultConsoleColor); +static thread_local ConsoleColors conlog_Color(DefaultConsoleColor); #ifdef __POSIX__ #include diff --git a/common/Threading.h b/common/Threading.h index 21bef6e88e..6d1d93056c 100644 --- a/common/Threading.h +++ b/common/Threading.h @@ -26,24 +26,6 @@ #include -// -------------------------------------------------------------------------------------- -// PCSX2_THREAD_LOCAL - Defines platform/operating system support for Thread Local Storage -// -------------------------------------------------------------------------------------- -// -// TLS is enabled by default. It will be disabled at compile time for Linux plugin. -// If you link SPU2X/ZZOGL with a TLS library, you will consume a DVT slots. Slots -// are rather limited and it ends up to "impossible to dlopen the library" -// None of the above plugin uses TLS variable in a multithread context -#ifndef PCSX2_THREAD_LOCAL -#define PCSX2_THREAD_LOCAL 1 -#endif - -#if PCSX2_THREAD_LOCAL -#define DeclareTls(x) thread_local x -#else -#define DeclareTls(x) x -#endif - namespace Threading { // -------------------------------------------------------------------------------------- diff --git a/common/emitter/x86emitter.cpp b/common/emitter/x86emitter.cpp index 03edefabf5..afbab735cb 100644 --- a/common/emitter/x86emitter.cpp +++ b/common/emitter/x86emitter.cpp @@ -60,8 +60,8 @@ // -__tls_emit u8* x86Ptr; -__tls_emit XMMSSEType g_xmmtypes[iREGCNT_XMM] = {XMMT_INT}; +thread_local u8* x86Ptr; +thread_local XMMSSEType g_xmmtypes[iREGCNT_XMM] = {XMMT_INT}; namespace x86Emitter { diff --git a/common/emitter/x86types.h b/common/emitter/x86types.h index 08c5448d94..06bff31420 100644 --- a/common/emitter/x86types.h +++ b/common/emitter/x86types.h @@ -29,38 +29,8 @@ enum XMMSSEType //XMMT_FPD = 3, // double }; -// -------------------------------------------------------------------------------------- -// __tls_emit / x86EMIT_MULTITHREADED -// -------------------------------------------------------------------------------------- -// Multithreaded support for the x86 emitter. (defaults to 0) -// To enable the multithreaded emitter, either set the below define to 1, or set the define -// as a project option. The multithreaded emitter relies on native compiler support for -// TLS -- Macs are crap out of luck there (for now). - -#ifndef x86EMIT_MULTITHREADED -#if PCSX2_THREAD_LOCAL -#define x86EMIT_MULTITHREADED 1 -#else -// No TLS support? Force-clear the MT flag: -#pragma message("x86emitter: TLS not available, multithreaded emitter disabled.") -#undef x86EMIT_MULTITHREADED -#define x86EMIT_MULTITHREADED 0 -#endif -#endif - -#ifndef __tls_emit -#if x86EMIT_MULTITHREADED -#define __tls_emit thread_local -#else -// Using TlsVariable is sub-optimal and could result in huge executables, so we -// force-disable TLS entirely, and disallow running multithreaded recompilation -// components within PCSX2 manually. -#define __tls_emit -#endif -#endif - -extern __tls_emit u8* x86Ptr; -extern __tls_emit XMMSSEType g_xmmtypes[iREGCNT_XMM]; +extern thread_local u8* x86Ptr; +extern thread_local XMMSSEType g_xmmtypes[iREGCNT_XMM]; namespace x86Emitter { diff --git a/pcsx2/gui/AppAssert.cpp b/pcsx2/gui/AppAssert.cpp index 5ef14d9d87..335897525c 100644 --- a/pcsx2/gui/AppAssert.cpp +++ b/pcsx2/gui/AppAssert.cpp @@ -105,7 +105,7 @@ static wxString pxGetStackTrace( const FnChar_t* calledFrom ) void Pcsx2App::OnAssertFailure( const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg ) { // Re-entrant assertions are bad mojo -- trap immediately. - static DeclareTls(int) _reentrant_lock( 0 ); + static thread_local int _reentrant_lock( 0 ); RecursionGuard guard( _reentrant_lock ); if( guard.IsReentrant() ) pxTrap(); diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 8ca6c4179f..f007e21f91 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -686,8 +686,8 @@ void SysExecEvent_CoreThreadPause::InvokeEvent() // ScopedCoreThreadClose / ScopedCoreThreadPause // -------------------------------------------------------------------------------------- -static DeclareTls(bool) ScopedCore_IsPaused = false; -static DeclareTls(bool) ScopedCore_IsFullyClosed = false; +static thread_local bool ScopedCore_IsPaused = false; +static thread_local bool ScopedCore_IsFullyClosed = false; BaseScopedCoreThread::BaseScopedCoreThread() { diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 408654cc16..629371ad68 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -24,8 +24,8 @@ using namespace x86Emitter; -__tls_emit u8* j8Ptr[32]; -__tls_emit u32* j32Ptr[32]; +thread_local u8* j8Ptr[32]; +thread_local u32* j32Ptr[32]; u16 g_x86AllocCounter = 0; u16 g_xmmAllocCounter = 0; diff --git a/pcsx2/x86/iCore.h b/pcsx2/x86/iCore.h index 8e453ea410..ff6b6d1048 100644 --- a/pcsx2/x86/iCore.h +++ b/pcsx2/x86/iCore.h @@ -256,8 +256,8 @@ extern u32 g_recWriteback; // used for jumps (VUrec mess!) extern _xmmregs xmmregs[iREGCNT_XMM], s_saveXMMregs[iREGCNT_XMM]; -extern __tls_emit u8* j8Ptr[32]; // depreciated item. use local u8* vars instead. -extern __tls_emit u32* j32Ptr[32]; // depreciated item. use local u32* vars instead. +extern thread_local u8* j8Ptr[32]; // depreciated item. use local u8* vars instead. +extern thread_local u32* j32Ptr[32]; // depreciated item. use local u32* vars instead. extern u16 g_x86AllocCounter; extern u16 g_xmmAllocCounter;