mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-31 15:53:17 +00:00
core: Add wrapper for calling into guest code. (#967)
This commit is contained in:
parent
ad9f1370d5
commit
4ba19a02b0
8 changed files with 57 additions and 35 deletions
|
@ -90,11 +90,8 @@ void Linker::Execute() {
|
|||
|
||||
// Init primary thread.
|
||||
Common::SetCurrentThreadName("GAME_MainThread");
|
||||
#ifdef ARCH_X86_64
|
||||
InitializeThreadPatchStack();
|
||||
#endif
|
||||
Libraries::Kernel::pthreadInitSelfMainThread();
|
||||
InitTlsForThread(true);
|
||||
EnsureThreadInitialized(true);
|
||||
|
||||
// Start shared library modules
|
||||
for (auto& m : m_modules) {
|
||||
|
@ -335,6 +332,17 @@ void* Linker::TlsGetAddr(u64 module_index, u64 offset) {
|
|||
return addr + offset;
|
||||
}
|
||||
|
||||
thread_local std::once_flag init_tls_flag;
|
||||
|
||||
void Linker::EnsureThreadInitialized(bool is_primary) {
|
||||
std::call_once(init_tls_flag, [this, is_primary] {
|
||||
#ifdef ARCH_X86_64
|
||||
InitializeThreadPatchStack();
|
||||
#endif
|
||||
InitTlsForThread(is_primary);
|
||||
});
|
||||
}
|
||||
|
||||
void Linker::InitTlsForThread(bool is_primary) {
|
||||
static constexpr size_t TcbSize = 0x40;
|
||||
static constexpr size_t TlsAllocAlign = 0x20;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue