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);
|
||||
#ifdef __x86_64__
|
||||
desc.EmulatedFaultAddr = (u8*)info->si_addr - curArea;
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__)
|
||||
desc.FaultPC = (u8*)context->uc_mcontext->__ss.__rip;
|
||||
#elif defined(__FreeBSD__)
|
||||
desc.FaultPC = (u8*)context->uc_mcontext.mc_rip;
|
||||
#else
|
||||
desc.FaultPC = (u8*)context->uc_mcontext.gregs[REG_RIP];
|
||||
#endif
|
||||
|
@ -174,8 +176,10 @@ static void SigsegvHandler(int sig, siginfo_t* info, void* rawContext)
|
|||
if (ARMJIT_Memory::FaultHandler(desc))
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__)
|
||||
context->uc_mcontext->__ss.__rip = (u64)desc.FaultPC;
|
||||
#elif defined(__FreeBSD__)
|
||||
context->uc_mcontext.mc_rip = (u64)desc.FaultPC;
|
||||
#else
|
||||
context->uc_mcontext.gregs[REG_RIP] = (u64)desc.FaultPC;
|
||||
#endif
|
||||
|
@ -745,15 +749,20 @@ void Init()
|
|||
ioctl(fd, ASHMEM_SET_SIZE, MemoryTotalSize);
|
||||
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
|
||||
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
|
||||
ftruncate(MemoryFile, MemoryTotalSize);
|
||||
if (ftruncate(MemoryFile, MemoryTotalSize) < 0)
|
||||
{
|
||||
printf("Failed to allocate memory using ftruncate!");
|
||||
}
|
||||
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = nullptr;
|
||||
|
@ -788,11 +797,6 @@ void DeInit()
|
|||
|
||||
svcUnmapProcessCodeMemory(envGetOwnProcessHandle(), (u64)MemoryBaseCodeMem, (u64)MemoryBase, MemoryTotalSize);
|
||||
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)
|
||||
assert(UnmapViewOfFile(MemoryBase));
|
||||
CloseHandle(MemoryFile);
|
||||
|
|
|
@ -106,17 +106,19 @@ if (APPLE)
|
|||
endif()
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||
elseif (APPLE)
|
||||
target_link_libraries(core "-framework OpenGL")
|
||||
else()
|
||||
target_link_libraries(core GL EGL)
|
||||
endif()
|
||||
find_package(OpenGL REQUIRED)
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||
elseif (APPLE)
|
||||
target_link_libraries(core ${OPENGL_gl_LIBRARY})
|
||||
else()
|
||||
target_include_directories(core PRIVATE ${OPENGL_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIRS})
|
||||
target_link_libraries(core rt OpenGL::GL ${OPENGL_egl_LIBRARY})
|
||||
endif()
|
||||
else()
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32)
|
||||
else()
|
||||
target_link_libraries(core)
|
||||
target_link_libraries(core rt)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -546,8 +546,8 @@ void Eject()
|
|||
HasSolarSensor = false;
|
||||
CartROM = NULL;
|
||||
CartROMSize = 0;
|
||||
CartCRC = NULL;
|
||||
CartID = NULL;
|
||||
CartCRC = 0;
|
||||
CartID = 0;
|
||||
CartGPIO = {};
|
||||
|
||||
GBACart_SRAM::Eject();
|
||||
|
|
|
@ -73,9 +73,8 @@ endif()
|
|||
|
||||
target_link_libraries(melonDS ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_include_directories(melonDS PRIVATE ${SLIRP_INCLUDE_DIRS})
|
||||
target_include_directories(melonDS PRIVATE ${LIBARCHIVE_INCLUDE_DIRS})
|
||||
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS} ${SLIRP_INCLUDE_DIRS} ${LIBARCHIVE_INCLUDE_DIRS})
|
||||
target_link_directories(melonDS PRIVATE ${SDL2_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS} ${LIBARCHIVE_LIBRARY_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}/../..")
|
||||
|
|
Loading…
Reference in New Issue