diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp index 55398808..5de185ba 100644 --- a/src/ARMJIT_Memory.cpp +++ b/src/ARMJIT_Memory.cpp @@ -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); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2bb1a448..ea350e82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() diff --git a/src/GBACart.cpp b/src/GBACart.cpp index 9188408a..97c83a7e 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -546,8 +546,8 @@ void Eject() HasSolarSensor = false; CartROM = NULL; CartROMSize = 0; - CartCRC = NULL; - CartID = NULL; + CartCRC = 0; + CartID = 0; CartGPIO = {}; GBACart_SRAM::Eject(); diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 612c3fda..8f48390e 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -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}/../..")