mirror of https://github.com/PCSX2/pcsx2.git
Common/Threading: Replace TLS macros with standard thread_local
This commit is contained in:
parent
f8dcff9fc4
commit
d2347d9972
|
@ -20,10 +20,10 @@
|
||||||
using namespace Threading;
|
using namespace Threading;
|
||||||
|
|
||||||
// thread-local console indentation setting.
|
// thread-local console indentation setting.
|
||||||
static DeclareTls(int) conlog_Indent(0);
|
static thread_local int conlog_Indent(0);
|
||||||
|
|
||||||
// thread-local console color storage.
|
// thread-local console color storage.
|
||||||
static DeclareTls(ConsoleColors) conlog_Color(DefaultConsoleColor);
|
static thread_local ConsoleColors conlog_Color(DefaultConsoleColor);
|
||||||
|
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -26,24 +26,6 @@
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// 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
|
namespace Threading
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -60,8 +60,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
__tls_emit u8* x86Ptr;
|
thread_local u8* x86Ptr;
|
||||||
__tls_emit XMMSSEType g_xmmtypes[iREGCNT_XMM] = {XMMT_INT};
|
thread_local XMMSSEType g_xmmtypes[iREGCNT_XMM] = {XMMT_INT};
|
||||||
|
|
||||||
namespace x86Emitter
|
namespace x86Emitter
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,38 +29,8 @@ enum XMMSSEType
|
||||||
//XMMT_FPD = 3, // double
|
//XMMT_FPD = 3, // double
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
extern thread_local u8* x86Ptr;
|
||||||
// __tls_emit / x86EMIT_MULTITHREADED
|
extern thread_local XMMSSEType g_xmmtypes[iREGCNT_XMM];
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// 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];
|
|
||||||
|
|
||||||
namespace x86Emitter
|
namespace x86Emitter
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 )
|
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.
|
// 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 );
|
RecursionGuard guard( _reentrant_lock );
|
||||||
if( guard.IsReentrant() ) pxTrap();
|
if( guard.IsReentrant() ) pxTrap();
|
||||||
|
|
||||||
|
|
|
@ -686,8 +686,8 @@ void SysExecEvent_CoreThreadPause::InvokeEvent()
|
||||||
// ScopedCoreThreadClose / ScopedCoreThreadPause
|
// ScopedCoreThreadClose / ScopedCoreThreadPause
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
static DeclareTls(bool) ScopedCore_IsPaused = false;
|
static thread_local bool ScopedCore_IsPaused = false;
|
||||||
static DeclareTls(bool) ScopedCore_IsFullyClosed = false;
|
static thread_local bool ScopedCore_IsFullyClosed = false;
|
||||||
|
|
||||||
BaseScopedCoreThread::BaseScopedCoreThread()
|
BaseScopedCoreThread::BaseScopedCoreThread()
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
using namespace x86Emitter;
|
using namespace x86Emitter;
|
||||||
|
|
||||||
__tls_emit u8* j8Ptr[32];
|
thread_local u8* j8Ptr[32];
|
||||||
__tls_emit u32* j32Ptr[32];
|
thread_local u32* j32Ptr[32];
|
||||||
|
|
||||||
u16 g_x86AllocCounter = 0;
|
u16 g_x86AllocCounter = 0;
|
||||||
u16 g_xmmAllocCounter = 0;
|
u16 g_xmmAllocCounter = 0;
|
||||||
|
|
|
@ -256,8 +256,8 @@ extern u32 g_recWriteback; // used for jumps (VUrec mess!)
|
||||||
|
|
||||||
extern _xmmregs xmmregs[iREGCNT_XMM], s_saveXMMregs[iREGCNT_XMM];
|
extern _xmmregs xmmregs[iREGCNT_XMM], s_saveXMMregs[iREGCNT_XMM];
|
||||||
|
|
||||||
extern __tls_emit u8* j8Ptr[32]; // depreciated item. use local u8* vars instead.
|
extern thread_local 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 u32* j32Ptr[32]; // depreciated item. use local u32* vars instead.
|
||||||
|
|
||||||
extern u16 g_x86AllocCounter;
|
extern u16 g_x86AllocCounter;
|
||||||
extern u16 g_xmmAllocCounter;
|
extern u16 g_xmmAllocCounter;
|
||||||
|
|
Loading…
Reference in New Issue