cmake: Enable userfaultfd

This commit is contained in:
IndecisiveTurtle 2024-10-26 15:30:13 +03:00
parent 8b2c151f1f
commit 54cae5dff8
2 changed files with 8 additions and 1 deletions

View file

@ -15,6 +15,8 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(CMakeDependentOption)
project(shadPS4)
# Forcing PIE makes sure that the base address is high enough so that it doesn't clash with the PS4 memory.
@ -31,6 +33,7 @@ endif()
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
option(ENABLE_DISCORD_RPC "Enable the Discord RPC integration" ON)
CMAKE_DEPENDENT_OPTION(ENABLE_USERFAULTFD "Enable write tracking using userfaultfd on unix" ON "NOT LINUX" OFF)
# First, determine whether to use CMAKE_OSX_ARCHITECTURES or CMAKE_SYSTEM_PROCESSOR.
if (APPLE AND CMAKE_OSX_ARCHITECTURES)
@ -833,6 +836,10 @@ if (ENABLE_QT_GUI)
add_definitions(-DENABLE_QT_GUI)
endif()
if (ENABLE_USERFAULTFD)
add_definitions(-DENABLE_USERFAULTFD)
endif()
if (WIN32)
target_link_libraries(shadps4 PRIVATE mincore winpthreads)

View file

@ -28,7 +28,7 @@ namespace VideoCore {
constexpr size_t PAGESIZE = 4_KB;
constexpr size_t PAGEBITS = 12;
#if ENABLE_USERFAULTFD
#ifdef ENABLE_USERFAULTFD
struct PageManager::Impl {
Impl(Vulkan::Rasterizer* rasterizer_) : rasterizer{rasterizer_} {
uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);