Add FreeBSD support (#939)
* Add FreeBSD support * Fix indentation * Fix Linux not finding OpenGL * Link POSIX Realtime Extensions library * Link POSIX Realtime Extensions when OpenGL is enabled too * Fail if shm_open memory exists and also check for errors * fix the last commit * (try to) Setup FreeBSD CI * Fix some issues with FreeBSD CI * Make with all cores * Remove FreeBSD CI It doesn't want to work for some reason
This commit is contained in:
parent
34da7f5cc3
commit
9994d3a644
|
@ -155,8 +155,10 @@ static void SigsegvHandler(int sig, siginfo_t* info, void* rawContext)
|
||||||
u8* curArea = (u8*)(NDS::CurCPU == 0 ? ARMJIT_Memory::FastMem9Start : ARMJIT_Memory::FastMem7Start);
|
u8* curArea = (u8*)(NDS::CurCPU == 0 ? ARMJIT_Memory::FastMem9Start : ARMJIT_Memory::FastMem7Start);
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
desc.EmulatedFaultAddr = (u8*)info->si_addr - curArea;
|
desc.EmulatedFaultAddr = (u8*)info->si_addr - curArea;
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__)
|
||||||
desc.FaultPC = (u8*)context->uc_mcontext->__ss.__rip;
|
desc.FaultPC = (u8*)context->uc_mcontext->__ss.__rip;
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
desc.FaultPC = (u8*)context->uc_mcontext.mc_rip;
|
||||||
#else
|
#else
|
||||||
desc.FaultPC = (u8*)context->uc_mcontext.gregs[REG_RIP];
|
desc.FaultPC = (u8*)context->uc_mcontext.gregs[REG_RIP];
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,8 +176,10 @@ static void SigsegvHandler(int sig, siginfo_t* info, void* rawContext)
|
||||||
if (ARMJIT_Memory::FaultHandler(desc))
|
if (ARMJIT_Memory::FaultHandler(desc))
|
||||||
{
|
{
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__)
|
||||||
context->uc_mcontext->__ss.__rip = (u64)desc.FaultPC;
|
context->uc_mcontext->__ss.__rip = (u64)desc.FaultPC;
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
context->uc_mcontext.mc_rip = (u64)desc.FaultPC;
|
||||||
#else
|
#else
|
||||||
context->uc_mcontext.gregs[REG_RIP] = (u64)desc.FaultPC;
|
context->uc_mcontext.gregs[REG_RIP] = (u64)desc.FaultPC;
|
||||||
#endif
|
#endif
|
||||||
|
@ -745,15 +749,20 @@ void Init()
|
||||||
ioctl(fd, ASHMEM_SET_SIZE, MemoryTotalSize);
|
ioctl(fd, ASHMEM_SET_SIZE, MemoryTotalSize);
|
||||||
MemoryFile = fd;
|
MemoryFile = fd;
|
||||||
}
|
}
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char* fastmemPidName = new char[snprintf(NULL, 0, "melondsfastmem%d", getpid()) + 1];
|
|
||||||
sprintf(fastmemPidName, "melondsfastmem%d", getpid());
|
|
||||||
MemoryFile = shm_open(fastmemPidName, O_RDWR|O_CREAT, 0600);
|
|
||||||
delete[] fastmemPidName;
|
|
||||||
#else
|
#else
|
||||||
MemoryFile = memfd_create("melondsfastmem", 0);
|
char fastmemPidName[snprintf(NULL, 0, "/melondsfastmem%d", getpid()) + 1];
|
||||||
|
sprintf(fastmemPidName, "/melondsfastmem%d", getpid());
|
||||||
|
MemoryFile = shm_open(fastmemPidName, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
if (MemoryFile == -1)
|
||||||
|
{
|
||||||
|
printf("Failed to open memory using shm_open!");
|
||||||
|
}
|
||||||
|
shm_unlink(fastmemPidName);
|
||||||
#endif
|
#endif
|
||||||
ftruncate(MemoryFile, MemoryTotalSize);
|
if (ftruncate(MemoryFile, MemoryTotalSize) < 0)
|
||||||
|
{
|
||||||
|
printf("Failed to allocate memory using ftruncate!");
|
||||||
|
}
|
||||||
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_handler = nullptr;
|
sa.sa_handler = nullptr;
|
||||||
|
@ -788,11 +797,6 @@ void DeInit()
|
||||||
|
|
||||||
svcUnmapProcessCodeMemory(envGetOwnProcessHandle(), (u64)MemoryBaseCodeMem, (u64)MemoryBase, MemoryTotalSize);
|
svcUnmapProcessCodeMemory(envGetOwnProcessHandle(), (u64)MemoryBaseCodeMem, (u64)MemoryBase, MemoryTotalSize);
|
||||||
free(MemoryBase);
|
free(MemoryBase);
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char* fastmemPidName = new char[snprintf(NULL, 0, "melondsfastmem%d", getpid()) + 1];
|
|
||||||
sprintf(fastmemPidName, "melondsfastmem%d", getpid());
|
|
||||||
shm_unlink(fastmemPidName);
|
|
||||||
delete[] fastmemPidName;
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
assert(UnmapViewOfFile(MemoryBase));
|
assert(UnmapViewOfFile(MemoryBase));
|
||||||
CloseHandle(MemoryFile);
|
CloseHandle(MemoryFile);
|
||||||
|
|
|
@ -106,17 +106,19 @@ if (APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_OGLRENDERER)
|
if (ENABLE_OGLRENDERER)
|
||||||
if (WIN32)
|
find_package(OpenGL REQUIRED)
|
||||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
if (WIN32)
|
||||||
elseif (APPLE)
|
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||||
target_link_libraries(core "-framework OpenGL")
|
elseif (APPLE)
|
||||||
else()
|
target_link_libraries(core ${OPENGL_gl_LIBRARY})
|
||||||
target_link_libraries(core GL EGL)
|
else()
|
||||||
endif()
|
target_include_directories(core PRIVATE ${OPENGL_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(core rt OpenGL::GL ${OPENGL_egl_LIBRARY})
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(core ole32 comctl32 ws2_32)
|
target_link_libraries(core ole32 comctl32 ws2_32)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(core)
|
target_link_libraries(core rt)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -546,8 +546,8 @@ void Eject()
|
||||||
HasSolarSensor = false;
|
HasSolarSensor = false;
|
||||||
CartROM = NULL;
|
CartROM = NULL;
|
||||||
CartROMSize = 0;
|
CartROMSize = 0;
|
||||||
CartCRC = NULL;
|
CartCRC = 0;
|
||||||
CartID = NULL;
|
CartID = 0;
|
||||||
CartGPIO = {};
|
CartGPIO = {};
|
||||||
|
|
||||||
GBACart_SRAM::Eject();
|
GBACart_SRAM::Eject();
|
||||||
|
|
|
@ -73,9 +73,8 @@ endif()
|
||||||
|
|
||||||
target_link_libraries(melonDS ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(melonDS ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS})
|
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS} ${SLIRP_INCLUDE_DIRS} ${LIBARCHIVE_INCLUDE_DIRS})
|
||||||
target_include_directories(melonDS PRIVATE ${SLIRP_INCLUDE_DIRS})
|
target_link_directories(melonDS PRIVATE ${SDL2_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS} ${LIBARCHIVE_LIBRARY_DIRS})
|
||||||
target_include_directories(melonDS PRIVATE ${LIBARCHIVE_INCLUDE_DIRS})
|
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||||
|
|
Loading…
Reference in New Issue