From d765f2e15c3b4ae21b1161ca5a801de9e5d83224 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 21 May 2024 23:14:47 +1000 Subject: [PATCH] Common: Fix Mac build --- common/Linux/LnxHostSys.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/Linux/LnxHostSys.cpp b/common/Linux/LnxHostSys.cpp index 81aa1eed4a..405b9a9dbd 100644 --- a/common/Linux/LnxHostSys.cpp +++ b/common/Linux/LnxHostSys.cpp @@ -29,6 +29,14 @@ #define MAP_ANONYMOUS MAP_ANON #endif +// MacOS does not have MAP_FIXED_NOREPLACE, which means our mappings are +// vulnerable to races with the main/Qt threads. TODO: Investigate using +// mach_vm_allocate()/mach_vm_map() instead of mmap(), but Apple's +// documentation for these routines is non-existant... +#if defined(__APPLE__) && !defined(MAP_FIXED_NOREPLACE) +#define MAP_FIXED_NOREPLACE MAP_FIXED +#endif + #include #include #include @@ -59,7 +67,7 @@ static struct sigaction s_old_sigsegv_action; [[maybe_unused]] static bool IsStoreInstruction(uptr ptr) { u32 bits; - std::memcpy(&bits, reinterpret_cast(pc), sizeof(bits)); + std::memcpy(&bits, reinterpret_cast(ptr), sizeof(bits)); // Based on vixl's disassembler Instruction::IsStore(). // if (Mask(LoadStoreAnyFMask) != LoadStoreAnyFixed)