mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-09-12 22:43:07 -06:00
JIT: fix building with ENABLE_JIT on OpenBSD targets (#2398)
* sockaddr_in is a forward declaration on *BSD, explicitly include the correct header * fix building with ENABLE_JIT on OpenBSD targets * add wxallowed linker flag for openbsd targets * OpenBSD armjit sc_exr -> sc_elr * wxallowed -> wxneeded * force mmap for jit on OpenBSD * disable fastmem on OpenBSD * fix typo in disabling fastmem for OpenBSD * add missing space in this if
This commit is contained in:
@ -25,7 +25,7 @@ std::mutex globalMutex;
|
||||
#define APPLE_AARCH64
|
||||
#endif
|
||||
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__)
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
static constexpr size_t NumCodeMemSlices = 4;
|
||||
static constexpr size_t CodeMemoryAlignedSize = NumCodeMemSlices * CodeMemorySliceSize;
|
||||
|
||||
@ -46,7 +46,7 @@ void* AllocateCodeMem()
|
||||
{
|
||||
std::lock_guard guard(globalMutex);
|
||||
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__)
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
if (AvailableCodeMemSlices)
|
||||
{
|
||||
int slice = __builtin_ctz(AvailableCodeMemSlices);
|
||||
@ -73,7 +73,7 @@ void FreeCodeMem(void* codeMem)
|
||||
{
|
||||
std::lock_guard guard(globalMutex);
|
||||
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__)
|
||||
#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
for (int i = 0; i < NumCodeMemSlices; i++)
|
||||
{
|
||||
if (codeMem == &GetAlignedCodeMemoryStart()[CodeMemorySliceSize * i])
|
||||
@ -102,7 +102,7 @@ void Init()
|
||||
#ifdef _WIN32
|
||||
DWORD dummy;
|
||||
VirtualProtect(GetAlignedCodeMemoryStart(), CodeMemoryAlignedSize, PAGE_EXECUTE_READWRITE, &dummy);
|
||||
#elif defined(APPLE_AARCH64) || defined(__NetBSD__)
|
||||
#elif defined(APPLE_AARCH64) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
// Apple aarch64 always uses dynamic allocation
|
||||
#else
|
||||
mprotect(GetAlignedCodeMemoryStart(), CodeMemoryAlignedSize, PROT_EXEC | PROT_READ | PROT_WRITE);
|
||||
|
@ -83,6 +83,8 @@
|
||||
#define CONTEXT_PC uc_mcontext.mc_rip
|
||||
#elif defined(__NetBSD__)
|
||||
#define CONTEXT_PC uc_mcontext.__gregs[_REG_RIP]
|
||||
#elif defined(__OpenBSD__)
|
||||
#define CONTEXT_PC sc_rip
|
||||
#endif
|
||||
#elif defined(__aarch64__)
|
||||
#if defined(_WIN32)
|
||||
@ -95,6 +97,8 @@
|
||||
#define CONTEXT_PC uc_mcontext.mc_gpregs.gp_elr
|
||||
#elif defined(__NetBSD__)
|
||||
#define CONTEXT_PC uc_mcontext.__gregs[_REG_PC]
|
||||
#elif defined(__OpenBSD__)
|
||||
#define CONTEXT_PC sc_elr
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -739,7 +743,7 @@ u32 ARMJIT_Memory::PageShift = 0;
|
||||
|
||||
bool ARMJIT_Memory::IsFastMemSupported()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__OpenBSD__)
|
||||
return false;
|
||||
#else
|
||||
static bool initialised = false;
|
||||
|
@ -115,6 +115,10 @@ if (ENABLE_JIT)
|
||||
target_link_libraries(core PRIVATE onecore)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
target_link_options(core PUBLIC -Wl,-z,wxneeded)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE STREQUAL x86_64)
|
||||
target_sources(core PRIVATE
|
||||
dolphin/x64ABI.cpp
|
||||
|
Reference in New Issue
Block a user