mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-10 10:14:44 -06:00
Use template <auto f> for HostCallWrapperImpl and OrbisWrapperImpl instead of passing the function type and value separately. This keeps the wrapper behavior the same while matching the form MinGW-w64 GCC accepts.
61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <cstring>
|
|
#include "common/types.h"
|
|
#ifdef _WIN32
|
|
#include <malloc.h>
|
|
#endif
|
|
|
|
namespace Xbyak {
|
|
class CodeGenerator;
|
|
}
|
|
|
|
namespace Libraries::Fiber {
|
|
struct OrbisFiberContext;
|
|
}
|
|
|
|
namespace Core {
|
|
|
|
union DtvEntry {
|
|
std::size_t counter;
|
|
u8* pointer;
|
|
};
|
|
|
|
struct Tcb {
|
|
Tcb* tcb_self;
|
|
DtvEntry* tcb_dtv;
|
|
void* tcb_thread;
|
|
::Libraries::Fiber::OrbisFiberContext* tcb_fiber;
|
|
};
|
|
|
|
#ifdef _WIN32
|
|
/// Gets the thread local storage key for the TCB block.
|
|
u32 GetTcbKey();
|
|
#endif
|
|
|
|
/// Sets the data pointer to the TCB block.
|
|
void SetTcbBase(void* image_address);
|
|
|
|
/// Retrieves Tcb structure for the calling thread.
|
|
Tcb* GetTcbBase();
|
|
|
|
/// Makes sure TLS is initialized for the thread before entering guest.
|
|
void InitializeTLS();
|
|
|
|
template <auto f>
|
|
struct HostCallWrapperImpl;
|
|
|
|
template <class ReturnType, class... Args, PS4_SYSV_ABI ReturnType (*func)(Args...)>
|
|
struct HostCallWrapperImpl<func> {
|
|
static ReturnType PS4_SYSV_ABI wrap(Args... args) {
|
|
return func(args...);
|
|
}
|
|
};
|
|
|
|
#define HOST_CALL(func) (Core::HostCallWrapperImpl<func>::wrap)
|
|
|
|
} // namespace Core
|