mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-26 04:16:18 +00:00
core: Introduce host call wrapper. (#2913)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
This commit is contained in:
parent
02d3ed4973
commit
678f18ddb9
3 changed files with 15 additions and 2 deletions
|
@ -35,7 +35,7 @@ public:
|
||||||
this->func = std::move(func);
|
this->func = std::move(func);
|
||||||
PthreadAttrT attr{};
|
PthreadAttrT attr{};
|
||||||
posix_pthread_attr_init(&attr);
|
posix_pthread_attr_init(&attr);
|
||||||
posix_pthread_create(&thread, &attr, RunWrapper, this);
|
posix_pthread_create(&thread, &attr, HOST_CALL(RunWrapper), this);
|
||||||
posix_pthread_attr_destroy(&attr);
|
posix_pthread_attr_destroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "core/loader/elf.h"
|
#include "core/loader/elf.h"
|
||||||
#include "core/loader/symbols_resolver.h"
|
#include "core/loader/symbols_resolver.h"
|
||||||
|
#include "core/tls.h"
|
||||||
|
|
||||||
#define LIB_FUNCTION(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \
|
#define LIB_FUNCTION(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
sr.module_version_major = moduleVersionMajor; \
|
sr.module_version_major = moduleVersionMajor; \
|
||||||
sr.module_version_minor = moduleVersionMinor; \
|
sr.module_version_minor = moduleVersionMinor; \
|
||||||
sr.type = Core::Loader::SymbolType::Function; \
|
sr.type = Core::Loader::SymbolType::Function; \
|
||||||
auto func = reinterpret_cast<u64>(function); \
|
auto func = reinterpret_cast<u64>(HOST_CALL(function)); \
|
||||||
sym->AddSymbol(sr, func); \
|
sym->AddSymbol(sr, func); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,16 @@ ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&
|
||||||
return func(std::forward<CallArgs>(args)...);
|
return func(std::forward<CallArgs>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class F, F f>
|
||||||
|
struct HostCallWrapperImpl;
|
||||||
|
|
||||||
|
template <class ReturnType, class... Args, PS4_SYSV_ABI ReturnType (*func)(Args...)>
|
||||||
|
struct HostCallWrapperImpl<PS4_SYSV_ABI ReturnType (*)(Args...), func> {
|
||||||
|
static ReturnType PS4_SYSV_ABI wrap(Args... args) {
|
||||||
|
return func(args...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define HOST_CALL(func) (Core::HostCallWrapperImpl<decltype(&(func)), func>::wrap)
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue