From a29669432ffd17dcc4256fcf12bba47a1d7dcb7e Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 21 Nov 2020 02:14:43 +1000 Subject: [PATCH] Common/PageFaultHandler: Fix compiling on 32-bit Windows --- src/common/page_fault_handler.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/page_fault_handler.cpp b/src/common/page_fault_handler.cpp index b58ab6afb..e94eff8ce 100644 --- a/src/common/page_fault_handler.cpp +++ b/src/common/page_fault_handler.cpp @@ -1,4 +1,5 @@ #include "page_fault_handler.h" +#include "common/cpu_detect.h" #include "common/log.h" #include #include @@ -67,7 +68,7 @@ static bool IsStoreInstruction(const void* ptr) } #endif -#if defined(WIN32) +#if defined(WIN32) && defined(CPU_X64) static PVOID s_veh_handle; static LONG ExceptionHandler(PEXCEPTION_POINTERS exi) @@ -189,7 +190,7 @@ bool InstallHandler(void* owner, Callback callback) if (was_empty) { -#if defined(WIN32) +#if defined(WIN32) && defined(CPU_X64) s_veh_handle = AddVectoredExceptionHandler(1, ExceptionHandler); if (!s_veh_handle) { @@ -246,10 +247,10 @@ bool RemoveHandler(void* owner) if (m_handlers.empty()) { -#if defined(WIN32) +#if defined(WIN32) && defined(CPU_X64) RemoveVectoredExceptionHandler(s_veh_handle); s_veh_handle = nullptr; -#else +#elif defined(USE_SIGSEGV) // restore old signal handler #if defined(__APPLE__) || defined(__aarch64__) if (sigaction(SIGBUS, &s_old_sigbus_action, nullptr) < 0) @@ -267,6 +268,8 @@ bool RemoveHandler(void* owner) } s_old_sigsegv_action = {}; +#else + return false; #endif }