mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Defined thread_local for MSVC
Updated asmjit project Tried to fix crash on exit Fixed hypothetical issue when pausing already stopped emulator
This commit is contained in:
parent
bf6507e9be
commit
ccfaabd1d7
2
.gitignore
vendored
2
.gitignore
vendored
@ -62,3 +62,5 @@ rpcs3/git-version.h
|
||||
|
||||
# Ignore other system generated files
|
||||
bin/dev_hdd0/log.txt
|
||||
x64/Debug/emucore.lib
|
||||
x64/Release/emucore.lib
|
||||
|
@ -1,5 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#define thread_local __declspec(thread)
|
||||
#elif __APPLE__
|
||||
#define thread_local __thread
|
||||
#endif
|
||||
|
||||
#if defined(__GNUG__)
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
|
@ -11,14 +11,7 @@ __forceinline void SM_Sleep()
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(thread)
|
||||
#elif __APPLE__
|
||||
__thread
|
||||
#else
|
||||
thread_local
|
||||
#endif
|
||||
size_t g_this_thread_id = 0;
|
||||
thread_local size_t g_this_thread_id = 0;
|
||||
|
||||
__forceinline size_t SM_GetCurrentThreadId()
|
||||
{
|
||||
|
@ -3,14 +3,8 @@
|
||||
|
||||
#include "Thread.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(thread)
|
||||
#elif __APPLE__
|
||||
__thread
|
||||
#else
|
||||
thread_local
|
||||
#endif
|
||||
NamedThreadBase* g_tls_this_thread = nullptr;
|
||||
thread_local NamedThreadBase* g_tls_this_thread = nullptr;
|
||||
std::atomic<u32> g_thread_count = 0;
|
||||
|
||||
NamedThreadBase* GetCurrentNamedThread()
|
||||
{
|
||||
@ -56,10 +50,12 @@ void ThreadBase::Start()
|
||||
[this]()
|
||||
{
|
||||
g_tls_this_thread = this;
|
||||
g_thread_count++;
|
||||
|
||||
Task();
|
||||
|
||||
m_alive = false;
|
||||
g_thread_count--;
|
||||
});
|
||||
}
|
||||
|
||||
@ -130,6 +126,7 @@ void thread::start(std::function<void()> func)
|
||||
{
|
||||
NamedThreadBase info(name);
|
||||
g_tls_this_thread = &info;
|
||||
g_thread_count++;
|
||||
|
||||
try
|
||||
{
|
||||
@ -140,6 +137,8 @@ void thread::start(std::function<void()> func)
|
||||
ConLog.Error("Crash :(");
|
||||
//std::terminate();
|
||||
}
|
||||
|
||||
g_thread_count--;
|
||||
});
|
||||
}
|
||||
|
||||
|
2
asmjit
2
asmjit
@ -1 +1 @@
|
||||
Subproject commit b76922fde96232030be302b3bdd9673e9bcec568
|
||||
Subproject commit a66efd54609aab7dd98e34c069937f34aa7c8f95
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@ -26,12 +26,10 @@
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\context.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\cpuinfo.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\cputicks.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\defs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\error.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\func.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\globals.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\logger.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\memorymanager.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\operand.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\podvector.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\runtime.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\string.cpp" />
|
||||
@ -42,8 +40,11 @@
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86compiler.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86context.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86cpuinfo.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86defs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86func.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86inst.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86operand.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86regs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86util.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\asmjit\src\asmjit\base\constpool.h" />
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86assembler.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86compiler.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86context.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86cpuinfo.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86defs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86func.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\contrib\winremoteruntime.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\assembler.cpp" />
|
||||
@ -14,18 +13,20 @@
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\context.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\cpuinfo.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\cputicks.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\defs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\error.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\func.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\globals.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\logger.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\memorymanager.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\podvector.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\runtime.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\string.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\vmem.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\zone.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\constpool.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\base\operand.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86inst.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86operand.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86regs.cpp" />
|
||||
<ClCompile Include="..\asmjit\src\asmjit\x86\x86util.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\asmjit\src\asmjit\base\constpool.h" />
|
||||
|
@ -1844,6 +1844,11 @@ void RSXThread::Task()
|
||||
|
||||
while(!TestDestroy())
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
{
|
||||
ConLog.Warning("RSX thread aborted");
|
||||
return;
|
||||
}
|
||||
rCriticalSectionLocker lock(m_cs_main);
|
||||
|
||||
inc=1;
|
||||
|
@ -471,7 +471,7 @@ int cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
|
||||
return CELL_GCM_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could stall on exit
|
||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could freeze on exit
|
||||
|
||||
u32 current = ctxt->current;
|
||||
u32 end = ctxt->end;
|
||||
|
@ -13,7 +13,7 @@ extern gcmInfo gcm_info;
|
||||
|
||||
int cellGcmCallback(u32 context_addr, u32 count)
|
||||
{
|
||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could stall on exit
|
||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could freeze on exit
|
||||
|
||||
CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr];
|
||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||
|
@ -83,7 +83,7 @@ void sys_ppu_thread_get_join_state(u32 isjoinable_addr)
|
||||
|
||||
int sys_ppu_thread_set_priority(u32 thread_id, int prio)
|
||||
{
|
||||
sysPrxForUser->Warning("sys_ppu_thread_set_priority(thread_id=%d, prio=%d)", thread_id, prio);
|
||||
sysPrxForUser->Log("sys_ppu_thread_set_priority(thread_id=%d, prio=%d)", thread_id, prio);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
@ -21,6 +21,7 @@ using namespace PPU_instr;
|
||||
|
||||
static const std::string& BreakPointsDBName = "BreakPoints.dat";
|
||||
static const u16 bpdb_version = 0x1000;
|
||||
extern std::atomic<u32> g_thread_count;
|
||||
|
||||
ModuleInitializer::ModuleInitializer()
|
||||
{
|
||||
@ -345,9 +346,11 @@ void Emulator::Pause()
|
||||
//ConLog.Write("pause...");
|
||||
SendDbgCommand(DID_PAUSE_EMU);
|
||||
|
||||
m_status = Paused;
|
||||
if (InterlockedCompareExchange((volatile unsigned long*)&m_status, Paused, Running) == Running)
|
||||
{
|
||||
SendDbgCommand(DID_PAUSED_EMU);
|
||||
}
|
||||
}
|
||||
|
||||
void Emulator::Resume()
|
||||
{
|
||||
@ -370,8 +373,27 @@ void Emulator::Stop()
|
||||
SendDbgCommand(DID_STOP_EMU);
|
||||
m_status = Stopped;
|
||||
|
||||
u32 uncounted = 0 + (u32)(bool)m_dbg_console;
|
||||
u32 counter = 0;
|
||||
while (true)
|
||||
{
|
||||
if (g_thread_count <= uncounted)
|
||||
{
|
||||
ConLog.Write("All threads stopped...");
|
||||
break;
|
||||
}
|
||||
Sleep(1);
|
||||
if (counter++ > 3000)
|
||||
{
|
||||
ConLog.Error("%d threads not stopped (timeout)", (u32)(g_thread_count - uncounted));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_rsx_callback = 0;
|
||||
|
||||
// TODO: check finalization order
|
||||
|
||||
SavePoints(BreakPointsDBName);
|
||||
m_break_points.clear();
|
||||
m_marked_points.clear();
|
||||
@ -388,7 +410,7 @@ void Emulator::Stop()
|
||||
GetKeyboardManager().Close();
|
||||
GetMouseManager().Close();
|
||||
GetCallbackManager().Clear();
|
||||
//not all modules unload cleanly, so we're not unloading them for now
|
||||
// TODO: not all modules unload cleanly, so we're not unloading them for now
|
||||
//GetModuleManager().UnloadModules();
|
||||
|
||||
CurGameInfo.Reset();
|
||||
|
Loading…
Reference in New Issue
Block a user