From 54cae5dff84cd8bd07d310354e9b64bcbf9dc4c7 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle Date: Sat, 26 Oct 2024 15:30:13 +0300 Subject: [PATCH] cmake: Enable userfaultfd --- CMakeLists.txt | 7 +++++++ src/video_core/page_manager.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04bd6a331..e73062c5d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/video_core/page_manager.cpp b/src/video_core/page_manager.cpp index a49fff43a..e3a18f11d 100644 --- a/src/video_core/page_manager.cpp +++ b/src/video_core/page_manager.cpp @@ -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);