mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 04:02:42 +01:00
SetCurrentNamedThread()
This commit is contained in:
parent
dd9df4f36f
commit
9eb280c367
@ -12,6 +12,11 @@ NamedThreadBase* GetCurrentNamedThread()
|
||||
return g_tls_this_thread;
|
||||
}
|
||||
|
||||
void SetCurrentNamedThread(NamedThreadBase* value)
|
||||
{
|
||||
g_tls_this_thread = value;
|
||||
}
|
||||
|
||||
std::string NamedThreadBase::GetThreadName() const
|
||||
{
|
||||
return m_name;
|
||||
@ -47,32 +52,27 @@ void ThreadBase::Start()
|
||||
m_destroy = false;
|
||||
m_alive = true;
|
||||
|
||||
m_executor = new std::thread(
|
||||
[this]()
|
||||
m_executor = new std::thread([this]()
|
||||
{
|
||||
SetCurrentNamedThread(this);
|
||||
g_thread_count++;
|
||||
|
||||
try
|
||||
{
|
||||
g_tls_this_thread = this;
|
||||
g_thread_count++;
|
||||
Task();
|
||||
}
|
||||
catch (const std::string& e)
|
||||
{
|
||||
LOG_ERROR(GENERAL, "Exception: %s", e.c_str());
|
||||
}
|
||||
catch (const char* e)
|
||||
{
|
||||
LOG_ERROR(GENERAL, "Exception: %s", e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Task();
|
||||
}
|
||||
catch (const std::string& e)
|
||||
{
|
||||
LOG_ERROR(GENERAL, "Exception: %s", e.c_str());
|
||||
}
|
||||
catch (const char* e)
|
||||
{
|
||||
LOG_ERROR(GENERAL, "Exception: %s", e);
|
||||
}
|
||||
catch (int exitcode)
|
||||
{
|
||||
LOG_SUCCESS(GENERAL, "Exit Code: %d", exitcode);
|
||||
}
|
||||
|
||||
m_alive = false;
|
||||
g_thread_count--;
|
||||
});
|
||||
m_alive = false;
|
||||
g_thread_count--;
|
||||
});
|
||||
}
|
||||
|
||||
void ThreadBase::Stop(bool wait, bool send_destroy)
|
||||
@ -141,7 +141,7 @@ void thread::start(std::function<void()> func)
|
||||
m_thr = std::thread([func, name]()
|
||||
{
|
||||
NamedThreadBase info(name);
|
||||
g_tls_this_thread = &info;
|
||||
SetCurrentNamedThread(&info);
|
||||
g_thread_count++;
|
||||
|
||||
try
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
};
|
||||
|
||||
NamedThreadBase* GetCurrentNamedThread();
|
||||
void SetCurrentNamedThread(NamedThreadBase* value);
|
||||
|
||||
class ThreadBase : public NamedThreadBase
|
||||
{
|
||||
|
@ -222,13 +222,6 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b)
|
||||
|
||||
u64 PPUThread::FastCall(u64 addr, u64 rtoc, u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8)
|
||||
{
|
||||
auto old_status = m_status;
|
||||
auto old_PC = PC;
|
||||
auto old_LR = LR;
|
||||
auto old_rtoc = GPR[2];
|
||||
|
||||
PC = addr;
|
||||
GPR[2] = rtoc;
|
||||
GPR[3] = arg1;
|
||||
GPR[4] = arg2;
|
||||
GPR[5] = arg3;
|
||||
@ -237,35 +230,31 @@ u64 PPUThread::FastCall(u64 addr, u64 rtoc, u64 arg1, u64 arg2, u64 arg3, u64 ar
|
||||
GPR[8] = arg6;
|
||||
GPR[9] = arg7;
|
||||
GPR[10] = arg8;
|
||||
LR = Emu.m_ppu_thr_stop;
|
||||
|
||||
Task();
|
||||
|
||||
GPR[2] = old_rtoc;
|
||||
LR = old_LR;
|
||||
PC = old_PC;
|
||||
m_status = old_status;
|
||||
|
||||
return GPR[3];
|
||||
|
||||
return FastCall2(addr, rtoc);
|
||||
}
|
||||
|
||||
u64 PPUThread::FastCall2(u64 addr, u64 rtoc)
|
||||
{
|
||||
auto old_status = m_status;
|
||||
auto old_PC = PC;
|
||||
auto old_LR = LR;
|
||||
auto old_rtoc = GPR[2];
|
||||
auto old_LR = LR;
|
||||
auto old_thread = GetCurrentNamedThread();
|
||||
|
||||
m_status = Running;
|
||||
PC = addr;
|
||||
GPR[2] = rtoc;
|
||||
LR = Emu.m_ppu_thr_stop;
|
||||
SetCurrentNamedThread(this);
|
||||
|
||||
Task();
|
||||
|
||||
m_status = old_status;
|
||||
PC = old_PC;
|
||||
GPR[2] = old_rtoc;
|
||||
LR = old_LR;
|
||||
PC = old_PC;
|
||||
m_status = old_status;
|
||||
SetCurrentNamedThread(old_thread);
|
||||
|
||||
return GPR[3];
|
||||
}
|
||||
|
@ -225,8 +225,9 @@ s32 _sys_spu_printf_initialize(u32 agcb, u32 dgcb, u32 atcb, u32 dtcb)
|
||||
{
|
||||
sysPrxForUser->Warning("_sys_spu_printf_initialize(agcb=0x%x, dgcb=0x%x, atcb=0x%x, dtcb=0x%x)", agcb, dgcb, atcb, dtcb);
|
||||
|
||||
// prx: register some callbacks
|
||||
spu_printf_agcb = agcb;
|
||||
spu_printf_dgcb = atcb;
|
||||
spu_printf_dgcb = dgcb;
|
||||
spu_printf_atcb = atcb;
|
||||
spu_printf_dtcb = dtcb;
|
||||
return CELL_OK;
|
||||
@ -291,6 +292,16 @@ s32 _sys_spu_printf_detach_thread(u32 arg)
|
||||
return GetCurrentPPUThread().FastCall(Memory.Read32(spu_printf_dtcb), Memory.Read32(spu_printf_dtcb + 4), arg);
|
||||
}
|
||||
|
||||
s32 _sys_printf(u32 arg1)
|
||||
{
|
||||
sysPrxForUser->Todo("_sys_printf(arg1=0x%x)", arg1);
|
||||
|
||||
// probably, assertion failed
|
||||
LOG_WARNING(TTY, "%s", (char*)(Memory + arg1));
|
||||
Emu.Pause();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
void sysPrxForUser_init()
|
||||
{
|
||||
REG_FUNC(sysPrxForUser, sys_initialize_tls);
|
||||
@ -381,4 +392,6 @@ void sysPrxForUser_init()
|
||||
REG_FUNC(sysPrxForUser, _sys_spu_printf_detach_group);
|
||||
REG_FUNC(sysPrxForUser, _sys_spu_printf_attach_thread);
|
||||
REG_FUNC(sysPrxForUser, _sys_spu_printf_detach_thread);
|
||||
|
||||
REG_FUNC(sysPrxForUser, _sys_printf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user