[dynarmic] use ARCHITECTURE_ macros instead of MCL ones
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
666e89b871
commit
5ade202fa8
2 changed files with 21 additions and 21 deletions
|
@ -15,15 +15,15 @@
|
||||||
#include <mcl/macro/architecture.hpp>
|
#include <mcl/macro/architecture.hpp>
|
||||||
#include "dynarmic/common/common_types.h"
|
#include "dynarmic/common/common_types.h"
|
||||||
|
|
||||||
#if defined(MCL_ARCHITECTURE_X86_64)
|
#if defined(ARCHITECTURE_x86_64)
|
||||||
namespace Dynarmic::Backend::X64 {
|
namespace Dynarmic::Backend::X64 {
|
||||||
class BlockOfCode;
|
class BlockOfCode;
|
||||||
} // namespace Dynarmic::Backend::X64
|
} // namespace Dynarmic::Backend::X64
|
||||||
#elif defined(MCL_ARCHITECTURE_ARM64)
|
#elif defined(ARCHITECTURE_arm64)
|
||||||
namespace oaknut {
|
namespace oaknut {
|
||||||
class CodeBlock;
|
class CodeBlock;
|
||||||
} // namespace oaknut
|
} // namespace oaknut
|
||||||
#elif defined(MCL_ARCHITECTURE_RISCV)
|
#elif defined(ARCHITECTURE_riscv64)
|
||||||
namespace Dynarmic::Backend::RV64 {
|
namespace Dynarmic::Backend::RV64 {
|
||||||
class CodeBlock;
|
class CodeBlock;
|
||||||
} // namespace Dynarmic::Backend::RV64
|
} // namespace Dynarmic::Backend::RV64
|
||||||
|
@ -33,16 +33,16 @@ class CodeBlock;
|
||||||
|
|
||||||
namespace Dynarmic::Backend {
|
namespace Dynarmic::Backend {
|
||||||
|
|
||||||
#if defined(MCL_ARCHITECTURE_X86_64)
|
#if defined(ARCHITECTURE_x86_64)
|
||||||
struct FakeCall {
|
struct FakeCall {
|
||||||
u64 call_rip;
|
u64 call_rip;
|
||||||
u64 ret_rip;
|
u64 ret_rip;
|
||||||
};
|
};
|
||||||
#elif defined(MCL_ARCHITECTURE_ARM64)
|
#elif defined(ARCHITECTURE_arm64)
|
||||||
struct FakeCall {
|
struct FakeCall {
|
||||||
u64 call_pc;
|
u64 call_pc;
|
||||||
};
|
};
|
||||||
#elif defined(MCL_ARCHITECTURE_RISCV)
|
#elif defined(ARCHITECTURE_riscv64)
|
||||||
struct FakeCall {
|
struct FakeCall {
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
@ -54,11 +54,11 @@ public:
|
||||||
ExceptionHandler();
|
ExceptionHandler();
|
||||||
~ExceptionHandler();
|
~ExceptionHandler();
|
||||||
|
|
||||||
#if defined(MCL_ARCHITECTURE_X86_64)
|
#if defined(ARCHITECTURE_x86_64)
|
||||||
void Register(X64::BlockOfCode& code);
|
void Register(X64::BlockOfCode& code);
|
||||||
#elif defined(MCL_ARCHITECTURE_ARM64)
|
#elif defined(ARCHITECTURE_arm64)
|
||||||
void Register(oaknut::CodeBlock& mem, std::size_t mem_size);
|
void Register(oaknut::CodeBlock& mem, std::size_t mem_size);
|
||||||
#elif defined(MCL_ARCHITECTURE_RISCV)
|
#elif defined(ARCHITECTURE_riscv64)
|
||||||
void Register(RV64::CodeBlock& mem, std::size_t mem_size);
|
void Register(RV64::CodeBlock& mem, std::size_t mem_size);
|
||||||
#else
|
#else
|
||||||
# error "Invalid architecture"
|
# error "Invalid architecture"
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <shared_mutex>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <ankerl/unordered_dense.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
#include "dynarmic/backend/exception_handler.h"
|
#include "dynarmic/backend/exception_handler.h"
|
||||||
|
@ -118,9 +115,11 @@ void SigHandler::SigAction(int sig, siginfo_t* info, void* raw_context) {
|
||||||
CTX_DECLARE(raw_context);
|
CTX_DECLARE(raw_context);
|
||||||
#if defined(ARCHITECTURE_x86_64)
|
#if defined(ARCHITECTURE_x86_64)
|
||||||
{
|
{
|
||||||
std::shared_lock guard(sig_handler->code_block_infos_mutex);
|
std::lock_guard<std::mutex> guard(sig_handler->code_block_infos_mutex);
|
||||||
if (auto const iter = sig_handler->FindCodeBlockInfo(CTX_RIP); iter != sig_handler->code_block_infos.end()) {
|
|
||||||
FakeCall fc = iter->second.cb(CTX_RIP);
|
const auto iter = sig_handler->FindCodeBlockInfo(CTX_RIP);
|
||||||
|
if (iter != sig_handler->code_block_infos.end()) {
|
||||||
|
FakeCall fc = iter->cb(CTX_RIP);
|
||||||
CTX_RSP -= sizeof(u64);
|
CTX_RSP -= sizeof(u64);
|
||||||
*mcl::bit_cast<u64*>(CTX_RSP) = fc.ret_rip;
|
*mcl::bit_cast<u64*>(CTX_RSP) = fc.ret_rip;
|
||||||
CTX_RIP = fc.call_rip;
|
CTX_RIP = fc.call_rip;
|
||||||
|
@ -130,9 +129,10 @@ void SigHandler::SigAction(int sig, siginfo_t* info, void* raw_context) {
|
||||||
fmt::print(stderr, "Unhandled {} at rip {:#018x}\n", sig == SIGSEGV ? "SIGSEGV" : "SIGBUS", CTX_RIP);
|
fmt::print(stderr, "Unhandled {} at rip {:#018x}\n", sig == SIGSEGV ? "SIGSEGV" : "SIGBUS", CTX_RIP);
|
||||||
#elif defined(ARCHITECTURE_arm64)
|
#elif defined(ARCHITECTURE_arm64)
|
||||||
{
|
{
|
||||||
std::shared_lock guard(sig_handler->code_block_infos_mutex);
|
std::lock_guard<std::mutex> guard(sig_handler->code_block_infos_mutex);
|
||||||
if (const auto iter = sig_handler->FindCodeBlockInfo(CTX_PC); iter != sig_handler->code_block_infos.end()) {
|
const auto iter = sig_handler->FindCodeBlockInfo(CTX_PC);
|
||||||
FakeCall fc = iter->second.cb(CTX_PC);
|
if (iter != sig_handler->code_block_infos.end()) {
|
||||||
|
FakeCall fc = iter->cb(CTX_PC);
|
||||||
CTX_PC = fc.call_pc;
|
CTX_PC = fc.call_pc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -187,15 +187,15 @@ private:
|
||||||
ExceptionHandler::ExceptionHandler() = default;
|
ExceptionHandler::ExceptionHandler() = default;
|
||||||
ExceptionHandler::~ExceptionHandler() = default;
|
ExceptionHandler::~ExceptionHandler() = default;
|
||||||
|
|
||||||
#if defined(MCL_ARCHITECTURE_X86_64)
|
#if defined(ARCHITECTURE_x86_64)
|
||||||
void ExceptionHandler::Register(X64::BlockOfCode& code) {
|
void ExceptionHandler::Register(X64::BlockOfCode& code) {
|
||||||
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(code.getCode()), code.GetTotalCodeSize());
|
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(code.getCode()), code.GetTotalCodeSize());
|
||||||
}
|
}
|
||||||
#elif defined(MCL_ARCHITECTURE_ARM64)
|
#elif defined(ARCHITECTURE_arm64)
|
||||||
void ExceptionHandler::Register(oaknut::CodeBlock& mem, std::size_t size) {
|
void ExceptionHandler::Register(oaknut::CodeBlock& mem, std::size_t size) {
|
||||||
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(mem.ptr()), size);
|
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(mem.ptr()), size);
|
||||||
}
|
}
|
||||||
#elif defined(MCL_ARCHITECTURE_RISCV)
|
#elif defined(ARCHITECTURE_riscv64)
|
||||||
void ExceptionHandler::Register(RV64::CodeBlock& mem, std::size_t size) {
|
void ExceptionHandler::Register(RV64::CodeBlock& mem, std::size_t size) {
|
||||||
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(mem.ptr<u64>()), size);
|
impl = std::make_unique<Impl>(mcl::bit_cast<u64>(mem.ptr<u64>()), size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue